[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/work/soc-kwin-cube/effects
From: Martin Gräßlin <ubuntu () martin-graesslin ! com>
Date: 2008-06-28 10:20:37
Message-ID: 1214648437.325350.6149.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 825458 by graesslin:
Beginning of cube rotating. Working for four desktops.
M +81 -20 cube.cpp
M +9 -0 cube.h
--- branches/work/soc-kwin-cube/effects/cube.cpp #825457:825458
@@ -46,11 +46,17 @@
, keyboard_grab( false )
, schedule_close( false )
, frontDesktop( 0 )
+ , rotating( false )
+ , desktopChangedWhileRotating( false )
+ , rotationDirection( Left )
{
KConfigGroup conf = effects->effectConfig("Cube");
borderActivate = (ElectricBorder)conf.readEntry("BorderActivate", \
(int)ElectricNone); effects->reserveElectricBorder( borderActivate );
+ timeLine.setCurveShape( TimeLine::EaseInOutCurve );
+ timeLine.setDuration( 2000 );
+
KActionCollection* actionCollection = new KActionCollection( this );
KAction* a = static_cast< KAction* >( actionCollection->addAction( "Cube" ));
a->setText( i18n("Desktop Cube" ));
@@ -69,6 +75,11 @@
{
//kDebug();
data.mask |= PAINT_SCREEN_TRANSFORMED | \
Effect::PAINT_SCREEN_WITH_TRANSFORMED_WINDOWS | PAINT_SCREEN_BACKGROUND_FIRST; +
+ if( rotating )
+ {
+ timeLine.addTime( time );
+ }
}
effects->prePaintScreen( data, time );
}
@@ -124,13 +135,46 @@
float yTop = (ymax-ymin)*scaleFactor;
int desktopIndex = 0;
int rotationSteps = 0;
+
+ // Rotation of the cube
+ if( rotating )
+ {
+ float point = 1.1547;
+ float rotationAngle = cubeAngle * timeLine.value();
+ if( rotationAngle > cubeAngle * 0.5f )
+ {
+ rotationAngle -= cubeAngle;
+ if( !desktopChangedWhileRotating )
+ {
+ desktopChangedWhileRotating = true;
+ if( rotationDirection == Left )
+ {
+ frontDesktop++;
+ if( frontDesktop > effects->numberOfDesktops() )
+ frontDesktop = 1;
+ }
+ else if( rotationDirection == Right )
+ {
+ frontDesktop--;
+ if( frontDesktop == 0 )
+ frontDesktop = effects->numberOfDesktops();
+ }
+ }
+ }
+ if( rotationDirection == Left )
+ {
+ rotationAngle *= -1;
+ }
+ glTranslatef( 0.0, 0.0, -point);
+ glRotatef( rotationAngle, 0.0, 1.0, 0.0 );
+ glTranslatef( 0.0, 0.0, point);
+ }
for( int i=0; i<effects->numberOfDesktops(); i++ )
{
float angle = 0.0f;
float xTranslate = 0.0f;
float xLeft = 0.0f;
float xRight = 0.0f;
- float yBottom = 0.0f;
int xScale = 1;
bool scaleTranslate = false;
if( i%2 == 0 && i != effects->numberOfDesktops() -1)
@@ -209,20 +253,33 @@
void CubeEffect::postPaintScreen()
{
effects->postPaintScreen();
- if( activated && schedule_close )
+ if( activated )
{
//kDebug();
- schedule_close = false;
- activated = false;
- if( keyboard_grab )
- effects->ungrabKeyboard();
- keyboard_grab = false;
- effects->destroyInputWindow( input );
+ if( rotating )
+ {
+ if( timeLine.value() == 1.0 )
+ {
+ timeLine.setProgress(0.0);
+ rotating = false;
+ desktopChangedWhileRotating = false;
+ }
+ effects->addRepaintFull();
+ }
+ if( schedule_close )
+ {
+ schedule_close = false;
+ activated = false;
+ if( keyboard_grab )
+ effects->ungrabKeyboard();
+ keyboard_grab = false;
+ effects->destroyInputWindow( input );
- // set the new desktop
- effects->setCurrentDesktop( frontDesktop );
- effects->setActiveFullScreenEffect( 0 );
- effects->addRepaintFull();
+ // set the new desktop
+ effects->setCurrentDesktop( frontDesktop );
+ effects->setActiveFullScreenEffect( 0 );
+ effects->addRepaintFull();
+ }
}
}
@@ -364,17 +421,21 @@
{ // wrap only on autorepeat
case Qt::Key_Left:
// rotate to previous desktop
- kDebug() << left;
- frontDesktop++;
- if( frontDesktop > effects->numberOfDesktops() )
- frontDesktop = 1;
+ kDebug() << "left";
+ if( !rotating )
+ {
+ rotating = true;
+ rotationDirection = Left;
+ }
break;
case Qt::Key_Right:
// rotate to next desktop
- kDebug() << right;
- frontDesktop--;
- if( frontDesktop == 0 )
- frontDesktop = effects->numberOfDesktops();
+ kDebug() << "right";
+ if( !rotating )
+ {
+ rotating = true;
+ rotationDirection = Right;
+ }
break;
case Qt::Key_Escape:
setActive( false );
--- branches/work/soc-kwin-cube/effects/cube.h #825457:825458
@@ -46,6 +46,11 @@
private slots:
void toggle();
private:
+ enum RotationDirection
+ {
+ Left,
+ Right
+ };
void setActive( bool active );
bool activated;
bool cube_painting;
@@ -55,6 +60,10 @@
int painting_desktop;
Window input;
int frontDesktop;
+ bool rotating;
+ bool desktopChangedWhileRotating;
+ TimeLine timeLine;
+ RotationDirection rotationDirection;
};
} // namespace
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic