1
0
Fork 0

Codechange: Prefer suggested widget padding.

pull/10169/head
Peter Nelson 2021-05-03 16:56:02 +01:00 committed by PeterN
parent 0108e9f387
commit b6ed595176
18 changed files with 38 additions and 36 deletions

View File

@ -112,7 +112,7 @@ struct AIListWindow : public Window {
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{ {
if (widget == WID_AIL_LIST) { if (widget == WID_AIL_LIST) {
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
resize->width = 1; resize->width = 1;
resize->height = this->line_height; resize->height = this->line_height;
@ -342,7 +342,7 @@ struct AISettingsWindow : public Window {
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
{ {
if (widget == WID_AIS_BACKGROUND) { if (widget == WID_AIS_BACKGROUND) {
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
resize->width = 1; resize->width = 1;
resize->height = this->line_height; resize->height = this->line_height;
@ -761,7 +761,7 @@ struct AIConfigWindow : public Window {
break; break;
case WID_AIC_LIST: case WID_AIC_LIST:
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
resize->height = this->line_height; resize->height = this->line_height;
size->height = 8 * this->line_height; size->height = 8 * this->line_height;
break; break;

View File

@ -343,7 +343,7 @@ public:
size->width = std::max(size->width, GetStringBoundingBox(as->name).width); size->width = std::max(size->width, GetStringBoundingBox(as->name).width);
} }
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
size->height = 5 * this->line_height; size->height = 5 * this->line_height;
break; break;
} }
@ -356,8 +356,8 @@ public:
SpriteID sprite = GetCustomAirportSprite(as, layout); SpriteID sprite = GetCustomAirportSprite(as, layout);
if (sprite != 0) { if (sprite != 0) {
Dimension d = GetSpriteSize(sprite); Dimension d = GetSpriteSize(sprite);
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.width += padding.width;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; d.height += padding.height;
*size = maxdim(d, *size); *size = maxdim(d, *size);
} }
} }
@ -375,6 +375,8 @@ public:
/* STR_BLACK_STRING is used to start the string with {BLACK} */ /* STR_BLACK_STRING is used to start the string with {BLACK} */
SetDParam(0, string); SetDParam(0, string);
Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size); Dimension d = GetStringMultiLineBoundingBox(STR_BLACK_STRING, *size);
d.width += padding.width;
d.height += padding.height;
*size = maxdim(d, *size); *size = maxdim(d, *size);
} }
} }

View File

@ -304,8 +304,8 @@ public:
case WID_RV_INFO_TAB: { case WID_RV_INFO_TAB: {
Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING); Dimension d = GetStringBoundingBox(STR_REPLACE_NOT_REPLACING);
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED)); d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT; d.width += padding.width;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; d.height += padding.height;
*size = maxdim(*size, d); *size = maxdim(*size, d);
break; break;
} }

View File

@ -152,14 +152,14 @@ struct GSConfigWindow : public Window {
{ {
switch (widget) { switch (widget) {
case WID_GSC_SETTINGS: case WID_GSC_SETTINGS:
this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + padding.height;
resize->width = 1; resize->width = 1;
resize->height = this->line_height; resize->height = this->line_height;
size->height = 5 * this->line_height; size->height = 5 * this->line_height;
break; break;
case WID_GSC_GSLIST: case WID_GSC_GSLIST:
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
size->height = 1 * this->line_height; size->height = 1 * this->line_height;
break; break;
} }

View File

@ -662,7 +662,7 @@ struct GenerateLandscapeWindow : public Window {
} }
} }
size->width += padding.width; size->width += padding.width;
size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + WD_DROPDOWNTEXT_TOP + WD_DROPDOWNTEXT_BOTTOM)); size->height = std::max(size->height, (uint)(FONT_HEIGHT_NORMAL + padding.height));
} }
void OnClick(Point pt, int widget, int click_count) override void OnClick(Point pt, int widget, int click_count) override

View File

@ -422,7 +422,7 @@ public:
if (this->index[i] == INVALID_INDUSTRYTYPE) continue; if (this->index[i] == INVALID_INDUSTRYTYPE) continue;
d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(this->index[i])->name)); d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(this->index[i])->name));
} }
resize->height = std::max<uint>(this->legend.height, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; resize->height = std::max<uint>(this->legend.height, FONT_HEIGHT_NORMAL) + padding.height;
d.width += this->legend.width + ScaleFontTrad(7) + padding.width; d.width += this->legend.width + ScaleFontTrad(7) + padding.width;
d.height = 5 * resize->height; d.height = 5 * resize->height;
*size = maxdim(*size, d); *size = maxdim(*size, d);
@ -471,8 +471,8 @@ public:
/* Set it to something more sane :) */ /* Set it to something more sane :) */
height += extra_lines_prd + extra_lines_req + extra_lines_newgrf; height += extra_lines_prd + extra_lines_req + extra_lines_newgrf;
size->height = height * FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; size->height = height * FONT_HEIGHT_NORMAL + padding.height;
size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; size->width = d.width + padding.width;
break; break;
} }

View File

@ -592,8 +592,8 @@ void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, const
} }
if (str != STR_NULL) { if (str != STR_NULL) {
Dimension dim = GetStringBoundingBox(str); Dimension dim = GetStringBoundingBox(str);
dim.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; dim.width += padding.width;
dim.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; dim.height += padding.height;
*size = maxdim(*size, dim); *size = maxdim(*size, dim);
} }
} }
@ -601,8 +601,8 @@ void LinkGraphLegendWindow::UpdateWidgetSize(int widget, Dimension *size, const
CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST); CargoSpec *cargo = CargoSpec::Get(widget - WID_LGL_CARGO_FIRST);
if (cargo->IsValid()) { if (cargo->IsValid()) {
Dimension dim = GetStringBoundingBox(cargo->abbrev); Dimension dim = GetStringBoundingBox(cargo->abbrev);
dim.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; dim.width += padding.width;
dim.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; dim.height += padding.height;
*size = maxdim(*size, dim); *size = maxdim(*size, dim);
} }
} }

View File

@ -721,8 +721,8 @@ struct TooltipsWindow : public Window
size->height = GetStringHeight(this->string_id, size->width); size->height = GetStringHeight(this->string_id, size->width);
/* Increase slightly to have some space around the box. */ /* Increase slightly to have some space around the box. */
size->width += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; size->width += 2 + padding.width;
size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; size->height += 2 + padding.height;
} }
void DrawWidget(const Rect &r, int widget) const override void DrawWidget(const Rect &r, int widget) const override

View File

@ -682,8 +682,8 @@ struct MusicWindow : public Window {
case WID_M_TRACK_NR: { case WID_M_TRACK_NR: {
Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE); Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.width += padding.width;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; d.height += padding.height;
*size = maxdim(*size, d); *size = maxdim(*size, d);
break; break;
} }
@ -694,8 +694,8 @@ struct MusicWindow : public Window {
SetDParamStr(0, song->songname); SetDParamStr(0, song->songname);
d = maxdim(d, GetStringBoundingBox(STR_MUSIC_TITLE_NAME)); d = maxdim(d, GetStringBoundingBox(STR_MUSIC_TITLE_NAME));
} }
d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.width += padding.width;
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; d.height += padding.height;
*size = maxdim(*size, d); *size = maxdim(*size, d);
break; break;
} }

View File

@ -573,7 +573,7 @@ public:
} }
case WID_NCL_MATRIX: case WID_NCL_MATRIX:
resize->height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; resize->height = std::max(this->checkbox_size.height, (uint)FONT_HEIGHT_NORMAL) + padding.height;
size->height = 10 * resize->height; size->height = 10 * resize->height;
break; break;
} }

View File

@ -859,7 +859,7 @@ struct SpriteAlignerWindow : Window {
size->height = ScaleGUITrad(200); size->height = ScaleGUITrad(200);
break; break;
case WID_SA_LIST: case WID_SA_LIST:
resize->height = FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; resize->height = FONT_HEIGHT_NORMAL + padding.height;
resize->width = 1; resize->width = 1;
fill->height = resize->height; fill->height = resize->height;
break; break;

View File

@ -732,13 +732,13 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
{ {
Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN)); Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U); resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U);
size->height = std::max(size->height, WD_FRAMERECT_TOP + 6 * resize->height + WD_FRAMERECT_BOTTOM); size->height = std::max(size->height, padding.height + 6 * resize->height);
break; break;
} }
case WID_NS_AVAIL_LIST: case WID_NS_AVAIL_LIST:
resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2); resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2);
size->height = std::max(size->height, WD_FRAMERECT_TOP + 8 * resize->height + WD_FRAMERECT_BOTTOM); size->height = std::max(size->height, padding.height + 8 * resize->height);
break; break;
case WID_NS_NEWGRF_INFO_TITLE: { case WID_NS_NEWGRF_INFO_TITLE: {

View File

@ -239,7 +239,7 @@ public:
size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width); size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width);
} }
size->width += padding.width; size->width += padding.width;
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
resize->height = this->line_height; resize->height = this->line_height;
size->height = 5 * this->line_height; size->height = 5 * this->line_height;
break; break;

View File

@ -793,7 +793,7 @@ public:
switch (widget) { switch (widget) {
case WID_O_ORDER_LIST: case WID_O_ORDER_LIST:
resize->height = FONT_HEIGHT_NORMAL; resize->height = FONT_HEIGHT_NORMAL;
size->height = 6 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; size->height = 6 * resize->height + padding.height;
break; break;
case WID_O_COND_VARIABLE: { case WID_O_COND_VARIABLE: {

View File

@ -1201,7 +1201,7 @@ public:
d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name)); d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
} }
size->width = std::max(size->width, d.width + padding.width); size->width = std::max(size->width, d.width + padding.width);
this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; this->line_height = FONT_HEIGHT_NORMAL + padding.height;
size->height = 5 * this->line_height; size->height = 5 * this->line_height;
resize->height = this->line_height; resize->height = this->line_height;
break; break;

View File

@ -392,7 +392,7 @@ public:
case WID_STL_LIST: case WID_STL_LIST:
resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleFontTrad(3)); resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleFontTrad(3));
size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM; size->height = padding.height + 5 * resize->height;
/* Determine appropriate width for mini station rating graph */ /* Determine appropriate width for mini station rating graph */
this->rating_width = 0; this->rating_width = 0;

View File

@ -133,8 +133,8 @@ struct SubsidyListWindow : Window {
resize->height = d.height; resize->height = d.height;
d.height *= 5; d.height *= 5;
d.width += padding.width + WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT; d.width += padding.width;
d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; d.height += padding.height;
*size = maxdim(*size, d); *size = maxdim(*size, d);
} }

View File

@ -159,8 +159,8 @@ public:
if (widget >= WID_BT_TYPE_BUTTON_FIRST) { if (widget >= WID_BT_TYPE_BUTTON_FIRST) {
/* Ensure tree type buttons are sized after the largest tree type */ /* Ensure tree type buttons are sized after the largest tree type */
Dimension d = GetMaxTreeSpriteSize(); Dimension d = GetMaxTreeSpriteSize();
size->width = d.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; size->width = d.width + padding.width;
size->height = d.height + WD_FRAMERECT_RIGHT + WD_FRAMERECT_BOTTOM + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space size->height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space
} }
} }