Changeset 46242 in vbox for trunk/src/VBox/Frontends/VirtualBox
- Timestamp:
- May 23, 2013 3:16:35 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 85971
- Location:
- trunk/src/VBox/Frontends/VirtualBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/Makefile.kmk
r46224 r46242 272 272 src/extensions/graphics/QIGraphicsWidget.h \ 273 273 src/globals/UIActionPool.h \ 274 src/globals/UIAnimationFramework.h \ 274 275 src/globals/UIExtraDataEventHandler.h \ 275 276 src/globals/UIMainEventListener.h \ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIAnimationFramework.cpp
r46195 r46242 27 27 #include "UIAnimationFramework.h" 28 28 29 QStateMachine* UIAnimationFramework::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 30 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 31 const char *pSignalForward, const char *pSignalBackward, 32 bool fReversive /*= false*/, int iAnimationDuration /*= 300*/) 29 /* static */ 30 UIAnimation* UIAnimation::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 31 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 32 const char *pszSignalForward, const char *pszSignalReverse, 33 bool fReverse /*= false*/, int iAnimationDuration /*= 300*/) 33 34 { 34 /* State-machine: */ 35 QStateMachine *pStateMachine = new QStateMachine(pTarget); 36 /* State-machine 'start' state: */ 37 QState *pStateStart = new QState(pStateMachine); 38 /* State-machine 'final' state: */ 39 QState *pStateFinal = new QState(pStateMachine); 40 41 /* State-machine 'forward' animation: */ 42 QPropertyAnimation *pForwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine); 43 pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 44 pForwardAnimation->setDuration(iAnimationDuration); 45 pForwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameStart)); 46 pForwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameFinal)); 47 /* State-machine 'backward' animation: */ 48 QPropertyAnimation *pBackwardAnimation = new QPropertyAnimation(pTarget, pszPropertyName, pStateMachine); 49 pBackwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 50 pBackwardAnimation->setDuration(iAnimationDuration); 51 pBackwardAnimation->setStartValue(pTarget->property(pszValuePropertyNameFinal)); 52 pBackwardAnimation->setEndValue(pTarget->property(pszValuePropertyNameStart)); 53 54 /* State-machine state transitions: */ 55 QSignalTransition *pDefaultToHovered = pStateStart->addTransition(pTarget, pSignalForward, pStateFinal); 56 pDefaultToHovered->addAnimation(pForwardAnimation); 57 QSignalTransition *pHoveredToDefault = pStateFinal->addTransition(pTarget, pSignalBackward, pStateStart); 58 pHoveredToDefault->addAnimation(pBackwardAnimation); 59 60 /* Initial state is 'start': */ 61 pStateMachine->setInitialState(!fReversive ? pStateStart : pStateFinal); 62 /* Start hover-machine: */ 63 pStateMachine->start(); 64 /* Return machine: */ 65 return pStateMachine; 35 /* Return newly created animation-machine: */ 36 return new UIAnimation(pTarget, pszPropertyName, 37 pszValuePropertyNameStart, pszValuePropertyNameFinal, 38 pszSignalForward, pszSignalReverse, 39 fReverse, iAnimationDuration); 66 40 } 67 41 42 UIAnimation::UIAnimation(QWidget *pParent, const char *pszPropertyName, 43 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 44 const char *pszSignalForward, const char *pszSignalReverse, 45 bool fReverse, int iAnimationDuration) 46 : QObject(pParent) 47 , m_pszPropertyName(pszPropertyName) 48 , m_pszValuePropertyNameStart(pszValuePropertyNameStart), m_pszValuePropertyNameFinal(pszValuePropertyNameFinal) 49 , m_pszSignalForward(pszSignalForward), m_pszSignalReverse(pszSignalReverse) 50 , m_fReverse(fReverse), m_iAnimationDuration(iAnimationDuration) 51 , m_pAnimationMachine(0), m_pForwardAnimation(0), m_pReverseAnimation(0) 52 { 53 /* Prepare: */ 54 prepare(); 55 } 56 57 void UIAnimation::prepare() 58 { 59 /* Prepare animation-machine: */ 60 m_pAnimationMachine = new QStateMachine(this); 61 /* Create 'start' and 'final' states: */ 62 QState *pStateStart = new QState(m_pAnimationMachine); 63 QState *pStateFinal = new QState(m_pAnimationMachine); 64 65 /* Prepare 'forward' animation: */ 66 m_pForwardAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine); 67 m_pForwardAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 68 m_pForwardAnimation->setDuration(m_iAnimationDuration); 69 /* Prepare 'reverse' animation: */ 70 m_pReverseAnimation = new QPropertyAnimation(parent(), m_pszPropertyName, m_pAnimationMachine); 71 m_pReverseAnimation->setEasingCurve(QEasingCurve(QEasingCurve::InOutCubic)); 72 m_pReverseAnimation->setDuration(m_iAnimationDuration); 73 74 /* Prepare state-transitions: */ 75 QSignalTransition *pStartToFinal = pStateStart->addTransition(parent(), m_pszSignalForward, pStateFinal); 76 pStartToFinal->addAnimation(m_pForwardAnimation); 77 QSignalTransition *pFinalToStart = pStateFinal->addTransition(parent(), m_pszSignalReverse, pStateStart); 78 pFinalToStart->addAnimation(m_pReverseAnimation); 79 80 /* Fetch animation-borders: */ 81 update(); 82 83 /* Choose initial state: */ 84 m_pAnimationMachine->setInitialState(!m_fReverse ? pStateStart : pStateFinal); 85 /* Start animation-machine: */ 86 m_pAnimationMachine->start(); 87 } 88 89 void UIAnimation::update() 90 { 91 /* Update 'forward' animation: */ 92 m_pForwardAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart)); 93 m_pForwardAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal)); 94 /* Update 'reverse' animation: */ 95 m_pReverseAnimation->setStartValue(parent()->property(m_pszValuePropertyNameFinal)); 96 m_pReverseAnimation->setEndValue(parent()->property(m_pszValuePropertyNameStart)); 97 } 98 -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIAnimationFramework.h
r46195 r46242 20 20 #define __UIAnimationFramework_h__ 21 21 22 /* Qt includes: */ 23 #include <QObject> 24 22 25 /* Forward declaration: */ 23 26 class QStateMachine; 27 class QPropertyAnimation; 24 28 25 /* UIAnimation Framework namespace: */26 namespace UIAnimationFramework 29 /* UIAnimation factory: */ 30 class UIAnimation : public QObject 27 31 { 28 /* API: Animation stuff: */ 29 QStateMachine* installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 30 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 31 const char *pSignalForward, const char *pSignalBackward, 32 bool fReversive = false, int iAnimationDuration = 300); 33 } 32 Q_OBJECT; 33 34 public: 35 36 /* API: Factory stuff: */ 37 static UIAnimation* installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName, 38 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 39 const char *pszSignalForward, const char *pszSignalReverse, 40 bool fReverse = false, int iAnimationDuration = 300); 41 42 /* API: Update stuff: */ 43 void update(); 44 45 protected: 46 47 /* Constructor: */ 48 UIAnimation(QWidget *pParent, const char *pszPropertyName, 49 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal, 50 const char *pszSignalForward, const char *pszSignalReverse, 51 bool fReverse, int iAnimationDuration); 52 53 private: 54 55 /* Helper: Prepare stuff: */ 56 void prepare(); 57 58 /* Variables: General stuff: */ 59 const char *m_pszPropertyName; 60 const char *m_pszValuePropertyNameStart; 61 const char *m_pszValuePropertyNameFinal; 62 const char *m_pszSignalForward; 63 const char *m_pszSignalReverse; 64 bool m_fReverse; 65 int m_iAnimationDuration; 66 67 /* Variables: Animation-machine stuff: */ 68 QStateMachine *m_pAnimationMachine; 69 QPropertyAnimation *m_pForwardAnimation; 70 QPropertyAnimation *m_pReverseAnimation; 71 }; 34 72 35 73 #endif /* __UIAnimationFramework_h__ */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIPopupPane.cpp
r46195 r46242 34 34 #include "UIAnimationFramework.h" 35 35 36 /* Other VBox includes: */37 #include <VBox/sup.h>38 39 36 40 37 /* Popup-pane text-pane prototype class: */ … … 115 112 /* Variables: Focus stuff: */ 116 113 bool m_fFocused; 117 QObject*m_pAnimation;114 UIAnimation *m_pAnimation; 118 115 }; 119 116 … … 308 305 { 309 306 /* Install 'hover' animation for 'opacity' property: */ 310 UIAnimation Framework::installPropertyAnimation(this, "opacity", "defaultOpacity", "hoveredOpacity",311 307 UIAnimation::installPropertyAnimation(this, "opacity", "defaultOpacity", "hoveredOpacity", 308 SIGNAL(sigHoverEnter()), SIGNAL(sigHoverLeave())); 312 309 /* Prepare content: */ 313 310 prepareContent(); … … 589 586 /* Prepare content: */ 590 587 prepareContent(); 588 /* Install geometry animation for 'minimumSizeHint' property: */ 589 m_pAnimation = UIAnimation::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint", 590 SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave())); 591 591 } 592 592 … … 658 658 m_minimumSizeHint = m_fFocused ? m_expandedSizeHint : m_collapsedSizeHint; 659 659 660 /* And reinstall size-hint animation: */ 661 delete m_pAnimation; 662 m_pAnimation = UIAnimationFramework::installPropertyAnimation(this, "minimumSizeHint", "collapsedSizeHint", "expandedSizeHint", 663 SIGNAL(sigFocusEnter()), SIGNAL(sigFocusLeave()), 664 m_fFocused); 660 /* Update animation: */ 661 m_pAnimation->update(); 665 662 } 666 663
Note:
See TracChangeset
for help on using the changeset viewer.