void GUIPanel::packXAxisLayout() { computeWindowBounds(); std::vector<int> childrenWidths, childrenHeights; float offset = 0; size_t t = 0; int height = 0, width = 0, panelHeight = windowBounds.w - windowBounds.y; for(t = 0; t < elements.size(); t++) { const Tuple4i &childBounds = elements[t]->getWindowBounds(); childrenHeights.push_back(childBounds.w - childBounds.y); childrenWidths.push_back (childBounds.z - childBounds.x + interval.x); width += childrenWidths[t]; height = childBounds.w - childBounds.y; panelHeight = height > panelHeight ? height : panelHeight; } dimensions.set(float(width), float(panelHeight)); GUIRectangle::computeWindowBounds(); windowBounds.z += interval.x; windowBounds.w += interval.y*2; update = false; width = interval.x; correctPosition(); computeClippedBounds(windowBounds); for(t = 0; t < elements.size(); t++) { offset = clamp(float(panelHeight - childrenHeights[t])/2.0f + interval.y, 0.0f, 1000.0f); elements[t]->setAnchorPoint(AT_CORNERLU); elements[t]->setPosition(float(width), offset); elements[t]->computeWindowBounds(); width += childrenWidths[t]; } }
void GUIPanel::packYAxisLayout() { computeWindowBounds(); std::vector<int> childrenHeights, childrenWidths; size_t t = 0; int height = 0, xOffset = 0, panelWidth = getWidth(); for(t = 0; t < elements.size(); t++) { const Tuple4i &childBounds = elements[t]->getWindowBounds(); childrenHeights.push_back(childBounds.w - childBounds.y + interval.y); childrenWidths.push_back(childBounds.z - childBounds.x); height += childrenHeights[t]; panelWidth = childrenWidths[t] > panelWidth ? childrenWidths[t] : panelWidth; } dimensions.set(float(panelWidth), float(height)); GUIRectangle::computeWindowBounds(); windowBounds.z += interval.x*2; windowBounds.w += interval.y; update = false; height = interval.y; correctPosition(); computeClippedBounds(windowBounds); for(t = 0; t < elements.size(); t++) { xOffset = (layout == PL_YAXIS_CEN_LAYOUT) * (panelWidth - childrenWidths[t])/2; elements[t]->setAnchorPoint(AT_CORNERLU); elements[t]->setPosition(float(interval.x + xOffset), float(height)); elements[t]->computeWindowBounds(); height += childrenHeights[t]; } }
const Tuple4i &GUIRectangle::getWindowBounds() { computeWindowBounds(); return windowBounds; }