|
|
@@ -6,9 +6,28 @@
|
|
|
|
|
|
namespace BansheeEngine
|
|
|
{
|
|
|
+ Vector2I GUILayoutY::_calculateOptimalLayoutSize() const
|
|
|
+ {
|
|
|
+ UINT32 optimalWidth = 0;
|
|
|
+ UINT32 optimalHeight = 0;
|
|
|
+
|
|
|
+ for (auto& child : mChildren)
|
|
|
+ {
|
|
|
+ Vector2I optimalSize = child->_calculateOptimalLayoutSize();
|
|
|
+
|
|
|
+ UINT32 paddingX = child->_getPadding().left + child->_getPadding().right;
|
|
|
+ UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom;
|
|
|
+
|
|
|
+ optimalHeight += optimalSize.y + paddingY;
|
|
|
+ optimalWidth = std::max((UINT32)optimalSize.x, optimalWidth + paddingX);
|
|
|
+ }
|
|
|
+
|
|
|
+ return Vector2I(optimalWidth, optimalHeight);
|
|
|
+ }
|
|
|
+
|
|
|
void GUILayoutY::_updateOptimalLayoutSizes()
|
|
|
{
|
|
|
- // Update all children first, otherwise we can't determine out own optimal size
|
|
|
+ // Update all children first, otherwise we can't determine our own optimal size
|
|
|
GUIElementBase::_updateOptimalLayoutSizes();
|
|
|
|
|
|
if(mChildren.size() != mOptimalSizes.size())
|
|
|
@@ -26,44 +45,16 @@ namespace BansheeEngine
|
|
|
if(child->_getType() == GUIElementBase::Type::FixedSpace)
|
|
|
{
|
|
|
GUIFixedSpace* fixedSpace = static_cast<GUIFixedSpace*>(child);
|
|
|
- optimalHeight = fixedSpace->getSize();
|
|
|
+ optimalHeight = fixedSpace->_calculateOptimalLayoutSize().y;
|
|
|
}
|
|
|
else if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
|
- Vector2I optimalSize;
|
|
|
- if(!layoutOptions.fixedWidth || !layoutOptions.fixedHeight)
|
|
|
- optimalSize = child->_getOptimalSize();
|
|
|
-
|
|
|
- if(layoutOptions.fixedHeight)
|
|
|
- {
|
|
|
- optimalHeight = layoutOptions.height;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- optimalHeight = optimalSize.y;
|
|
|
-
|
|
|
- if(layoutOptions.minHeight > 0)
|
|
|
- optimalHeight = std::max(layoutOptions.minHeight, optimalHeight);
|
|
|
-
|
|
|
- if(layoutOptions.maxHeight > 0)
|
|
|
- optimalHeight = std::min(layoutOptions.maxHeight, optimalHeight);
|
|
|
- }
|
|
|
-
|
|
|
- if(layoutOptions.fixedWidth)
|
|
|
- optimalWidth = layoutOptions.width;
|
|
|
- else
|
|
|
- {
|
|
|
- optimalWidth = optimalSize.x;
|
|
|
-
|
|
|
- if(layoutOptions.minWidth > 0)
|
|
|
- optimalWidth = std::max(layoutOptions.minWidth, optimalWidth);
|
|
|
-
|
|
|
- if(layoutOptions.maxWidth > 0)
|
|
|
- optimalWidth = std::min(layoutOptions.maxWidth, optimalWidth);
|
|
|
- }
|
|
|
+ Vector2I optimalSize = child->_calculateOptimalLayoutSize();
|
|
|
+ optimalWidth = optimalSize.x;
|
|
|
+ optimalHeight = optimalSize.y;
|
|
|
}
|
|
|
else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
|
@@ -85,51 +76,56 @@ namespace BansheeEngine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
|
|
|
+ void GUILayoutY::getElementAreas(UINT32 width, UINT32 height, RectI* elementAreas, UINT32 numElements, const Vector<Vector2I>& optimalSizes) const
|
|
|
{
|
|
|
+ assert(mChildren.size() == numElements);
|
|
|
+
|
|
|
UINT32 totalOptimalSize = _getOptimalSize().y;
|
|
|
UINT32 totalNonClampedSize = 0;
|
|
|
UINT32 numNonClampedElements = 0;
|
|
|
UINT32 numFlexibleSpaces = 0;
|
|
|
|
|
|
- bool* processedElements = stackAllocN<bool>((UINT32)mChildren.size());
|
|
|
- memset(processedElements, 0, mChildren.size() * sizeof(bool));
|
|
|
+ bool* processedElements = nullptr;
|
|
|
+ float* elementScaleWeights = nullptr;
|
|
|
|
|
|
- UINT32* elementSizes = stackAllocN<UINT32>((UINT32)mChildren.size());
|
|
|
- memset(elementSizes, 0, mChildren.size() * sizeof(UINT32));
|
|
|
+ if (mChildren.size() > 0)
|
|
|
+ {
|
|
|
+ processedElements = stackAllocN<bool>((UINT32)mChildren.size());
|
|
|
+ memset(processedElements, 0, mChildren.size() * sizeof(bool));
|
|
|
|
|
|
- float* elementScaleWeights = stackAllocN<float>((UINT32)mChildren.size());
|
|
|
- memset(elementScaleWeights, 0, mChildren.size() * sizeof(float));
|
|
|
+ elementScaleWeights = stackAllocN<float>((UINT32)mChildren.size());
|
|
|
+ memset(elementScaleWeights, 0, mChildren.size() * sizeof(float));
|
|
|
+ }
|
|
|
|
|
|
// Set initial sizes, count number of children per type and mark fixed elements as already processed
|
|
|
UINT32 childIdx = 0;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- elementSizes[childIdx] = mOptimalSizes[childIdx].y;
|
|
|
+ elementAreas[childIdx].height = optimalSizes[childIdx].y;
|
|
|
|
|
|
- if(child->_getType() == GUIElementBase::Type::FixedSpace)
|
|
|
+ if (child->_getType() == GUIElementBase::Type::FixedSpace)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
|
- if(layoutOptions.fixedHeight)
|
|
|
+ if (layoutOptions.fixedHeight)
|
|
|
processedElements[childIdx] = true;
|
|
|
else
|
|
|
{
|
|
|
numNonClampedElements++;
|
|
|
- totalNonClampedSize += elementSizes[childIdx];
|
|
|
+ totalNonClampedSize += elementAreas[childIdx].height;
|
|
|
}
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
|
numNonClampedElements++;
|
|
|
- totalNonClampedSize += elementSizes[childIdx];
|
|
|
+ totalNonClampedSize += elementAreas[childIdx].height;
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
{
|
|
|
numFlexibleSpaces++;
|
|
|
numNonClampedElements++;
|
|
|
@@ -139,34 +135,34 @@ namespace BansheeEngine
|
|
|
}
|
|
|
|
|
|
// If there is some room left, calculate flexible space sizes (since they will fill up all that extra room)
|
|
|
- if(height > totalOptimalSize)
|
|
|
+ if (height > totalOptimalSize)
|
|
|
{
|
|
|
UINT32 extraSize = height - totalOptimalSize;
|
|
|
UINT32 remainingSize = extraSize;
|
|
|
|
|
|
// Flexible spaces always expand to fill up all unused space
|
|
|
- if(numFlexibleSpaces > 0)
|
|
|
+ if (numFlexibleSpaces > 0)
|
|
|
{
|
|
|
float avgSize = remainingSize / (float)numFlexibleSpaces;
|
|
|
|
|
|
childIdx = 0;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- if(processedElements[childIdx])
|
|
|
+ if (processedElements[childIdx])
|
|
|
{
|
|
|
childIdx++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
UINT32 extraHeight = std::min((UINT32)Math::ceilToInt(avgSize), remainingSize);
|
|
|
- UINT32 elementHeight = elementSizes[childIdx] + extraHeight;
|
|
|
+ UINT32 elementHeight = elementAreas[childIdx].height + extraHeight;
|
|
|
|
|
|
// Clamp if needed
|
|
|
- if(child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
+ if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
- elementSizes[childIdx] = elementHeight;
|
|
|
+ elementAreas[childIdx].height = elementHeight;
|
|
|
|
|
|
remainingSize = (UINT32)std::max(0, (INT32)remainingSize - (INT32)extraHeight);
|
|
|
}
|
|
|
@@ -182,35 +178,35 @@ namespace BansheeEngine
|
|
|
// Weight is to ensure all elements are scaled fairly, so elements that are large will get effected more than smaller elements.
|
|
|
childIdx = 0;
|
|
|
float invOptimalSize = 1.0f / totalNonClampedSize;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- if(processedElements[childIdx])
|
|
|
+ if (processedElements[childIdx])
|
|
|
{
|
|
|
childIdx++;
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- elementScaleWeights[childIdx] = invOptimalSize * elementSizes[childIdx];
|
|
|
+ elementScaleWeights[childIdx] = invOptimalSize * elementAreas[childIdx].height;
|
|
|
|
|
|
childIdx++;
|
|
|
}
|
|
|
|
|
|
// Our optimal size is larger than maximum allowed, so we need to reduce size of some elements
|
|
|
- if(totalOptimalSize > height)
|
|
|
+ if (totalOptimalSize > height)
|
|
|
{
|
|
|
UINT32 extraSize = totalOptimalSize - height;
|
|
|
UINT32 remainingSize = extraSize;
|
|
|
|
|
|
// Iterate until we reduce everything so it fits, while maintaining
|
|
|
// equal average sizes using the weights we calculated earlier
|
|
|
- while(remainingSize > 0 && numNonClampedElements > 0)
|
|
|
+ while (remainingSize > 0 && numNonClampedElements > 0)
|
|
|
{
|
|
|
UINT32 totalRemainingSize = remainingSize;
|
|
|
|
|
|
childIdx = 0;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- if(processedElements[childIdx])
|
|
|
+ if (processedElements[childIdx])
|
|
|
{
|
|
|
childIdx++;
|
|
|
continue;
|
|
|
@@ -219,20 +215,20 @@ namespace BansheeEngine
|
|
|
float avgSize = totalRemainingSize * elementScaleWeights[childIdx];
|
|
|
|
|
|
UINT32 extraHeight = std::min((UINT32)Math::ceilToInt(avgSize), remainingSize);
|
|
|
- UINT32 elementHeight = (UINT32)std::max(0, (INT32)elementSizes[childIdx] - (INT32)extraHeight);
|
|
|
+ UINT32 elementHeight = (UINT32)std::max(0, (INT32)elementAreas[childIdx].height - (INT32)extraHeight);
|
|
|
|
|
|
// Clamp if needed
|
|
|
- if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
+ if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
|
- if(elementHeight == 0)
|
|
|
+ if (elementHeight == 0)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
- else if(layoutOptions.minHeight > 0 && elementHeight < layoutOptions.minHeight)
|
|
|
+ else if (layoutOptions.minHeight > 0 && elementHeight < layoutOptions.minHeight)
|
|
|
{
|
|
|
elementHeight = layoutOptions.minHeight;
|
|
|
|
|
|
@@ -240,25 +236,25 @@ namespace BansheeEngine
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
|
|
|
- extraHeight = elementSizes[childIdx] - elementHeight;
|
|
|
- elementSizes[childIdx] = elementHeight;
|
|
|
+ extraHeight = elementAreas[childIdx].height - elementHeight;
|
|
|
+ elementAreas[childIdx].height = elementHeight;
|
|
|
remainingSize = (UINT32)std::max(0, (INT32)remainingSize - (INT32)extraHeight);
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
|
- if(elementHeight == 0)
|
|
|
+ if (elementHeight == 0)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
|
|
|
- extraHeight = elementSizes[childIdx] - elementHeight;
|
|
|
- elementSizes[childIdx] = elementHeight;
|
|
|
+ extraHeight = elementAreas[childIdx].height - elementHeight;
|
|
|
+ elementAreas[childIdx].height = elementHeight;
|
|
|
remainingSize = (UINT32)std::max(0, (INT32)remainingSize - (INT32)extraHeight);
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
{
|
|
|
- elementSizes[childIdx] = 0;
|
|
|
+ elementAreas[childIdx].height = 0;
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
@@ -274,14 +270,14 @@ namespace BansheeEngine
|
|
|
|
|
|
// Iterate until we reduce everything so it fits, while maintaining
|
|
|
// equal average sizes using the weights we calculated earlier
|
|
|
- while(remainingSize > 0 && numNonClampedElements > 0)
|
|
|
+ while (remainingSize > 0 && numNonClampedElements > 0)
|
|
|
{
|
|
|
UINT32 totalRemainingSize = remainingSize;
|
|
|
|
|
|
childIdx = 0;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- if(processedElements[childIdx])
|
|
|
+ if (processedElements[childIdx])
|
|
|
{
|
|
|
childIdx++;
|
|
|
continue;
|
|
|
@@ -289,20 +285,20 @@ namespace BansheeEngine
|
|
|
|
|
|
float avgSize = totalRemainingSize * elementScaleWeights[childIdx];
|
|
|
UINT32 extraHeight = std::min((UINT32)Math::ceilToInt(avgSize), remainingSize);
|
|
|
- UINT32 elementHeight = elementSizes[childIdx] + extraHeight;
|
|
|
+ UINT32 elementHeight = elementAreas[childIdx].height + extraHeight;
|
|
|
|
|
|
// Clamp if needed
|
|
|
- if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
+ if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
|
- if(elementHeight == 0)
|
|
|
+ if (elementHeight == 0)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
- else if(layoutOptions.maxHeight > 0 && elementHeight > layoutOptions.maxHeight)
|
|
|
+ else if (layoutOptions.maxHeight > 0 && elementHeight > layoutOptions.maxHeight)
|
|
|
{
|
|
|
elementHeight = layoutOptions.maxHeight;
|
|
|
|
|
|
@@ -310,16 +306,16 @@ namespace BansheeEngine
|
|
|
numNonClampedElements--;
|
|
|
}
|
|
|
|
|
|
- extraHeight = elementHeight - elementSizes[childIdx];
|
|
|
- elementSizes[childIdx] = elementHeight;
|
|
|
+ extraHeight = elementHeight - elementAreas[childIdx].height;
|
|
|
+ elementAreas[childIdx].height = elementHeight;
|
|
|
remainingSize = (UINT32)std::max(0, (INT32)remainingSize - (INT32)extraHeight);
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
|
- elementSizes[childIdx] = elementHeight;
|
|
|
+ elementAreas[childIdx].height = elementHeight;
|
|
|
remainingSize = (UINT32)std::max(0, (INT32)remainingSize - (INT32)extraHeight);
|
|
|
}
|
|
|
- else if(child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
|
numNonClampedElements--;
|
|
|
@@ -330,41 +326,84 @@ namespace BansheeEngine
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // Now that we have all the sizes, actually assign them
|
|
|
- // Also assign offsets, clip rectangles and depth
|
|
|
+ if (elementScaleWeights != nullptr)
|
|
|
+ stackDeallocLast(elementScaleWeights);
|
|
|
+
|
|
|
+ if (processedElements != nullptr)
|
|
|
+ stackDeallocLast(processedElements);
|
|
|
+
|
|
|
+ // Compute offsets and width
|
|
|
UINT32 yOffset = 0;
|
|
|
childIdx = 0;
|
|
|
|
|
|
- mActualWidth = 0;
|
|
|
- mActualHeight = 0;
|
|
|
- for(auto& child : mChildren)
|
|
|
+ for (auto& child : mChildren)
|
|
|
{
|
|
|
- UINT32 elemHeight = elementSizes[childIdx];
|
|
|
+ UINT32 elemHeight = elementAreas[childIdx].height;
|
|
|
yOffset += child->_getPadding().top;
|
|
|
-
|
|
|
- if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
+
|
|
|
+ if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
- UINT32 elemWidth = mOptimalSizes[childIdx].x;
|
|
|
+ UINT32 elemWidth = optimalSizes[childIdx].x;
|
|
|
const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
- if(!layoutOptions.fixedWidth)
|
|
|
+ if (!layoutOptions.fixedWidth)
|
|
|
{
|
|
|
elemWidth = width;
|
|
|
- if(layoutOptions.minWidth > 0 && elemWidth < layoutOptions.minWidth)
|
|
|
+ if (layoutOptions.minWidth > 0 && elemWidth < layoutOptions.minWidth)
|
|
|
elemWidth = layoutOptions.minWidth;
|
|
|
|
|
|
- if(layoutOptions.maxWidth > 0 && elemWidth > layoutOptions.maxWidth)
|
|
|
+ if (layoutOptions.maxWidth > 0 && elemWidth > layoutOptions.maxWidth)
|
|
|
elemWidth = layoutOptions.maxWidth;
|
|
|
}
|
|
|
|
|
|
- element->_setWidth(elemWidth);
|
|
|
- element->_setHeight(elemHeight);
|
|
|
+ elementAreas[childIdx].width = elemWidth;
|
|
|
|
|
|
UINT32 xPadding = element->_getPadding().left + element->_getPadding().right;
|
|
|
- INT32 xOffset = Math::ceilToInt((INT32)(width - (INT32)(element->_getWidth() + xPadding)) * 0.5f);
|
|
|
+ INT32 xOffset = Math::ceilToInt((INT32)(width - (INT32)(elemWidth + xPadding)) * 0.5f);
|
|
|
xOffset = std::max(0, xOffset);
|
|
|
|
|
|
- Vector2I offset(x + xOffset, y + yOffset);
|
|
|
+ elementAreas[childIdx].x = xOffset;
|
|
|
+ elementAreas[childIdx].y = yOffset;
|
|
|
+ }
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Layout)
|
|
|
+ {
|
|
|
+ elementAreas[childIdx].width = width;
|
|
|
+ elementAreas[childIdx].x = 0;
|
|
|
+ elementAreas[childIdx].y = yOffset;
|
|
|
+ }
|
|
|
+
|
|
|
+ yOffset += elemHeight + child->_getPadding().bottom;
|
|
|
+ childIdx++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ void GUILayoutY::_updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height, RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth)
|
|
|
+ {
|
|
|
+ UINT32 numElements = (UINT32)mChildren.size();
|
|
|
+ RectI* elementAreas = nullptr;
|
|
|
+
|
|
|
+ if (numElements > 0)
|
|
|
+ elementAreas = stackConstructN<RectI>(numElements);
|
|
|
+
|
|
|
+ getElementAreas(width, height, elementAreas, numElements, mOptimalSizes);
|
|
|
+
|
|
|
+ // Now that we have all the areas, actually assign them
|
|
|
+ UINT32 childIdx = 0;
|
|
|
+
|
|
|
+ mActualWidth = 0;
|
|
|
+ mActualHeight = 0;
|
|
|
+ for(auto& child : mChildren)
|
|
|
+ {
|
|
|
+ RectI childArea = elementAreas[childIdx];
|
|
|
+
|
|
|
+ if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
+ {
|
|
|
+ GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
+
|
|
|
+ element->_setWidth(childArea.width);
|
|
|
+ element->_setHeight(childArea.height);
|
|
|
+
|
|
|
+ Vector2I offset(x + childArea.x, y + childArea.y);
|
|
|
element->_setOffset(offset);
|
|
|
element->_setWidgetDepth(widgetDepth);
|
|
|
element->_setAreaDepth(areaDepth);
|
|
|
@@ -372,34 +411,29 @@ namespace BansheeEngine
|
|
|
RectI elemClipRect(clipRect.x - offset.x, clipRect.y - offset.y, clipRect.width, clipRect.height);
|
|
|
element->_setClipRect(elemClipRect);
|
|
|
|
|
|
- RectI newClipRect(offset.x, offset.y, elemWidth, elemHeight);
|
|
|
+ RectI newClipRect(offset.x, offset.y, childArea.width, childArea.height);
|
|
|
newClipRect.clip(clipRect);
|
|
|
- element->_updateLayoutInternal(offset.x, offset.y, elemWidth, elemHeight, newClipRect, widgetDepth, areaDepth);
|
|
|
+ element->_updateLayoutInternal(offset.x, offset.y, childArea.width, childArea.height, newClipRect, widgetDepth, areaDepth);
|
|
|
|
|
|
- mActualWidth = std::max(width, elemWidth);
|
|
|
+ mActualWidth = std::max(width, (UINT32)childArea.width);
|
|
|
}
|
|
|
else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
|
GUILayout* layout = static_cast<GUILayout*>(child);
|
|
|
|
|
|
- RectI newClipRect(x, y + yOffset, width, elemHeight);
|
|
|
+ RectI newClipRect(x, y + childArea.y, width, childArea.height);
|
|
|
newClipRect.clip(clipRect);
|
|
|
- layout->_updateLayoutInternal(x, y + yOffset, width, elemHeight, newClipRect, widgetDepth, areaDepth);
|
|
|
+ layout->_updateLayoutInternal(x, y + childArea.y, width, childArea.height, newClipRect, widgetDepth, areaDepth);
|
|
|
|
|
|
mActualWidth = std::max(width, layout->_getActualWidth());
|
|
|
-
|
|
|
- // It's possible all elements didn't fit in the child layout size we provided, in which case adjust our measurements
|
|
|
- elemHeight = layout->_getActualHeight();
|
|
|
}
|
|
|
|
|
|
- mActualHeight += elemHeight + child->_getPadding().top + child->_getPadding().bottom;
|
|
|
- yOffset += elemHeight + child->_getPadding().bottom;
|
|
|
+ mActualHeight += childArea.height + child->_getPadding().top + child->_getPadding().bottom;
|
|
|
childIdx++;
|
|
|
}
|
|
|
|
|
|
- stackDeallocLast(elementScaleWeights);
|
|
|
- stackDeallocLast(elementSizes);
|
|
|
- stackDeallocLast(processedElements);
|
|
|
+ if (elementAreas != nullptr)
|
|
|
+ stackDeallocLast(elementAreas);
|
|
|
|
|
|
_markAsClean();
|
|
|
}
|