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
+6 -5
View File
@@ -1150,14 +1150,15 @@ public:
if (this->IsShaded()) return;
/* 'Accepts' and 'Supplies' texts. */
Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->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) {
this->coverage_height += top - r.bottom;
if (r.top > bottom) {
this->coverage_height += r.top - bottom;
this->ReInit();
}
}