Changeset 77285 in vbox
- Timestamp:
- Feb 12, 2019 3:46:59 PM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.cpp
r77274 r77285 218 218 , m_iHoverOnTimerId(0) 219 219 , m_iHoverOffTimerId(0) 220 , m_i AnimatedValue(0)220 , m_iHoveringValue(0) 221 221 { 222 222 pScene->addItem(this); … … 238 238 , m_iHoverOnTimerId(0) 239 239 , m_iHoverOffTimerId(0) 240 , m_i AnimatedValue(0)240 , m_iHoveringValue(0) 241 241 { 242 242 prepare(); … … 579 579 void UIGraphicsScrollBar::prepareAnimation() 580 580 { 581 prepareHoveringAnimation(); 582 } 583 584 void UIGraphicsScrollBar::prepareHoveringAnimation() 585 { 581 586 /* Create hovering animation machine: */ 582 587 QStateMachine *pHoveringMachine = new QStateMachine(this); … … 591 596 if (pStateDefault) 592 597 { 593 /* When we entering default state => we assigning animatedValue to 0: */594 pStateDefault->assignProperty(this, " animatedValue", 0);598 /* When we entering default state => we assigning hoveringValue to 0: */ 599 pStateDefault->assignProperty(this, "hoveringValue", 0); 595 600 connect(pStateDefault, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredDefault); 596 601 … … 602 607 603 608 /* Create forward animation: */ 604 QPropertyAnimation *pHoveringAnimationForward = new QPropertyAnimation(this, " animatedValue", this);609 QPropertyAnimation *pHoveringAnimationForward = new QPropertyAnimation(this, "hoveringValue", this); 605 610 if (pHoveringAnimationForward) 606 611 { … … 618 623 if (pStateHovered) 619 624 { 620 /* When we entering hovered state => we assigning animatedValue to 100: */621 pStateHovered->assignProperty(this, " animatedValue", 100);625 /* When we entering hovered state => we assigning hoveringValue to 100: */ 626 pStateHovered->assignProperty(this, "hoveringValue", 100); 622 627 connect(pStateHovered, &QState::propertiesAssigned, this, &UIGraphicsScrollBar::sltStateEnteredHovered); 623 628 … … 629 634 630 635 /* Create backward animation: */ 631 QPropertyAnimation *pHoveringAnimationBackward = new QPropertyAnimation(this, " animatedValue", this);636 QPropertyAnimation *pHoveringAnimationBackward = new QPropertyAnimation(this, "hoveringValue", this); 632 637 if (pHoveringAnimationBackward) 633 638 { … … 748 753 pPainter->save(); 749 754 QColor windowColor = pal.color(QPalette::Active, QPalette::Window); 750 windowColor.setAlpha(255 * ((double)m_i AnimatedValue / 100));755 windowColor.setAlpha(255 * ((double)m_iHoveringValue / 100)); 751 756 pPainter->fillRect(rectangle, windowColor); 752 757 pPainter->restore(); … … 755 760 pPainter->save(); 756 761 QColor frameColor = pal.color(QPalette::Active, QPalette::Window); 757 frameColor.setAlpha(255 * ((double)m_i AnimatedValue / 100));762 frameColor.setAlpha(255 * ((double)m_iHoveringValue / 100)); 758 763 frameColor = frameColor.darker(120); 759 764 pPainter->setPen(frameColor); … … 762 767 763 768 /* Emulate token when necessary: */ 764 if (m_i AnimatedValue < 100)769 if (m_iHoveringValue < 100) 765 770 { 766 771 QColor tokenColor = pal.color(QPalette::Active, QPalette::Mid); … … 768 773 QRectF tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, 2 * m_iExtent)); 769 774 QRectF actualRectangle = tokenRectangle; 770 actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_i AnimatedValue) / 100);771 actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_i AnimatedValue) / 100 - 1);775 actualRectangle.setLeft(tokenRectangle.left() + .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100); 776 actualRectangle.setRight(tokenRectangle.right() - .22 * tokenRectangle.width() + .22 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100 - 1); 772 777 const double dRadius = actualRectangle.width() / 2; 773 778 QPainterPath painterPath = QPainterPath(QPoint(actualRectangle.x(), actualRectangle.y() + dRadius)); … … 786 791 backgroundColor.setAlpha(200); 787 792 QRect actualRectangle = rectangle; 788 actualRectangle.setLeft(actualRectangle.left() + .9 * actualRectangle.width() * ((double)100 - m_i AnimatedValue) / 100);793 actualRectangle.setLeft(actualRectangle.left() + .9 * actualRectangle.width() * ((double)100 - m_iHoveringValue) / 100); 789 794 pPainter->fillRect(actualRectangle, backgroundColor); 790 795 791 796 /* Emulate token when necessary: */ 792 if (m_i AnimatedValue < 100)797 if (m_iHoveringValue < 100) 793 798 { 794 799 QColor tokenColor = pal.color(QPalette::Active, QPalette::Window); 795 800 tokenColor.setAlpha(200); 796 801 QRect tokenRectangle = QRect(actualTokenPosition(), QSize(m_iExtent, m_iExtent)); 797 tokenRectangle.setLeft(tokenRectangle.left() + .9 * tokenRectangle.width() * ((double)100 - m_i AnimatedValue) / 100);802 tokenRectangle.setLeft(tokenRectangle.left() + .9 * tokenRectangle.width() * ((double)100 - m_iHoveringValue) / 100); 798 803 pPainter->fillRect(tokenRectangle, tokenColor); 799 804 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/graphics/UIGraphicsScrollBar.h
r77267 r77285 34 34 { 35 35 Q_OBJECT; 36 Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue);36 Q_PROPERTY(int hoveringValue READ hoveringValue WRITE setHoveringValue); 37 37 38 38 signals: … … 127 127 /** Prepares animation. */ 128 128 void prepareAnimation(); 129 /** Prepares hovering animation. */ 130 void prepareHoveringAnimation(); 129 131 130 132 /** Updates scroll-bar extent value. */ … … 143 145 void paintBackground(QPainter *pPainter, const QRect &rectangle) const; 144 146 145 /** Defines item's animated@a iValue. */146 void set AnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); }147 /** Returns item's animatedvalue. */148 int animatedValue() const { return m_iAnimatedValue; }147 /** Defines hovering animation @a iValue. */ 148 void setHoveringValue(int iValue) { m_iHoveringValue = iValue; update(); } 149 /** Returns hovering animation value. */ 150 int hoveringValue() const { return m_iHoveringValue; } 149 151 150 152 /** Holds the orientation. */ … … 177 179 /** Holds the hover-off timer id. */ 178 180 int m_iHoverOffTimerId; 179 /** Holds the animatedvalue. */180 int m_i AnimatedValue;181 /** Holds the hovering animation value. */ 182 int m_iHoveringValue; 181 183 }; 182 184
Note:
See TracChangeset
for help on using the changeset viewer.