From 7f8b7e78f6cf6df2e39ecf6077613ab0ad35b820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Mon, 4 Aug 2008 14:18:05 +0000 Subject: [PATCH] Improvement to reflection: reflection does not interfer with normal cube when vertically rotated. Rotation duration is changed in slide mode. Whole sliding does only take defined duration and not n*duration. svn path=/trunk/KDE/kdebase/workspace/; revision=842024 --- effects/cube.cpp | 20 +++++++++++++++++++- effects/cube.h | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/effects/cube.cpp b/effects/cube.cpp index db90b9cecd..c3f73b34a3 100644 --- a/effects/cube.cpp +++ b/effects/cube.cpp @@ -77,7 +77,7 @@ CubeEffect::CubeEffect() cubeOpacity = (float)conf.readEntry( "Opacity", 80 )/100.0f; displayDesktopName = conf.readEntry( "DisplayDesktopName", true ); reflection = conf.readEntry( "Reflection", true ); - int rotationDuration = conf.readEntry( "RotationDuration", 500 ); + rotationDuration = conf.readEntry( "RotationDuration", 500 ); backgroundColor = conf.readEntry( "BackgroundColor", QColor( Qt::black ) ); capColor = conf.readEntry( "CapColor", KColorScheme( QPalette::Active, KColorScheme::Window ).background().color() ); paintCaps = conf.readEntry( "Caps", true ); @@ -183,9 +183,13 @@ void CubeEffect::paintScreen( int mask, QRegion region, ScreenPaintData& data ) float scaleFactor = 6100 * tan( 60.0 * M_PI / 360.0f )/rect.height(); glScalef( 1.0, -1.0, 1.0 ); glTranslatef( 0.0, -rect.height()*2, 0.0 ); + + glEnable( GL_CLIP_PLANE0 ); reflectionPainting = true; paintScene( mask, region, data ); reflectionPainting = false; + glDisable( GL_CLIP_PLANE0 ); + glPopMatrix(); glPushMatrix(); glTranslatef( 0.0, rect.height(), 0.0 ); @@ -776,6 +780,7 @@ void CubeEffect::postPaintScreen() { activated = false; slide = false; + timeLine.setDuration( rotationDuration ); effects->setActiveFullScreenEffect( 0 ); } effects->addRepaintFull(); @@ -1230,6 +1235,9 @@ void CubeEffect::rotateToDesktop( int desktop ) { currentShape = TimeLine::EaseInCurve; timeLine.setCurveShape( currentShape ); + // change timeline duration in slide mode + if( slide ) + timeLine.setDuration( rotationDuration / (rotations.count()+1) ); } } @@ -1252,6 +1260,16 @@ void CubeEffect::setActive( bool active ) verticalRotating = false; manualAngle = 0.0; manualVerticalAngle = 0.0; + if( reflection && !slide ) + { + // clip parts above the reflection area + double eqn[4] = {0.0, 1.0, 0.0, 0.0}; + glPushMatrix(); + QRect rect = effects->clientArea( FullArea, effects->activeScreen(), effects->currentDesktop()); + glTranslatef( 0.0, rect.height(), 0.0 ); + glClipPlane( GL_CLIP_PLANE0, eqn ); + glPopMatrix(); + } effects->addRepaintFull(); } else diff --git a/effects/cube.h b/effects/cube.h index 7631e5e9b9..1f3a987482 100644 --- a/effects/cube.h +++ b/effects/cube.h @@ -102,6 +102,7 @@ class CubeEffect bool reflectionPainting; bool slide; int oldDesktop; + int rotationDuration; }; } // namespace