Add documentation of padding on base Widget

This commit is contained in:
Cole Green
2026-07-27 17:07:41 +03:00
committed by Alexei Kotov
parent 63dcd80a89
commit a166325465
3 changed files with 13 additions and 11 deletions
+2 -1
View File
@@ -76,7 +76,8 @@ namespace LuaUi
std::max(0, normalSize.height - static_cast<int>(mPadding.y() + mPadding.w())));
mEditBox->setSize(contentSize);
int targetHeight = mMultiline ? mEditBox->getTextSize().height : mEditBox->getFontHeight();
normalSize.height = std::max(normalSize.height, targetHeight + static_cast<int>(mPadding.y() + mPadding.w()));
normalSize.height
= std::max(normalSize.height, targetHeight + static_cast<int>(mPadding.y() + mPadding.w()));
}
return normalSize;
}
+5 -10
View File
@@ -346,11 +346,7 @@ namespace LuaUi
bottom = table.get<sol::optional<float>>(4);
}
mPadding = osg::Vec4(
left.value_or(0.f),
top.value_or(0.f),
right.value_or(0.f),
bottom.value_or(0.f));
mPadding = osg::Vec4(left.value_or(0.f), top.value_or(0.f), right.value_or(0.f), bottom.value_or(0.f));
}
else if (padding != sol::nil)
throw std::logic_error("Property \"padding\" must be either a number or a table");
@@ -379,12 +375,11 @@ namespace LuaUi
return MyGUI::IntPoint(static_cast<int>(mPadding.x()), static_cast<int>(mPadding.y()));
}
MyGUI::IntSize WidgetExtension::getContentSize() const {
MyGUI::IntSize WidgetExtension::getContentSize() const
{
MyGUI::IntSize fullSize = calculateSize();
return MyGUI::IntSize(
std::max(0, fullSize.width - static_cast<int>(mPadding.x() + mPadding.z())),
std::max(0, fullSize.height - static_cast<int>(mPadding.y() + mPadding.w()))
);
return MyGUI::IntSize(std::max(0, fullSize.width - static_cast<int>(mPadding.x() + mPadding.z())),
std::max(0, fullSize.height - static_cast<int>(mPadding.y() + mPadding.w())));
}
MyGUI::IntSize WidgetExtension::calculateSize() const
@@ -31,6 +31,12 @@ Properties
- util.vector2 (0, 0)
- | Offsets the widget's position by a fraction of its size.
| Useful for centering or aligning to a corner.
* - padding
- number or table (default 0)
- | Adds inset spacing between the outer edge of the widget and its content.
- | When providing a number: the top, right, bottom, and right margins are all set
- | to that provided numebr. When providing a table, you can provide any of the padding directions
- | individually. Such as `{ top = 10, right = 5 }`.
* - visible
- boolean (true)
- Defines if the widget is visible