VirtualBox

Changeset 43822 in vbox


Ignore:
Timestamp:
Nov 7, 2012 8:46:33 AM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: One more group-item rework (painting related).

Location:
trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.cpp

    r43821 r43822  
    10541054}
    10551055
    1056 int UIGChooserItemGroup::minimumWidthHint(bool fClosedGroup) const
     1056int UIGChooserItemGroup::minimumWidthHint(bool fOpenedGroup) const
    10571057{
    10581058    /* Prepare variables: */
    10591059    int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
    1060     QSize fullHeaderSize = data(GroupItemData_FullHeaderSize).toSize();
     1060    int iFullHeaderWidth = data(GroupItemData_FullHeaderSize).toSize().width();
    10611061
    10621062    /* Calculating proposed width: */
     
    10661066    iProposedWidth += 2 * iHorizontalMargin;
    10671067    /* And full header width to take into account: */
    1068     iProposedWidth += fullHeaderSize.width();
     1068    iProposedWidth += iFullHeaderWidth;
    10691069    /* But if group is opened: */
    1070     if (!fClosedGroup)
     1070    if (fOpenedGroup)
    10711071    {
    10721072        /* Prepare variables: */
     
    10841084}
    10851085
    1086 int UIGChooserItemGroup::minimumHeightHint(bool fClosedGroup) const
     1086int UIGChooserItemGroup::minimumHeightHint(bool fOpenedGroup) const
    10871087{
    10881088    /* Prepare variables: */
     
    10901090    int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt();
    10911091    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    1092     QSize fullHeaderSize = data(GroupItemData_FullHeaderSize).toSize();
     1092    int iFullHeaderHeight = data(GroupItemData_FullHeaderSize).toSize().height();
    10931093
    10941094    /* Calculating proposed height: */
     
    10981098    iProposedHeight += 2 * iVerticalMargin;
    10991099    /* And full header height to take into account: */
    1100     iProposedHeight += fullHeaderSize.height();
     1100    iProposedHeight += iFullHeaderHeight;
    11011101    /* But if group is opened: */
    1102     if (!fClosedGroup)
     1102    if (fOpenedGroup)
    11031103    {
    11041104        /* We should take into account vertical indent: */
     
    11171117    }
    11181118    /* Finally, additional height during animation: */
    1119     if (fClosedGroup && m_pToggleButton && m_pToggleButton->isAnimationRunning())
     1119    if (!fOpenedGroup && m_pToggleButton && m_pToggleButton->isAnimationRunning())
    11201120        iProposedHeight += m_iAdditionalHeight;
    11211121
     
    11261126int UIGChooserItemGroup::minimumWidthHint() const
    11271127{
    1128     return minimumWidthHint(isClosed());
     1128    return minimumWidthHint(isOpened());
    11291129}
    11301130
    11311131int UIGChooserItemGroup::minimumHeightHint() const
    11321132{
    1133     return minimumHeightHint(isClosed());
    1134 }
    1135 
    1136 QSizeF UIGChooserItemGroup::minimumSizeHint(bool fClosedGroup) const
    1137 {
    1138     return QSizeF(minimumWidthHint(fClosedGroup), minimumHeightHint(fClosedGroup));
     1133    return minimumHeightHint(isOpened());
     1134}
     1135
     1136QSizeF UIGChooserItemGroup::minimumSizeHint(bool fOpenedGroup) const
     1137{
     1138    return QSizeF(minimumWidthHint(fOpenedGroup), minimumHeightHint(fOpenedGroup));
    11391139}
    11401140
     
    11431143    /* If Qt::MinimumSize requested: */
    11441144    if (which == Qt::MinimumSize)
    1145         return minimumSizeHint(isClosed());
     1145        return minimumSizeHint(isOpened());
    11461146    /* Else call to base-class: */
    11471147    return UIGChooserItem::sizeHint(which, constraint);
     
    11601160QPixmap UIGChooserItemGroup::toPixmap()
    11611161{
    1162     QSize minimumSize = minimumSizeHint(true).toSize();
     1162    QSize minimumSize = minimumSizeHint(false).toSize();
    11631163    QPixmap pixmap(minimumSize);
    11641164    pixmap.fill(Qt::transparent);
     
    11671167    QStyleOptionGraphicsItem options;
    11681168    options.rect = QRect(QPoint(0, 0), minimumSize);
    1169     paint(&painter, &options, true);
     1169    paint(&painter, &options);
    11701170    return pixmap;
    11711171}
     
    14011401void UIGChooserItemGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget* /* pWidget = 0 */)
    14021402{
    1403     paint(pPainter, pOption, isClosed());
    1404 }
    1405 
    1406 void UIGChooserItemGroup::paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, bool fClosedGroup)
    1407 {
    14081403    /* Setup: */
    14091404    pPainter->setRenderHint(QPainter::Antialiasing);
    14101405
    1411     /* Paint decorations: */
    1412     paintDecorations(pPainter, pOption);
    1413 
    1414     /* Non for main root: */
    1415     if (!isMainRoot())
    1416     {
    1417         /* Paint group info: */
    1418         paintGroupInfo(pPainter, pOption, fClosedGroup);
    1419     }
    1420 }
    1421 
    1422 void UIGChooserItemGroup::paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption)
    1423 {
    14241406    /* Paint background: */
    14251407    paintBackground(pPainter, pOption->rect);
     1408
     1409    /* Paint header: */
     1410    paintHeader(pPainter, pOption->rect);
    14261411}
    14271412
     
    15481533}
    15491534
    1550 void UIGChooserItemGroup::paintGroupInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, bool)
    1551 {
     1535void UIGChooserItemGroup::paintHeader(QPainter *pPainter, const QRect &rect)
     1536{
     1537    /* Non for main root: */
     1538    if (isMainRoot())
     1539        return;
     1540
    15521541    /* Prepare variables: */
    15531542    int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
     
    16011590
    16021591        /* Prepare variables: */
    1603         QRect fullRect = pOption->rect;
    16041592        int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    16051593        int iEnterButtonWidth = data(GroupItemData_EnterButtonSize).toSize().width();
     
    16121600
    16131601        /* Indent: */
    1614         int iHorizontalIndent = fullRect.right() - iHorizontalMargin;
     1602        int iHorizontalIndent = rect.right() - iHorizontalMargin;
    16151603        if (!isRoot())
    16161604            iHorizontalIndent -= (iEnterButtonWidth + iMinorSpacing);
     
    16911679
    16921680    /* Recalculate animation parameters: */
    1693     QSizeF openedSize = minimumSizeHint(false);
    1694     QSizeF closedSize = minimumSizeHint(true);
     1681    QSizeF openedSize = minimumSizeHint(true);
     1682    QSizeF closedSize = minimumSizeHint(false);
    16951683    int iAdditionalHeight = openedSize.height() - closedSize.height();
    16961684    m_pToggleButton->setAnimationRange(0, iAdditionalHeight);
  • trunk/src/VBox/Frontends/VirtualBox/src/selector/graphics/chooser/UIGChooserItemGroup.h

    r43821 r43822  
    161161    /* Helpers: Layout stuff: */
    162162    void updateLayout();
    163     int minimumWidthHint(bool fClosedGroup) const;
    164     int minimumHeightHint(bool fClosedGroup) const;
     163    int minimumWidthHint(bool fOpenedGroup) const;
     164    int minimumHeightHint(bool fOpenedGroup) const;
    165165    int minimumWidthHint() const;
    166166    int minimumHeightHint() const;
    167     QSizeF minimumSizeHint(bool fClosedGroup) const;
     167    QSizeF minimumSizeHint(bool fOpenedGroup) const;
    168168    QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
    169169
     
    184184    /* Helpers: Paint stuff: */
    185185    void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, QWidget *pWidget = 0);
    186     void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, bool fClosedGroup);
    187     void paintDecorations(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption);
    188186    void paintBackground(QPainter *pPainter, const QRect &rect);
    189     void paintGroupInfo(QPainter *pPainter, const QStyleOptionGraphicsItem *pOption, bool fClosedGroup);
     187    void paintHeader(QPainter *pPainter, const QRect &rect);
    190188
    191189    /* Helpers: Animation stuff: */
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette