Minimizing windows now uses the new TimeLine feature. This way, they

accelerate towards the taskbar.

svn path=/trunk/KDE/kdebase/workspace/; revision=798723
This commit is contained in:
Sebastian Kügler 2008-04-19 00:12:24 +00:00
parent b953f0a046
commit a827c19cf1
2 changed files with 17 additions and 22 deletions

View file

@ -33,7 +33,7 @@ MinimizeAnimationEffect::MinimizeAnimationEffect()
void MinimizeAnimationEffect::prePaintScreen( ScreenPrePaintData& data, int time ) void MinimizeAnimationEffect::prePaintScreen( ScreenPrePaintData& data, int time )
{ {
mActiveAnimations = mAnimationProgress.count(); mActiveAnimations = mTimeLine.count();
if( mActiveAnimations > 0 ) if( mActiveAnimations > 0 )
// We need to mark the screen windows as transformed. Otherwise the // We need to mark the screen windows as transformed. Otherwise the
// whole screen won't be repainted, resulting in artefacts // whole screen won't be repainted, resulting in artefacts
@ -44,25 +44,24 @@ void MinimizeAnimationEffect::prePaintScreen( ScreenPrePaintData& data, int time
void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time )
{ {
const double changeTime = 300; if( mTimeLine.contains( w ))
if( mAnimationProgress.contains( w ))
{ {
if( w->isMinimized() ) if( w->isMinimized() )
{ {
mAnimationProgress[w] += time / changeTime; mTimeLine[w].addTime(time);
if( mAnimationProgress[w] >= 1.0f ) if( mTimeLine[w].progress() >= 1.0f )
mAnimationProgress.remove( w ); mTimeLine.remove( w );
} }
else else
{ {
mAnimationProgress[w] -= time / changeTime; mTimeLine[w].removeTime(time);
if( mAnimationProgress[w] <= 0.0f ) if( mTimeLine[w].progress() <= 0.0f )
mAnimationProgress.remove( w ); mTimeLine.remove( w );
} }
// Schedule window for transformation if the animation is still in // Schedule window for transformation if the animation is still in
// progress // progress
if( mAnimationProgress.contains( w )) if( mTimeLine.contains( w ))
{ {
// We'll transform this window // We'll transform this window
data.setTransformed(); data.setTransformed();
@ -75,10 +74,10 @@ void MinimizeAnimationEffect::prePaintWindow( EffectWindow* w, WindowPrePaintDat
void MinimizeAnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) void MinimizeAnimationEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data )
{ {
if( mAnimationProgress.contains( w )) if( mTimeLine.contains( w ))
{ {
// 0 = not minimized, 1 = fully minimized // 0 = not minimized, 1 = fully minimized
double progress = mAnimationProgress[w]; double progress = mTimeLine[w].value();
QRect geo = w->geometry(); QRect geo = w->geometry();
QRect icon = w->iconGeometry(); QRect icon = w->iconGeometry();
@ -101,7 +100,7 @@ void MinimizeAnimationEffect::postPaintScreen()
if( mActiveAnimations > 0 ) if( mActiveAnimations > 0 )
// Repaint the workspace so that everything would be repainted next time // Repaint the workspace so that everything would be repainted next time
effects->addRepaintFull(); effects->addRepaintFull();
mActiveAnimations = mAnimationProgress.count(); mActiveAnimations = mTimeLine.count();
// Call the next effect. // Call the next effect.
effects->postPaintScreen(); effects->postPaintScreen();
@ -109,18 +108,14 @@ void MinimizeAnimationEffect::postPaintScreen()
void MinimizeAnimationEffect::windowMinimized( EffectWindow* w ) void MinimizeAnimationEffect::windowMinimized( EffectWindow* w )
{ {
if( !mAnimationProgress.contains(w) ) mTimeLine[w].setCurveShape(TimeLine::EaseInCurve);
{ mTimeLine[w].setProgress(0.0f);
mAnimationProgress[w] = 0.0f;
}
} }
void MinimizeAnimationEffect::windowUnminimized( EffectWindow* w ) void MinimizeAnimationEffect::windowUnminimized( EffectWindow* w )
{ {
if( !mAnimationProgress.contains(w) ) mTimeLine[w].setCurveShape(TimeLine::EaseOutCurve);
{ mTimeLine[w].setProgress(1.0f);
mAnimationProgress[w] = 1.0f;
}
} }
} // namespace } // namespace

View file

@ -46,7 +46,7 @@ class MinimizeAnimationEffect
virtual void windowUnminimized( EffectWindow* c ); virtual void windowUnminimized( EffectWindow* c );
private: private:
QHash< EffectWindow*, double > mAnimationProgress; QHash< EffectWindow*, TimeLine > mTimeLine;
int mActiveAnimations; int mActiveAnimations;
}; };