VirtualBox

Changeset 77285 in vbox


Ignore:
Timestamp:
Feb 12, 2019 3:46:59 PM (6 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9373: A bit of refactoring for UIGraphicsScrollBar to make it ready for other animation types (like stuff required for macOS).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp

    r77274 r77285  
    218218    , m_iHoverOnTimerId(0)
    219219    , m_iHoverOffTimerId(0)
    220     , m_iAnimatedValue(0)
     220    , m_iHoveringValue(0)
    221221{
    222222    pScene->addItem(this);
     
    238238    , m_iHoverOnTimerId(0)
    239239    , m_iHoverOffTimerId(0)
    240     , m_iAnimatedValue(0)
     240    , m_iHoveringValue(0)
    241241{
    242242    prepare();
     
    579579void UIGraphicsScrollBar::prepareAnimation()
    580580{
     581    prepareHoveringAnimation();
     582}
     583
     584void UIGraphicsScrollBar::prepareHoveringAnimation()
     585{
    581586    /* Create hovering animation machine: */
    582587    QStateMachine *pHoveringMachine = new QStateMachine(this);
     
    591596        if (pStateDefault)
    592597        {
    593             /* When we entering default state => we assigning animatedValue to 0: */
    594             pStateDefault->assignProperty(this, "animatedValue", 0);
     598            /* When we entering default state => we assigning hoveringValue to 0: */
     599            pStateDefault->assignProperty(this, "hoveringValue", 0);
    595600            connect(pStateDefault, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredDefault);
    596601
     
    602607
    603608                /* Create forward animation: */
    604                 QPropertyAnimation *pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this);
     609                QPropertyAnimation *pHoveringAnimationForward = new QPropertyAnimation(this, "hoveringValue", this);
    605610                if (pHoveringAnimationForward)
    606611                {
     
    618623        if (pStateHovered)
    619624        {
    620             /* When we entering hovered state => we assigning animatedValue to 100: */
    621             pStateHovered->assignProperty(this, "animatedValue", 100);
     625            /* When we entering hovered state => we assigning hoveringValue to 100: */
     626            pStateHovered->assignProperty(this, "hoveringValue", 100);
    622627            connect(pStateHovered, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredHovered);
    623628
     
    629634
    630635                /* Create backward animation: */
    631                 QPropertyAnimation *pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this);
     636                QPropertyAnimation *pHoveringAnimationBackward = new QPropertyAnimation(this, "hoveringValue", this);
    632637                if (pHoveringAnimationBackward)
    633638                {
     
    748753    pPainter->save();
    749754    QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
    750     windowColor.setAlpha(255 * ((double)m_iAnimatedValue / 100));
     755    windowColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
    751756    pPainter->fillRect(rectangle, windowColor);
    752757    pPainter->restore();
     
    755760    pPainter->save();
    756761    QColor frameColor = pal.color(QPalette::Active, QPalette::Window);
    757     frameColor.setAlpha(255 * ((double)m_iAnimatedValue / 100));
     762    frameColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
    758763    frameColor = frameColor.darker(120);
    759764    pPainter->setPen(frameColor);
     
    762767
    763768    /* Emulate token when necessary: */
    764     if (m_iAnimatedValue < 100)
     769    if (m_iHoveringValue < 100)
    765770    {
    766771        QColor tokenColor = pal.color(QPalette::Active, QPalette::Mid);
     
    768773        QRectF tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, 2 * m_iExtent));
    769774        QRectF actualRectangle = tokenRectangle;
    770         actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iAnimatedValue) / 100);
    771         actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iAnimatedValue) / 100 - 1);
     775        actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100);
     776        actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100 - 1);
    772777        const double dRadius = actualRectangle.width() / 2;
    773778        QPainterPath painterPath = QPainterPath(QPoint(actualRectangle.x(), actualRectangle.y() + dRadius));
     
    786791    backgroundColor.setAlpha(200);
    787792    QRect actualRectangle = rectangle;
    788     actualRectangle.setLeft(actualRectangle.left() + .9 * actualRectangle.width() * ((double)100 - m_iAnimatedValue) / 100);
     793    actualRectangle.setLeft(actualRectangle.left() + .9 * actualRectangle.width() * ((double)100 - m_iHoveringValue) / 100);
    789794    pPainter->fillRect(actualRectangle, backgroundColor);
    790795
    791796    /* Emulate token when necessary: */
    792     if (m_iAnimatedValue < 100)
     797    if (m_iHoveringValue < 100)
    793798    {
    794799        QColor tokenColor = pal.color(QPalette::Active, QPalette::Window);
    795800        tokenColor.setAlpha(200);
    796801        QRect tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, m_iExtent));
    797         tokenRectangle.setLeft(tokenRectangle.left() + .9 * tokenRectangle.width() * ((double)100 - m_iAnimatedValue) / 100);
     802        tokenRectangle.setLeft(tokenRectangle.left() + .9 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100);
    798803        pPainter->fillRect(tokenRectangle, tokenColor);
    799804    }
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.h

    r77267 r77285  
    3434{
    3535    Q_OBJECT;
    36     Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);
     36    Q_PROPERTY(int hoveringValue READ hoveringValue WRITE setHoveringValue);
    3737
    3838signals:
     
    127127    /** Prepares animation. */
    128128    void prepareAnimation();
     129    /** Prepares hovering animation. */
     130    void prepareHoveringAnimation();
    129131
    130132    /** Updates scroll-bar extent value. */
     
    143145    void paintBackground(QPainter *pPainter, const QRect &rectangle) const;
    144146
    145     /** Defines item's animated @a iValue. */
    146     void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }
    147     /** Returns item's animated value. */
    148     int animatedValue() const { return m_iAnimatedValue; }
     147    /** Defines hovering animation @a iValue. */
     148    void setHoveringValue(int iValue) { m_iHoveringValue = iValue; update(); }
     149    /** Returns hovering animation value. */
     150    int hoveringValue() const { return m_iHoveringValue; }
    149151
    150152    /** Holds the orientation. */
     
    177179    /** Holds the hover-off timer id. */
    178180    int   m_iHoverOffTimerId;
    179     /** Holds the animated value. */
    180     int   m_iAnimatedValue;
     181    /** Holds the hovering animation value. */
     182    int   m_iHoveringValue;
    181183};
    182184
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