VirtualBox

Ignore:
Timestamp:
Feb 12, 2019 12:10:43 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128787
Message:

FE/Qt: bugref:9373: Make UIGraphicsScroollBarToken orientation aware; make macOS token larger.

File:
1 edited

Legend:

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

    r77268 r77273  
    4848
    4949    /** Constructs graphics scroll-bar token passing @a pParent to the base-class. */
    50     UIGraphicsScrollBarToken(QIGraphicsWidget *pParent = 0);
     50    UIGraphicsScrollBarToken(Qt::Orientation enmOrientation, QIGraphicsWidget *pParent = 0);
    5151
    5252    /** Returns minimum size-hint. */
     
    7878    void updateExtent();
    7979
     80    /** Holds the orientation. */
     81    const Qt::Orientation  m_enmOrientation;
     82
    8083    /** Holds the scroll-bar extent. */
    8184    int  m_iExtent;
     
    9093*********************************************************************************************************************************/
    9194
    92 UIGraphicsScrollBarToken::UIGraphicsScrollBarToken(QIGraphicsWidget *pParent /* = 0 */)
     95UIGraphicsScrollBarToken::UIGraphicsScrollBarToken(Qt::Orientation enmOrientation, QIGraphicsWidget *pParent /* = 0 */)
    9396    : QIGraphicsWidget(pParent)
     97    , m_enmOrientation(enmOrientation)
    9498    , m_fHovered(false)
    9599{
     
    99103QSizeF UIGraphicsScrollBarToken::minimumSizeHint() const
    100104{
    101     return QSizeF(m_iExtent, m_iExtent);
     105    /* Calculate minimum size-hint depending on orientation: */
     106    switch (m_enmOrientation)
     107    {
     108#ifdef VBOX_WS_MAC
     109        case Qt::Horizontal: return QSizeF(2 * m_iExtent, m_iExtent);
     110        case Qt::Vertical:   return QSizeF(m_iExtent, 2 * m_iExtent);
     111#else
     112        case Qt::Horizontal: return QSizeF(m_iExtent, m_iExtent);
     113        case Qt::Vertical:   return QSizeF(m_iExtent, m_iExtent);
     114#endif
     115    }
     116
     117    /* Call to base-class: */
     118    return QIGraphicsWidget::minimumSizeHint();
    102119}
    103120
     
    392409#ifdef VBOX_WS_MAC
    393410            const int iMin = 0;
    394             const int iMax = size().width() - m_iExtent;
     411            const int iMax = size().width() - 2 * m_iExtent;
    395412#else
    396413            const int iMin = m_iExtent;
     
    409426#ifdef VBOX_WS_MAC
    410427            const int iMin = 0;
    411             const int iMax = size().height() - m_iExtent;
     428            const int iMax = size().height() - 2 * m_iExtent;
    412429#else
    413430            const int iMin = m_iExtent;
     
    533550{
    534551    /* Create token: */
    535     m_pToken = new UIGraphicsScrollBarToken(this);
     552    m_pToken = new UIGraphicsScrollBarToken(m_enmOrientation, this);
    536553    if (m_pToken)
    537554        connect(m_pToken, &UIGraphicsScrollBarToken::sigMouseMoved,
     
    668685#ifdef VBOX_WS_MAC
    669686            const int iMin = 0;
    670             const int iMax = size().width() - m_iExtent;
     687            const int iMax = size().width() - 2 * m_iExtent;
    671688#else
    672689            const int iMin = m_iExtent;
     
    682699#ifdef VBOX_WS_MAC
    683700            const int iMin = 0;
    684             const int iMax = size().height() - m_iExtent;
     701            const int iMax = size().height() - 2 * m_iExtent;
    685702#else
    686703            const int iMin = m_iExtent;
     
    717734        QColor tokenColor = pal.color(QPalette::Active, QPalette::Window);
    718735        tokenColor.setAlpha(200);
     736#ifdef VBOX_WS_MAC
     737        QRect tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, 2 * m_iExtent));
     738#else
    719739        QRect tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, m_iExtent));
     740#endif
    720741        tokenRectangle.setLeft(tokenRectangle.left() + .9 * tokenRectangle.width() * ((double)100 - m_iAnimatedValue) / 100);
    721742        pPainter->fillRect(tokenRectangle, tokenColor);
Note: See TracChangeset for help on using the changeset viewer.

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