ZoomIn/ZoomOut/ActualSize actions.
svn path=/branches/work/kwin_composite/; revision=653520
This commit is contained in:
parent
a2a8c39a27
commit
6c971a4462
2 changed files with 43 additions and 4 deletions
|
@ -10,6 +10,10 @@ License. See the file "COPYING" for the exact licensing terms.
|
|||
|
||||
#include "zoom.h"
|
||||
|
||||
#include <kaction.h>
|
||||
#include <kactioncollection.h>
|
||||
#include <kstandardaction.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
||||
|
@ -17,8 +21,16 @@ KWIN_EFFECT( Zoom, ZoomEffect )
|
|||
|
||||
ZoomEffect::ZoomEffect()
|
||||
: zoom( 1 )
|
||||
, target_zoom( 2 )
|
||||
, target_zoom( 1 )
|
||||
{
|
||||
KActionCollection* actionCollection = new KActionCollection( this );
|
||||
KAction* a;
|
||||
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ZoomIn, this, SLOT( zoomIn())));
|
||||
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Equal));
|
||||
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ZoomOut, this, SLOT( zoomOut())));
|
||||
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_Minus));
|
||||
a = static_cast< KAction* >( actionCollection->addAction( KStandardAction::ActualSize, this, SLOT( actualSize())));
|
||||
a->setGlobalShortcut(KShortcut(Qt::META + Qt::Key_0));
|
||||
}
|
||||
|
||||
void ZoomEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
||||
|
@ -27,9 +39,9 @@ void ZoomEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|||
{
|
||||
double diff = time / 500.0;
|
||||
if( target_zoom > zoom )
|
||||
zoom = qMin( zoom + diff, target_zoom );
|
||||
zoom = qMin( zoom * qMax( 1 + diff, 1.2 ), target_zoom );
|
||||
else
|
||||
zoom = qMax( zoom - diff, target_zoom );
|
||||
zoom = qMax( zoom * qMin( 1 - diff, 0.8 ), target_zoom );
|
||||
}
|
||||
if( zoom != 1.0 )
|
||||
*mask |= PAINT_SCREEN_TRANSFORMED;
|
||||
|
@ -57,4 +69,26 @@ void ZoomEffect::postPaintScreen()
|
|||
effects->postPaintScreen();
|
||||
}
|
||||
|
||||
void ZoomEffect::zoomIn()
|
||||
{
|
||||
target_zoom *= 1.2;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
void ZoomEffect::zoomOut()
|
||||
{
|
||||
target_zoom /= 1.2;
|
||||
if( target_zoom < 1 )
|
||||
target_zoom = 1;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
void ZoomEffect::actualSize()
|
||||
{
|
||||
target_zoom = 1;
|
||||
effects->addRepaintFull();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "zoom.moc"
|
||||
|
|
|
@ -17,13 +17,18 @@ namespace KWin
|
|||
{
|
||||
|
||||
class ZoomEffect
|
||||
: public Effect
|
||||
: public QObject, public Effect
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ZoomEffect();
|
||||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||
virtual void paintScreen( int mask, QRegion region, ScreenPaintData& data );
|
||||
virtual void postPaintScreen();
|
||||
private slots:
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
void actualSize();
|
||||
private:
|
||||
double zoom;
|
||||
double target_zoom;
|
||||
|
|
Loading…
Reference in a new issue