VirtualBox

Changeset 74080 in vbox for trunk


Ignore:
Timestamp:
Sep 5, 2018 11:45:27 AM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: VirtualBox Manager UI: Details pane re-styling: Element item: Hovering animation cleanup.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/manager/details
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp

    r74049 r74080  
    5050    , m_fHovered(false)
    5151    , m_fNameHovered(false)
    52     , m_pHighlightMachine(0)
    53     , m_pForwardAnimation(0)
    54     , m_pBackwardAnimation(0)
    55     , m_iAnimationDuration(400)
    56     , m_iDefaultDarkness(100)
    57     , m_iHighlightDarkness(90)
    58     , m_iAnimationDarkness(m_iDefaultDarkness)
     52    , m_pHoveringMachine(0)
     53    , m_pHoveringAnimationForward(0)
     54    , m_pHoveringAnimationBackward(0)
     55    , m_iAnimationDuration(300)
     56    , m_iDefaultValue(100)
     57    , m_iHoveredValue(90)
     58    , m_iAnimatedValue(m_iDefaultValue)
    5959    , m_pButton(0)
    6060    , m_fClosed(!fOpened)
     
    457457    updateIcon();
    458458
    459     /* Create highlight machine: */
    460     m_pHighlightMachine = new QStateMachine(this);
    461     /* Create 'default' state: */
    462     QState *pStateDefault = new QState(m_pHighlightMachine);
    463     pStateDefault->assignProperty(this, "animationDarkness", m_iDefaultDarkness);
    464     /* Create 'highlighted' state: */
    465     QState *pStateHighlighted = new QState(m_pHighlightMachine);
    466     pStateHighlighted->assignProperty(this, "animationDarkness", m_iHighlightDarkness);
    467 
    468     /* Forward animation: */
    469     m_pForwardAnimation = new QPropertyAnimation(this, "animationDarkness", this);
    470     m_pForwardAnimation->setDuration(m_iAnimationDuration);
    471     m_pForwardAnimation->setStartValue(m_iDefaultDarkness);
    472     m_pForwardAnimation->setEndValue(m_iHighlightDarkness);
    473 
    474     /* Backward animation: */
    475     m_pBackwardAnimation = new QPropertyAnimation(this, "animationDarkness", this);
    476     m_pBackwardAnimation->setDuration(m_iAnimationDuration);
    477     m_pBackwardAnimation->setStartValue(m_iHighlightDarkness);
    478     m_pBackwardAnimation->setEndValue(m_iDefaultDarkness);
    479 
    480     /* Add state transitions: */
    481     QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted);
    482     pDefaultToHighlighted->addAnimation(m_pForwardAnimation);
    483     QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);
    484     pHighlightedToDefault->addAnimation(m_pBackwardAnimation);
    485 
    486     /* Initial state is 'default': */
    487     m_pHighlightMachine->setInitialState(pStateDefault);
    488     /* Start state-machine: */
    489     m_pHighlightMachine->start();
     459    /* Create hovering animation machine: */
     460    m_pHoveringMachine = new QStateMachine(this);
     461    if (m_pHoveringMachine)
     462    {
     463        /* Create 'default' state: */
     464        QState *pStateDefault = new QState(m_pHoveringMachine);
     465        /* Create 'hovered' state: */
     466        QState *pStateHovered = new QState(m_pHoveringMachine);
     467
     468        /* Configure 'default' state: */
     469        if (pStateDefault)
     470        {
     471            /* When we entering default state => we assigning animatedValue to m_iDefaultValue: */
     472            pStateDefault->assignProperty(this, "animatedValue", m_iDefaultValue);
     473
     474            /* Add state transition: */
     475            QSignalTransition *pDefaultToHovered = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHovered);
     476            if (pDefaultToHovered)
     477            {
     478                /* Create forward animation: */
     479                m_pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this);
     480                if (m_pHoveringAnimationForward)
     481                {
     482                    m_pHoveringAnimationForward->setDuration(m_iAnimationDuration);
     483                    m_pHoveringAnimationForward->setStartValue(m_iDefaultValue);
     484                    m_pHoveringAnimationForward->setEndValue(m_iHoveredValue);
     485
     486                    /* Add to transition: */
     487                    pDefaultToHovered->addAnimation(m_pHoveringAnimationForward);
     488                }
     489            }
     490        }
     491
     492        /* Configure 'hovered' state: */
     493        if (pStateHovered)
     494        {
     495            /* When we entering hovered state => we assigning animatedValue to m_iHoveredValue: */
     496            pStateHovered->assignProperty(this, "animatedValue", m_iHoveredValue);
     497
     498            /* Add state transition: */
     499            QSignalTransition *pHoveredToDefault = pStateHovered->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);
     500            if (pHoveredToDefault)
     501            {
     502                /* Create backward animation: */
     503                m_pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this);
     504                if (m_pHoveringAnimationBackward)
     505                {
     506                    m_pHoveringAnimationBackward->setDuration(m_iAnimationDuration);
     507                    m_pHoveringAnimationBackward->setStartValue(m_iHoveredValue);
     508                    m_pHoveringAnimationBackward->setEndValue(m_iDefaultValue);
     509
     510                    /* Add to transition: */
     511                    pHoveredToDefault->addAnimation(m_pHoveringAnimationBackward);
     512                }
     513            }
     514        }
     515
     516        /* Initial state is 'default': */
     517        m_pHoveringMachine->setInitialState(pStateDefault);
     518        /* Start state-machine: */
     519        m_pHoveringMachine->start();
     520    }
    490521
    491522    /* Configure connections: */
     
    711742    QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
    712743    tGradient.setColorAt(0, headerColor.darker(110));
    713     tGradient.setColorAt(1, headerColor.darker(animationDarkness()));
     744    tGradient.setColorAt(1, headerColor.darker(animatedValue()));
    714745
    715746    /* Paint all the stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h

    r74049 r74080  
    4343{
    4444    Q_OBJECT;
    45     Q_PROPERTY(int animationDarkness READ animationDarkness WRITE setAnimationDarkness);
     45    Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);
    4646    Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight);
    4747
     
    248248        void updateIcon();
    249249
    250         /** Defines @a iAnimationDarkness. */
    251         void setAnimationDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }
    252         /** Returns animation darkness. */
    253         int animationDarkness() const { return m_iAnimationDarkness; }
     250        /** Defines animated @a iValue. */
     251        void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }
     252        /** Returns animated value. */
     253        int animatedValue() const { return m_iAnimatedValue; }
    254254
    255255        /** Handles any kind of hover @a pEvent. */
     
    306306        /** Holds whether element name is hovered. */
    307307        bool                m_fNameHovered;
    308         /** Holds the highlight machine instance. */
    309         QStateMachine      *m_pHighlightMachine;
    310         /** Holds the forward highlight animation instance. */
    311         QPropertyAnimation *m_pForwardAnimation;
    312         /** Holds the backward highlight animation instance. */
    313         QPropertyAnimation *m_pBackwardAnimation;
     308        /** Holds the hovering animation machine instance. */
     309        QStateMachine      *m_pHoveringMachine;
     310        /** Holds the forward hovering animation instance. */
     311        QPropertyAnimation *m_pHoveringAnimationForward;
     312        /** Holds the backward hovering animation instance. */
     313        QPropertyAnimation *m_pHoveringAnimationBackward;
    314314        /** Holds the animation duration. */
    315315        int                 m_iAnimationDuration;
    316         /** Holds the default darkness. */
    317         int                 m_iDefaultDarkness;
    318         /** Holds the highlight darkness. */
    319         int                 m_iHighlightDarkness;
    320         /** Holds the animation darkness. */
    321         int                 m_iAnimationDarkness;
     316        /** Holds the default animation value. */
     317        int                 m_iDefaultValue;
     318        /** Holds the hovered animation value. */
     319        int                 m_iHoveredValue;
     320        /** Holds the animated value. */
     321        int                 m_iAnimatedValue;
    322322
    323323        /** Holds the toggle button instance. */
Note: See TracChangeset for help on using the changeset viewer.

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