2006-10-29 19:08:09 +00:00
|
|
|
/*****************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
|
|
|
|
|
|
|
|
You can Freely distribute this program under the GNU General Public
|
|
|
|
License. See the file "COPYING" for the exact licensing terms.
|
|
|
|
******************************************************************/
|
|
|
|
|
2007-04-12 13:12:11 +00:00
|
|
|
#include "demo_shiftworkspaceup.h"
|
2006-10-29 19:08:09 +00:00
|
|
|
|
2007-04-05 12:07:35 +00:00
|
|
|
namespace KWin
|
2006-10-29 19:08:09 +00:00
|
|
|
{
|
|
|
|
|
2007-04-13 10:08:18 +00:00
|
|
|
KWIN_EFFECT( Demo_ShiftWorkspaceUp, ShiftWorkspaceUpEffect )
|
2007-04-12 10:16:02 +00:00
|
|
|
|
2007-02-04 22:19:17 +00:00
|
|
|
ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect()
|
2006-10-29 19:08:09 +00:00
|
|
|
: up( false )
|
|
|
|
, diff( 0 )
|
|
|
|
{
|
|
|
|
connect( &timer, SIGNAL( timeout()), SLOT( tick()));
|
|
|
|
timer.start( 2000 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShiftWorkspaceUpEffect::prePaintScreen( int* mask, QRegion* region, int time )
|
|
|
|
{
|
|
|
|
if( up && diff < 1000 )
|
|
|
|
diff = qBound( 0, diff + time, 1000 ); // KDE3: note this differs from KCLAMP
|
|
|
|
if( !up && diff > 0 )
|
|
|
|
diff = qBound( 0, diff - time, 1000 );
|
|
|
|
if( diff != 0 )
|
2007-04-12 10:16:02 +00:00
|
|
|
*mask |= PAINT_SCREEN_TRANSFORMED;
|
2006-10-29 19:08:09 +00:00
|
|
|
effects->prePaintScreen( mask, region, time );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShiftWorkspaceUpEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
|
|
|
|
{
|
|
|
|
if( diff != 0 )
|
|
|
|
data.yTranslate -= diff / 100;
|
|
|
|
effects->paintScreen( mask, region, data );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShiftWorkspaceUpEffect::postPaintScreen()
|
|
|
|
{
|
|
|
|
if( up ? diff < 1000 : diff > 0 )
|
2007-04-12 10:16:02 +00:00
|
|
|
effects->addRepaintFull(); // trigger next animation repaint
|
2006-10-29 19:08:09 +00:00
|
|
|
effects->postPaintScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShiftWorkspaceUpEffect::tick()
|
|
|
|
{
|
|
|
|
up = !up;
|
2007-04-12 10:16:02 +00:00
|
|
|
effects->addRepaintFull();
|
2006-10-29 19:08:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2007-04-12 13:12:11 +00:00
|
|
|
#include "demo_shiftworkspaceup.moc"
|