Changeset 71425 in vbox
- Timestamp:
- Mar 21, 2018 11:38:25 AM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 121392
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/globals
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIAnimationFramework.cpp
r69500 r71425 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 21 21 22 22 /* Qt includes: */ 23 # include <QWidget>24 # include <QStateMachine>25 23 # include <QPropertyAnimation> 26 24 # include <QSignalTransition> 25 # include <QStateMachine> 26 # include <QWidget> 27 27 28 28 /* GUI includes: */ … … 35 35 36 36 37 /********************************************************************************************************************************* 38 * Class UIAnimation implementation. * 39 *********************************************************************************************************************************/ 40 37 41 /* static */ 38 42 UIAnimation* UIAnimation::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 39 43 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 40 44 const char *pszSignalForward, const char *pszSignalReverse, 41 bool fReverse /* = false */, int iAnimationDuration /* = 300*/)45 bool fReverse /* = false */, int iAnimationDuration /* = 300 */) 42 46 { 43 47 /* Return newly created animation-machine: */ … … 48 52 } 49 53 50 /* static */ 51 UIAnimationLoop* UIAnimationLoop::installAnimationLoop(QWidget *pTarget, const char *pszPropertyName, 52 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 53 int iAnimationDuration /* = 300*/) 54 void UIAnimation::update() 54 55 { 55 /* Return newly created animation-loop: */ 56 return new UIAnimationLoop(pTarget, pszPropertyName, 57 pszValuePropertyNameStart, pszValuePropertyNameFinal, 58 iAnimationDuration); 56 /* Update 'forward' animation: */ 57 m_pForwardAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart)); 58 m_pForwardAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal)); 59 m_pStateStart->assignProperty(parent(), m_pszPropertyName, parent()->property(m_pszValuePropertyNameStart)); 60 /* Update 'reverse' animation: */ 61 m_pReverseAnimation->setStartValue(parent()->property(m_pszValuePropertyNameFinal)); 62 m_pReverseAnimation->setEndValue(parent()->property(m_pszValuePropertyNameStart)); 63 m_pStateFinal->assignProperty(parent(), m_pszPropertyName, parent()->property(m_pszValuePropertyNameFinal)); 59 64 } 60 61 65 62 66 UIAnimation::UIAnimation(QWidget *pParent, const char *pszPropertyName, … … 117 121 } 118 122 119 void UIAnimation::update() 123 124 /********************************************************************************************************************************* 125 * Class UIAnimation implementation. * 126 *********************************************************************************************************************************/ 127 128 /* static */ 129 UIAnimationLoop* UIAnimationLoop::installAnimationLoop(QWidget *pTarget, const char *pszPropertyName, 130 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 131 int iAnimationDuration /* = 300*/) 120 132 { 121 /* Update 'forward' animation: */ 122 m_pForwardAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart)); 123 m_pForwardAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal)); 124 m_pStateStart->assignProperty(parent(), m_pszPropertyName, parent()->property(m_pszValuePropertyNameStart)); 125 /* Update 'reverse' animation: */ 126 m_pReverseAnimation->setStartValue(parent()->property(m_pszValuePropertyNameFinal)); 127 m_pReverseAnimation->setEndValue(parent()->property(m_pszValuePropertyNameStart)); 128 m_pStateFinal->assignProperty(parent(), m_pszPropertyName, parent()->property(m_pszValuePropertyNameFinal)); 133 /* Return newly created animation-loop: */ 134 return new UIAnimationLoop(pTarget, pszPropertyName, 135 pszValuePropertyNameStart, pszValuePropertyNameFinal, 136 iAnimationDuration); 129 137 } 130 138 139 void UIAnimationLoop::update() 140 { 141 /* Update animation: */ 142 m_pAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart)); 143 m_pAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal)); 144 } 145 146 void UIAnimationLoop::start() 147 { 148 /* Start animation: */ 149 m_pAnimation->start(); 150 } 151 152 void UIAnimationLoop::stop() 153 { 154 /* Stop animation: */ 155 m_pAnimation->stop(); 156 } 131 157 132 158 UIAnimationLoop::UIAnimationLoop(QWidget *pParent, const char *pszPropertyName, … … 154 180 } 155 181 156 void UIAnimationLoop::update()157 {158 /* Update animation: */159 m_pAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart));160 m_pAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal));161 }162 163 void UIAnimationLoop::start()164 {165 /* Start animation: */166 m_pAnimation->start();167 }168 169 void UIAnimationLoop::stop()170 {171 /* Stop animation: */172 m_pAnimation->stop();173 }174 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIAnimationFramework.h
r69500 r71425 5 5 6 6 /* 7 * Copyright (C) 2013-201 7Oracle Corporation7 * Copyright (C) 2013-2018 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 16 16 */ 17 17 18 #ifndef __ UIAnimationFramework_h__19 #define __ UIAnimationFramework_h__18 #ifndef ___UIAnimationFramework_h___ 19 #define ___UIAnimationFramework_h___ 20 20 21 21 /* Qt includes: */ … … 23 23 24 24 /* Forward declaration: */ 25 class QPropertyAnimation; 26 class QState; 25 27 class QStateMachine; 26 class QState;27 class QPropertyAnimation;28 28 29 /* UIAnimation factory: */ 29 30 /** QObject subclass used as animation factory. */ 30 31 class UIAnimation : public QObject 31 32 { … … 34 35 signals: 35 36 36 /* Notifiers: State-change stuff:*/37 /** Notifies listener about 'Start' state entered. */ 37 38 void sigStateEnteredStart(); 39 /** Notifies listener about 'Final' state entered. */ 38 40 void sigStateEnteredFinal(); 39 41 40 42 public: 41 43 42 /* API: Factory stuff: */ 43 static UIAnimation* installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 44 /** Installs property animation. 45 * @param pTarget Brings the object being animated. 46 * @param pszPropertyName Brings the name of property being animated. 47 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value. 48 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value. 49 * @param pszSignalForward Brings the signal to start forward animation. 50 * @param pszSignalReverse Brings the signal to start reverse animation. 51 * @param fReverse Brings whether the animation should be inverted. 52 * @param iAnimationDuration Brings the animation duration. */ 53 static UIAnimation *installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 44 54 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 45 55 const char *pszSignalForward, const char *pszSignalReverse, 46 56 bool fReverse = false, int iAnimationDuration = 300); 47 57 48 /* API: Update stuff:*/58 /** Updates the animation, fetching new initial values. */ 49 59 void update(); 50 60 51 pr otected:61 private: 52 62 53 /* Constructor: */ 63 /** Constructs animation. Doesn't mean to be used directly. 64 * @param pParent Brings the object animation being applied to. 65 * @param pszPropertyName Brings the name of property being animated. 66 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value. 67 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value. 68 * @param pszSignalForward Brings the signal to start forward animation. 69 * @param pszSignalReverse Brings the signal to start reverse animation. 70 * @param fReverse Brings whether the animation should be inverted. 71 * @param iAnimationDuration Brings the animation duration. */ 54 72 UIAnimation(QWidget *pParent, const char *pszPropertyName, 55 73 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, … … 57 75 bool fReverse, int iAnimationDuration); 58 76 59 private: 60 61 /* Helper: Prepare stuff: */ 77 /** Prepares all. */ 62 78 void prepare(); 63 79 64 /* Variables: General stuff:*/80 /** Holds the name of property being animated. */ 65 81 const char *m_pszPropertyName; 82 83 /** Holds the name of the property holding 'start' value. */ 66 84 const char *m_pszValuePropertyNameStart; 85 /** Holds the name of the property holding 'final' value. */ 67 86 const char *m_pszValuePropertyNameFinal; 87 88 /** Holds the signal to start forward animation. */ 68 89 const char *m_pszSignalForward; 90 /** Holds the signal to start reverse animation. */ 69 91 const char *m_pszSignalReverse; 92 93 /** Holds whether the animation should be inverted. */ 70 94 bool m_fReverse; 95 96 /** Holds the animation duration. */ 71 97 int m_iAnimationDuration; 72 98 73 /* Variables: Animation-machine stuff: */ 74 QStateMachine *m_pAnimationMachine; 75 QState *m_pStateStart; 76 QState *m_pStateFinal; 99 /** Holds the animation machine instance. */ 100 QStateMachine *m_pAnimationMachine; 101 /** Holds the instance of the animation 'Start' state. */ 102 QState *m_pStateStart; 103 /** Holds the instance of the animation 'Final' state. */ 104 QState *m_pStateFinal; 105 /** Holds the instance of the 'Forward' animation. */ 77 106 QPropertyAnimation *m_pForwardAnimation; 107 /** Holds the instance of the 'Reverse' animation. */ 78 108 QPropertyAnimation *m_pReverseAnimation; 79 109 }; 80 110 81 /* UIAnimationLoop factory: */ 111 112 /** QObject subclass used as animation loop factory. */ 82 113 class UIAnimationLoop : public QObject 83 114 { … … 86 117 public: 87 118 88 /* API: Factory stuff: */ 89 static UIAnimationLoop* installAnimationLoop(QWidget *pTarget, const char *pszPropertyName, 119 /** Installs property animation. 120 * @param pTarget Brings the object being animated. 121 * @param pszPropertyName Brings the name of property being animated. 122 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value. 123 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value. 124 * @param iAnimationDuration Brings the animation duration. */ 125 static UIAnimationLoop *installAnimationLoop(QWidget *pTarget, const char *pszPropertyName, 90 126 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 91 127 int iAnimationDuration = 300); 92 128 93 /* API: Update stuff:*/129 /** Updates the animation, fetching new initial values. */ 94 130 void update(); 95 131 96 /* API: Loop stuff:*/132 /** Starts the loop. */ 97 133 void start(); 134 /** Stops the loop. */ 98 135 void stop(); 99 136 100 pr otected:137 private: 101 138 102 /* Constructor: */ 139 /** Constructs animation loop. Doesn't mean to be used directly. 140 * @param pParent Brings the object animation being applied to. 141 * @param pszPropertyName Brings the name of property being animated. 142 * @param pszValuePropertyNameStart Brings the name of the property holding 'start' value. 143 * @param pszValuePropertyNameFinal Brings the name of the property holding 'final' value. 144 * @param iAnimationDuration Brings the animation duration. */ 103 145 UIAnimationLoop(QWidget *pParent, const char *pszPropertyName, 104 146 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 105 147 int iAnimationDuration); 106 148 107 private: 108 109 /* Helper: Prepare stuff: */ 149 /** Prepares all. */ 110 150 void prepare(); 111 151 112 /* Variables:*/152 /** Holds the name of property being animated. */ 113 153 const char *m_pszPropertyName; 154 155 /** Holds the name of the property holding 'start' value. */ 114 156 const char *m_pszValuePropertyNameStart; 157 /** Holds the name of the property holding 'final' value. */ 115 158 const char *m_pszValuePropertyNameFinal; 159 160 /** Holds the animation duration. */ 116 161 int m_iAnimationDuration; 162 163 /** Holds the instance of the animation. */ 117 164 QPropertyAnimation *m_pAnimation; 118 165 }; 119 166 120 #endif /* __UIAnimationFramework_h__ */ 167 168 #endif /* !___UIAnimationFramework_h___ */ 169
Note:
See TracChangeset
for help on using the changeset viewer.