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 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *********************************************************************/
26 KWIN_EFFECT( scalein
, ScaleInEffect
)
28 void ScaleInEffect::prePaintScreen( ScreenPrePaintData
& data
, int time
)
30 if( !mTimeLineWindows
.isEmpty() )
31 data
.mask
|= PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS
;
32 effects
->prePaintScreen( data
, time
);
35 void ScaleInEffect::prePaintWindow( EffectWindow
* w
, WindowPrePaintData
& data
, int time
)
37 if( mTimeLineWindows
.contains( w
) )
39 mTimeLineWindows
[ w
].setCurveShape( TimeLine::EaseOutCurve
);
40 mTimeLineWindows
[ w
].addTime( time
);
41 if( mTimeLineWindows
[ w
].value() < 1 )
42 data
.setTransformed();
44 mTimeLineWindows
.remove( w
);
46 effects
->prePaintWindow( w
, data
, time
);
49 void ScaleInEffect::paintWindow( EffectWindow
* w
, int mask
, QRegion region
, WindowPaintData
& data
)
51 if( mTimeLineWindows
.contains( w
) && isScaleWindow( w
) )
53 data
.opacity
*= mTimeLineWindows
[ w
].value();
54 data
.xScale
*= mTimeLineWindows
[ w
].value();
55 data
.yScale
*= mTimeLineWindows
[ w
].value();
56 data
.xTranslate
+= int( w
->width() / 2 * ( 1 - mTimeLineWindows
[ w
].value() ) );
57 data
.yTranslate
+= int( w
->height() / 2 * ( 1 - mTimeLineWindows
[ w
].value() ) );
59 effects
->paintWindow( w
, mask
, region
, data
);
62 bool ScaleInEffect::isScaleWindow( EffectWindow
* w
)
64 // TODO: isSpecialWindow is rather generic, maybe tell windowtypes separately?
65 if ( w
->isPopupMenu() || w
->isSpecialWindow() || w
->isUtility() )
70 void ScaleInEffect::postPaintWindow( EffectWindow
* w
)
72 if( mTimeLineWindows
.contains( w
) )
73 w
->addRepaintFull(); // trigger next animation repaint
74 effects
->postPaintWindow( w
);
77 void ScaleInEffect::windowAdded( EffectWindow
* c
)
79 if( c
->isOnCurrentDesktop())
81 mTimeLineWindows
[ c
].setDuration( animationTime( 250 ));
82 mTimeLineWindows
[ c
].setProgress( 0.0 );
87 void ScaleInEffect::windowClosed( EffectWindow
* c
)
89 mTimeLineWindows
.remove( c
);