VirtualBox

Changeset 80695 in vbox


Ignore:
Timestamp:
Sep 10, 2019 11:29:51 AM (5 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:9241: UIGraphicsScrollArea & UIGraphicsScrollBar: A theoretical (for now) possibility to create area in legacy mode which shows scroll-bar always.

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

Legend:

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

    r79389 r80695  
    2727UIGraphicsScrollArea::UIGraphicsScrollArea(Qt::Orientation enmOrientation, QGraphicsScene *pScene /* = 0 */)
    2828    : m_enmOrientation(enmOrientation)
     29    , m_fAutoHideMode(true)
    2930    , m_pScrollBar(0)
    3031    , m_pViewport(0)
     
    3738    : QIGraphicsWidget(pParent)
    3839    , m_enmOrientation(enmOrientation)
     40    , m_fAutoHideMode(true)
    3941    , m_pScrollBar(0)
    4042    , m_pViewport(0)
     
    5557                /* Expand it with viewport height: */
    5658                const int iWidgetHeight = m_pViewport->size().height();
    57                 if (msh.height() < iWidgetHeight)
    58                     msh.setHeight(iWidgetHeight);
     59                if (m_fAutoHideMode)
     60                {
     61                    if (msh.height() < iWidgetHeight)
     62                        msh.setHeight(iWidgetHeight);
     63                }
     64                else
     65                    msh.setHeight(msh.height() + iWidgetHeight);
    5966                break;
    6067            }
     
    6370                /* Expand it with viewport width: */
    6471                const int iWidgetWidth = m_pViewport->size().width();
    65                 if (msh.width() < iWidgetWidth)
    66                     msh.setWidth(iWidgetWidth);
     72                if (m_fAutoHideMode)
     73                {
     74                    if (msh.width() < iWidgetWidth)
     75                        msh.setWidth(iWidgetWidth);
     76                }
     77                else
     78                    msh.setWidth(msh.width() + iWidgetWidth);
    6779                break;
    6880            }
     
    234246{
    235247    /* Create scroll-bar: */
    236     m_pScrollBar = new UIGraphicsScrollBar(m_enmOrientation, this);
     248    m_pScrollBar = new UIGraphicsScrollBar(m_enmOrientation, m_fAutoHideMode, this);
    237249    if (m_pScrollBar)
    238250    {
     
    258270            {
    259271                /* Align viewport and shift it horizontally: */
    260                 m_pViewport->resize(m_pViewport->minimumSizeHint().width(), size().height());
     272                if (m_fAutoHideMode)
     273                    m_pViewport->resize(m_pViewport->minimumSizeHint().width(), size().height());
     274                else
     275                    m_pViewport->resize(m_pViewport->minimumSizeHint().width(), size().height() - m_pScrollBar->minimumSizeHint().height());
    261276                m_pViewport->setPos(-m_pScrollBar->value(), 0);
    262277                break;
     
    265280            {
    266281                /* Align viewport and shift it vertically: */
    267                 m_pViewport->resize(size().width(), m_pViewport->minimumSizeHint().height());
     282                if (m_fAutoHideMode)
     283                    m_pViewport->resize(size().width(), m_pViewport->minimumSizeHint().height());
     284                else
     285                    m_pViewport->resize(size().width() - m_pScrollBar->minimumSizeHint().width(), m_pViewport->minimumSizeHint().height());
    268286                m_pViewport->setPos(0, -m_pScrollBar->value());
    269287                break;
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.h

    r77923 r80695  
    8585    /** Holds the orientation. */
    8686    Qt::Orientation  m_enmOrientation;
     87    /** Holds whether scroll-bar is in auto-hide mode. */
     88    bool             m_fAutoHideMode;
    8789
    8890    /** Holds the scroll-bar instance. */
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp

    r80694 r80695  
    233233*********************************************************************************************************************************/
    234234
    235 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, QGraphicsScene *pScene)
     235UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QGraphicsScene *pScene)
    236236    : m_enmOrientation(enmOrientation)
     237    , m_fAutoHideMode(fAutoHideMode)
    237238    , m_iExtent(-1)
    238239    , m_iMinimum(0)
     
    249250#ifdef VBOX_WS_MAC
    250251    , m_fRevealed(false)
    251     , m_iRevealingValue(0)
     252    , m_iRevealingValue(m_fAutoHideMode ? 0 : 50)
    252253    , m_iRevealOnTimerId(0)
    253254    , m_iRevealOffTimerId(0)
     
    258259}
    259260
    260 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, QIGraphicsWidget *pParent /* = 0 */)
     261UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QIGraphicsWidget *pParent /* = 0 */)
    261262    : QIGraphicsWidget(pParent)
    262263    , m_enmOrientation(enmOrientation)
     264    , m_fAutoHideMode(fAutoHideMode)
    263265    , m_iExtent(-1)
    264266    , m_iMinimum(0)
     
    275277#ifdef VBOX_WS_MAC
    276278    , m_fRevealed(false)
    277     , m_iRevealingValue(0)
     279    , m_iRevealingValue(m_fAutoHideMode ? 0 : 50)
    278280    , m_iRevealOnTimerId(0)
    279281    , m_iRevealOffTimerId(0)
     
    461463    {
    462464        /* Start hover-on timer, handled in timerEvent() below: */
    463         m_iHoverOnTimerId = startTimer(400);
     465        m_iHoverOnTimerId = startTimer(m_fAutoHideMode ? 400 : 100);
    464466        m_fHovered = true;
    465467    }
     
    475477    {
    476478        /* Start hover-off timer, handled in timerEvent() below: */
    477         m_iHoverOffTimerId = startTimer(1000);
     479        m_iHoverOffTimerId = startTimer(m_fAutoHideMode ? 1000 : 100);
    478480        m_fHovered = false;
    479481    }
     
    537539        /* Restart timer otherwise: */
    538540        else
    539             m_iRevealOffTimerId = startTimer(2000);
     541            m_iRevealOffTimerId = startTimer(m_fAutoHideMode ? 2000 : 100);
    540542        /* Update in any case: */
    541543        update();
     
    657659
    658660    /* Restart fresh sustain timer: */
    659     m_iRevealOnTimerId = startTimer(1000);
     661    m_iRevealOnTimerId = startTimer(m_fAutoHideMode ? 1000 : 100);
    660662}
    661663
     
    669671{
    670672    /* Start reveal-out timer: */
    671     m_iRevealOffTimerId = startTimer(2000);
     673    m_iRevealOffTimerId = startTimer(m_fAutoHideMode ? 2000 : 100);
    672674}
    673675#endif /* VBOX_WS_MAC */
     
    839841        {
    840842            /* When we entering fade state => we assigning revealingValue to 0: */
    841             pStateFaded->assignProperty(this, "revealingValue", 0);
     843            pStateFaded->assignProperty(this, "revealingValue", m_fAutoHideMode ? 0 : 50);
    842844            connect(pStateFaded, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredFaded);
    843845
     
    851853                {
    852854                    pRevealingAnimationForward->setDuration(200);
    853                     pRevealingAnimationForward->setStartValue(0);
     855                    pRevealingAnimationForward->setStartValue(m_fAutoHideMode ? 0 : 50);
    854856                    pRevealingAnimationForward->setEndValue(100);
    855857
     
    877879                    pRevealingAnimationBackward->setDuration(200);
    878880                    pRevealingAnimationBackward->setStartValue(100);
    879                     pRevealingAnimationBackward->setEndValue(0);
     881                    pRevealingAnimationBackward->setEndValue(m_fAutoHideMode ? 0 : 50);
    880882
    881883                    /* Add to transition: */
     
    996998    pPainter->save();
    997999    QColor windowColor = pal.color(QPalette::Active, QPalette::Window);
    998     windowColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
     1000    if (m_fAutoHideMode)
     1001        windowColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
    9991002    pPainter->fillRect(rectangle, windowColor);
    10001003    pPainter->restore();
     
    10031006    pPainter->save();
    10041007    QColor frameColor = pal.color(QPalette::Active, QPalette::Window);
    1005     frameColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
     1008    if (m_fAutoHideMode)
     1009        frameColor.setAlpha(255 * ((double)m_iHoveringValue / 100));
    10061010    frameColor = frameColor.darker(120);
    10071011    pPainter->setPen(frameColor);
     
    10171021        QRectF tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, 2 * m_iExtent));
    10181022        QRectF actualRectangle = tokenRectangle;
    1019         actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100);
    1020         actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100 - 1);
     1023        if (m_fAutoHideMode)
     1024        {
     1025            actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100);
     1026            actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100 - 1);
     1027        }
     1028        else
     1029        {
     1030            actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width());
     1031            actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() - 1);
     1032        }
    10211033        const double dRadius = actualRectangle.width() / 2;
    10221034        QPainterPath painterPath = QPainterPath(QPoint(actualRectangle.x(), actualRectangle.y() + dRadius));
  • trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.h

    r79414 r80695  
    5858public:
    5959
    60     /** Constructs graphics scroll-bar of requested @a enmOrientation, embedding it directly to passed @a pScene. */
    61     UIGraphicsScrollBar(Qt::Orientation enmOrientation, QGraphicsScene *pScene);
    62 
    63     /** Constructs graphics scroll-bar of requested @a enmOrientation passing @a pParent to the base-class. */
    64     UIGraphicsScrollBar(Qt::Orientation enmOrientation, QIGraphicsWidget *pParent = 0);
     60    /** Constructs graphics scroll-bar of requested @a enmOrientation, embedding it directly to passed @a pScene.
     61      * @param  fAutoHideMode  Brings whether scroll-bar should be created in auto-hide mode. */
     62    UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QGraphicsScene *pScene);
     63
     64    /** Constructs graphics scroll-bar of requested @a enmOrientation passing @a pParent to the base-class.
     65      * @param  fAutoHideMode  Brings whether scroll-bar should be created in auto-hide mode. */
     66    UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QIGraphicsWidget *pParent = 0);
    6567
    6668    /** Returns minimum size-hint. */
     
    187189    /** Holds the orientation. */
    188190    const Qt::Orientation  m_enmOrientation;
     191    /** Holds whether scroll-bar is in auto-hide mode. */
     192    bool                   m_fAutoHideMode;
    189193
    190194    /** Holds the scroll-bar extent. */
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