~ubuntu-branches/ubuntu/gutsy/kdebase-workspace/gutsy-backports

« back to all changes in this revision

Viewing changes to kwin/effects/demo_shiftworkspaceup.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2007-09-05 20:45:14 UTC
  • Revision ID: james.westby@ubuntu.com-20070905204514-632hhspl0nvrc84i
Tags: upstream-3.93.0
ImportĀ upstreamĀ versionĀ 3.93.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************
 
2
 KWin - the KDE window manager
 
3
 This file is part of the KDE project.
 
4
 
 
5
Copyright (C) 2006 Lubos Lunak <l.lunak@kde.org>
 
6
 
 
7
You can Freely distribute this program under the GNU General Public
 
8
License. See the file "COPYING" for the exact licensing terms.
 
9
******************************************************************/
 
10
 
 
11
#include "demo_shiftworkspaceup.h"
 
12
 
 
13
namespace KWin
 
14
{
 
15
 
 
16
KWIN_EFFECT( demo_shiftworkspaceup, ShiftWorkspaceUpEffect )
 
17
 
 
18
ShiftWorkspaceUpEffect::ShiftWorkspaceUpEffect()
 
19
    : up( false )
 
20
    , diff( 0 )
 
21
    {
 
22
    connect( &timer, SIGNAL( timeout()), SLOT( tick()));
 
23
    timer.start( 2000 );
 
24
    }
 
25
 
 
26
void ShiftWorkspaceUpEffect::prePaintScreen( ScreenPrePaintData& data, int time )
 
27
    {
 
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 );
 
35
    }
 
36
 
 
37
void ShiftWorkspaceUpEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data )
 
38
    {
 
39
    if( diff != 0 )
 
40
        data.yTranslate -= diff / 100;
 
41
    effects->paintScreen( mask, region, data );
 
42
    }
 
43
 
 
44
void ShiftWorkspaceUpEffect::postPaintScreen()
 
45
    {
 
46
    if( up ? diff < 1000 : diff > 0 )
 
47
        effects->addRepaintFull(); // trigger next animation repaint
 
48
    effects->postPaintScreen();
 
49
    }
 
50
 
 
51
void ShiftWorkspaceUpEffect::tick()
 
52
    {
 
53
    up = !up;
 
54
    effects->addRepaintFull();
 
55
    }
 
56
 
 
57
} // namespace
 
58
 
 
59
#include "demo_shiftworkspaceup.moc"