- Timestamp:
- Sep 5, 2018 11:37:59 AM (6 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.cpp
r74002 r74078 204 204 , m_fRoot(!pParent) 205 205 , m_fHovered(false) 206 , m_pH ighlightMachine(0)207 , m_p ForwardAnimation(0)208 , m_p BackwardAnimation(0)206 , m_pHoveringMachine(0) 207 , m_pHoveringAnimationForward(0) 208 , m_pHoveringAnimationBackward(0) 209 209 , m_iAnimationDuration(400) 210 , m_iDefault Darkness(100)211 , m_iH ighlightDarkness(90)212 , m_iAnimat ionDarkness(m_iDefaultDarkness)210 , m_iDefaultValue(100) 211 , m_iHoveredValue(90) 212 , m_iAnimatedValue(m_iDefaultValue) 213 213 , m_iPreviousMinimumWidthHint(0) 214 214 , m_iPreviousMinimumHeightHint(0) … … 229 229 if (!isRoot()) 230 230 { 231 /* Create state machine: */ 232 m_pHighlightMachine = new QStateMachine(this); 233 /* Create 'default' state: */ 234 QState *pStateDefault = new QState(m_pHighlightMachine); 235 pStateDefault->assignProperty(this, "animationDarkness", m_iDefaultDarkness); 236 /* Create 'highlighted' state: */ 237 QState *pStateHighlighted = new QState(m_pHighlightMachine); 238 pStateHighlighted->assignProperty(this, "animationDarkness", m_iHighlightDarkness); 239 240 /* Forward animation: */ 241 m_pForwardAnimation = new QPropertyAnimation(this, "animationDarkness", this); 242 m_pForwardAnimation->setDuration(m_iAnimationDuration); 243 m_pForwardAnimation->setStartValue(m_iDefaultDarkness); 244 m_pForwardAnimation->setEndValue(m_iHighlightDarkness); 245 246 /* Backward animation: */ 247 m_pBackwardAnimation = new QPropertyAnimation(this, "animationDarkness", this); 248 m_pBackwardAnimation->setDuration(m_iAnimationDuration); 249 m_pBackwardAnimation->setStartValue(m_iHighlightDarkness); 250 m_pBackwardAnimation->setEndValue(m_iDefaultDarkness); 251 252 /* Add state transitions: */ 253 QSignalTransition *pDefaultToHighlighted = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHighlighted); 254 pDefaultToHighlighted->addAnimation(m_pForwardAnimation); 255 QSignalTransition *pHighlightedToDefault = pStateHighlighted->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault); 256 pHighlightedToDefault->addAnimation(m_pBackwardAnimation); 257 258 /* Initial state is 'default': */ 259 m_pHighlightMachine->setInitialState(pStateDefault); 260 /* Start state-machine: */ 261 m_pHighlightMachine->start(); 231 /* Create hovering animation machine: */ 232 m_pHoveringMachine = new QStateMachine(this); 233 if (m_pHoveringMachine) 234 { 235 /* Create 'default' state: */ 236 QState *pStateDefault = new QState(m_pHoveringMachine); 237 /* Create 'hovered' state: */ 238 QState *pStateHovered = new QState(m_pHoveringMachine); 239 240 /* Configure 'default' state: */ 241 if (pStateDefault) 242 { 243 /* When we entering default state => we assigning animatedValue to m_iDefaultValue: */ 244 pStateDefault->assignProperty(this, "animatedValue", m_iDefaultValue); 245 246 /* Add state transitions: */ 247 QSignalTransition *pDefaultToHovered = pStateDefault->addTransition(this, SIGNAL(sigHoverEnter()), pStateHovered); 248 if (pDefaultToHovered) 249 { 250 /* Create forward animation: */ 251 m_pHoveringAnimationForward = new QPropertyAnimation(this, "animatedValue", this); 252 if (m_pHoveringAnimationForward) 253 { 254 m_pHoveringAnimationForward->setDuration(m_iAnimationDuration); 255 m_pHoveringAnimationForward->setStartValue(m_iDefaultValue); 256 m_pHoveringAnimationForward->setEndValue(m_iHoveredValue); 257 258 /* Add to transition: */ 259 pDefaultToHovered->addAnimation(m_pHoveringAnimationForward); 260 } 261 } 262 } 263 264 /* Configure 'hovered' state: */ 265 if (pStateHovered) 266 { 267 /* When we entering hovered state => we assigning animatedValue to m_iHoveredValue: */ 268 pStateHovered->assignProperty(this, "animatedValue", m_iHoveredValue); 269 270 /* Add state transitions: */ 271 QSignalTransition *pHoveredToDefault = pStateHovered->addTransition(this, SIGNAL(sigHoverLeave()), pStateDefault); 272 if (pHoveredToDefault) 273 { 274 /* Create backward animation: */ 275 m_pHoveringAnimationBackward = new QPropertyAnimation(this, "animatedValue", this); 276 if (m_pHoveringAnimationBackward) 277 { 278 m_pHoveringAnimationBackward->setDuration(m_iAnimationDuration); 279 m_pHoveringAnimationBackward->setStartValue(m_iHoveredValue); 280 m_pHoveringAnimationBackward->setEndValue(m_iDefaultValue); 281 282 /* Add to transition: */ 283 pHoveredToDefault->addAnimation(m_pHoveringAnimationBackward); 284 } 285 } 286 } 287 288 /* Initial state is 'default': */ 289 m_pHoveringMachine->setInitialState(pStateDefault); 290 /* Start state-machine: */ 291 m_pHoveringMachine->start(); 292 } 262 293 } 263 294 } -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItem.h
r74002 r74078 78 78 { 79 79 Q_OBJECT; 80 Q_PROPERTY(int animat ionDarkness READ animationDarkness WRITE setAnimationDarkness);80 Q_PROPERTY(int animatedValue READ animatedValue WRITE setAnimatedValue); 81 81 82 82 signals: … … 255 255 virtual void handleRootStatusChange(); 256 256 257 /** Defines item's @a iDefaultDarkness. */258 void setDefault Darkness(int iDefaultDarkness) { m_iDefaultDarkness = iDefaultDarkness; update(); }259 /** Returns default item darkness. */260 int default Darkness() const { return m_iDefaultDarkness; }261 262 /** Defines item's @a iHighlightDarkness. */263 void setH ighlightDarkness(int iHighlightDarkness) { m_iHighlightDarkness = iHighlightDarkness; update(); }264 /** Returns highlight item darkness. */265 int h ighlightDarkness() const { return m_iHighlightDarkness; }266 267 /** Defines item's @a iAnimationDarkness. */268 void setAnimat ionDarkness(int iAnimationDarkness) { m_iAnimationDarkness = iAnimationDarkness; update(); }269 /** Returns animation item darkness. */270 int animat ionDarkness() const { return m_iAnimationDarkness; }257 /** Defines item's default animation @a iValue. */ 258 void setDefaultValue(int iValue) { m_iDefaultValue = iValue; update(); } 259 /** Returns item's default animation value. */ 260 int defaultValue() const { return m_iDefaultValue; } 261 262 /** Defines item's hovered animation @a iValue. */ 263 void setHoveredValue(int iValue) { m_iHoveredValue = iValue; update(); } 264 /** Returns item's hovered animation value. */ 265 int hoveredValue() const { return m_iHoveredValue; } 266 267 /** Defines item's animated @a iValue. */ 268 void setAnimatedValue(int iValue) { m_iAnimatedValue = iValue; update(); } 269 /** Returns item's animated value. */ 270 int animatedValue() const { return m_iAnimatedValue; } 271 271 /** @} */ 272 272 … … 327 327 /** Holds whether item is root. */ 328 328 bool m_fRoot; 329 329 330 /** Holds whether item is hovered. */ 330 bool m_fHovered; 331 332 /** Holds item highlight machine instance. */ 333 QStateMachine *m_pHighlightMachine; 334 335 /** Holds item forward animation instance. */ 336 QPropertyAnimation *m_pForwardAnimation; 337 /** Holds item backward animation instance. */ 338 QPropertyAnimation *m_pBackwardAnimation; 339 340 /** Holds item animation duration. */ 341 int m_iAnimationDuration; 342 343 /** Holds default item darkness. */ 344 int m_iDefaultDarkness; 345 /** Holds highlight item darkness. */ 346 int m_iHighlightDarkness; 347 /** Holds animation item darkness. */ 348 int m_iAnimationDarkness; 331 bool m_fHovered; 332 /** Holds the hovering animation machine instance. */ 333 QStateMachine *m_pHoveringMachine; 334 /** Holds the forward hovering animation instance. */ 335 QPropertyAnimation *m_pHoveringAnimationForward; 336 /** Holds the backward hovering animation instance. */ 337 QPropertyAnimation *m_pHoveringAnimationBackward; 338 /** Holds the animation duration. */ 339 int m_iAnimationDuration; 340 /** Holds the default animation value. */ 341 int m_iDefaultValue; 342 /** Holds the hovered animation value. */ 343 int m_iHoveredValue; 344 /** Holds the animated value. */ 345 int m_iAnimatedValue; 349 346 /** @} */ 350 347 -
trunk/src/VBox/Frontends/VirtualBox/src/manager/chooser/UIChooserItemGroup.cpp
r74002 r74078 1672 1672 QLinearGradient headerGradient(headerRect.bottomLeft(), headerRect.topLeft()); 1673 1673 headerGradient.setColorAt(1, headerColor.darker(blackoutDarkness())); 1674 headerGradient.setColorAt(0, headerColor.darker(animat ionDarkness()));1674 headerGradient.setColorAt(0, headerColor.darker(animatedValue())); 1675 1675 pPainter->fillRect(headerRect, headerGradient); 1676 1676 pPainter->fillRect(bodyRect, bodyColor); … … 1689 1689 /* Prepare top gradient: */ 1690 1690 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 1691 tGradient.setColorAt(1, headerColor.darker(animat ionDarkness()));1691 tGradient.setColorAt(1, headerColor.darker(animatedValue())); 1692 1692 tGradient.setColorAt(0, headerColor.darker(blackoutDarkness())); 1693 1693 /* Fill top rectangle: */
Note:
See TracChangeset
for help on using the changeset viewer.