Commit 6408e0ba authored by Igor Poboiko's avatar Igor Poboiko
Browse files

[effects/cube] Fix animation and reflection issues

The main problem was that inside the effect there was manualVerticalAngle,
which did not represent the actual rotation angle of the cube during the
animation, but used to calculate the position of the reflection. The actual
angle was calculated on-the-fly and was not exposed outside.

Brief description of what the code does:

- variables currentAngle and verticalCurrentAngle now always represent the
current position of the cube. They are updated when one uses the mouse and
inside the rotateCube() method, which is called in prePaintScreen().
- two queues, animations (used for Start / Stop / Left / Right) and
verticalAnimations (used for Up / Down) are used for scheduling the animations
if i.e. user presses several keys in a row. The code checks whether the last
animation has finished (and thus we need to start a new one) inside
prePaintScreen() and postPaintScreen()
 - when the animation starts, code saves the starting position of the cube
inside startAngle, startFrontDesktop and verticalStartAngle variables, which
are used to calculate the actual cube position during the animation later.
This is done by startAnimation() and startVerticalAnimation(), which also
calculates the QTimeLine curves needed for animation

BUG: 213599
BUG: 373101

Differential Revision:
parent 81f38abe
This diff is collapsed.
......@@ -142,17 +142,18 @@ private Q_SLOTS:
void slotCubeCapLoaded();
void slotWallPaperLoaded();
enum RotationDirection {
enum class AnimationState {
enum class VerticalAnimationState {
enum VerticalRotationPosition {
enum CubeMode {
......@@ -170,6 +171,9 @@ private:
void setActive(bool active);
QImage loadCubeCap(const QString &capPath);
QImage loadWallPaper(const QString &file);
void startAnimation(AnimationState state);
void startVerticalAnimation(VerticalAnimationState state);
bool activated;
bool cube_painting;
bool keyboard_grab;
......@@ -189,23 +193,26 @@ private:
bool verticalRotating;
bool desktopChangedWhileRotating;
bool paintCaps;
QTimeLine timeLine;
QTimeLine verticalTimeLine;
RotationDirection rotationDirection;
RotationDirection verticalRotationDirection;
VerticalRotationPosition verticalPosition;
QQueue<RotationDirection> rotations;
QQueue<RotationDirection> verticalRotations;
QColor backgroundColor;
QColor capColor;
GLTexture* wallpaper;
bool texturedCaps;
GLTexture* capTexture;
float manualAngle;
float manualVerticalAngle;
QTimeLine::CurveShape currentShape;
bool start;
bool stop;
// animations
// Horizontal/start/stop
float startAngle;
float currentAngle;
int startFrontDesktop;
AnimationState animationState;
QTimeLine timeLine;
QQueue<AnimationState> animations;
// vertical
float verticalStartAngle;
float verticalCurrentAngle;
VerticalAnimationState verticalAnimationState;
QTimeLine verticalTimeLine;
QQueue<VerticalAnimationState> verticalAnimations;
bool reflectionPainting;
int rotationDuration;
int activeScreen;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment