Changeset 42827 in vbox for trunk/src/VBox
- Timestamp:
- Aug 15, 2012 3:21:45 PM (12 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.cpp
r42812 r42827 40 40 , m_pSet(pParent) 41 41 , m_type(type) 42 , m_iCornerRadius(10) 42 43 , m_fClosed(!fOpened) 43 44 , m_pButton(0) 44 45 , m_iAdditionalHeight(0) 45 , m_ iCornerRadius(10)46 , m_fAnimationRunning(false) 46 47 , m_fHovered(false) 47 48 , m_fNameHoveringAccessible(false) … … 135 136 void UIGDetailsElement::sltElementToggleStart() 136 137 { 138 /* Mark animation running: */ 139 m_fAnimationRunning = true; 140 137 141 /* Setup animation: */ 138 142 updateAnimationParameters(); 139 143 140 /* Element closed, we are opening it: */ 141 if (m_fClosed) 142 { 143 /* Toggle-state will be updated 144 * on toggle finish signal! */ 145 } 146 /* Group opened, we are closing it: */ 147 else 148 { 149 /* Update toggle-state: */ 150 m_fClosed = true; 151 } 144 /* Toggle element state: */ 145 m_fClosed = !m_fClosed; 146 /* Relayout model: */ 147 model()->updateLayout(); 148 update(); 152 149 } 153 150 154 151 void UIGDetailsElement::sltElementToggleFinish(bool fToggled) 155 152 { 153 /* Mark animation stopped: */ 154 m_fAnimationRunning = false; 155 156 156 /* Update toggle-state: */ 157 157 m_fClosed = !fToggled; … … 470 470 { 471 471 m_iAdditionalHeight = iAdditionalHeight; 472 model()->updateLayout(); 472 updateLayout(); 473 update(); 473 474 } 474 475 … … 506 507 iProposedHeight += 2 * iMargin + iTextHeight; 507 508 } 508 else 509 { 510 /* Additional height during animation: */ 511 if (m_pButton->isAnimationRunning()) 512 iProposedHeight += m_iAdditionalHeight; 513 } 509 510 /* Additional height during animation: */ 511 if (m_fAnimationRunning) 512 iProposedHeight += m_iAdditionalHeight; 514 513 515 514 /* Return result: */ … … 548 547 { 549 548 /* Paint background: */ 550 paintBackground(/* Painter: */ 551 pPainter, 552 /* Rectangle to paint in: */ 553 pOption->rect, 554 /* Rounded corners radius: */ 555 m_iCornerRadius, 556 /* Header height: */ 557 2 * data(ElementData_Margin).toInt() + 558 data(ElementData_HeaderSize).toSize().height(), 559 /* Gradient color: */ 560 gradient()); 549 paintBackground(pPainter, pOption); 561 550 } 562 551 … … 604 593 605 594 /* Paint text: */ 606 if (!m_fClosed && !m_text.isEmpty() )595 if (!m_fClosed && !m_text.isEmpty() && !m_fAnimationRunning) 607 596 { 608 597 /* Prepare variables: */ … … 679 668 } 680 669 681 /* static */ 682 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QRect &rect, 683 int iRadius, int iHeaderHeight, int iGradient) 670 void UIGDetailsElement::paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption) 684 671 { 685 672 /* Save painter: */ … … 687 674 688 675 /* Prepare variables: */ 689 int iFullHeight = rect.height(); 676 int iMargin = data(ElementData_Margin).toInt(); 677 int iHeaderContentHeight = data(ElementData_HeaderSize).toSize().height(); 678 int iHeaderHeight = 2 * iMargin + iHeaderContentHeight; 679 QRect optionRect = pOption->rect; 680 QRect fullRect = !m_fAnimationRunning ? optionRect : 681 QRect(optionRect.topLeft(), QSize(optionRect.width(), iHeaderHeight + m_iAdditionalHeight)); 682 int iFullHeight = fullRect.height(); 690 683 691 684 /* Prepare color: */ … … 695 688 /* Add clipping: */ 696 689 QPainterPath path; 697 path.moveTo( iRadius, 0);698 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, 0), 90, 90);699 path.lineTo(path.currentPosition().x(), iFullHeight - iRadius);700 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(0, -iRadius), 180, 90);701 path.lineTo( rect.width() - iRadius, path.currentPosition().y());702 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-iRadius, -2 * iRadius), 270, 90);703 path.lineTo(path.currentPosition().x(), iRadius);704 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * iRadius, 2 * iRadius)).translated(-2 * iRadius, -iRadius), 0, 90);690 path.moveTo(m_iCornerRadius, 0); 691 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, 0), 90, 90); 692 path.lineTo(path.currentPosition().x(), iFullHeight - m_iCornerRadius); 693 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(0, -m_iCornerRadius), 180, 90); 694 path.lineTo(fullRect.width() - m_iCornerRadius, path.currentPosition().y()); 695 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-m_iCornerRadius, -2 * m_iCornerRadius), 270, 90); 696 path.lineTo(path.currentPosition().x(), m_iCornerRadius); 697 path.arcTo(QRectF(path.currentPosition(), QSizeF(2 * m_iCornerRadius, 2 * m_iCornerRadius)).translated(-2 * m_iCornerRadius, -m_iCornerRadius), 0, 90); 705 698 path.closeSubpath(); 706 699 pPainter->setClipPath(path); 707 700 708 701 /* Calculate top rectangle: */ 709 QRect tRect = rect;702 QRect tRect = fullRect; 710 703 tRect.setBottom(tRect.top() + iHeaderHeight); 711 704 /* Calculate bottom rectangle: */ 712 QRect bRect = rect;705 QRect bRect = fullRect; 713 706 bRect.setTop(tRect.bottom()); 714 707 … … 716 709 QLinearGradient tGradient(tRect.bottomLeft(), tRect.topLeft()); 717 710 tGradient.setColorAt(0, windowColor.darker(110)); 718 tGradient.setColorAt(1, windowColor.darker( iGradient));711 tGradient.setColorAt(1, windowColor.darker(gradient())); 719 712 720 713 /* Paint all the stuff: */ … … 857 850 int iClosedHeight = minimumHeightHint(true); 858 851 int iAdditionalHeight = iOpenedHeight - iClosedHeight; 852 if (m_fClosed) 853 m_iAdditionalHeight = 0; 854 else 855 m_iAdditionalHeight = iAdditionalHeight; 859 856 m_pButton->setAnimationRange(0, iAdditionalHeight); 860 857 } -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElement.h
r42813 r42827 89 89 void updateHoverAccessibility(); 90 90 virtual void updateAppearance() = 0; 91 92 protected slots: 93 94 /* Handlers: Collapse/expand stuff: */ 95 void sltElementToggleStart(); 96 void sltElementToggleFinish(bool fToggled); 91 97 92 98 protected: … … 141 147 UIGraphicsRotatorButton* button() const; 142 148 143 private slots: 144 145 /* Handlers: Collapse/expand stuff: */ 146 void sltElementToggleStart(); 147 void sltElementToggleFinish(bool fToggled); 148 149 private: 149 protected: 150 150 151 151 /* API: Children stuff: */ … … 168 168 void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 169 169 void paintElementInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 170 static void paintBackground(QPainter *pPainter, const QRect &rect, 171 int iRadius, int iHeaderHeight, int iGradient); 170 void paintBackground(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption); 172 171 173 172 /* Handlers: Mouse stuff: */ … … 192 191 QIcon m_icon; 193 192 QString m_strName; 193 UITextTable m_text; 194 int m_iCornerRadius; 195 196 /* Variables: Toggle stuff: */ 194 197 bool m_fClosed; 195 198 UIGraphicsRotatorButton *m_pButton; 196 UITextTable m_text;197 199 int m_iAdditionalHeight; 198 int m_iCornerRadius;200 bool m_fAnimationRunning; 199 201 200 202 /* Variables: Hover stuff: */ -
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/details/UIGDetailsElements.cpp
r42813 r42827 232 232 if (closed() && m_pPreview->isVisible()) 233 233 m_pPreview->hide(); 234 if (opened() && !m_pPreview->isVisible() )234 if (opened() && !m_pPreview->isVisible() && !m_fAnimationRunning) 235 235 m_pPreview->show(); 236 236 }
Note:
See TracChangeset
for help on using the changeset viewer.