1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-31 08:04:36 +01:00

Codechange: Pass rect to DrawStationCoverageAreaText. (#13442)

This moves the overflow behaviour to the callers, making it clearer why that is desired.
This commit is contained in:
Peter Nelson
2025-02-02 17:15:47 +00:00
committed by GitHub
parent 5ffaf6cdb9
commit fb55ab0742
6 changed files with 33 additions and 30 deletions

View File

@@ -442,14 +442,15 @@ public:
/* strings such as 'Size' and 'Coverage Area' */
Rect r = this->GetWidget<NWidgetBase>(BDSW_ACCEPTANCE)->GetCurrentRect();
int top = r.top;
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true);
const int bottom = r.bottom;
r.bottom = INT_MAX; // Allow overflow as we want to know the required height.
r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, true);
/* Resize background if the window is too small.
* Never make the window smaller to avoid oscillating if the size change affects the acceptance.
* (This is the case, if making the window bigger moves the mouse into the window.) */
if (top > r.bottom) {
ResizeWindow(this, 0, top - r.bottom, false);
if (r.top > bottom) {
ResizeWindow(this, 0, r.top - bottom, false);
}
}