Skip to content

Commit

Permalink
fix(ui): Correctly account for WrappedText padding when calculating m…
Browse files Browse the repository at this point in the history
…aximum height available in dialogs (endless-sky#10304)
  • Loading branch information
tibetiroka authored Jul 15, 2024
1 parent 4f8e55e commit 5d0d87e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/Dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool

// The dialog with no extenders is 80 pixels tall. 10 pixels at the top and
// bottom are "padding," but text.Height() over-reports the height by about
// 5 pixels because it includes its own padding at the bottom. If there is a
// 6 pixels because it includes its own padding at the bottom. If there is a
// text input, we need another 20 pixels for it and 10 pixels padding.
height = 10 + (textRectSize.Y() - 5) + 10 + 30 * (!isMission && (intFun || stringFun));
height = 10 + (textRectSize.Y() - 6) + 10 + 30 * (!isMission && (intFun || stringFun));
// Determine how many 40-pixel extension panels we need.
if(height <= 80)
height = 0;
Expand All @@ -382,7 +382,8 @@ void Dialog::Init(const string &message, Truncate truncate, bool canCancel, bool
// Resize textRectSize to match the visual height of the dialog, which will
// be rounded up from the actual text height by the number of panels that
// were added. This helps correctly position the TextArea scroll buttons.
textRectSize.Y() = 60 + height * 40 - 30 * (!isMission && (intFun || stringFun));
// The text height was over-reported by 6 pixels, so we add those pixels back for consistency.
textRectSize.Y() = 60 + height * 40 + 6 - 30 * (!isMission && (intFun || stringFun));

Rectangle textRect = Rectangle::FromCorner(textPos, textRectSize);
text->SetRect(textRect);
Expand Down

0 comments on commit 5d0d87e

Please sign in to comment.