- Timestamp:
- Sep 5, 2018 11:45:27 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/details
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.cpp
r74049 r74080 50 50 , m_fHovered(false) 51 51 , m_fNameHovered(false) 52 , m_pH ighlightMachine(0)53 , m_p ForwardAnimation(0)54 , m_p BackwardAnimation(0)55 , m_iAnimationDuration( 400)56 , m_iDefault Darkness(100)57 , m_iH ighlightDarkness(90)58 , m_iAnimat ionDarkness(m_iDefaultDarkness)52 , m_pHoveringMachine(0) 53 , m_pHoveringAnimationForward(0) 54 , m_pHoveringAnimationBackward(0) 55 , m_iAnimationDuration(300) 56 , m_iDefaultValue(100) 57 , m_iHoveredValue(90) 58 , m_iAnimatedValue(m_iDefaultValue) 59 59 , m_pButton(0) 60 60 , m_fClosed(!fOpened) … … 457 457 updateIcon(); 458 458 459 /* Create highlight machine: */ 460 m_pHighlightMachine = new QStateMachine(this); 461 /* Create 'default' state: */ 462 QState *pStateDefault = new QState(m_pHighlightMachine); 463 pStateDefault->assignProperty(this, "animationDarkness", m_iDefaultDarkness); 464 /* Create 'highlighted' state: */ 465 QState *pStateHighlighted = new QState(m_pHighlightMachine); 466 pStateHighlighted->assignProperty(this, "animationDarkness", m_iHighlightDarkness); 467 468 /* Forward animation: */ 469 m_pForwardAnimation = new QPropertyAnimation(this, "animationDarkness", this); 470 m_pForwardAnimation->setDuration(m_iAnimationDuration); 471 m_pForwardAnimation->setStartValue(m_iDefaultDarkness); 472 m_pForwardAnimation->setEndValue(m_iHighlightDarkness); 473 474 /* Backward animation: */ 475 m_pBackwardAnimation = new QPropertyAnimation(this, "animationDarkness", this); 476 m_pBackwardAnimation->setDuration(m_iAnimationDuration); 477 m_pBackwardAnimation->setStartValue(m_iHighlightDarkness); 478 m_pBackwardAnimation->setEndValue(m_iDefaultDarkness); 479 480 /* Add state transitions: */ 481 QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted); 482 pDefaultToHighlighted->addAnimation(m_pForwardAnimation); 483 QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault); 484 pHighlightedToDefault->addAnimation(m_pBackwardAnimation); 485 486 /* Initial state is 'default': */ 487 m_pHighlightMachine->setInitialState(pStateDefault); 488 /* Start state-machine: */ 489 m_pHighlightMachine->start(); 459 /* Create hovering animation machine: */ 460 m_pHoveringMachine = new QStateMachine(this); 461 if (m_pHoveringMachine) 462 { 463 /* Create 'default' state: */ 464 QState *pStateDefault = new QState(m_pHoveringMachine); 465 /* Create 'hovered' state: */ 466 QState *pStateHovered = new QState(m_pHoveringMachine); 467 468 /* Configure 'default' state: */ 469 if (pStateDefault) 470 { 471 /* When we entering default state => we assigning animatedValue to m_iDefaultValue: */ 472 pStateDefault->assignProperty(this, "animatedValue", m_iDefaultValue); 473 474 /* Add state transition: */ 475 QSignalTransition *pDefaultToHovered = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHovered); 476 if (pDefaultToHovered) 477 { 478 /* Create forward animation: */ 479 m_pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this); 480 if (m_pHoveringAnimationForward) 481 { 482 m_pHoveringAnimationForward->setDuration(m_iAnimationDuration); 483 m_pHoveringAnimationForward->setStartValue(m_iDefaultValue); 484 m_pHoveringAnimationForward->setEndValue(m_iHoveredValue); 485 486 /* Add to transition: */ 487 pDefaultToHovered->addAnimation(m_pHoveringAnimationForward); 488 } 489 } 490 } 491 492 /* Configure 'hovered' state: */ 493 if (pStateHovered) 494 { 495 /* When we entering hovered state => we assigning animatedValue to m_iHoveredValue: */ 496 pStateHovered->assignProperty(this, "animatedValue", m_iHoveredValue); 497 498 /* Add state transition: */ 499 QSignalTransition *pHoveredToDefault = pStateHovered->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault); 500 if (pHoveredToDefault) 501 { 502 /* Create backward animation: */ 503 m_pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this); 504 if (m_pHoveringAnimationBackward) 505 { 506 m_pHoveringAnimationBackward->setDuration(m_iAnimationDuration); 507 m_pHoveringAnimationBackward->setStartValue(m_iHoveredValue); 508 m_pHoveringAnimationBackward->setEndValue(m_iDefaultValue); 509 510 /* Add to transition: */ 511 pHoveredToDefault->addAnimation(m_pHoveringAnimationBackward); 512 } 513 } 514 } 515 516 /* Initial state is 'default': */ 517 m_pHoveringMachine->setInitialState(pStateDefault); 518 /* Start state-machine: */ 519 m_pHoveringMachine->start(); 520 } 490 521 491 522 /* Configure connections: */ … … 711 742 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 712 743 tGradient.setColorAt(0, headerColor.darker(110)); 713 tGradient.setColorAt(1, headerColor.darker(animat ionDarkness()));744 tGradient.setColorAt(1, headerColor.darker(animatedValue())); 714 745 715 746 /* Paint all the stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/manager/details/UIDetailsElement.h
r74049 r74080 43 43 { 44 44 Q_OBJECT; 45 Q_PROPERTY(int animat ionDarkness READ animationDarkness WRITE setAnimationDarkness);45 Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue); 46 46 Q_PROPERTY(int additionalHeight READ additionalHeight WRITE setAdditionalHeight); 47 47 … … 248 248 void updateIcon(); 249 249 250 /** Defines @a iAnimationDarkness. */251 void setAnimat ionDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }252 /** Returns animat ion darkness. */253 int animat ionDarkness() const { return m_iAnimationDarkness; }250 /** Defines animated @a iValue. */ 251 void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); } 252 /** Returns animated value. */ 253 int animatedValue() const { return m_iAnimatedValue; } 254 254 255 255 /** Handles any kind of hover @a pEvent. */ … … 306 306 /** Holds whether element name is hovered. */ 307 307 bool m_fNameHovered; 308 /** Holds the h ighlightmachine instance. */309 QStateMachine *m_pH ighlightMachine;310 /** Holds the forward h ighlightanimation instance. */311 QPropertyAnimation *m_p ForwardAnimation;312 /** Holds the backward h ighlightanimation instance. */313 QPropertyAnimation *m_p BackwardAnimation;308 /** Holds the hovering animation machine instance. */ 309 QStateMachine *m_pHoveringMachine; 310 /** Holds the forward hovering animation instance. */ 311 QPropertyAnimation *m_pHoveringAnimationForward; 312 /** Holds the backward hovering animation instance. */ 313 QPropertyAnimation *m_pHoveringAnimationBackward; 314 314 /** Holds the animation duration. */ 315 315 int m_iAnimationDuration; 316 /** Holds the default darkness. */317 int m_iDefault Darkness;318 /** Holds the h ighlight darkness. */319 int m_iH ighlightDarkness;320 /** Holds the animat ion darkness. */321 int m_iAnimat ionDarkness;316 /** Holds the default animation value. */ 317 int m_iDefaultValue; 318 /** Holds the hovered animation value. */ 319 int m_iHoveredValue; 320 /** Holds the animated value. */ 321 int m_iAnimatedValue; 322 322 323 323 /** Holds the toggle button instance. */
Note:
See TracChangeset
for help on using the changeset viewer.