VirtualBox

Changeset 71425 in vbox


Ignore:
Timestamp:
Mar 21, 2018 11:38:25 AM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121392
Message:

FE/Qt: bugref:9049: Full and heavy cleanup for UIAnimationFramework.

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  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    2121
    2222/* Qt includes: */
    23 # include <QWidget>
    24 # include <QStateMachine>
    2523# include <QPropertyAnimation>
    2624# include <QSignalTransition>
     25# include <QStateMachine>
     26# include <QWidget>
    2727
    2828/* GUI includes: */
     
    3535
    3636
     37/*********************************************************************************************************************************
     38*   Class UIAnimation implementation.                                                                                            *
     39*********************************************************************************************************************************/
     40
    3741/* static */
    3842UIAnimation* UIAnimation::installPropertyAnimation(QWidget *pTarget, const char *pszPropertyName,
    3943                                                   const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
    4044                                                   const char *pszSignalForward, const char *pszSignalReverse,
    41                                                    bool fReverse /* = false*/, int iAnimationDuration /* = 300*/)
     45                                                   bool fReverse /* = false */, int iAnimationDuration /* = 300 */)
    4246{
    4347    /* Return newly created animation-machine: */
     
    4852}
    4953
    50 /* static */
    51 UIAnimationLoop* UIAnimationLoop::installAnimationLoop(QWidget *pTarget, const char *pszPropertyName,
    52                                                        const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
    53                                                        int iAnimationDuration /* = 300*/)
     54void UIAnimation::update()
    5455{
    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));
    5964}
    60 
    6165
    6266UIAnimation::UIAnimation(QWidget *pParent, const char *pszPropertyName,
     
    117121}
    118122
    119 void UIAnimation::update()
     123
     124/*********************************************************************************************************************************
     125*   Class UIAnimation implementation.                                                                                            *
     126*********************************************************************************************************************************/
     127
     128/* static */
     129UIAnimationLoop* UIAnimationLoop::installAnimationLoop(QWidget *pTarget, const char *pszPropertyName,
     130                                                       const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
     131                                                       int iAnimationDuration /* = 300*/)
    120132{
    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);
    129137}
    130138
     139void UIAnimationLoop::update()
     140{
     141    /* Update animation: */
     142    m_pAnimation->setStartValue(parent()->property(m_pszValuePropertyNameStart));
     143    m_pAnimation->setEndValue(parent()->property(m_pszValuePropertyNameFinal));
     144}
     145
     146void UIAnimationLoop::start()
     147{
     148    /* Start animation: */
     149    m_pAnimation->start();
     150}
     151
     152void UIAnimationLoop::stop()
     153{
     154    /* Stop animation: */
     155    m_pAnimation->stop();
     156}
    131157
    132158UIAnimationLoop::UIAnimationLoop(QWidget *pParent, const char *pszPropertyName,
     
    154180}
    155181
    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  
    55
    66/*
    7  * Copyright (C) 2013-2017 Oracle Corporation
     7 * Copyright (C) 2013-2018 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1616 */
    1717
    18 #ifndef __UIAnimationFramework_h__
    19 #define __UIAnimationFramework_h__
     18#ifndef ___UIAnimationFramework_h___
     19#define ___UIAnimationFramework_h___
    2020
    2121/* Qt includes: */
     
    2323
    2424/* Forward declaration: */
     25class QPropertyAnimation;
     26class QState;
    2527class QStateMachine;
    26 class QState;
    27 class QPropertyAnimation;
    2828
    29 /* UIAnimation factory: */
     29
     30/** QObject subclass used as animation factory. */
    3031class UIAnimation : public QObject
    3132{
     
    3435signals:
    3536
    36     /* Notifiers: State-change stuff: */
     37    /** Notifies listener about 'Start' state entered. */
    3738    void sigStateEnteredStart();
     39    /** Notifies listener about 'Final' state entered. */
    3840    void sigStateEnteredFinal();
    3941
    4042public:
    4143
    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,
    4454                                                 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
    4555                                                 const char *pszSignalForward, const char *pszSignalReverse,
    4656                                                 bool fReverse = false, int iAnimationDuration = 300);
    4757
    48     /* API: Update stuff: */
     58    /** Updates the animation, fetching new initial values. */
    4959    void update();
    5060
    51 protected:
     61private:
    5262
    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. */
    5472    UIAnimation(QWidget *pParent, const char *pszPropertyName,
    5573                const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
     
    5775                bool fReverse, int iAnimationDuration);
    5876
    59 private:
    60 
    61     /* Helper: Prepare stuff: */
     77    /** Prepares all. */
    6278    void prepare();
    6379
    64     /* Variables: General stuff: */
     80    /** Holds the name of property being animated. */
    6581    const char *m_pszPropertyName;
     82
     83    /** Holds the name of the property holding 'start' value. */
    6684    const char *m_pszValuePropertyNameStart;
     85    /** Holds the name of the property holding 'final' value. */
    6786    const char *m_pszValuePropertyNameFinal;
     87
     88    /** Holds the signal to start forward animation. */
    6889    const char *m_pszSignalForward;
     90    /** Holds the signal to start reverse animation. */
    6991    const char *m_pszSignalReverse;
     92
     93    /** Holds whether the animation should be inverted. */
    7094    bool m_fReverse;
     95
     96    /** Holds the animation duration. */
    7197    int m_iAnimationDuration;
    7298
    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. */
    77106    QPropertyAnimation *m_pForwardAnimation;
     107    /** Holds the instance of the 'Reverse' animation. */
    78108    QPropertyAnimation *m_pReverseAnimation;
    79109};
    80110
    81 /* UIAnimationLoop factory: */
     111
     112/** QObject subclass used as animation loop factory. */
    82113class UIAnimationLoop : public QObject
    83114{
     
    86117public:
    87118
    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,
    90126                                                 const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
    91127                                                 int iAnimationDuration = 300);
    92128
    93     /* API: Update stuff: */
     129    /** Updates the animation, fetching new initial values. */
    94130    void update();
    95131
    96     /* API: Loop stuff: */
     132    /** Starts the loop. */
    97133    void start();
     134    /** Stops the loop. */
    98135    void stop();
    99136
    100 protected:
     137private:
    101138
    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. */
    103145    UIAnimationLoop(QWidget *pParent, const char *pszPropertyName,
    104146                    const char *pszValuePropertyNameStart, const char *pszValuePropertyNameFinal,
    105147                    int iAnimationDuration);
    106148
    107 private:
    108 
    109     /* Helper: Prepare stuff: */
     149    /** Prepares all. */
    110150    void prepare();
    111151
    112     /* Variables: */
     152    /** Holds the name of property being animated. */
    113153    const char *m_pszPropertyName;
     154
     155    /** Holds the name of the property holding 'start' value. */
    114156    const char *m_pszValuePropertyNameStart;
     157    /** Holds the name of the property holding 'final' value. */
    115158    const char *m_pszValuePropertyNameFinal;
     159
     160    /** Holds the animation duration. */
    116161    int m_iAnimationDuration;
     162
     163    /** Holds the instance of the animation. */
    117164    QPropertyAnimation *m_pAnimation;
    118165};
    119166
    120 #endif /* __UIAnimationFramework_h__ */
     167
     168#endif /* !___UIAnimationFramework_h___ */
     169
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette