VirtualBox

Changeset 42827 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 15, 2012 3:21:45 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: 6234: Support for VM groups: Details-view element expand/collapse animation rework (taking into account very huge details-view layouts).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp

    r42812 r42827  
    4040    , m_pSet(pParent)
    4141    , m_type(type)
     42    , m_iCornerRadius(10)
    4243    , m_fClosed(!fOpened)
    4344    , m_pButton(0)
    4445    , m_iAdditionalHeight(0)
    45     , m_iCornerRadius(10)
     46    , m_fAnimationRunning(false)
    4647    , m_fHovered(false)
    4748    , m_fNameHoveringAccessible(false)
     
    135136void UIGDetailsElement::sltElementToggleStart()
    136137{
     138    /* Mark animation running: */
     139    m_fAnimationRunning = true;
     140
    137141    /* Setup animation: */
    138142    updateAnimationParameters();
    139143
    140     /* Element closed, we are opening it: */
    141     if (m_fClosed)
    142     {
    143         /* Toggle-state will be updated
    144          * on toggle finish signal! */
    145     }
    146     /* Group opened, we are closing it: */
    147     else
    148     {
    149         /* Update toggle-state: */
    150         m_fClosed = true;
    151     }
     144    /* Toggle element state: */
     145    m_fClosed = !m_fClosed;
     146    /* Relayout model: */
     147    model()->updateLayout();
     148    update();
    152149}
    153150
    154151void UIGDetailsElement::sltElementToggleFinish(bool fToggled)
    155152{
     153    /* Mark animation stopped: */
     154    m_fAnimationRunning = false;
     155
    156156    /* Update toggle-state: */
    157157    m_fClosed = !fToggled;
     
    470470{
    471471    m_iAdditionalHeight = iAdditionalHeight;
    472     model()->updateLayout();
     472    updateLayout();
     473    update();
    473474}
    474475
     
    506507            iProposedHeight += 2 * iMargin + iTextHeight;
    507508    }
    508     else
    509     {
    510         /* Additional height during animation: */
    511         if (m_pButton->isAnimationRunning())
    512             iProposedHeight += m_iAdditionalHeight;
    513     }
     509
     510    /* Additional height during animation: */
     511    if (m_fAnimationRunning)
     512        iProposedHeight += m_iAdditionalHeight;
    514513
    515514    /* Return result: */
     
    548547{
    549548    /* Paint background: */
    550     paintBackground(/* Painter: */
    551                     pPainter,
    552                     /* Rectangle to paint in: */
    553                     pOption->rect,
    554                     /* Rounded corners radius: */
    555                     m_iCornerRadius,
    556                     /* Header height: */
    557                     2 * data(ElementData_Margin).toInt() +
    558                     data(ElementData_HeaderSize).toSize().height(),
    559                     /* Gradient color: */
    560                     gradient());
     549    paintBackground(pPainter, pOption);
    561550}
    562551
     
    604593
    605594    /* Paint text: */
    606     if (!m_fClosed && !m_text.isEmpty())
     595    if (!m_fClosed && !m_text.isEmpty() && !m_fAnimationRunning)
    607596    {
    608597        /* Prepare variables: */
     
    679668}
    680669
    681 /* static */
    682 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect,
    683                                         int iRadius, int iHeaderHeight, int iGradient)
     670void UIGDetailsElement::paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
    684671{
    685672    /* Save painter: */
     
    687674
    688675    /* Prepare variables: */
    689     int iFullHeight = rect.height();
     676    int iMargin = data(ElementData_Margin).toInt();
     677    int iHeaderContentHeight = data(ElementData_HeaderSize).toSize().height();
     678    int iHeaderHeight = 2 * iMargin + iHeaderContentHeight;
     679    QRect optionRect = pOption->rect;
     680    QRect fullRect = !m_fAnimationRunning ? optionRect :
     681                     QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight));
     682    int iFullHeight = fullRect.height();
    690683
    691684    /* Prepare color: */
     
    695688    /* Add clipping: */
    696689    QPainterPath path;
    697     path.moveTo(iRadius, 0);
    698     path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, 0), 90, 90);
    699     path.lineTo(path.currentPosition().x(), iFullHeight - iRadius);
    700     path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(0, -iRadius), 180, 90);
    701     path.lineTo(rect.width() - iRadius, path.currentPosition().y());
    702     path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, -2 * iRadius), 270, 90);
    703     path.lineTo(path.currentPosition().x(), iRadius);
    704     path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-2 * iRadius, -iRadius), 0, 90);
     690    path.moveTo(m_iCornerRadius, 0);
     691    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, 0), 90, 90);
     692    path.lineTo(path.currentPosition().x(), iFullHeight - m_iCornerRadius);
     693    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(0, -m_iCornerRadius), 180, 90);
     694    path.lineTo(fullRect.width() - m_iCornerRadius, path.currentPosition().y());
     695    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, -2 * m_iCornerRadius), 270, 90);
     696    path.lineTo(path.currentPosition().x(), m_iCornerRadius);
     697    path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-2 * m_iCornerRadius, -m_iCornerRadius), 0, 90);
    705698    path.closeSubpath();
    706699    pPainter->setClipPath(path);
    707700
    708701    /* Calculate top rectangle: */
    709     QRect tRect = rect;
     702    QRect tRect = fullRect;
    710703    tRect.setBottom(tRect.top() + iHeaderHeight);
    711704    /* Calculate bottom rectangle: */
    712     QRect bRect = rect;
     705    QRect bRect = fullRect;
    713706    bRect.setTop(tRect.bottom());
    714707
     
    716709    QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft());
    717710    tGradient.setColorAt(0, windowColor.darker(110));
    718     tGradient.setColorAt(1, windowColor.darker(iGradient));
     711    tGradient.setColorAt(1, windowColor.darker(gradient()));
    719712
    720713    /* Paint all the stuff: */
     
    857850    int iClosedHeight = minimumHeightHint(true);
    858851    int iAdditionalHeight = iOpenedHeight - iClosedHeight;
     852    if (m_fClosed)
     853        m_iAdditionalHeight = 0;
     854    else
     855        m_iAdditionalHeight = iAdditionalHeight;
    859856    m_pButton->setAnimationRange(0, iAdditionalHeight);
    860857}
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h

    r42813 r42827  
    8989    void updateHoverAccessibility();
    9090    virtual void updateAppearance() = 0;
     91
     92protected slots:
     93
     94    /* Handlers: Collapse/expand stuff: */
     95    void sltElementToggleStart();
     96    void sltElementToggleFinish(bool fToggled);
    9197
    9298protected:
     
    141147    UIGraphicsRotatorButton* button() const;
    142148
    143 private slots:
    144 
    145     /* Handlers: Collapse/expand stuff: */
    146     void sltElementToggleStart();
    147     void sltElementToggleFinish(bool fToggled);
    148 
    149 private:
     149protected:
    150150
    151151    /* API: Children stuff: */
     
    168168    void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    169169    void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    170     static void paintBackground(QPainter *pPainter, const QRect &rect,
    171                                 int iRadius, int iHeaderHeight, int iGradient);
     170    void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    172171
    173172    /* Handlers: Mouse stuff: */
     
    192191    QIcon m_icon;
    193192    QString m_strName;
     193    UITextTable m_text;
     194    int m_iCornerRadius;
     195
     196    /* Variables: Toggle stuff: */
    194197    bool m_fClosed;
    195198    UIGraphicsRotatorButton *m_pButton;
    196     UITextTable m_text;
    197199    int m_iAdditionalHeight;
    198     int m_iCornerRadius;
     200    bool m_fAnimationRunning;
    199201
    200202    /* Variables: Hover stuff: */
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp

    r42813 r42827  
    232232    if (closed() && m_pPreview->isVisible())
    233233        m_pPreview->hide();
    234     if (opened() && !m_pPreview->isVisible())
     234    if (opened() && !m_pPreview->isVisible() && !m_fAnimationRunning)
    235235        m_pPreview->show();
    236236}
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