Changeset 80695 in vbox
- Timestamp:
- Sep 10, 2019 11:29:51 AM (5 years ago)
- 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 27 27 UIGraphicsScrollArea::UIGraphicsScrollArea(Qt::Orientation enmOrientation, QGraphicsScene *pScene /* = 0 */) 28 28 : m_enmOrientation(enmOrientation) 29 , m_fAutoHideMode(true) 29 30 , m_pScrollBar(0) 30 31 , m_pViewport(0) … … 37 38 : QIGraphicsWidget(pParent) 38 39 , m_enmOrientation(enmOrientation) 40 , m_fAutoHideMode(true) 39 41 , m_pScrollBar(0) 40 42 , m_pViewport(0) … … 55 57 /* Expand it with viewport height: */ 56 58 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); 59 66 break; 60 67 } … … 63 70 /* Expand it with viewport width: */ 64 71 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); 67 79 break; 68 80 } … … 234 246 { 235 247 /* Create scroll-bar: */ 236 m_pScrollBar = new UIGraphicsScrollBar(m_enmOrientation, this);248 m_pScrollBar = new UIGraphicsScrollBar(m_enmOrientation, m_fAutoHideMode, this); 237 249 if (m_pScrollBar) 238 250 { … … 258 270 { 259 271 /* 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()); 261 276 m_pViewport->setPos(-m_pScrollBar->value(), 0); 262 277 break; … … 265 280 { 266 281 /* 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()); 268 286 m_pViewport->setPos(0, -m_pScrollBar->value()); 269 287 break; -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollArea.h
r77923 r80695 85 85 /** Holds the orientation. */ 86 86 Qt::Orientation m_enmOrientation; 87 /** Holds whether scroll-bar is in auto-hide mode. */ 88 bool m_fAutoHideMode; 87 89 88 90 /** Holds the scroll-bar instance. */ -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp
r80694 r80695 233 233 *********************************************************************************************************************************/ 234 234 235 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, QGraphicsScene *pScene)235 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QGraphicsScene *pScene) 236 236 : m_enmOrientation(enmOrientation) 237 , m_fAutoHideMode(fAutoHideMode) 237 238 , m_iExtent(-1) 238 239 , m_iMinimum(0) … … 249 250 #ifdef VBOX_WS_MAC 250 251 , m_fRevealed(false) 251 , m_iRevealingValue( 0)252 , m_iRevealingValue(m_fAutoHideMode ? 0 : 50) 252 253 , m_iRevealOnTimerId(0) 253 254 , m_iRevealOffTimerId(0) … … 258 259 } 259 260 260 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, QIGraphicsWidget *pParent /* = 0 */)261 UIGraphicsScrollBar::UIGraphicsScrollBar(Qt::Orientation enmOrientation, bool fAutoHideMode, QIGraphicsWidget *pParent /* = 0 */) 261 262 : QIGraphicsWidget(pParent) 262 263 , m_enmOrientation(enmOrientation) 264 , m_fAutoHideMode(fAutoHideMode) 263 265 , m_iExtent(-1) 264 266 , m_iMinimum(0) … … 275 277 #ifdef VBOX_WS_MAC 276 278 , m_fRevealed(false) 277 , m_iRevealingValue( 0)279 , m_iRevealingValue(m_fAutoHideMode ? 0 : 50) 278 280 , m_iRevealOnTimerId(0) 279 281 , m_iRevealOffTimerId(0) … … 461 463 { 462 464 /* Start hover-on timer, handled in timerEvent() below: */ 463 m_iHoverOnTimerId = startTimer( 400);465 m_iHoverOnTimerId = startTimer(m_fAutoHideMode ? 400 : 100); 464 466 m_fHovered = true; 465 467 } … … 475 477 { 476 478 /* Start hover-off timer, handled in timerEvent() below: */ 477 m_iHoverOffTimerId = startTimer( 1000);479 m_iHoverOffTimerId = startTimer(m_fAutoHideMode ? 1000 : 100); 478 480 m_fHovered = false; 479 481 } … … 537 539 /* Restart timer otherwise: */ 538 540 else 539 m_iRevealOffTimerId = startTimer( 2000);541 m_iRevealOffTimerId = startTimer(m_fAutoHideMode ? 2000 : 100); 540 542 /* Update in any case: */ 541 543 update(); … … 657 659 658 660 /* Restart fresh sustain timer: */ 659 m_iRevealOnTimerId = startTimer( 1000);661 m_iRevealOnTimerId = startTimer(m_fAutoHideMode ? 1000 : 100); 660 662 } 661 663 … … 669 671 { 670 672 /* Start reveal-out timer: */ 671 m_iRevealOffTimerId = startTimer( 2000);673 m_iRevealOffTimerId = startTimer(m_fAutoHideMode ? 2000 : 100); 672 674 } 673 675 #endif /* VBOX_WS_MAC */ … … 839 841 { 840 842 /* 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); 842 844 connect(pStateFaded, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredFaded); 843 845 … … 851 853 { 852 854 pRevealingAnimationForward->setDuration(200); 853 pRevealingAnimationForward->setStartValue( 0);855 pRevealingAnimationForward->setStartValue(m_fAutoHideMode ? 0 : 50); 854 856 pRevealingAnimationForward->setEndValue(100); 855 857 … … 877 879 pRevealingAnimationBackward->setDuration(200); 878 880 pRevealingAnimationBackward->setStartValue(100); 879 pRevealingAnimationBackward->setEndValue( 0);881 pRevealingAnimationBackward->setEndValue(m_fAutoHideMode ? 0 : 50); 880 882 881 883 /* Add to transition: */ … … 996 998 pPainter->save(); 997 999 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)); 999 1002 pPainter->fillRect(rectangle, windowColor); 1000 1003 pPainter->restore(); … … 1003 1006 pPainter->save(); 1004 1007 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)); 1006 1010 frameColor = frameColor.darker(120); 1007 1011 pPainter->setPen(frameColor); … … 1017 1021 QRectF tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, 2 * m_iExtent)); 1018 1022 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 } 1021 1033 const double dRadius = actualRectangle.width() / 2; 1022 1034 QPainterPath painterPath = QPainterPath(QPoint(actualRectangle.x(), actualRectangle.y() + dRadius)); -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.h
r79414 r80695 58 58 public: 59 59 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); 65 67 66 68 /** Returns minimum size-hint. */ … … 187 189 /** Holds the orientation. */ 188 190 const Qt::Orientation m_enmOrientation; 191 /** Holds whether scroll-bar is in auto-hide mode. */ 192 bool m_fAutoHideMode; 189 193 190 194 /** Holds the scroll-bar extent. */
Note:
See TracChangeset
for help on using the changeset viewer.