void GUIPanel::_updateOptimalLayoutSizes() { // Update all children first, otherwise we can't determine our own optimal size GUIElementBase::_updateOptimalLayoutSizes(); if (mChildren.size() != mChildSizeRanges.size()) mChildSizeRanges.resize(mChildren.size()); Vector2I optimalSize; Vector2I minSize; UINT32 childIdx = 0; for (auto& child : mChildren) { LayoutSizeRange& childSizeRange = mChildSizeRanges[childIdx]; if (child->_isActive()) { childSizeRange = _getElementSizeRange(child); UINT32 paddingX = child->_getPadding().left + child->_getPadding().right; UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom; Vector2I childMax; childMax.x = child->_getDimensions().x + childSizeRange.optimal.x + paddingX; childMax.y = child->_getDimensions().y + childSizeRange.optimal.y + paddingY; optimalSize.x = std::max(optimalSize.x, childMax.x); optimalSize.y = std::max(optimalSize.y, childMax.y); childMax.x = child->_getDimensions().x + childSizeRange.min.x + paddingX; childMax.y = child->_getDimensions().y + childSizeRange.min.y + paddingY; minSize.x = std::max(minSize.x, childMax.x); minSize.y = std::max(minSize.y, childMax.y); } else childSizeRange = LayoutSizeRange(); childIdx++; } mSizeRange = _getDimensions().calculateSizeRange(optimalSize); mSizeRange.min.x = std::max(mSizeRange.min.x, minSize.x); mSizeRange.min.y = std::max(mSizeRange.min.y, minSize.y); }
void GUILayoutX::_updateOptimalLayoutSizes() { // Update all children first, otherwise we can't determine our own optimal size GUIElementBase::_updateOptimalLayoutSizes(); if(mChildren.size() != mChildSizeRanges.size()) mChildSizeRanges.resize(mChildren.size()); Vector2I optimalSize; Vector2I minSize; UINT32 childIdx = 0; for(auto& child : mChildren) { LayoutSizeRange& childSizeRange = mChildSizeRanges[childIdx]; if (child->_isActive()) { childSizeRange = child->_getLayoutSizeRange(); if (child->_getType() == GUIElementBase::Type::FixedSpace) { childSizeRange.optimal.y = 0; childSizeRange.min.y = 0; } UINT32 paddingX = child->_getPadding().left + child->_getPadding().right; UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom; optimalSize.x += childSizeRange.optimal.x + paddingX; optimalSize.y = std::max((UINT32)optimalSize.y, childSizeRange.optimal.y + paddingY); minSize.x += childSizeRange.min.x + paddingX; minSize.y = std::max((UINT32)minSize.y, childSizeRange.min.y + paddingY); } else childSizeRange = LayoutSizeRange(); childIdx++; } mSizeRange = _getDimensions().calculateSizeRange(optimalSize); mSizeRange.min.x = std::max(mSizeRange.min.x, minSize.x); mSizeRange.min.y = std::max(mSizeRange.min.y, minSize.y); }
void GUIScrollArea::_updateOptimalLayoutSizes() { // Update all children first, otherwise we can't determine our own optimal size GUIElementBase::_updateOptimalLayoutSizes(); if (mChildren.size() != mChildSizeRanges.size()) mChildSizeRanges.resize(mChildren.size()); UINT32 childIdx = 0; for (auto& child : mChildren) { if (child->_isActive()) mChildSizeRanges[childIdx] = child->_getLayoutSizeRange(); else mChildSizeRanges[childIdx] = LayoutSizeRange(); childIdx++; } mSizeRange = mDimensions.calculateSizeRange(_getOptimalSize()); }