Skip to content

Commit

Permalink
fix(ui): Fix text height issues in the conversation panel (endless-sk…
Browse files Browse the repository at this point in the history
  • Loading branch information
tibetiroka authored Dec 19, 2024
1 parent 08cb0b3 commit 3543ed5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions source/Dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool
const Sprite *top = SpriteSet::Get("ui/dialog top");
// If the dialog is too tall, then switch to wide mode.
int maxHeight = Screen::Height() * 3 / 4;
if(text->GetTextHeight() > maxHeight)
if(text->GetTextHeight(false) > maxHeight)
{
textRectSize.Y() = maxHeight;
isWide = true;
Expand All @@ -392,7 +392,7 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool
}
}
else
textRectSize.Y() = text->GetTextHeight();
textRectSize.Y() = text->GetTextHeight(false);

top = SpriteSet::Get(isWide ? "ui/dialog top wide" : "ui/dialog top");
const Sprite *middle = SpriteSet::Get(isWide ? "ui/dialog middle wide" : "ui/dialog middle");
Expand Down
4 changes: 2 additions & 2 deletions source/TextArea.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ void TextArea::SetTruncate(Truncate t)



int TextArea::GetTextHeight()
int TextArea::GetTextHeight(bool trailingBreak)
{
Validate();
return wrappedText.Height();
return wrappedText.Height(trailingBreak);
}


Expand Down
2 changes: 1 addition & 1 deletion source/TextArea.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TextArea : public Panel
void SetAlignment(Alignment a);
void SetTruncate(Truncate t);

int GetTextHeight();
int GetTextHeight(bool trailingBreak = true);
int GetLongestLineWidth();


Expand Down
7 changes: 4 additions & 3 deletions source/text/WrappedText.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ void WrappedText::Wrap(const char *str)



// Get the height of the wrapped text.
int WrappedText::Height() const
/// Get the height of the wrapped text.
/// With trailingBreak, include a paragraph break after the text.
int WrappedText::Height(bool trailingBreak) const
{
return height;
return height + trailingBreak * paragraphBreak;
}


Expand Down
5 changes: 3 additions & 2 deletions source/text/WrappedText.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class WrappedText {
void Wrap(const std::string &str);
void Wrap(const char *str);

// Get the height of the wrapped text.
int Height() const;
/// Get the height of the wrapped text.
/// With trailingBreak, include a paragraph break after the text.
int Height(bool trailingBreak = true) const;

// Return the width of the longest line of the wrapped text.
int LongestLineWidth() const;
Expand Down

0 comments on commit 3543ed5

Please sign in to comment.