diff options
author | Ken Moore <ken@ixsystems.com> | 2017-07-20 12:40:16 -0400 |
---|---|---|
committer | Ken Moore <ken@ixsystems.com> | 2017-07-20 12:40:16 -0400 |
commit | 23b870f04c46e8fa6d4ca2b14eb6d9ea2285a4c0 (patch) | |
tree | 2c8a5443b880b7261838d264e3db386bfc7a5fd3 /src-qt5/core/libLumina/RootSubWindow-animations.cpp | |
parent | Get the compositing working much smoother now. (diff) | |
download | lumina-23b870f04c46e8fa6d4ca2b14eb6d9ea2285a4c0.tar.gz lumina-23b870f04c46e8fa6d4ca2b14eb6d9ea2285a4c0.tar.bz2 lumina-23b870f04c46e8fa6d4ca2b14eb6d9ea2285a4c0.zip |
Add a window animation framework, with 7 visibility animations for starters.
Diffstat (limited to 'src-qt5/core/libLumina/RootSubWindow-animations.cpp')
-rw-r--r-- | src-qt5/core/libLumina/RootSubWindow-animations.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/src-qt5/core/libLumina/RootSubWindow-animations.cpp b/src-qt5/core/libLumina/RootSubWindow-animations.cpp new file mode 100644 index 00000000..e3deed3a --- /dev/null +++ b/src-qt5/core/libLumina/RootSubWindow-animations.cpp @@ -0,0 +1,94 @@ +//=========================================== +// Lumina Desktop source code +// Copyright (c) 2017, Ken Moore +// Available under the 3-clause BSD license +// See the LICENSE file for full details +//=========================================== +#include "RootSubWindow.h" +#include <QDebug> + +QStringList RootSubWindow::validAnimations(NativeWindow::Property prop){ + QStringList valid; + if(prop == NativeWindow::Visible){ + valid << "zoom" << "wipe-center-vertical" << "wipe-center-horizontal" << "shade-top" << "shade-right" << "shade-left" << "shade-bottom"; + } + return valid; +} + +void RootSubWindow::loadAnimation(QString name, NativeWindow::Property prop, QVariant nval){ + animResetProp.clear(); + //Special case - random animation each time + if(name=="random"){ + QStringList valid = validAnimations(prop); + name = valid.at(qrand()%valid.length()); + } + //Now setup the animation + if(prop == NativeWindow::Visible){ + //NOTE: Assigns values for "invisible->visible" animation: will reverse it afterwards as needed + anim->setPropertyName("geometry"); + QRect geom = this->geometry(); + if(name == "zoom"){ + //Zoom to/from the center point + anim->setStartValue( QRect(geom.center(), QSize(0,0)) ); + anim->setEndValue(geom); + }else if(name == "wipe-center-vertical"){ + anim->setStartValue( QRect( geom.center().x(), geom.y(), 0, geom.height()) ); + anim->setEndValue( geom ); + }else if(name == "wipe-center-horizontal"){ + anim->setStartValue( QRect( geom.x(), geom.center().y(), geom.width(), 0) ); + anim->setEndValue( geom ); + }else if(name == "shade-top"){ + anim->setStartValue( QRect( geom.x(), geom.y(), geom.width(), 0) ); + anim->setEndValue( geom ); + }else if(name == "shade-bottom"){ + anim->setStartValue( QRect( geom.x(), geom.y()+geom.height(), geom.width(), 0) ); + anim->setEndValue( geom ); + }else if(name == "shade-left"){ + anim->setStartValue( QRect( geom.x(), geom.y(), 0, geom.height()) ); + anim->setEndValue( geom ); + }else if(name == "shade-right"){ + anim->setStartValue( QRect( geom.x()+geom.width(), geom.y(), 0, geom.height()) ); + anim->setEndValue( geom ); + }else{ + //Invalid/None animation + if(nval.toBool()){ this->show(); } + else{ this->hide(); } + return; + } + if(nval.toBool()){ + this->setGeometry( anim->startValue().toRect() ); //ensure the window is the initial geom before it becomes visible + }else{ + QVariant tmp = anim->startValue(); + anim->setStartValue(anim->endValue()); + anim->setEndValue(tmp); + animResetProp = anim->startValue(); + QTimer::singleShot(anim->duration(), this, SLOT(hide()) ); + } + anim->start(); + this->show(); + } //end of Visibility animation +} + +void RootSubWindow::animFinished(){ + if(closing){ this->close(); return;} + else if(anim->propertyName()=="geometry"){ + if(!animResetProp.isNull()){ + /*qDebug() << "Animation Finished, Reset Geometry:" << animResetProp.toRect(); + qDebug() << " - Starting Value:" << anim->startValue().toRect(); + qDebug() << " - Ending Value:" << anim->endValue().toRect();*/ + this->setGeometry( animResetProp.toRect() ); + //Also ensure that the proper geometry is saved to the window structure + QRect curg = this->geometry(); + QRect wing = WIN->geometry(); + qDebug() << " - After Animation Reset:" << curg << wing; + if(curg!=wing){ + QRect clientg = clientGlobalGeom(); + qDebug() << "Sub Window geometry:" << clientg; + WIN->setProperties(QList< NativeWindow::Property>() << NativeWindow::Size << NativeWindow::GlobalPos, + QList<QVariant>() << clientg.size() << clientg.topLeft() ); + WinWidget->resyncWindow(); //also let the window know about the current geometry + } + } + } + animResetProp = QVariant(); //clear the variable +} |