|
|
|
@ -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"
|
|
|
|
|