VirtualBox

Changeset 77222 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Feb 8, 2019 2:41:34 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
128729
Message:

FE/Qt: bugref:9373: Sync UIGraphicsScrollBar mouse-press event and UIGraphicsScrollBarToken mouse-move event.

File:
1 edited

Legend:

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

    r77220 r77222  
    284284    /* Redirect to token move handler: */
    285285    sltTokenMoved(pEvent->pos());
    286     layoutToken();
    287286}
    288287
     
    366365        case Qt::Horizontal:
    367366        {
    368             /* We have to adjust the X coord of the token, leaving Y unchanged: */
    369             int iX = pos.x();
     367            /* We have to calculate the X coord of the token, leaving Y untouched: */
    370368            const int iMin = m_iExtent;
    371369            const int iMax = size().width() - 2 * m_iExtent;
    372             if (iX < iMin)
    373                 iX = iMin;
    374             if (iX > iMax)
    375                 iX = iMax;
    376             /* We also calculating new ratio to update value same way: */
    377             dRatio = (double)(iX - iMin) / (iMax - iMin);
    378             m_pToken->setPos(iX, 0);
     370            int iX = pos.x() - m_iExtent / 2;
     371            iX = qMax(iX, iMin);
     372            iX = qMin(iX, iMax);
     373            /* And then calculate new ratio to update value finally: */
     374            dRatio = iMax > iMin ? (double)(iX - iMin) / (iMax - iMin) : 0;
    379375            break;
    380376        }
    381377        case Qt::Vertical:
    382378        {
    383             /* We have to adjust the Y coord of the token, leaving X unchanged: */
    384             int iY = pos.y();
     379            /* We have to calculate the Y coord of the token, leaving X untouched: */
    385380            const int iMin = m_iExtent;
    386381            const int iMax = size().height() - 2 * m_iExtent;
    387             if (iY < iMin)
    388                 iY = iMin;
    389             if (iY > iMax)
    390                 iY = iMax;
    391             /* We also calculating new ratio to update value same way: */
    392             dRatio = (double)(iY - iMin) / (iMax - iMin);
    393             m_pToken->setPos(0, iY);
     382            int iY = pos.y() - m_iExtent / 2;
     383            iY = qMax(iY, iMin);
     384            iY = qMin(iY, iMax);
     385            /* And then calculate new ratio to update value finally: */
     386            dRatio = iMax > iMin ? (double)(iY - iMin) / (iMax - iMin) : 0;
    394387            break;
    395388        }
     
    399392    m_iValue = dRatio * (m_iMaximum - m_iMinimum) + m_iMinimum;
    400393    emit sigValueChanged(m_iValue);
     394    layoutToken();
    401395}
    402396
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