Changeset 77222 in vbox
- Timestamp:
- Feb 8, 2019 2:41:34 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128729
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp
r77220 r77222 284 284 /* Redirect to token move handler: */ 285 285 sltTokenMoved(pEvent->pos()); 286 layoutToken();287 286 } 288 287 … … 366 365 case Qt::Horizontal: 367 366 { 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: */ 370 368 const int iMin = m_iExtent; 371 369 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; 379 375 break; 380 376 } 381 377 case Qt::Vertical: 382 378 { 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: */ 385 380 const int iMin = m_iExtent; 386 381 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; 394 387 break; 395 388 } … … 399 392 m_iValue = dRatio * (m_iMaximum - m_iMinimum) + m_iMinimum; 400 393 emit sigValueChanged(m_iValue); 394 layoutToken(); 401 395 } 402 396
Note:
See TracChangeset
for help on using the changeset viewer.