|
@@ -12,33 +12,25 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
LayoutSizeRange GUILayoutX::_calculateLayoutSizeRange() const
|
|
LayoutSizeRange GUILayoutX::_calculateLayoutSizeRange() const
|
|
|
{
|
|
{
|
|
|
- LayoutSizeRange layoutSizeRange;
|
|
|
|
|
-
|
|
|
|
|
if (mIsDisabled)
|
|
if (mIsDisabled)
|
|
|
- return layoutSizeRange;
|
|
|
|
|
|
|
+ return LayoutSizeRange();
|
|
|
|
|
|
|
|
|
|
+ Vector2I optimalSize;
|
|
|
for (auto& child : mChildren)
|
|
for (auto& child : mChildren)
|
|
|
{
|
|
{
|
|
|
LayoutSizeRange sizeRange = child->_calculateLayoutSizeRange();
|
|
LayoutSizeRange sizeRange = child->_calculateLayoutSizeRange();
|
|
|
|
|
|
|
|
if (child->_getType() == GUIElementBase::Type::FixedSpace)
|
|
if (child->_getType() == GUIElementBase::Type::FixedSpace)
|
|
|
- sizeRange.optimal.y = sizeRange.min.y = sizeRange.max.y = 0;
|
|
|
|
|
|
|
+ sizeRange.optimal.y = 0;
|
|
|
|
|
|
|
|
UINT32 paddingX = child->_getPadding().left + child->_getPadding().right;
|
|
UINT32 paddingX = child->_getPadding().left + child->_getPadding().right;
|
|
|
UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom;
|
|
UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom;
|
|
|
|
|
|
|
|
- layoutSizeRange.optimal.x += sizeRange.optimal.x + paddingX;
|
|
|
|
|
- layoutSizeRange.optimal.y = std::max((UINT32)layoutSizeRange.optimal.y, sizeRange.optimal.y + paddingY);
|
|
|
|
|
|
|
+ optimalSize.x += sizeRange.optimal.x + paddingX;
|
|
|
|
|
+ optimalSize.y = std::max((UINT32)optimalSize.y, sizeRange.optimal.y + paddingY);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Layout has no min or max, it respects the bounds of its parent element and
|
|
|
|
|
- // child elements
|
|
|
|
|
- layoutSizeRange.min.x = 0;
|
|
|
|
|
- layoutSizeRange.min.y = 0;
|
|
|
|
|
- layoutSizeRange.max.x = 0;
|
|
|
|
|
- layoutSizeRange.max.y = 0;
|
|
|
|
|
-
|
|
|
|
|
- return layoutSizeRange;
|
|
|
|
|
|
|
+ return _getDimensions().calculateSizeRange(optimalSize);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GUILayoutX::_updateOptimalLayoutSizes()
|
|
void GUILayoutX::_updateOptimalLayoutSizes()
|
|
@@ -49,7 +41,7 @@ namespace BansheeEngine
|
|
|
if(mChildren.size() != mChildSizeRanges.size())
|
|
if(mChildren.size() != mChildSizeRanges.size())
|
|
|
mChildSizeRanges.resize(mChildren.size());
|
|
mChildSizeRanges.resize(mChildren.size());
|
|
|
|
|
|
|
|
- mSizeRange = LayoutSizeRange();
|
|
|
|
|
|
|
+ Vector2I optimalSize;
|
|
|
|
|
|
|
|
UINT32 childIdx = 0;
|
|
UINT32 childIdx = 0;
|
|
|
for(auto& child : mChildren)
|
|
for(auto& child : mChildren)
|
|
@@ -62,14 +54,9 @@ namespace BansheeEngine
|
|
|
|
|
|
|
|
childSizeRange = fixedSpace->_calculateLayoutSizeRange();
|
|
childSizeRange = fixedSpace->_calculateLayoutSizeRange();
|
|
|
childSizeRange.optimal.y = 0;
|
|
childSizeRange.optimal.y = 0;
|
|
|
- childSizeRange.min.y = 0;
|
|
|
|
|
- childSizeRange.max.y = 0;
|
|
|
|
|
}
|
|
}
|
|
|
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();
|
|
|
|
|
-
|
|
|
|
|
childSizeRange = child->_calculateLayoutSizeRange();
|
|
childSizeRange = child->_calculateLayoutSizeRange();
|
|
|
}
|
|
}
|
|
|
else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
else if(child->_getType() == GUIElementBase::Type::Layout)
|
|
@@ -81,18 +68,13 @@ namespace BansheeEngine
|
|
|
UINT32 paddingX = child->_getPadding().left + child->_getPadding().right;
|
|
UINT32 paddingX = child->_getPadding().left + child->_getPadding().right;
|
|
|
UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom;
|
|
UINT32 paddingY = child->_getPadding().top + child->_getPadding().bottom;
|
|
|
|
|
|
|
|
- mSizeRange.optimal.x += childSizeRange.optimal.x + paddingX;
|
|
|
|
|
- mSizeRange.optimal.y = std::max((UINT32)mSizeRange.optimal.y, childSizeRange.optimal.y + paddingY);
|
|
|
|
|
|
|
+ optimalSize.x += childSizeRange.optimal.x + paddingX;
|
|
|
|
|
+ optimalSize.y = std::max((UINT32)optimalSize.y, childSizeRange.optimal.y + paddingY);
|
|
|
|
|
|
|
|
childIdx++;
|
|
childIdx++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Layout has no min or max, it respects the bounds of its parent element and
|
|
|
|
|
- // child elements
|
|
|
|
|
- mSizeRange.min.x = 0;
|
|
|
|
|
- mSizeRange.min.y = 0;
|
|
|
|
|
- mSizeRange.max.x = 0;
|
|
|
|
|
- mSizeRange.max.y = 0;
|
|
|
|
|
|
|
+ mSizeRange = _getDimensions().calculateSizeRange(optimalSize);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void GUILayoutX::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements,
|
|
void GUILayoutX::_getElementAreas(INT32 x, INT32 y, UINT32 width, UINT32 height, Rect2I* elementAreas, UINT32 numElements,
|
|
@@ -127,12 +109,11 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
processedElements[childIdx] = true;
|
|
processedElements[childIdx] = true;
|
|
|
}
|
|
}
|
|
|
- else if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
|
|
|
|
+ else if (child->_getType() == GUIElementBase::Type::Element || child->_getType() == GUIElementBase::Type::Layout)
|
|
|
{
|
|
{
|
|
|
- GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
|
|
- const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
|
|
+ const GUIDimensions& dimensions = child->_getDimensions();
|
|
|
|
|
|
|
|
- if (layoutOptions.fixedWidth)
|
|
|
|
|
|
|
+ if (dimensions.fixedWidth())
|
|
|
processedElements[childIdx] = true;
|
|
processedElements[childIdx] = true;
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -140,11 +121,6 @@ namespace BansheeEngine
|
|
|
totalNonClampedSize += elementAreas[childIdx].width;
|
|
totalNonClampedSize += elementAreas[childIdx].width;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- else if (child->_getType() == GUIElementBase::Type::Layout)
|
|
|
|
|
- {
|
|
|
|
|
- numNonClampedElements++;
|
|
|
|
|
- totalNonClampedSize += elementAreas[childIdx].width;
|
|
|
|
|
- }
|
|
|
|
|
else if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
else if (child->_getType() == GUIElementBase::Type::FlexibleSpace)
|
|
|
{
|
|
{
|
|
|
numFlexibleSpaces++;
|
|
numFlexibleSpaces++;
|
|
@@ -336,24 +312,23 @@ namespace BansheeEngine
|
|
|
UINT32 elemWidth = elementAreas[childIdx].width;
|
|
UINT32 elemWidth = elementAreas[childIdx].width;
|
|
|
xOffset += child->_getPadding().left;
|
|
xOffset += child->_getPadding().left;
|
|
|
|
|
|
|
|
- if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
|
|
|
|
+ UINT32 elemHeight = (UINT32)sizeRanges[childIdx].optimal.y;
|
|
|
|
|
+ const GUIDimensions& layoutOptions = child->_getDimensions();
|
|
|
|
|
+ if (!layoutOptions.fixedHeight())
|
|
|
{
|
|
{
|
|
|
- GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
|
|
- element->setWidth(elemWidth);
|
|
|
|
|
|
|
+ elemHeight = height;
|
|
|
|
|
+ if (layoutOptions.minHeight > 0 && elemHeight < layoutOptions.minHeight)
|
|
|
|
|
+ elemHeight = layoutOptions.minHeight;
|
|
|
|
|
|
|
|
- UINT32 elemHeight = (UINT32)sizeRanges[childIdx].optimal.y;
|
|
|
|
|
- const GUILayoutOptions& layoutOptions = element->_getLayoutOptions();
|
|
|
|
|
- if (!layoutOptions.fixedHeight)
|
|
|
|
|
- {
|
|
|
|
|
- elemHeight = height;
|
|
|
|
|
- if (layoutOptions.minHeight > 0 && elemHeight < layoutOptions.minHeight)
|
|
|
|
|
- elemHeight = layoutOptions.minHeight;
|
|
|
|
|
|
|
+ if (layoutOptions.maxHeight > 0 && elemHeight > layoutOptions.maxHeight)
|
|
|
|
|
+ elemHeight = layoutOptions.maxHeight;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (layoutOptions.maxHeight > 0 && elemHeight > layoutOptions.maxHeight)
|
|
|
|
|
- elemHeight = layoutOptions.maxHeight;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ elementAreas[childIdx].height = elemHeight;
|
|
|
|
|
|
|
|
- elementAreas[childIdx].height = elemHeight;
|
|
|
|
|
|
|
+ if (child->_getType() == GUIElementBase::Type::Element)
|
|
|
|
|
+ {
|
|
|
|
|
+ GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
|
|
|
|
|
UINT32 yPadding = element->_getPadding().top + element->_getPadding().bottom;
|
|
UINT32 yPadding = element->_getPadding().top + element->_getPadding().bottom;
|
|
|
INT32 yOffset = Math::ceilToInt(((INT32)height - (INT32)(elemHeight + yPadding)) * 0.5f);
|
|
INT32 yOffset = Math::ceilToInt(((INT32)height - (INT32)(elemHeight + yPadding)) * 0.5f);
|
|
@@ -366,7 +341,6 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
GUILayout* layout = static_cast<GUILayout*>(child);
|
|
GUILayout* layout = static_cast<GUILayout*>(child);
|
|
|
|
|
|
|
|
- elementAreas[childIdx].height = height;
|
|
|
|
|
elementAreas[childIdx].x = x + xOffset;
|
|
elementAreas[childIdx].x = x + xOffset;
|
|
|
elementAreas[childIdx].y = y;
|
|
elementAreas[childIdx].y = y;
|
|
|
}
|
|
}
|
|
@@ -401,14 +375,13 @@ namespace BansheeEngine
|
|
|
Rect2I childArea = elementAreas[childIdx];
|
|
Rect2I childArea = elementAreas[childIdx];
|
|
|
|
|
|
|
|
Vector2I offset(childArea.x, childArea.y);
|
|
Vector2I offset(childArea.x, childArea.y);
|
|
|
- child->setOffset(offset);
|
|
|
|
|
- child->setWidth(childArea.width);
|
|
|
|
|
-
|
|
|
|
|
if(child->_getType() == GUIElementBase::Type::Element)
|
|
if(child->_getType() == GUIElementBase::Type::Element)
|
|
|
{
|
|
{
|
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
GUIElement* element = static_cast<GUIElement*>(child);
|
|
|
|
|
|
|
|
- element->setHeight(childArea.height);
|
|
|
|
|
|
|
+ element->_setPosition(offset);
|
|
|
|
|
+ element->_setWidth(childArea.width);
|
|
|
|
|
+ element->_setHeight(childArea.height);
|
|
|
element->_setWidgetDepth(widgetDepth);
|
|
element->_setWidgetDepth(widgetDepth);
|
|
|
element->_setAreaDepth(areaDepth);
|
|
element->_setAreaDepth(areaDepth);
|
|
|
|
|
|
|
@@ -425,8 +398,6 @@ namespace BansheeEngine
|
|
|
{
|
|
{
|
|
|
GUILayout* layout = static_cast<GUILayout*>(child);
|
|
GUILayout* layout = static_cast<GUILayout*>(child);
|
|
|
|
|
|
|
|
- layout->setHeight(height);
|
|
|
|
|
-
|
|
|
|
|
Rect2I newClipRect(childArea.x, childArea.y, childArea.width, height);
|
|
Rect2I newClipRect(childArea.x, childArea.y, childArea.width, height);
|
|
|
newClipRect.clip(clipRect);
|
|
newClipRect.clip(clipRect);
|
|
|
layout->_updateLayoutInternal(childArea.x, childArea.y, childArea.width, height, newClipRect, widgetDepth, areaDepth);
|
|
layout->_updateLayoutInternal(childArea.x, childArea.y, childArea.width, height, newClipRect, widgetDepth, areaDepth);
|
|
@@ -435,15 +406,14 @@ namespace BansheeEngine
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- child->setHeight(childArea.height);
|
|
|
|
|
actualSizes[childIdx].height = childArea.height;
|
|
actualSizes[childIdx].height = childArea.height;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- actualSizes[childIdx].x = childArea.width + child->_getPadding().left + child->_getPadding().right;
|
|
|
|
|
|
|
+ actualSizes[childIdx].width = childArea.width + child->_getPadding().left + child->_getPadding().right;
|
|
|
childIdx++;
|
|
childIdx++;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Vector2I actualSize = _calcActualSize(actualSizes, numElements);
|
|
|
|
|
|
|
+ Vector2I actualSize = _calcActualSize(x, y, actualSizes, numElements);
|
|
|
mActualWidth = (UINT32)actualSize.x;
|
|
mActualWidth = (UINT32)actualSize.x;
|
|
|
mActualHeight = (UINT32)actualSize.y;
|
|
mActualHeight = (UINT32)actualSize.y;
|
|
|
|
|
|
|
@@ -453,15 +423,15 @@ namespace BansheeEngine
|
|
|
_markAsClean();
|
|
_markAsClean();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- Vector2I GUILayoutX::_calcActualSize(Rect2I* elementAreas, UINT32 numElements) const
|
|
|
|
|
|
|
+ Vector2I GUILayoutX::_calcActualSize(INT32 x, INT32 y, Rect2I* elementAreas, UINT32 numElements) const
|
|
|
{
|
|
{
|
|
|
Vector2I actualArea;
|
|
Vector2I actualArea;
|
|
|
for (UINT32 i = 0; i < numElements; i++)
|
|
for (UINT32 i = 0; i < numElements; i++)
|
|
|
{
|
|
{
|
|
|
Rect2I childArea = elementAreas[i];
|
|
Rect2I childArea = elementAreas[i];
|
|
|
|
|
|
|
|
- actualArea.x = childArea.width;
|
|
|
|
|
- actualArea.y += std::max(actualArea.x, childArea.width);
|
|
|
|
|
|
|
+ actualArea.x += childArea.width;
|
|
|
|
|
+ actualArea.y = std::max(actualArea.y, childArea.height);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return actualArea;
|
|
return actualArea;
|