Skip to content

Commit

Permalink
Fix wordwrap layout spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasvinbr committed Mar 2, 2024
1 parent 011843e commit a5f5946
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions Source/Urho3D/UI/Text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,18 @@ void Text::UpdateText(bool onResize)
else
{
int maxWidth = GetWidth();

if (!IsFixedWidth())
{
// use parent layout to set our max width if possible
UIElement* parent = GetParent();
if (parent && parent->GetLayoutMode() != LM_FREE)
{
auto& parentBorder = parent->GetLayoutBorder();
maxWidth = parent->GetWidth() - (parentBorder.left_ + parentBorder.right_);
}
}

unsigned nextBreak = 0;
unsigned lineStart = 0;
printToText_.Clear();
Expand Down Expand Up @@ -648,10 +660,20 @@ void Text::UpdateText(bool onResize)
// Set minimum and current size according to the text size, but respect fixed width if set
if (!IsFixedWidth())
{
if (wordWrap_)
SetMinWidth(0);
else
{
if (wordWrap_) {
// don't set min width to 0 if we're inside a layout
UIElement* parent = GetParent();
if (parent && parent->GetLayoutMode() != LM_FREE)
{
SetMinWidth(width);
SetWidth(width);
}
else
{
SetMinWidth(0);
}
}
else {
SetMinWidth(width);
SetWidth(width);
}
Expand Down

0 comments on commit a5f5946

Please sign in to comment.