From ab330beb5958326ccdd5c4dee831e96e4e5adf8e Mon Sep 17 00:00:00 2001 From: Lucas Murray Date: Fri, 28 Nov 2008 15:23:21 +0000 Subject: [PATCH] Enable box switch animations by default. Add window fading when activating or deactivating to make it look nicer. CCBUG: 176338 svn path=/trunk/KDE/kdebase/workspace/; revision=890199 --- effects/boxswitch.cpp | 38 ++++++++++++++++++++++++++---------- effects/boxswitch.h | 1 + effects/boxswitch_config.cpp | 4 ++-- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/effects/boxswitch.cpp b/effects/boxswitch.cpp index 63edc8ebf7..13c9029975 100644 --- a/effects/boxswitch.cpp +++ b/effects/boxswitch.cpp @@ -63,12 +63,15 @@ void BoxSwitchEffect::reconfigure( ReconfigureFlags ) color_highlight = KColorScheme( QPalette::Active, KColorScheme::Selection ).background().color(); color_highlight.setAlphaF( 0.9 ); color_text = KColorScheme( QPalette::Active, KColorScheme::Window ).foreground().color(); + activeTimeLine.setDuration( animationTime( 250 )); + activeTimeLine.setCurveShape( TimeLine::EaseInOutCurve ); timeLine.setDuration( animationTime( 150 )); + timeLine.setCurveShape( TimeLine::EaseInOutCurve ); KConfigGroup conf = effects->effectConfig( "BoxSwitch" ); bg_opacity = conf.readEntry( "BackgroundOpacity", 25 ) / 100.0; elevate_window = conf.readEntry( "ElevateSelected", true ); - mAnimateSwitch = conf.readEntry( "AnimateSwitch", false ); + mAnimateSwitch = conf.readEntry( "AnimateSwitch", true ); } void BoxSwitchEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, int time ) @@ -100,6 +103,10 @@ void BoxSwitchEffect::prePaintWindow( EffectWindow* w, WindowPrePaintData& data, void BoxSwitchEffect::prePaintScreen( ScreenPrePaintData& data, int time ) { + if( mActivated ) + activeTimeLine.addTime( time ); + else + activeTimeLine.removeTime( time ); if( mActivated && animation ) { timeLine.addTime( time ); @@ -167,6 +174,10 @@ void BoxSwitchEffect::paintScreen( int mask, QRegion region, ScreenPaintData& da void BoxSwitchEffect::postPaintScreen() { + if( mActivated && activeTimeLine.value() != 1.0 ) + effects->addRepaintFull(); + if( !mActivated && activeTimeLine.value() != 0.0 ) + effects->addRepaintFull(); if( mActivated && animation ) { if( timeLine.value() == 1.0 ) @@ -190,14 +201,15 @@ void BoxSwitchEffect::postPaintScreen() void BoxSwitchEffect::paintWindow( EffectWindow* w, int mask, QRegion region, WindowPaintData& data ) { - if( mActivated ) + if(( mActivated && mMode == TabBoxWindowsMode ) || ( !mActivated && activeTimeLine.value() != 0.0 )) { - if( mMode == TabBoxWindowsMode ) + if( windows.contains( w ) && w != selected_window ) { - if( windows.contains( w ) && w != selected_window ) - { - data.opacity *= bg_opacity; - } + if( w->isMinimized() ) + // TODO: When deactivating minimized windows are not painted at all + data.opacity *= activeTimeLine.value() * bg_opacity; + else + data.opacity *= 1.0 - activeTimeLine.value() * ( 1.0 - bg_opacity ); } } effects->paintWindow( w, mask, region, data ); @@ -414,6 +426,11 @@ void BoxSwitchEffect::tabBoxUpdated() void BoxSwitchEffect::setActive() { mActivated = true; + + // Do this here so we have correct fading on deactivation + qDeleteAll( windows ); + windows.clear(); + if( mMode == TabBoxWindowsMode ) { original_windows = effects->currentTabBoxWindowList(); @@ -454,9 +471,10 @@ void BoxSwitchEffect::setInactive() if( w != selected_window ) w->addRepaintFull(); } - qDeleteAll( windows ); - windows.clear(); - setSelectedWindow( 0 ); + // We don't unset the selected window so we have correct fading + // But we do need to remove elevation status + if( elevate_window && selected_window ) + effects->setElevatedWindow( selected_window, false ); } else { // DesktopMode diff --git a/effects/boxswitch.h b/effects/boxswitch.h index 83df5a887f..667a482c1a 100644 --- a/effects/boxswitch.h +++ b/effects/boxswitch.h @@ -100,6 +100,7 @@ class BoxSwitchEffect int painting_desktop; bool mAnimateSwitch; + TimeLine activeTimeLine; TimeLine timeLine; bool animation; QRect highlight_area; diff --git a/effects/boxswitch_config.cpp b/effects/boxswitch_config.cpp index a48ee808e7..89bc0ace9f 100644 --- a/effects/boxswitch_config.cpp +++ b/effects/boxswitch_config.cpp @@ -68,7 +68,7 @@ void BoxSwitchEffectConfig::load() bool elevate = conf.readEntry( "ElevateSelected", true ); m_ui->elevateBox->setChecked( elevate ); - bool animate = conf.readEntry( "AnimateSwitch", false ); + bool animate = conf.readEntry( "AnimateSwitch", true ); m_ui->animateBox->setChecked( animate ); emit changed(false); @@ -96,7 +96,7 @@ void BoxSwitchEffectConfig::defaults() { m_ui->opacitySpin->setValue( 25 ); m_ui->elevateBox->setChecked( true ); - m_ui->animateBox->setChecked( false ); + m_ui->animateBox->setChecked( true ); emit changed(true); }