VirtualBox

Changeset 42689 in vbox for trunk


Ignore:
Timestamp:
Aug 8, 2012 6:14:23 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Add hovering animation to details-view elements.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItem.cpp

    r42678 r42689  
    4343    , m_pForwardAnimation(0)
    4444    , m_pBackwardAnimation(0)
    45     , m_iAnimationDuration(300)
     45    , m_iAnimationDuration(400)
    4646    , m_iDefaultDarkness(103)
    4747    , m_iHighlightDarkness(90)
     
    186186void UIGChooserItem::hoverMoveEvent(QGraphicsSceneHoverEvent*)
    187187{
    188     if (m_fHovered != true)
     188    if (!m_fHovered)
    189189    {
    190190        m_fHovered = true;
     
    195195void UIGChooserItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
    196196{
    197     if (m_fHovered != false)
     197    if (m_fHovered)
    198198    {
    199199        m_fHovered = false;
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r42678 r42689  
    2323#include <QTextLayout>
    2424#include <QGraphicsSceneMouseEvent>
     25#include <QStateMachine>
     26#include <QPropertyAnimation>
     27#include <QSignalTransition>
    2528
    2629/* GUI includes: */
     
    4548    , m_fNameHoveringAccessible(false)
    4649    , m_fNameHovered(false)
     50    , m_pHighlightMachine(0)
     51    , m_pForwardAnimation(0)
     52    , m_pBackwardAnimation(0)
     53    , m_iAnimationDuration(400)
     54    , m_iDefaultDarkness(103)
     55    , m_iHighlightDarkness(90)
     56    , m_iGradient(m_iDefaultDarkness)
    4757{
    4858    /* Prepare element: */
     
    350360void UIGDetailsElement::prepareElement()
    351361{
     362    /* Create highlight machine: */
     363    m_pHighlightMachine = new QStateMachine(this);
     364    /* Create 'default' state: */
     365    QState *pStateDefault = new QState(m_pHighlightMachine);
     366    /* Create 'highlighted' state: */
     367    QState *pStateHighlighted = new QState(m_pHighlightMachine);
     368
     369    /* Forward animation: */
     370    m_pForwardAnimation = new QPropertyAnimation(this, "gradient", this);
     371    m_pForwardAnimation->setDuration(m_iAnimationDuration);
     372    m_pForwardAnimation->setStartValue(m_iDefaultDarkness);
     373    m_pForwardAnimation->setEndValue(m_iHighlightDarkness);
     374
     375    /* Backward animation: */
     376    m_pBackwardAnimation = new QPropertyAnimation(this, "gradient", this);
     377    m_pBackwardAnimation->setDuration(m_iAnimationDuration);
     378    m_pBackwardAnimation->setStartValue(m_iHighlightDarkness);
     379    m_pBackwardAnimation->setEndValue(m_iDefaultDarkness);
     380
     381    /* Add state transitions: */
     382    QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted);
     383    pDefaultToHighlighted->addAnimation(m_pForwardAnimation);
     384    QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault);
     385    pHighlightedToDefault->addAnimation(m_pBackwardAnimation);
     386
     387    /* Initial state is 'default': */
     388    m_pHighlightMachine->setInitialState(pStateDefault);
     389    /* Start state-machine: */
     390    m_pHighlightMachine->start();
     391
    352392    connect(gVBoxEvents, SIGNAL(sigMachineStateChange(QString, KMachineState)), this, SLOT(sltMachineStateChange(QString)));
    353393    connect(gVBoxEvents, SIGNAL(sigMachineDataChange(QString)), this, SLOT(sltShouldWeUpdateAppearance(QString)));
     
    480520                    /* Header height: */
    481521                    2 * data(ElementData_Margin).toInt() +
    482                     data(ElementData_HeaderSize).toSize().height());
     522                    data(ElementData_HeaderSize).toSize().height(),
     523                    /* Gradient color: */
     524                    gradient());
    483525}
    484526
     
    587629
    588630/* static */
    589 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect, int iRadius, int iHeaderHeight)
     631void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect,
     632                                        int iRadius, int iHeaderHeight, int iGradient)
    590633{
    591634    /* Save painter: */
     
    622665    QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
    623666    tGradient.setColorAt(0, windowColor.darker(110));
    624     tGradient.setColorAt(1, windowColor.darker(103));
     667    tGradient.setColorAt(1, windowColor.darker(iGradient));
    625668
    626669    /* Paint all the stuff: */
     
    642685    {
    643686        m_fHovered = true;
    644         update();
     687        emit sigHoverEnter();
    645688    }
    646689
     
    655698    {
    656699        m_fHovered = false;
    657         update();
     700        emit sigHoverLeave();
    658701    }
    659702
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42608 r42689  
    3232class UIGraphicsRotatorButton;
    3333class QTextLayout;
     34class QStateMachine;
     35class QPropertyAnimation;
    3436
    3537/* Typedefs: */
     
    4345{
    4446    Q_OBJECT;
     47    Q_PROPERTY(int gradient READ gradient WRITE setGradient);
    4548    Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight);
    4649
    4750signals:
     51
     52    /* Notifiers: Hover stuff: */
     53    void sigHoverEnter();
     54    void sigHoverLeave();
    4855
    4956    /* Notifier: Toggle stuff: */
     
    123130    void updateLayout();
    124131
     132    /* Helpers: Hover stuff: */
     133    int gradient() const { return m_iGradient; }
     134    void setGradient(int iGradient) { m_iGradient = iGradient; update(); }
     135
    125136    /* Helpers: Animation stuff: */
    126137    void setAdditionalHeight(int iAdditionalHeight);
     
    159170    void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    160171    void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    161     static void paintBackground(QPainter *pPainter, const QRect &rect, int iRadius, int iHeaderHeight);
     172    static void paintBackground(QPainter *pPainter, const QRect &rect,
     173                                int iRadius, int iHeaderHeight, int iGradient);
    162174
    163175    /* Handlers: Mouse stuff: */
     
    189201    int m_iAdditionalHeight;
    190202    int m_iCornerRadius;
     203
     204    /* Variables: Hover stuff: */
    191205    bool m_fHovered;
    192206    bool m_fNameHoveringAccessible;
    193207    bool m_fNameHovered;
     208    QStateMachine *m_pHighlightMachine;
     209    QPropertyAnimation *m_pForwardAnimation;
     210    QPropertyAnimation *m_pBackwardAnimation;
     211    int m_iAnimationDuration;
     212    int m_iDefaultDarkness;
     213    int m_iHighlightDarkness;
     214    int m_iGradient;
    194215};
    195216
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.cpp

    r42608 r42689  
    8686}
    8787
    88 #if 0
    89 void UIGDetailsItem::hoverEnterEvent(QGraphicsSceneHoverEvent*)
    90 {
    91 }
    92 
    93 void UIGDetailsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent*)
    94 {
    95 }
    96 #endif
    97 
    9888/* static */
    9989void UIGDetailsItem::configurePainterShape(QPainter *pPainter,
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsItem.h

    r42608 r42689  
    7676protected:
    7777
    78 #if 0
    79     /* Hover-enter event: */
    80     void hoverEnterEvent(QGraphicsSceneHoverEvent *pEvent);
    81     /* Hover-leave event: */
    82     void hoverLeaveEvent(QGraphicsSceneHoverEvent *pEvent);
    83 #endif
    84 
    8578    /* Helpers: Paint stuff: */
    8679    static void configurePainterShape(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, int iRadius);
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