VirtualBox

Changeset 44054 in vbox


Ignore:
Timestamp:
Dec 6, 2012 4:25:26 PM (12 years ago)
Author:
vboxsync
Message:

FE/Qt: VM group UI: Chooser-view: Consistent size-hint calculation for main root-item.

File:
1 edited

Legend:

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

    r44051 r44054  
    403403    m_pixmapSizeGroups = m_groupsPixmap.size();
    404404    m_pixmapSizeMachines = m_machinesPixmap.size();
     405    m_minimumHeaderSize = QSize(0, 0);
    405406
    406407    /* Items except roots: */
     
    10721073int UIGChooserItemGroup::minimumWidthHint(bool fOpenedGroup) const
    10731074{
    1074     /* Prepare variables: */
    1075     int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
    1076     int iRootIndent = data(GroupItemData_RootIndent).toInt();
    1077     int iFullHeaderWidth = m_minimumHeaderSize.width();
    1078 
    10791075    /* Calculating proposed width: */
    10801076    int iProposedWidth = 0;
    10811077
    1082     /* Simple group-item have 2 margins - left and right: */
    1083     iProposedWidth += 2 * iHorizontalMargin;
    1084     /* And full header width to take into account: */
    1085     iProposedWidth += iFullHeaderWidth;
    1086     /* But if group is opened: */
    1087     if (fOpenedGroup)
     1078    /* Main root-item: */
     1079    if (isMainRoot())
     1080    {
     1081        /* Main root-item always takes body into account: */
     1082        if (hasItems())
     1083        {
     1084            /* Prepare variables: */
     1085            int iRootIndent = data(GroupItemData_RootIndent).toInt();
     1086
     1087            /* We have to take every child width into account: */
     1088            int iMaximumChildWidth = 0;
     1089            foreach (UIGChooserItem *pItem, items())
     1090                iMaximumChildWidth = qMax(iMaximumChildWidth, pItem->minimumWidthHint());
     1091            iProposedWidth += iMaximumChildWidth;
     1092
     1093            /* And 2 indents at last - left and right: */
     1094            iProposedWidth += 2 * iRootIndent;
     1095        }
     1096    }
     1097    /* Other items, including temporary roots: */
     1098    else
    10881099    {
    10891100        /* Prepare variables: */
    1090         int iHorizontalIndent = isRoot() ? iRootIndent : iHorizontalMargin;
    1091         /* We have to make sure that we had taken into account: */
    1092         foreach (UIGChooserItem *pItem, items())
    1093         {
    1094             int iItemWidth = 2 * iHorizontalIndent + pItem->minimumWidthHint();
    1095             iProposedWidth = qMax(iProposedWidth, iItemWidth);
    1096         }
     1101        int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
     1102
     1103        /* Basically we have to take header width into account: */
     1104        iProposedWidth += m_minimumHeaderSize.width();
     1105
     1106        /* But if group-item is opened: */
     1107        if (fOpenedGroup)
     1108        {
     1109            /* We have to take every child width into account: */
     1110            int iMaximumChildWidth = 0;
     1111            foreach (UIGChooserItem *pItem, items())
     1112                iMaximumChildWidth = qMax(iMaximumChildWidth, pItem->minimumWidthHint());
     1113            iProposedWidth = qMax(iProposedWidth, iMaximumChildWidth);
     1114        }
     1115
     1116        /* And 2 margins at last - left and right: */
     1117        iProposedWidth += 2 * iHorizontalMargin;
    10971118    }
    10981119
     
    11041125{
    11051126    /* Prepare variables: */
    1106     int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
    1107     int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt();
    11081127    int iMinorSpacing = data(GroupItemData_MinorSpacing).toInt();
    1109     int iFullHeaderHeight = m_minimumHeaderSize.height();
    11101128
    11111129    /* Calculating proposed height: */
    11121130    int iProposedHeight = 0;
    11131131
    1114     /* Simple group-item have 2 margins - top and bottom: */
    1115     iProposedHeight += 2 * iVerticalMargin;
    1116     /* And full header height to take into account: */
    1117     iProposedHeight += iFullHeaderHeight;
    1118     /* But if group is opened: */
    1119     if (fOpenedGroup)
    1120     {
    1121         /* We should take into account vertical indent: */
    1122         iProposedHeight += iVerticalMargin;
    1123         /* And every item height: */
    1124         QList<UIGChooserItem*> allItems = items();
    1125         for (int i = 0; i < allItems.size(); ++i)
    1126         {
    1127             UIGChooserItem *pItem = allItems[i];
    1128             iProposedHeight += (pItem->minimumHeightHint() + iMinorSpacing);
    1129         }
    1130         /* Minus last spacing: */
    1131         iProposedHeight -= iMinorSpacing;
    1132         /* Bottom margin: */
    1133         iProposedHeight += iHorizontalMargin;
    1134     }
    1135     /* Finally, additional height during animation: */
    1136     if (!fOpenedGroup && m_pToggleButton && m_pToggleButton->isAnimationRunning())
    1137         iProposedHeight += m_iAdditionalHeight;
     1132    /* Main root-item: */
     1133    if (isMainRoot())
     1134    {
     1135        /* Main root-item always takes body into account: */
     1136        if (hasItems())
     1137        {
     1138            /* Prepare variables: */
     1139            int iRootIndent = data(GroupItemData_RootIndent).toInt();
     1140
     1141            /* Main root-item have 2 indents - top and bottom: */
     1142            iProposedHeight += 2 * iRootIndent;
     1143            /* And every existing: */
     1144            foreach (UIGChooserItem *pItem, items())
     1145            {
     1146                /* Child height: */
     1147                iProposedHeight += pItem->minimumHeightHint();
     1148                /* And interline spacing: */
     1149                iProposedHeight += iMinorSpacing;
     1150            }
     1151            /* Excpect the last one spacing: */
     1152            iProposedHeight -= iMinorSpacing;
     1153        }
     1154    }
     1155    /* Other items, including temporary roots: */
     1156    else
     1157    {
     1158        /* Prepare variables: */
     1159        int iVerticalMargin = data(GroupItemData_VerticalMargin).toInt();
     1160
     1161        /* Group-item header have 2 margins - top and bottom: */
     1162        iProposedHeight += 2 * iVerticalMargin;
     1163        /* And header content height to take into account: */
     1164        iProposedHeight += m_minimumHeaderSize.height();
     1165
     1166        /* But if group-item is opened: */
     1167        if (fOpenedGroup)
     1168        {
     1169            /* Prepare variables: */
     1170            int iHorizontalMargin = data(GroupItemData_HorizonalMargin).toInt();
     1171
     1172            /* We should take into spacing between header and body: */
     1173            iProposedHeight += iVerticalMargin;
     1174            /* Every existing: */
     1175            foreach (UIGChooserItem *pItem, items())
     1176            {
     1177                /* Child height: */
     1178                iProposedHeight += pItem->minimumHeightHint();
     1179                /* And interline spacing: */
     1180                iProposedHeight += iMinorSpacing;
     1181            }
     1182            /* Excpect the last one spacing: */
     1183            iProposedHeight -= iMinorSpacing;
     1184            /* And bottom margin at last: */
     1185            iProposedHeight += iHorizontalMargin;
     1186        }
     1187
     1188        /* Finally, additional height during animation: */
     1189        if (!fOpenedGroup && m_pToggleButton && m_pToggleButton->isAnimationRunning())
     1190            iProposedHeight += m_iAdditionalHeight;
     1191    }
    11381192
    11391193    /* Return result: */
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