add more spacing
[personal-kdebase.git] / workspace / kwin / effects / test / demo_shiftworkspaceup.cpp
blobce2121754ee63f8cbb5d290bcc0e0b4dc3278b3e
1 /*****************************************************************
2 KWin - the KDE window manager
3 This file is part of the KDE project.
5 Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
7 You can Freely distribute this program under the GNU General Public
8 License. See the file "COPYING" for the exact licensing terms.
9 ******************************************************************/
11 #include "demo_shiftworkspaceup.h"
13 namespace KWin
16 KWIN_EFFECT( demo_shiftworkspaceup, ShiftWorkspaceUpEffect )
18 ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect()
19 : up( false )
20 , diff( 0 )
22 connect( &timer, SIGNAL( timeout()), SLOT( tick()));
23 timer.start( 2000 );
26 void ShiftWorkspaceUpEffect::prePaintScreen( ScreenPrePaintData& data, int time )
28 if( up && diff < 1000 )
29 diff = qBound( 0, diff + time, 1000 ); // KDE3: note this differs from KCLAMP
30 if( !up && diff > 0 )
31 diff = qBound( 0, diff - time, 1000 );
32 if( diff != 0 )
33 data.mask |= PAINT_SCREEN_TRANSFORMED;
34 effects->prePaintScreen( data, time );
37 void ShiftWorkspaceUpEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
39 if( diff != 0 )
40 data.yTranslate -= diff / 100;
41 effects->paintScreen( mask, region, data );
44 void ShiftWorkspaceUpEffect::postPaintScreen()
46 if( up ? diff < 1000 : diff > 0 )
47 effects->addRepaintFull(); // trigger next animation repaint
48 effects->postPaintScreen();
51 void ShiftWorkspaceUpEffect::tick()
53 up = !up;
54 effects->addRepaintFull();
57 } // namespace
59 #include "demo_shiftworkspaceup.moc"