Codechange: Pass by reference to UpdateWidgetSize. (#12457)

These parameters are always provided and not optional.
This commit is contained in:
Peter Nelson 2024-04-09 08:34:45 +01:00 committed by GitHub
parent b5ad28022d
commit de4e00c93f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 602 additions and 602 deletions

View File

@ -128,20 +128,20 @@ struct AIConfigWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_AIC_DECREASE_NUMBER: case WID_AIC_DECREASE_NUMBER:
case WID_AIC_INCREASE_NUMBER: case WID_AIC_INCREASE_NUMBER:
case WID_AIC_DECREASE_INTERVAL: case WID_AIC_DECREASE_INTERVAL:
case WID_AIC_INCREASE_INTERVAL: case WID_AIC_INCREASE_INTERVAL:
*size = maxdim(*size, NWidgetScrollbar::GetHorizontalDimension()); size = maxdim(size, NWidgetScrollbar::GetHorizontalDimension());
break; break;
case WID_AIC_LIST: case WID_AIC_LIST:
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_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

@ -317,7 +317,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_AP_CLASS_DROPDOWN: { case WID_AP_CLASS_DROPDOWN: {
@ -327,7 +327,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -336,11 +336,11 @@ public:
const AirportSpec *as = AirportSpec::Get(i); const AirportSpec *as = AirportSpec::Get(i);
if (!as->enabled) continue; if (!as->enabled) continue;
size->width = std::max(size->width, GetStringBoundingBox(as->name).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(as->name).width + padding.width);
} }
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = 5 * this->line_height; size.height = 5 * this->line_height;
break; break;
} }
@ -354,7 +354,7 @@ public:
Dimension d = GetSpriteSize(sprite); Dimension d = GetSpriteSize(sprite);
d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.width += WidgetDimensions::scaled.framerect.Horizontal();
d.height += WidgetDimensions::scaled.framerect.Vertical(); d.height += WidgetDimensions::scaled.framerect.Vertical();
*size = maxdim(d, *size); size = maxdim(d, size);
} }
} }
} }
@ -368,8 +368,8 @@ public:
StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT); StringID string = GetAirportTextCallback(as, layout, CBID_AIRPORT_ADDITIONAL_TEXT);
if (string == STR_UNDEFINED) continue; if (string == STR_UNDEFINED) continue;
Dimension d = GetStringMultiLineBoundingBox(string, *size); Dimension d = GetStringMultiLineBoundingBox(string, size);
*size = maxdim(d, *size); size = maxdim(d, size);
} }
} }
break; break;

View File

@ -316,26 +316,26 @@ public:
this->sel_group = id_g; this->sel_group = id_g;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_RV_SORT_ASCENDING_DESCENDING: { case WID_RV_SORT_ASCENDING_DESCENDING: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_RV_LEFT_MATRIX: case WID_RV_LEFT_MATRIX:
case WID_RV_RIGHT_MATRIX: case WID_RV_RIGHT_MATRIX:
resize->height = GetEngineListHeight((VehicleType)this->window_number); resize.height = GetEngineListHeight((VehicleType)this->window_number);
size->height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize->height; size.height = (this->window_number <= VEH_ROAD ? 8 : 4) * resize.height;
break; break;
case WID_RV_LEFT_DETAILS: case WID_RV_LEFT_DETAILS:
case WID_RV_RIGHT_DETAILS: case WID_RV_RIGHT_DETAILS:
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
break; break;
case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: { case WID_RV_TRAIN_WAGONREMOVE_TOGGLE: {
@ -346,7 +346,7 @@ public:
d = maxdim(d, GetStringBoundingBox(str)); d = maxdim(d, GetStringBoundingBox(str));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -355,7 +355,7 @@ public:
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS)); d = maxdim(d, GetStringBoundingBox(STR_REPLACE_WAGONS));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -364,7 +364,7 @@ public:
d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED)); d = maxdim(d, GetStringBoundingBox(STR_REPLACE_NOT_REPLACING_VEHICLE_SELECTED));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -375,7 +375,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -386,7 +386,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -397,7 +397,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -97,12 +97,12 @@ public:
this->Window::Close(); this->Window::Close();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_BEM_MESSAGE) { if (widget == WID_BEM_MESSAGE) {
*size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR); size = GetStringBoundingBox(STR_MISSING_GRAPHICS_ERROR);
size->width += WidgetDimensions::scaled.frametext.Horizontal(); size.width += WidgetDimensions::scaled.frametext.Horizontal();
size->height += WidgetDimensions::scaled.frametext.Vertical(); size.height += WidgetDimensions::scaled.frametext.Vertical();
} }
} }
@ -211,7 +211,7 @@ public:
this->Window::Close(); this->Window::Close();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
/* We cache the button size. This is safe as no reinit can happen here. */ /* We cache the button size. This is safe as no reinit can happen here. */
if (this->button_size.width == 0) { if (this->button_size.width == 0) {
@ -223,13 +223,13 @@ public:
switch (widget) { switch (widget) {
case WID_BAFD_QUESTION: case WID_BAFD_QUESTION:
/* The question is twice as wide as the buttons, and determine the height based on the width. */ /* The question is twice as wide as the buttons, and determine the height based on the width. */
size->width = this->button_size.width * 2; size.width = this->button_size.width * 2;
size->height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size->width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical(); size.height = GetStringHeight(STR_MISSING_GRAPHICS_SET_MESSAGE, size.width - WidgetDimensions::scaled.frametext.Horizontal()) + WidgetDimensions::scaled.frametext.Vertical();
break; break;
case WID_BAFD_YES: case WID_BAFD_YES:
case WID_BAFD_NO: case WID_BAFD_NO:
*size = this->button_size; size = this->button_size;
break; break;
} }
} }

View File

@ -174,14 +174,14 @@ public:
this->last_sorting = this->bridges.GetListing(); this->last_sorting = this->bridges.GetListing();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BBS_DROPDOWN_ORDER: { case WID_BBS_DROPDOWN_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_BBS_DROPDOWN_CRITERIA: { case WID_BBS_DROPDOWN_CRITERIA: {
@ -191,7 +191,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_BBS_BRIDGE_LIST: { case WID_BBS_BRIDGE_LIST: {
@ -201,11 +201,11 @@ public:
sprite_dim = maxdim(sprite_dim, GetScaledSpriteSize(bridge_data.spec->sprite)); sprite_dim = maxdim(sprite_dim, GetScaledSpriteSize(bridge_data.spec->sprite));
text_dim = maxdim(text_dim, GetStringBoundingBox(GetBridgeSelectString(bridge_data))); text_dim = maxdim(text_dim, GetStringBoundingBox(GetBridgeSelectString(bridge_data)));
} }
resize->height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges. resize.height = std::max(sprite_dim.height, text_dim.height) + padding.height; // Max of both sizes + account for matrix edges.
this->icon_width = sprite_dim.width; // Width of bridge icon. this->icon_width = sprite_dim.width; // Width of bridge icon.
size->width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width; size.width = this->icon_width + WidgetDimensions::scaled.hsep_normal + text_dim.width + padding.width;
size->height = 4 * resize->height; // Smallest bridge gui is 4 entries high in the matrix. size.height = 4 * resize.height; // Smallest bridge gui is 4 entries high in the matrix.
break; break;
} }
} }

View File

@ -1741,43 +1741,43 @@ struct BuildVehicleWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BV_LIST: case WID_BV_LIST:
resize->height = GetEngineListHeight(this->vehicle_type); resize.height = GetEngineListHeight(this->vehicle_type);
size->height = 3 * resize->height; size.height = 3 * resize.height;
size->width = std::max(size->width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width; size.width = std::max(size.width, GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_left + GetVehicleImageCellSize(this->vehicle_type, EIT_PURCHASE).extend_right + 165) + padding.width;
break; break;
case WID_BV_PANEL: case WID_BV_PANEL:
size->height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height; size.height = GetCharacterHeight(FS_NORMAL) * this->details_height + padding.height;
break; break;
case WID_BV_SORT_ASCENDING_DESCENDING: { case WID_BV_SORT_ASCENDING_DESCENDING: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_BV_CARGO_FILTER_DROPDOWN: case WID_BV_CARGO_FILTER_DROPDOWN:
size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width); size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList()).width + padding.width);
break; break;
case WID_BV_BUILD: case WID_BV_BUILD:
*size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type); size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_VEHICLE_BUTTON + this->vehicle_type);
*size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type)); size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_BUY_REFIT_VEHICLE_BUTTON + this->vehicle_type));
size->width += padding.width; size.width += padding.width;
size->height += padding.height; size.height += padding.height;
break; break;
case WID_BV_SHOW_HIDE: case WID_BV_SHOW_HIDE:
*size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type); size = GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_HIDE_TOGGLE_BUTTON + this->vehicle_type);
*size = maxdim(*size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type)); size = maxdim(size, GetStringBoundingBox(STR_BUY_VEHICLE_TRAIN_SHOW_TOGGLE_BUTTON + this->vehicle_type));
size->width += padding.width; size.width += padding.width;
size->height += padding.height; size.height += padding.height;
break; break;
} }
} }

View File

@ -298,7 +298,7 @@ struct CheatWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_C_PANEL) return; if (widget != WID_C_PANEL) return;
@ -339,8 +339,8 @@ struct CheatWindow : Window {
this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT); this->line_height = std::max<uint>(this->icon.height, SETTING_BUTTON_HEIGHT);
this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical(); this->line_height = std::max<uint>(this->line_height, GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.framerect.Vertical();
size->width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH; size.width = width + WidgetDimensions::scaled.hsep_wide * 2 + SETTING_BUTTON_WIDTH;
size->height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui); size.height = WidgetDimensions::scaled.framerect.Vertical() + this->line_height * lengthof(_cheats_ui);
} }
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override

View File

@ -389,29 +389,29 @@ struct CompanyFinancesWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_CF_EXPS_CATEGORY: case WID_CF_EXPS_CATEGORY:
size->width = GetMaxCategoriesWidth(); size.width = GetMaxCategoriesWidth();
size->height = GetTotalCategoriesHeight(); size.height = GetTotalCategoriesHeight();
break; break;
case WID_CF_EXPS_PRICE1: case WID_CF_EXPS_PRICE1:
case WID_CF_EXPS_PRICE2: case WID_CF_EXPS_PRICE2:
case WID_CF_EXPS_PRICE3: case WID_CF_EXPS_PRICE3:
size->height = GetTotalCategoriesHeight(); size.height = GetTotalCategoriesHeight();
[[fallthrough]]; [[fallthrough]];
case WID_CF_BALANCE_VALUE: case WID_CF_BALANCE_VALUE:
case WID_CF_LOAN_VALUE: case WID_CF_LOAN_VALUE:
case WID_CF_OWN_VALUE: case WID_CF_OWN_VALUE:
SetDParamMaxValue(0, CompanyFinancesWindow::max_money); SetDParamMaxValue(0, CompanyFinancesWindow::max_money);
size->width = std::max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width; size.width = std::max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width;
break; break;
case WID_CF_INTEREST_RATE: case WID_CF_INTEREST_RATE:
size->height = GetCharacterHeight(FS_NORMAL); size.height = GetCharacterHeight(FS_NORMAL);
break; break;
} }
} }
@ -718,7 +718,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SCL_SPACER_DROPDOWN: { case WID_SCL_SPACER_DROPDOWN: {
@ -736,7 +736,7 @@ public:
} }
} }
size->width = std::max(size->width, 5 + d.width + padding.width); size.width = std::max(size.width, 5 + d.width + padding.width);
break; break;
} }
@ -745,15 +745,15 @@ public:
this->square = GetSpriteSize(SPR_SQUARE); this->square = GetSpriteSize(SPR_SQUARE);
this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; this->line_height = std::max(this->square.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
size->height = 5 * this->line_height; size.height = 5 * this->line_height;
resize->width = 1; resize.width = 1;
resize->height = this->line_height; resize.height = this->line_height;
break; break;
} }
case WID_SCL_SEC_COL_DROPDOWN: case WID_SCL_SEC_COL_DROPDOWN:
if (!_loaded_newgrf_features.has_2CC) { if (!_loaded_newgrf_features.has_2CC) {
size->width = 0; size.width = 0;
break; break;
} }
[[fallthrough]]; [[fallthrough]];
@ -762,9 +762,9 @@ public:
this->square = GetSpriteSize(SPR_SQUARE); this->square = GetSpriteSize(SPR_SQUARE);
int string_padding = this->square.width + WidgetDimensions::scaled.hsep_normal + padding.width; int string_padding = this->square.width + WidgetDimensions::scaled.hsep_normal + padding.width;
for (Colours colour = COLOUR_BEGIN; colour != COLOUR_END; colour++) { for (Colours colour = COLOUR_BEGIN; colour != COLOUR_END; colour++) {
size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DARK_BLUE + colour).width + string_padding); size.width = std::max(size.width, GetStringBoundingBox(STR_COLOUR_DARK_BLUE + colour).width + string_padding);
} }
size->width = std::max(size->width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding); size.width = std::max(size.width, GetStringBoundingBox(STR_COLOUR_DEFAULT).width + string_padding);
break; break;
} }
} }
@ -1405,31 +1405,31 @@ public:
this->number_dim = number_dim; this->number_dim = number_dim;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT: case WID_SCMF_HAS_MOUSTACHE_EARRING_TEXT:
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING)); size = maxdim(size, GetStringBoundingBox(STR_FACE_EARRING));
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); size = maxdim(size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
break; break;
case WID_SCMF_TIE_EARRING_TEXT: case WID_SCMF_TIE_EARRING_TEXT:
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_EARRING)); size = maxdim(size, GetStringBoundingBox(STR_FACE_EARRING));
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_TIE)); size = maxdim(size, GetStringBoundingBox(STR_FACE_TIE));
break; break;
case WID_SCMF_LIPS_MOUSTACHE_TEXT: case WID_SCMF_LIPS_MOUSTACHE_TEXT:
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_LIPS)); size = maxdim(size, GetStringBoundingBox(STR_FACE_LIPS));
*size = maxdim(*size, GetStringBoundingBox(STR_FACE_MOUSTACHE)); size = maxdim(size, GetStringBoundingBox(STR_FACE_MOUSTACHE));
break; break;
case WID_SCMF_FACE: case WID_SCMF_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
break; break;
case WID_SCMF_HAS_MOUSTACHE_EARRING: case WID_SCMF_HAS_MOUSTACHE_EARRING:
case WID_SCMF_HAS_GLASSES: case WID_SCMF_HAS_GLASSES:
*size = this->yesno_dim; size = this->yesno_dim;
break; break;
case WID_SCMF_EYECOLOUR: case WID_SCMF_EYECOLOUR:
@ -1442,7 +1442,7 @@ public:
case WID_SCMF_COLLAR: case WID_SCMF_COLLAR:
case WID_SCMF_TIE_EARRING: case WID_SCMF_TIE_EARRING:
case WID_SCMF_GLASSES: case WID_SCMF_GLASSES:
*size = this->number_dim; size = this->number_dim;
break; break;
} }
} }
@ -1840,7 +1840,7 @@ struct CompanyInfrastructureWindow : Window
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
const Company *c = Company::Get((CompanyID)this->window_number); const Company *c = Company::Get((CompanyID)this->window_number);
@ -1848,20 +1848,20 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_RAIL_DESC: { case WID_CI_RAIL_DESC: {
uint lines = 1; // Starts at 1 because a line is also required for the section title uint lines = 1; // Starts at 1 because a line is also required for the section title
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT).width + padding.width);
for (const auto &rt : _sorted_railtypes) { for (const auto &rt : _sorted_railtypes) {
if (HasBit(this->railtypes, rt)) { if (HasBit(this->railtypes, rt)) {
lines++; lines++;
size->width = std::max(size->width, GetStringBoundingBox(GetRailTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(GetRailTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent);
} }
} }
if (this->railtypes != RAILTYPES_NONE) { if (this->railtypes != RAILTYPES_NONE) {
lines++; lines++;
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS).width + padding.width + WidgetDimensions::scaled.hsep_indent);
} }
size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); size.height = std::max(size.height, lines * GetCharacterHeight(FS_NORMAL));
break; break;
} }
@ -1869,28 +1869,28 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_TRAM_DESC: { case WID_CI_TRAM_DESC: {
uint lines = 1; // Starts at 1 because a line is also required for the section title uint lines = 1; // Starts at 1 because a line is also required for the section title
size->width = std::max(size->width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(widget == WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT).width + padding.width);
for (const auto &rt : _sorted_roadtypes) { for (const auto &rt : _sorted_roadtypes) {
if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) { if (HasBit(this->roadtypes, rt) && RoadTypeIsRoad(rt) == (widget == WID_CI_ROAD_DESC)) {
lines++; lines++;
size->width = std::max(size->width, GetStringBoundingBox(GetRoadTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(GetRoadTypeInfo(rt)->strings.name).width + padding.width + WidgetDimensions::scaled.hsep_indent);
} }
} }
size->height = std::max(size->height, lines * GetCharacterHeight(FS_NORMAL)); size.height = std::max(size.height, lines * GetCharacterHeight(FS_NORMAL));
break; break;
} }
case WID_CI_WATER_DESC: case WID_CI_WATER_DESC:
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT).width + padding.width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS).width + padding.width + WidgetDimensions::scaled.hsep_indent);
break; break;
case WID_CI_STATION_DESC: case WID_CI_STATION_DESC:
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT).width + padding.width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS).width + padding.width + WidgetDimensions::scaled.hsep_indent);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + padding.width + WidgetDimensions::scaled.hsep_indent); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS).width + padding.width + WidgetDimensions::scaled.hsep_indent);
break; break;
case WID_CI_RAIL_COUNT: case WID_CI_RAIL_COUNT:
@ -1930,17 +1930,17 @@ struct CompanyInfrastructureWindow : Window
StringID str_total = TimerGameEconomy::UsingWallclockUnits() ? STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD : STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR; StringID str_total = TimerGameEconomy::UsingWallclockUnits() ? STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_PERIOD : STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL_YEAR;
SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
this->total_width = GetStringBoundingBox(str_total).width + WidgetDimensions::scaled.hsep_indent * 2; this->total_width = GetStringBoundingBox(str_total).width + WidgetDimensions::scaled.hsep_indent * 2;
size->width = std::max(size->width, this->total_width); size.width = std::max(size.width, this->total_width);
SetDParamMaxValue(0, max_cost * 12); // Convert to per year SetDParamMaxValue(0, max_cost * 12); // Convert to per year
count_width += std::max(this->total_width, GetStringBoundingBox(str_total).width); count_width += std::max(this->total_width, GetStringBoundingBox(str_total).width);
} }
size->width = std::max(size->width, count_width); size.width = std::max(size.width, count_width);
/* Set height of the total line. */ /* Set height of the total line. */
if (widget == WID_CI_TOTAL) { if (widget == WID_CI_TOTAL) {
size->height = _settings_game.economy.infrastructure_maintenance ? std::max<uint>(size->height, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)) : 0; size.height = _settings_game.economy.infrastructure_maintenance ? std::max<uint>(size.height, WidgetDimensions::scaled.vsep_normal + GetCharacterHeight(FS_NORMAL)) : 0;
} }
break; break;
} }
@ -2249,11 +2249,11 @@ struct CompanyWindow : Window
this->DrawWidgets(); this->DrawWidgets();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_C_FACE: case WID_C_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
break; break;
case WID_C_DESC_COLOUR_SCHEME_EXAMPLE: { case WID_C_DESC_COLOUR_SCHEME_EXAMPLE: {
@ -2261,31 +2261,31 @@ struct CompanyWindow : Window
Dimension d = GetSpriteSize(SPR_VEH_BUS_SW_VIEW, &offset); Dimension d = GetSpriteSize(SPR_VEH_BUS_SW_VIEW, &offset);
d.width -= offset.x; d.width -= offset.x;
d.height -= offset.y; d.height -= offset.y;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_C_DESC_COMPANY_VALUE: case WID_C_DESC_COMPANY_VALUE:
SetDParam(0, INT64_MAX); // Arguably the maximum company value SetDParam(0, INT64_MAX); // Arguably the maximum company value
size->width = GetStringBoundingBox(STR_COMPANY_VIEW_COMPANY_VALUE).width; size.width = GetStringBoundingBox(STR_COMPANY_VIEW_COMPANY_VALUE).width;
break; break;
case WID_C_DESC_VEHICLE_COUNTS: case WID_C_DESC_VEHICLE_COUNTS:
SetDParamMaxValue(0, 5000); // Maximum number of vehicles SetDParamMaxValue(0, 5000); // Maximum number of vehicles
for (uint i = 0; i < lengthof(_company_view_vehicle_count_strings); i++) { for (uint i = 0; i < lengthof(_company_view_vehicle_count_strings); i++) {
size->width = std::max(size->width, GetStringBoundingBox(_company_view_vehicle_count_strings[i]).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(_company_view_vehicle_count_strings[i]).width + padding.width);
} }
break; break;
case WID_C_DESC_INFRASTRUCTURE_COUNTS: case WID_C_DESC_INFRASTRUCTURE_COUNTS:
SetDParamMaxValue(0, UINT_MAX); SetDParamMaxValue(0, UINT_MAX);
size->width = GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL).width; size.width = GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL).width;
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_WATER).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_WATER).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_STATION).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_STATION).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_NONE).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_NONE).width);
size->width += padding.width; size.width += padding.width;
break; break;
case WID_C_VIEW_HQ: case WID_C_VIEW_HQ:
@ -2296,19 +2296,19 @@ struct CompanyWindow : Window
case WID_C_HOSTILE_TAKEOVER: case WID_C_HOSTILE_TAKEOVER:
case WID_C_COMPANY_PASSWORD: case WID_C_COMPANY_PASSWORD:
case WID_C_COMPANY_JOIN: case WID_C_COMPANY_JOIN:
size->width = GetStringBoundingBox(STR_COMPANY_VIEW_VIEW_HQ_BUTTON).width; size.width = GetStringBoundingBox(STR_COMPANY_VIEW_VIEW_HQ_BUTTON).width;
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_BUILD_HQ_BUTTON).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_BUILD_HQ_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_RELOCATE_HQ).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_RELOCATE_HQ).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_GIVE_MONEY_BUTTON).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_GIVE_MONEY_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_HOSTILE_TAKEOVER_BUTTON).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_PASSWORD).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_PASSWORD).width);
size->width = std::max(size->width, GetStringBoundingBox(STR_COMPANY_VIEW_JOIN).width); size.width = std::max(size.width, GetStringBoundingBox(STR_COMPANY_VIEW_JOIN).width);
size->width += padding.width; size.width += padding.width;
break; break;
case WID_C_HAS_PASSWORD: case WID_C_HAS_PASSWORD:
if (_networking) *size = maxdim(*size, GetSpriteSize(SPR_LOCK)); if (_networking) size = maxdim(size, GetSpriteSize(SPR_LOCK));
break; break;
} }
} }
@ -2622,18 +2622,18 @@ struct BuyCompanyWindow : Window {
this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value; this->company_value = hostile_takeover ? CalculateHostileTakeoverValue(c) : c->bankrupt_value;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BC_FACE: case WID_BC_FACE:
*size = GetScaledSpriteSize(SPR_GRADIENT); size = GetScaledSpriteSize(SPR_GRADIENT);
break; break;
case WID_BC_QUESTION: case WID_BC_QUESTION:
const Company *c = Company::Get((CompanyID)this->window_number); const Company *c = Company::Get((CompanyID)this->window_number);
SetDParam(0, c->index); SetDParam(0, c->index);
SetDParam(1, this->company_value); SetDParam(1, this->company_value);
size->height = GetStringHeight(this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, size->width); size.height = GetStringHeight(this->hostile_takeover ? STR_BUY_COMPANY_HOSTILE_TAKEOVER : STR_BUY_COMPANY_MESSAGE, size.width);
break; break;
} }
} }

View File

@ -100,7 +100,7 @@ struct SetDateWindow : Window {
ShowDropDownList(this, std::move(list), selected, widget); ShowDropDownList(this, std::move(list), selected, widget);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
Dimension d = {0, 0}; Dimension d = {0, 0};
switch (widget) { switch (widget) {
@ -126,7 +126,7 @@ struct SetDateWindow : Window {
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = d; size = d;
} }
void SetStringParameters(WidgetID widget) const override void SetStringParameters(WidgetID widget) const override

View File

@ -653,7 +653,7 @@ struct DepotWindow : Window {
this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING)); this->flag_size = maxdim(GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED), GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING));
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_D_MATRIX: { case WID_D_MATRIX: {
@ -679,18 +679,18 @@ struct DepotWindow : Window {
} }
int base_width = this->count_width + this->header_width + padding.width; int base_width = this->count_width + this->header_width + padding.width;
resize->height = std::max<uint>(this->cell_size.height, min_height + padding.height); resize.height = std::max<uint>(this->cell_size.height, min_height + padding.height);
if (this->type == VEH_TRAIN) { if (this->type == VEH_TRAIN) {
resize->width = 1; resize.width = 1;
size->width = base_width + 2 * ScaleSpriteTrad(29); // about 2 parts size.width = base_width + 2 * ScaleSpriteTrad(29); // about 2 parts
size->height = resize->height * 6; size.height = resize.height * 6;
} else { } else {
resize->width = base_width + this->cell_size.extend_left + this->cell_size.extend_right; resize.width = base_width + this->cell_size.extend_left + this->cell_size.extend_right;
size->width = resize->width * (this->type == VEH_ROAD ? 5 : 3); size.width = resize.width * (this->type == VEH_ROAD ? 5 : 3);
size->height = resize->height * (this->type == VEH_ROAD ? 5 : 3); size.height = resize.height * (this->type == VEH_ROAD ? 5 : 3);
} }
fill->width = resize->width; fill.width = resize.width;
fill->height = resize->height; fill.height = resize.height;
break; break;
} }
} }

View File

@ -529,13 +529,13 @@ public:
UpdateDocksDirection(); UpdateDocksDirection();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BDD_X: case WID_BDD_X:
case WID_BDD_Y: case WID_BDD_Y:
size->width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(96) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
} }
} }

View File

@ -210,9 +210,9 @@ struct DropdownWindow : Window {
if (this->position.y < button_rect.top && list_dim.height > widget_dim.height) this->vscroll->UpdatePosition(INT_MAX); if (this->position.y < button_rect.top && list_dim.height > widget_dim.height) this->vscroll->UpdatePosition(INT_MAX);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_DM_ITEMS) *size = this->items_dim; if (widget == WID_DM_ITEMS) size = this->items_dim;
} }
Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override Point OnInitialPosition([[maybe_unused]] int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override

View File

@ -78,7 +78,7 @@ struct EnginePreviewWindow : Window {
this->flags |= WF_STICKY; this->flags |= WF_STICKY;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_EP_QUESTION) return; if (widget != WID_EP_QUESTION) return;
@ -98,11 +98,11 @@ struct EnginePreviewWindow : Window {
} }
this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs); this->vehicle_space = std::max<int>(ScaleSpriteTrad(40), y - y_offs);
size->width = std::max(size->width, x + std::abs(x_offs)); size.width = std::max(size.width, x + std::abs(x_offs));
SetDParam(0, GetEngineCategoryName(engine)); SetDParam(0, GetEngineCategoryName(engine));
size->height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size->width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space; size.height = GetStringHeight(STR_ENGINE_PREVIEW_MESSAGE, size.width) + WidgetDimensions::scaled.vsep_wide + GetCharacterHeight(FS_NORMAL) + this->vehicle_space;
SetDParam(0, engine); SetDParam(0, engine);
size->height += GetStringHeight(GetEngineInfoString(engine), size->width); size.height += GetStringHeight(GetEngineInfoString(engine), size.width);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -189,16 +189,16 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_EM_MESSAGE: { case WID_EM_MESSAGE: {
CopyInDParam(this->params); CopyInDParam(this->params);
if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack); if (this->textref_stack_size > 0) StartTextRefStackUsage(this->textref_stack_grffile, this->textref_stack_size, this->textref_stack);
this->height_summary = GetStringHeight(this->summary_msg, size->width); this->height_summary = GetStringHeight(this->summary_msg, size.width);
this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, size->width); this->height_detailed = (this->detailed_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->detailed_msg, size.width);
this->height_extra = (this->extra_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->extra_msg, size->width); this->height_extra = (this->extra_msg == INVALID_STRING_ID) ? 0 : GetStringHeight(this->extra_msg, size.width);
if (this->textref_stack_size > 0) StopTextRefStackUsage(); if (this->textref_stack_size > 0) StopTextRefStackUsage();
@ -206,11 +206,11 @@ public:
if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide; if (this->detailed_msg != INVALID_STRING_ID) panel_height += this->height_detailed + WidgetDimensions::scaled.vsep_wide;
if (this->extra_msg != INVALID_STRING_ID) panel_height += this->height_extra + WidgetDimensions::scaled.vsep_wide; if (this->extra_msg != INVALID_STRING_ID) panel_height += this->height_extra + WidgetDimensions::scaled.vsep_wide;
size->height = std::max(size->height, panel_height); size.height = std::max(size.height, panel_height);
break; break;
} }
case WID_EM_FACE: case WID_EM_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
break; break;
} }
} }

View File

@ -561,23 +561,23 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SL_BACKGROUND: case WID_SL_BACKGROUND:
size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
break; break;
case WID_SL_DRIVES_DIRECTORIES_LIST: case WID_SL_DRIVES_DIRECTORIES_LIST:
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
size->height = resize->height * 10 + padding.height; size.height = resize.height * 10 + padding.height;
break; break;
case WID_SL_SORT_BYNAME: case WID_SL_SORT_BYNAME:
case WID_SL_SORT_BYDATE: { case WID_SL_SORT_BYDATE: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -540,32 +540,32 @@ struct FramerateWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_FRW_RATE_GAMELOOP: case WID_FRW_RATE_GAMELOOP:
SetDParam(0, STR_FRAMERATE_FPS_GOOD); SetDParam(0, STR_FRAMERATE_FPS_GOOD);
SetDParam(1, 999999); SetDParam(1, 999999);
SetDParam(2, 2); SetDParam(2, 2);
*size = GetStringBoundingBox(STR_FRAMERATE_RATE_GAMELOOP); size = GetStringBoundingBox(STR_FRAMERATE_RATE_GAMELOOP);
break; break;
case WID_FRW_RATE_DRAWING: case WID_FRW_RATE_DRAWING:
SetDParam(0, STR_FRAMERATE_FPS_GOOD); SetDParam(0, STR_FRAMERATE_FPS_GOOD);
SetDParam(1, 999999); SetDParam(1, 999999);
SetDParam(2, 2); SetDParam(2, 2);
*size = GetStringBoundingBox(STR_FRAMERATE_RATE_BLITTER); size = GetStringBoundingBox(STR_FRAMERATE_RATE_BLITTER);
break; break;
case WID_FRW_RATE_FACTOR: case WID_FRW_RATE_FACTOR:
SetDParam(0, 999999); SetDParam(0, 999999);
SetDParam(1, 2); SetDParam(1, 2);
*size = GetStringBoundingBox(STR_FRAMERATE_SPEED_FACTOR); size = GetStringBoundingBox(STR_FRAMERATE_SPEED_FACTOR);
break; break;
case WID_FRW_TIMES_NAMES: { case WID_FRW_TIMES_NAMES: {
size->width = 0; size.width = 0;
size->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL); size.height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + MIN_ELEMENTS * GetCharacterHeight(FS_NORMAL);
resize->width = 0; resize.width = 0;
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
for (PerformanceElement e : DISPLAY_ORDER_PFE) { for (PerformanceElement e : DISPLAY_ORDER_PFE) {
if (_pf_data[e].num_valid == 0) continue; if (_pf_data[e].num_valid == 0) continue;
Dimension line_size; Dimension line_size;
@ -576,7 +576,7 @@ struct FramerateWindow : Window {
SetDParamStr(1, GetAIName(e - PFE_AI0)); SetDParamStr(1, GetAIName(e - PFE_AI0));
line_size = GetStringBoundingBox(STR_FRAMERATE_AI); line_size = GetStringBoundingBox(STR_FRAMERATE_AI);
} }
size->width = std::max(size->width, line_size.width); size.width = std::max(size.width, line_size.width);
} }
break; break;
} }
@ -584,14 +584,14 @@ struct FramerateWindow : Window {
case WID_FRW_TIMES_CURRENT: case WID_FRW_TIMES_CURRENT:
case WID_FRW_TIMES_AVERAGE: case WID_FRW_TIMES_AVERAGE:
case WID_FRW_ALLOCSIZE: { case WID_FRW_ALLOCSIZE: {
*size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT)); size = GetStringBoundingBox(STR_FRAMERATE_CURRENT + (widget - WID_FRW_TIMES_CURRENT));
SetDParam(0, 999999); SetDParam(0, 999999);
SetDParam(1, 2); SetDParam(1, 2);
Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD); Dimension item_size = GetStringBoundingBox(STR_FRAMERATE_MS_GOOD);
size->width = std::max(size->width, item_size.width); size.width = std::max(size.width, item_size.width);
size->height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal; size.height += GetCharacterHeight(FS_NORMAL) * MIN_ELEMENTS + WidgetDimensions::scaled.vsep_normal;
resize->width = 0; resize.width = 0;
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
break; break;
} }
} }
@ -780,7 +780,7 @@ struct FrametimeGraphWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_FGW_GRAPH) { if (widget == WID_FGW_GRAPH) {
SetDParam(0, 100); SetDParam(0, 100);
@ -792,10 +792,10 @@ struct FrametimeGraphWindow : Window {
graph_size.height = std::max(100u, 10 * (size_ms_label.height + 1)); graph_size.height = std::max(100u, 10 * (size_ms_label.height + 1));
/* Always 2:1 graph area */ /* Always 2:1 graph area */
graph_size.width = 2 * graph_size.height; graph_size.width = 2 * graph_size.height;
*size = graph_size; size = graph_size;
size->width += size_ms_label.width + 2; size.width += size_ms_label.width + 2;
size->height += size_s_label.height + 2; size.height += size_s_label.height + 2;
} }
} }

View File

@ -136,19 +136,19 @@ struct GSConfigWindow : public Window {
this->vscroll->SetCount(this->visible_settings.size()); this->vscroll->SetCount(this->visible_settings.size());
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_GSC_SETTINGS: case WID_GSC_SETTINGS:
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_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 = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = 1 * this->line_height; size.height = 1 * this->line_height;
break; break;
} }
} }

View File

@ -571,15 +571,15 @@ struct GenerateLandscapeWindow : public Window {
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)}; Dimension d{0, (uint)GetCharacterHeight(FS_NORMAL)};
const StringID *strs = nullptr; const StringID *strs = nullptr;
switch (widget) { switch (widget) {
case WID_GL_TEMPERATE: case WID_GL_ARCTIC: case WID_GL_TEMPERATE: case WID_GL_ARCTIC:
case WID_GL_TROPICAL: case WID_GL_TOYLAND: case WID_GL_TROPICAL: case WID_GL_TOYLAND:
size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); size.width += WidgetDimensions::scaled.fullbevel.Horizontal();
size->height += WidgetDimensions::scaled.fullbevel.Vertical(); size.height += WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
case WID_GL_HEIGHTMAP_HEIGHT_TEXT: case WID_GL_HEIGHTMAP_HEIGHT_TEXT:
@ -654,7 +654,7 @@ struct GenerateLandscapeWindow : public Window {
break; break;
case WID_GL_HEIGHTMAP_NAME_TEXT: case WID_GL_HEIGHTMAP_NAME_TEXT:
size->width = 0; size.width = 0;
break; break;
default: default:
@ -667,7 +667,7 @@ struct GenerateLandscapeWindow : public Window {
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
} }
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
@ -1121,14 +1121,14 @@ struct CreateScenarioWindow : public Window
this->DrawWidgets(); this->DrawWidgets();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
StringID str = STR_JUST_INT; StringID str = STR_JUST_INT;
switch (widget) { switch (widget) {
case WID_CS_TEMPERATE: case WID_CS_ARCTIC: case WID_CS_TEMPERATE: case WID_CS_ARCTIC:
case WID_CS_TROPICAL: case WID_CS_TOYLAND: case WID_CS_TROPICAL: case WID_CS_TOYLAND:
size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); size.width += WidgetDimensions::scaled.fullbevel.Horizontal();
size->height += WidgetDimensions::scaled.fullbevel.Vertical(); size.height += WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
case WID_CS_START_DATE_TEXT: case WID_CS_START_DATE_TEXT:
@ -1151,7 +1151,7 @@ struct CreateScenarioWindow : public Window
Dimension d = GetStringBoundingBox(str); Dimension d = GetStringBoundingBox(str);
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
} }
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
@ -1405,23 +1405,23 @@ struct GenerateProgressWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_GP_PROGRESS_BAR: { case WID_GP_PROGRESS_BAR: {
SetDParamMaxValue(0, 100); SetDParamMaxValue(0, 100);
*size = GetStringBoundingBox(STR_GENERATION_PROGRESS); size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
/* We need some spacing for the 'border' */ /* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal(); size.height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical(); size.width += WidgetDimensions::scaled.frametext.Vertical();
break; break;
} }
case WID_GP_PROGRESS_TEXT: case WID_GP_PROGRESS_TEXT:
for (uint i = 0; i < GWP_CLASS_COUNT; i++) { for (uint i = 0; i < GWP_CLASS_COUNT; i++) {
size->width = std::max(size->width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(_generation_class_table[i]).width + padding.width);
} }
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break; break;
} }
} }

View File

@ -168,18 +168,18 @@ struct GoalListWindow : public Window {
return num; return num;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_GOAL_LIST) return; if (widget != WID_GOAL_LIST) return;
Dimension d = GetStringBoundingBox(STR_GOALS_NONE); Dimension d = GetStringBoundingBox(STR_GOALS_NONE);
resize->width = 1; resize.width = 1;
resize->height = d.height; resize.height = d.height;
d.height *= 5; d.height *= 5;
d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.width += WidgetDimensions::scaled.framerect.Horizontal();
d.height += WidgetDimensions::scaled.framerect.Vertical(); d.height += WidgetDimensions::scaled.framerect.Vertical();
*size = maxdim(*size, d); size = maxdim(size, d);
} }
/** /**
@ -388,12 +388,12 @@ struct GoalQuestionWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_GQ_QUESTION) return; if (widget != WID_GQ_QUESTION) return;
SetDParamStr(0, this->question); SetDParamStr(0, this->question);
size->height = GetStringHeight(STR_JUST_RAW_STRING, size->width); size.height = GetStringHeight(STR_JUST_RAW_STRING, size.width);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -517,7 +517,7 @@ protected:
} }
public: public:
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_GRAPH_GRAPH) return; if (widget != WID_GRAPH_GRAPH) return;
@ -548,9 +548,9 @@ public:
SetDParam(1, INT64_MAX); SetDParam(1, INT64_MAX);
uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width; uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
size->width = std::max<uint>(size->width, ScaleGUITrad(5) + y_label_width + this->num_vert_lines * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9)); size.width = std::max<uint>(size.width, ScaleGUITrad(5) + y_label_width + this->num_vert_lines * (x_label_width + ScaleGUITrad(5)) + ScaleGUITrad(9));
size->height = std::max<uint>(size->height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4)); size.height = std::max<uint>(size.height, ScaleGUITrad(5) + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->draw_dates ? 3 : 1)) * GetCharacterHeight(FS_SMALL) + ScaleGUITrad(4));
size->height = std::max<uint>(size->height, size->width / 3); size.height = std::max<uint>(size.height, size.width / 3);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -990,14 +990,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_CPR_MATRIX) { if (widget != WID_CPR_MATRIX) {
BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize); BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
return; return;
} }
size->height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical(); size.height = GetCharacterHeight(FS_SMALL) + WidgetDimensions::scaled.framerect.Vertical();
for (const CargoSpec *cs : _sorted_standard_cargo_specs) { for (const CargoSpec *cs : _sorted_standard_cargo_specs) {
SetDParam(0, cs->name); SetDParam(0, cs->name);
@ -1005,13 +1005,13 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
d.width += this->legend_width + WidgetDimensions::scaled.hsep_normal; // colour field d.width += this->legend_width + WidgetDimensions::scaled.hsep_normal; // colour field
d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.width += WidgetDimensions::scaled.framerect.Horizontal();
d.height += WidgetDimensions::scaled.framerect.Vertical(); d.height += WidgetDimensions::scaled.framerect.Vertical();
*size = maxdim(d, *size); size = maxdim(d, size);
} }
this->line_height = size->height; this->line_height = size.height;
size->height = this->line_height * 11; /* Default number of cargo types in most climates. */ size.height = this->line_height * 11; /* Default number of cargo types in most climates. */
resize->width = 0; resize.width = 0;
resize->height = this->line_height; resize.height = this->line_height;
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -1216,12 +1216,12 @@ struct PerformanceRatingDetailWindow : Window {
uint score_detail_left; uint score_detail_left;
uint score_detail_right; uint score_detail_right;
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_PRD_SCORE_FIRST: case WID_PRD_SCORE_FIRST:
this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical(); this->bar_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.fullbevel.Vertical();
size->height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical(); size.height = this->bar_height + WidgetDimensions::scaled.matrix.Vertical();
uint score_info_width = 0; uint score_info_width = 0;
for (uint i = SCORE_BEGIN; i < SCORE_END; i++) { for (uint i = SCORE_BEGIN; i < SCORE_END; i++) {
@ -1257,9 +1257,9 @@ struct PerformanceRatingDetailWindow : Window {
SetDParam(1, max); SetDParam(1, max);
uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width; uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width;
size->width = WidgetDimensions::scaled.frametext.Horizontal() + score_info_width + WidgetDimensions::scaled.hsep_wide + this->bar_width + WidgetDimensions::scaled.hsep_wide + score_detail_width; size.width = WidgetDimensions::scaled.frametext.Horizontal() + score_info_width + WidgetDimensions::scaled.hsep_wide + this->bar_width + WidgetDimensions::scaled.hsep_wide + score_detail_width;
uint left = WidgetDimensions::scaled.frametext.left; uint left = WidgetDimensions::scaled.frametext.left;
uint right = size->width - WidgetDimensions::scaled.frametext.right; uint right = size.width - WidgetDimensions::scaled.frametext.right;
bool rtl = _current_text_dir == TD_RTL; bool rtl = _current_text_dir == TD_RTL;
this->score_info_left = rtl ? right - score_info_width : left; this->score_info_left = rtl ? right - score_info_width : left;

View File

@ -400,56 +400,56 @@ public:
*this->sorting = this->vehgroups.GetListing(); *this->sorting = this->vehgroups.GetListing();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_GL_LIST_GROUP: case WID_GL_LIST_GROUP:
size->width = this->ComputeGroupInfoSize(); size.width = this->ComputeGroupInfoSize();
resize->height = this->tiny_step_height; resize.height = this->tiny_step_height;
fill->height = this->tiny_step_height; fill.height = this->tiny_step_height;
break; break;
case WID_GL_ALL_VEHICLES: case WID_GL_ALL_VEHICLES:
case WID_GL_DEFAULT_VEHICLES: case WID_GL_DEFAULT_VEHICLES:
size->width = this->ComputeGroupInfoSize(); size.width = this->ComputeGroupInfoSize();
size->height = this->tiny_step_height; size.height = this->tiny_step_height;
break; break;
case WID_GL_SORT_BY_ORDER: { case WID_GL_SORT_BY_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_GL_LIST_VEHICLE: case WID_GL_LIST_VEHICLE:
this->ComputeGroupInfoSize(); this->ComputeGroupInfoSize();
resize->height = GetVehicleListHeight(this->vli.vtype, this->tiny_step_height); resize.height = GetVehicleListHeight(this->vli.vtype, this->tiny_step_height);
size->height = 4 * resize->height; size.height = 4 * resize.height;
break; break;
case WID_GL_GROUP_BY_DROPDOWN: case WID_GL_GROUP_BY_DROPDOWN:
size->width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; size.width = GetStringListWidth(this->vehicle_group_by_names) + padding.width;
break; break;
case WID_GL_SORT_BY_DROPDOWN: case WID_GL_SORT_BY_DROPDOWN:
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); size.width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock));
size->width += padding.width; size.width += padding.width;
break; break;
case WID_GL_FILTER_BY_CARGO: case WID_GL_FILTER_BY_CARGO:
size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width);
break; break;
case WID_GL_MANAGE_VEHICLES_DROPDOWN: { case WID_GL_MANAGE_VEHICLES_DROPDOWN: {
Dimension d = this->GetActionDropdownSize(true, true, true); Dimension d = this->GetActionDropdownSize(true, true, true);
d.height += padding.height; d.height += padding.height;
d.width += padding.width; d.width += padding.width;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -423,7 +423,7 @@ public:
this->SetupArrays(); this->SetupArrays();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_DPI_MATRIX_WIDGET: { case WID_DPI_MATRIX_WIDGET: {
@ -431,10 +431,10 @@ public:
for (const auto &indtype : this->list) { for (const auto &indtype : this->list) {
d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name)); d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(indtype)->name));
} }
resize->height = std::max<uint>(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height; resize.height = std::max<uint>(this->legend.height, GetCharacterHeight(FS_NORMAL)) + padding.height;
d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width; d.width += this->legend.width + WidgetDimensions::scaled.hsep_wide + padding.width;
d.height = 5 * resize->height; d.height = 5 * resize.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -478,8 +478,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 * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = height * GetCharacterHeight(FS_NORMAL) + padding.height;
size->width = d.width + padding.width; size.width = d.width + padding.width;
break; break;
} }
@ -489,7 +489,7 @@ public:
d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY)); d = maxdim(d, GetStringBoundingBox(STR_FUND_INDUSTRY_FUND_NEW_INDUSTRY));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }
@ -1004,9 +1004,9 @@ public:
if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number); if (widget == WID_IV_CAPTION) SetDParam(0, this->window_number);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_IV_INFO) size->height = this->info_height; if (widget == WID_IV_INFO) size.height = this->info_height;
} }
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
@ -1720,14 +1720,14 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_ID_DROPDOWN_ORDER: { case WID_ID_DROPDOWN_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -1738,17 +1738,17 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_ID_INDUSTRY_LIST: { case WID_ID_INDUSTRY_LIST: {
Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE); Dimension d = GetStringBoundingBox(STR_INDUSTRY_DIRECTORY_NONE);
resize->height = d.height; resize.height = d.height;
d.height *= 5; d.height *= 5;
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }
@ -2626,21 +2626,21 @@ struct IndustryCargoesWindow : public Window {
CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1); CargoesField::cargo_field_width = CargoesField::cargo_border.width * 2 + CargoesField::cargo_line.width * CargoesField::max_cargoes + CargoesField::cargo_space.width * (CargoesField::max_cargoes - 1);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_IC_PANEL: case WID_IC_PANEL:
resize->height = CargoesField::normal_height; resize.height = CargoesField::normal_height;
size->width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal(); size.width = CargoesField::industry_width * 3 + CargoesField::cargo_field_width * 2 + WidgetDimensions::scaled.frametext.Horizontal();
size->height = CargoesField::small_height + 2 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); size.height = CargoesField::small_height + 2 * resize.height + WidgetDimensions::scaled.frametext.Vertical();
break; break;
case WID_IC_IND_DROPDOWN: case WID_IC_IND_DROPDOWN:
size->width = std::max(size->width, this->ind_textsize.width + padding.width); size.width = std::max(size.width, this->ind_textsize.width + padding.width);
break; break;
case WID_IC_CARGO_DROPDOWN: case WID_IC_CARGO_DROPDOWN:
size->width = std::max(size->width, this->cargo_textsize.width + padding.width); size.width = std::max(size.width, this->cargo_textsize.width + padding.width);
break; break;
} }
} }

View File

@ -297,13 +297,13 @@ struct SelectGameWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE: case WID_SGI_TEMPERATE_LANDSCAPE: case WID_SGI_ARCTIC_LANDSCAPE:
case WID_SGI_TROPIC_LANDSCAPE: case WID_SGI_TOYLAND_LANDSCAPE: case WID_SGI_TROPIC_LANDSCAPE: case WID_SGI_TOYLAND_LANDSCAPE:
size->width += WidgetDimensions::scaled.fullbevel.Horizontal(); size.width += WidgetDimensions::scaled.fullbevel.Horizontal();
size->height += WidgetDimensions::scaled.fullbevel.Vertical(); size.height += WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
} }
} }

View File

@ -129,7 +129,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_PLT_BACKGROUND) return; if (widget != WID_PLT_BACKGROUND) return;
@ -162,8 +162,8 @@ public:
this->text_width = widest_width + WidgetDimensions::scaled.hsep_indent * 3; // Keep some extra spacing this->text_width = widest_width + WidgetDimensions::scaled.hsep_indent * 3; // Keep some extra spacing
size->width = WidgetDimensions::scaled.framerect.Horizontal() + this->ordinal_width + this->icon.width + this->text_width + WidgetDimensions::scaled.hsep_wide; size.width = WidgetDimensions::scaled.framerect.Horizontal() + this->ordinal_width + this->icon.width + this->text_width + WidgetDimensions::scaled.hsep_wide;
size->height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical(); size.height = this->line_height * MAX_COMPANIES + WidgetDimensions::scaled.framerect.Vertical();
} }
void OnGameTick() override void OnGameTick() override
@ -359,7 +359,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_SLT_BACKGROUND) return; if (widget != WID_SLT_BACKGROUND) return;
@ -385,18 +385,18 @@ public:
if (!show_icon_column) this->icon_size.width = 0; if (!show_icon_column) this->icon_size.width = 0;
else this->icon_size.width += WidgetDimensions::scaled.hsep_wide; else this->icon_size.width += WidgetDimensions::scaled.hsep_wide;
size->width = this->rank_width + this->icon_size.width + this->text_width + this->score_width + WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.hsep_wide * 2; size.width = this->rank_width + this->icon_size.width + this->text_width + this->score_width + WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.hsep_wide * 2;
size->height = this->line_height * std::max<uint>(3u, (unsigned)this->rows.size()) + WidgetDimensions::scaled.framerect.Vertical(); size.height = this->line_height * std::max<uint>(3u, (unsigned)this->rows.size()) + WidgetDimensions::scaled.framerect.Vertical();
if (!lt->header.empty()) { if (!lt->header.empty()) {
SetDParamStr(0, lt->header); SetDParamStr(0, lt->header);
this->header_height = GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; this->header_height = GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide;
size->height += header_height; size.height += header_height;
} else this->header_height = 0; } else this->header_height = 0;
if (!lt->footer.empty()) { if (!lt->footer.empty()) {
SetDParamStr(0, lt->footer); SetDParamStr(0, lt->footer);
size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide; size.height += GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.framerect.Horizontal()) + WidgetDimensions::scaled.vsep_wide;
} }
} }

View File

@ -579,7 +579,7 @@ void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay
} }
} }
void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize)
{ {
if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) { if (IsInsideMM(widget, WID_LGL_SATURATION_FIRST, WID_LGL_SATURATION_LAST + 1)) {
StringID str = STR_NULL; StringID str = STR_NULL;
@ -594,7 +594,7 @@ void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [
Dimension dim = GetStringBoundingBox(str, FS_SMALL); Dimension dim = GetStringBoundingBox(str, FS_SMALL);
dim.width += padding.width; dim.width += padding.width;
dim.height += padding.height; dim.height += padding.height;
*size = maxdim(*size, dim); size = maxdim(size, dim);
} }
} }
if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) { if (IsInsideMM(widget, WID_LGL_CARGO_FIRST, WID_LGL_CARGO_LAST + 1)) {
@ -602,7 +602,7 @@ void LinkGraphLegendWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [
Dimension dim = GetStringBoundingBox(cargo->abbrev, FS_SMALL); Dimension dim = GetStringBoundingBox(cargo->abbrev, FS_SMALL);
dim.width += padding.width; dim.width += padding.width;
dim.height += padding.height; dim.height += padding.height;
*size = maxdim(*size, dim); size = maxdim(size, dim);
} }
} }

View File

@ -108,7 +108,7 @@ public:
LinkGraphLegendWindow(WindowDesc *desc, int window_number); LinkGraphLegendWindow(WindowDesc *desc, int window_number);
void SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay); void SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay);
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override;
void DrawWidget(const Rect &r, WidgetID widget) const override; void DrawWidget(const Rect &r, WidgetID widget) const override;
bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override; bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override;
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override;

View File

@ -89,23 +89,23 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_LI_BACKGROUND) return; if (widget != WID_LI_BACKGROUND) return;
size->height = WidgetDimensions::scaled.frametext.Vertical(); size.height = WidgetDimensions::scaled.frametext.Vertical();
for (size_t i = 0; i < this->landinfo_data.size(); i++) { for (size_t i = 0; i < this->landinfo_data.size(); i++) {
uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal(); uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
size->width = std::max(size->width, width); size.width = std::max(size.width, width);
size->height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal); size.height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
} }
if (!this->cargo_acceptance.empty()) { if (!this->cargo_acceptance.empty()) {
uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal(); uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal();
size->width = std::max(size->width, std::min(static_cast<uint>(ScaleGUITrad(300)), width)); size.width = std::max(size.width, std::min(static_cast<uint>(ScaleGUITrad(300)), width));
SetDParamStr(0, cargo_acceptance); SetDParamStr(0, cargo_acceptance);
size->height += GetStringHeight(STR_JUST_RAW_STRING, size->width - WidgetDimensions::scaled.frametext.Horizontal()); size.height += GetStringHeight(STR_JUST_RAW_STRING, size.width - WidgetDimensions::scaled.frametext.Horizontal());
} }
} }
@ -489,7 +489,7 @@ struct AboutWindow : public Window {
if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year); if (widget == WID_A_COPYRIGHT) SetDParamStr(0, _openttd_revision_year);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_A_SCROLLING_TEXT) return; if (widget != WID_A_SCROLLING_TEXT) return;
@ -502,7 +502,7 @@ struct AboutWindow : public Window {
for (const auto &str : _credits) { for (const auto &str : _credits) {
d.width = std::max(d.width, GetStringBoundingBox(str).width); d.width = std::max(d.width, GetStringBoundingBox(str).width);
} }
*size = maxdim(*size, d); size = maxdim(size, d);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -702,17 +702,17 @@ struct TooltipsWindow : public Window
return pt; return pt;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_TT_BACKGROUND) return; if (widget != WID_TT_BACKGROUND) return;
CopyInDParam(this->params); CopyInDParam(this->params);
size->width = std::min<uint>(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194)); size.width = std::min<uint>(GetStringBoundingBox(this->string_id).width, ScaleGUITrad(194));
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 += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width += WidgetDimensions::scaled.framerect.Horizontal() + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical(); size.height += WidgetDimensions::scaled.framerect.Vertical() + WidgetDimensions::scaled.fullbevel.Vertical();
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -986,17 +986,17 @@ struct QueryStringWindow : public Window
this->ReInit(); this->ReInit();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) { if (widget == WID_QS_DEFAULT && (this->flags & QSF_ENABLE_DEFAULT) == 0) {
/* We don't want this widget to show! */ /* We don't want this widget to show! */
fill->width = 0; fill.width = 0;
resize->width = 0; resize.width = 0;
size->width = 0; size.width = 0;
} }
if (widget == WID_QS_WARNING) { if (widget == WID_QS_WARNING) {
*size = this->warning_size; size = this->warning_size;
} }
} }
@ -1139,11 +1139,11 @@ struct QueryWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_Q_TEXT) return; if (widget != WID_Q_TEXT) return;
*size = GetStringMultiLineBoundingBox(this->message, *size); size = GetStringMultiLineBoundingBox(this->message, size);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -518,7 +518,7 @@ struct MusicTrackSelectionWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_MTS_PLAYLIST: { case WID_MTS_PLAYLIST: {
@ -530,7 +530,7 @@ struct MusicTrackSelectionWindow : public Window {
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -547,7 +547,7 @@ struct MusicTrackSelectionWindow : public Window {
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }
@ -700,7 +700,7 @@ struct MusicWindow : public Window {
); );
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
/* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size. /* Make sure that WID_M_SHUFFLE and WID_M_PROGRAMME have the same size.
@ -710,7 +710,7 @@ struct MusicWindow : public Window {
Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE)); Dimension d = maxdim(GetStringBoundingBox(STR_MUSIC_PROGRAM), GetStringBoundingBox(STR_MUSIC_SHUFFLE));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -718,7 +718,7 @@ struct MusicWindow : public Window {
Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE); Dimension d = GetStringBoundingBox(STR_MUSIC_TRACK_NONE);
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -730,7 +730,7 @@ struct MusicWindow : public Window {
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }

View File

@ -116,21 +116,21 @@ void BaseNetworkContentDownloadStatusWindow::Close([[maybe_unused]] int data)
this->Window::Close(); this->Window::Close();
} }
void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) void BaseNetworkContentDownloadStatusWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize)
{ {
switch (widget) { switch (widget) {
case WID_NCDS_PROGRESS_BAR: case WID_NCDS_PROGRESS_BAR:
SetDParamMaxDigits(0, 8); SetDParamMaxDigits(0, 8);
SetDParamMaxDigits(1, 8); SetDParamMaxDigits(1, 8);
SetDParamMaxDigits(2, 8); SetDParamMaxDigits(2, 8);
*size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE); size = GetStringBoundingBox(STR_CONTENT_DOWNLOAD_PROGRESS_SIZE);
/* We need some spacing for the 'border' */ /* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal(); size.height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical(); size.width += WidgetDimensions::scaled.frametext.Vertical();
break; break;
case WID_NCDS_PROGRESS_TEXT: case WID_NCDS_PROGRESS_TEXT:
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break; break;
} }
} }
@ -585,25 +585,25 @@ public:
this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT)); this->checkbox_size = maxdim(maxdim(GetSpriteSize(SPR_BOX_EMPTY), GetSpriteSize(SPR_BOX_CHECKED)), GetSpriteSize(SPR_BLOT));
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NCL_CHECKBOX: case WID_NCL_CHECKBOX:
size->width = this->checkbox_size.width + padding.width; size.width = this->checkbox_size.width + padding.width;
break; break;
case WID_NCL_TYPE: { case WID_NCL_TYPE: {
Dimension d = *size; Dimension d = size;
for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) { for (int i = CONTENT_TYPE_BEGIN; i < CONTENT_TYPE_END; i++) {
d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS)); d = maxdim(d, GetStringBoundingBox(STR_CONTENT_TYPE_BASE_GRAPHICS + i - CONTENT_TYPE_BASE_GRAPHICS));
} }
size->width = d.width + padding.width; size.width = d.width + padding.width;
break; break;
} }
case WID_NCL_MATRIX: case WID_NCL_MATRIX:
resize->height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; resize.height = std::max(this->checkbox_size.height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
size->height = 10 * resize->height; size.height = 10 * resize.height;
break; break;
} }
} }

View File

@ -33,7 +33,7 @@ public:
BaseNetworkContentDownloadStatusWindow(WindowDesc *desc); BaseNetworkContentDownloadStatusWindow(WindowDesc *desc);
void Close([[maybe_unused]] int data = 0) override; void Close([[maybe_unused]] int data = 0) override;
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override;
void DrawWidget(const Rect &r, WidgetID widget) const override; void DrawWidget(const Rect &r, WidgetID widget) const override;
void OnDownloadProgress(const ContentInfo *ci, int bytes) override; void OnDownloadProgress(const ContentInfo *ci, int bytes) override;
}; };

View File

@ -475,48 +475,48 @@ public:
this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width; this->flag_offset = this->blot_offset + ScaleGUITrad(2) + GetSpriteSize(SPR_BLOT).width;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NG_MATRIX: case WID_NG_MATRIX:
resize->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; resize.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
fill->height = resize->height; fill.height = resize.height;
size->height = 12 * resize->height; size.height = 12 * resize.height;
break; break;
case WID_NG_LASTJOINED: case WID_NG_LASTJOINED:
size->height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical(); size.height = std::max(GetSpriteSize(SPR_BLOT).height, (uint)GetCharacterHeight(FS_NORMAL)) + WidgetDimensions::scaled.matrix.Vertical();
break; break;
case WID_NG_LASTJOINED_SPACER: case WID_NG_LASTJOINED_SPACER:
size->width = NWidgetScrollbar::GetVerticalDimension().width; size.width = NWidgetScrollbar::GetVerticalDimension().width;
break; break;
case WID_NG_NAME: case WID_NG_NAME:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
break; break;
case WID_NG_CLIENTS: case WID_NG_CLIENTS:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, MAX_CLIENTS); SetDParamMaxValue(0, MAX_CLIENTS);
SetDParamMaxValue(1, MAX_CLIENTS); SetDParamMaxValue(1, MAX_CLIENTS);
SetDParamMaxValue(2, MAX_COMPANIES); SetDParamMaxValue(2, MAX_COMPANIES);
SetDParamMaxValue(3, MAX_COMPANIES); SetDParamMaxValue(3, MAX_COMPANIES);
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_GENERAL_ONLINE));
break; break;
case WID_NG_MAPSIZE: case WID_NG_MAPSIZE:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, MAX_MAP_SIZE); SetDParamMaxValue(0, MAX_MAP_SIZE);
SetDParamMaxValue(1, MAX_MAP_SIZE); SetDParamMaxValue(1, MAX_MAP_SIZE);
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_SERVER_LIST_MAP_SIZE_SHORT));
break; break;
case WID_NG_DATE: case WID_NG_DATE:
case WID_NG_YEARS: case WID_NG_YEARS:
size->width += 2 * Window::SortButtonWidth(); // Make space for the arrow size.width += 2 * Window::SortButtonWidth(); // Make space for the arrow
SetDParamMaxValue(0, 5); SetDParamMaxValue(0, 5);
*size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT)); size = maxdim(size, GetStringBoundingBox(STR_JUST_INT));
break; break;
} }
} }
@ -1010,13 +1010,13 @@ struct NetworkStartServerWindow : public Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NSS_CONNTYPE_BTN: case WID_NSS_CONNTYPE_BTN:
*size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
size->width += padding.width; size.width += padding.width;
size->height += padding.height; size.height += padding.height;
break; break;
} }
} }
@ -1673,7 +1673,7 @@ public:
this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server); this->SetWidgetDisabledState(WID_CL_SERVER_NAME_EDIT, !_network_server);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_CL_SERVER_NAME: case WID_CL_SERVER_NAME:
@ -1684,14 +1684,14 @@ public:
const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id); const NetworkClientInfo *own_ci = NetworkClientInfo::GetByClientID(_network_own_client_id);
SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name); SetDParamStr(0, own_ci != nullptr ? own_ci->client_name : _settings_client.network.client_name);
} }
*size = GetStringBoundingBox(STR_JUST_RAW_STRING); size = GetStringBoundingBox(STR_JUST_RAW_STRING);
size->width = std::min(size->width, static_cast<uint>(ScaleGUITrad(200))); // By default, don't open the window too wide. size.width = std::min(size.width, static_cast<uint>(ScaleGUITrad(200))); // By default, don't open the window too wide.
break; break;
case WID_CL_SERVER_VISIBILITY: case WID_CL_SERVER_VISIBILITY:
*size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY)); size = maxdim(maxdim(GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_LOCAL), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_PUBLIC)), GetStringBoundingBox(STR_NETWORK_SERVER_VISIBILITY_INVITE_ONLY));
size->width += padding.width; size.width += padding.width;
size->height += padding.height; size.height += padding.height;
break; break;
case WID_CL_MATRIX: { case WID_CL_MATRIX: {
@ -1699,10 +1699,10 @@ public:
height += WidgetDimensions::scaled.framerect.Vertical(); height += WidgetDimensions::scaled.framerect.Vertical();
this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height; this->line_height = std::max(height, (uint)GetCharacterHeight(FS_NORMAL)) + padding.height;
resize->width = 1; resize.width = 1;
resize->height = this->line_height; resize.height = this->line_height;
fill->height = this->line_height; fill.height = this->line_height;
size->height = std::max(size->height, 5 * this->line_height); size.height = std::max(size.height, 5 * this->line_height);
break; break;
} }
} }
@ -2162,28 +2162,28 @@ struct NetworkJoinStatusWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NJS_PROGRESS_BAR: case WID_NJS_PROGRESS_BAR:
/* Account for the statuses */ /* Account for the statuses */
for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) { for (uint i = 0; i < NETWORK_JOIN_STATUS_END; i++) {
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_1 + i));
} }
/* For the number of waiting (other) players */ /* For the number of waiting (other) players */
SetDParamMaxValue(0, MAX_CLIENTS); SetDParamMaxValue(0, MAX_CLIENTS);
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_WAITING));
/* We need some spacing for the 'border' */ /* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal(); size.height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical(); size.width += WidgetDimensions::scaled.frametext.Vertical();
break; break;
case WID_NJS_PROGRESS_TEXT: case WID_NJS_PROGRESS_TEXT:
/* Account for downloading ~ 10 MiB */ /* Account for downloading ~ 10 MiB */
SetDParamMaxDigits(0, 8); SetDParamMaxDigits(0, 8);
SetDParamMaxDigits(1, 8); SetDParamMaxDigits(1, 8);
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
*size = maxdim(*size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1)); size = maxdim(size, GetStringBoundingBox(STR_NETWORK_CONNECTING_DOWNLOADING_1));
break; break;
} }
} }
@ -2273,10 +2273,10 @@ struct NetworkCompanyPasswordWindow : public Window {
this->ReInit(); this->ReInit();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_NCP_WARNING) { if (widget == WID_NCP_WARNING) {
*size = this->warning_size; size = this->warning_size;
} }
} }
@ -2379,10 +2379,10 @@ struct NetworkAskRelayWindow : public Window {
this->Window::Close(); this->Window::Close();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_NAR_TEXT) { if (widget == WID_NAR_TEXT) {
*size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT); size = GetStringBoundingBox(STR_NETWORK_ASK_RELAY_TEXT);
} }
} }
@ -2482,10 +2482,10 @@ struct NetworkAskSurveyWindow : public Window {
this->InitNested(0); this->InitNested(0);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_NAS_TEXT) { if (widget == WID_NAS_TEXT) {
*size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT); size = GetStringBoundingBox(STR_NETWORK_ASK_SURVEY_TEXT);
} }
} }

View File

@ -357,21 +357,21 @@ struct NewGRFInspectWindow : Window {
GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex()); GetFeatureHelper(this->window_number)->SetStringParameters(this->GetFeatureIndex());
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NGRFI_VEH_CHAIN: { case WID_NGRFI_VEH_CHAIN: {
assert(this->HasChainIndex()); assert(this->HasChainIndex());
GrfSpecFeature f = GetFeatureNum(this->window_number); GrfSpecFeature f = GetFeatureNum(this->window_number);
size->height = std::max(size->height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical()); size.height = std::max(size.height, GetVehicleImageCellSize((VehicleType)(VEH_TRAIN + (f - GSF_TRAINS)), EIT_IN_DEPOT).height + 2 + WidgetDimensions::scaled.bevel.Vertical());
break; break;
} }
case WID_NGRFI_MAINPANEL: case WID_NGRFI_MAINPANEL:
resize->height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal); resize.height = std::max(11, GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal);
resize->width = 1; resize.width = 1;
size->height = 5 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); size.height = 5 * resize.height + WidgetDimensions::scaled.frametext.Vertical();
break; break;
} }
} }
@ -882,11 +882,11 @@ struct SpriteAlignerWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SA_SPRITE: case WID_SA_SPRITE:
size->height = ScaleGUITrad(200); size.height = ScaleGUITrad(200);
break; break;
case WID_SA_LIST: { case WID_SA_LIST: {
@ -896,10 +896,10 @@ struct SpriteAlignerWindow : Window {
SetDParamMaxDigits(1, 6); SetDParamMaxDigits(1, 6);
d = maxdim(d, GetStringBoundingBox(STR_SPRITE_ALIGNER_SPRITE)); d = maxdim(d, GetStringBoundingBox(STR_SPRITE_ALIGNER_SPRITE));
} }
size->width = d.width + padding.width; size.width = d.width + padding.width;
resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; resize.height = GetCharacterHeight(FS_NORMAL) + padding.height;
resize->width = 1; resize.width = 1;
fill->height = resize->height; fill.height = resize.height;
break; break;
} }

View File

@ -210,13 +210,13 @@ struct NewGRFParametersWindow : public Window {
return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr); return this->HasParameterInfo(nr) ? this->grf_config->param_info[nr].value() : GetDummyParameterInfo(nr);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NP_NUMPAR_DEC: case WID_NP_NUMPAR_DEC:
case WID_NP_NUMPAR_INC: { case WID_NP_NUMPAR_INC: {
size->width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL)); size.width = std::max(SETTING_BUTTON_WIDTH / 2, GetCharacterHeight(FS_NORMAL));
size->height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)); size.height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL));
break; break;
} }
@ -225,16 +225,16 @@ struct NewGRFParametersWindow : public Window {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_NP_BACKGROUND: case WID_NP_BACKGROUND:
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_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_NP_DESCRIPTION: case WID_NP_DESCRIPTION:
@ -248,7 +248,7 @@ struct NewGRFParametersWindow : public Window {
d.height += WidgetDimensions::scaled.frametext.Vertical(); d.height += WidgetDimensions::scaled.frametext.Vertical();
suggestion = maxdim(d, suggestion); suggestion = maxdim(d, suggestion);
} }
size->height = suggestion.height; size.height = suggestion.height;
break; break;
} }
} }
@ -743,34 +743,34 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_NS_FILE_LIST: case WID_NS_FILE_LIST:
{ {
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL)); resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
size->height = std::max(size->height, padding.height + 6 * resize->height); size.height = std::max(size.height, padding.height + 6 * resize.height);
break; break;
} }
case WID_NS_AVAIL_LIST: case WID_NS_AVAIL_LIST:
{ {
Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN)); Dimension d = maxdim(GetScaledSpriteSize(SPR_SQUARE), GetScaledSpriteSize(SPR_WARNING_SIGN));
resize->height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL)); resize.height = std::max<uint>(d.height + 2U, GetCharacterHeight(FS_NORMAL));
size->height = std::max(size->height, padding.height + 8 * resize->height); 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: {
Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE); Dimension dim = GetStringBoundingBox(STR_NEWGRF_SETTINGS_INFO_TITLE);
size->height = std::max(size->height, dim.height + WidgetDimensions::scaled.frametext.Vertical()); size.height = std::max(size.height, dim.height + WidgetDimensions::scaled.frametext.Vertical());
size->width = std::max(size->width, dim.width + WidgetDimensions::scaled.frametext.Horizontal()); size.width = std::max(size.width, dim.width + WidgetDimensions::scaled.frametext.Horizontal());
break; break;
} }
case WID_NS_NEWGRF_INFO: case WID_NS_NEWGRF_INFO:
size->height = std::max<uint>(size->height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL)); size.height = std::max<uint>(size.height, WidgetDimensions::scaled.framerect.Vertical() + 10 * GetCharacterHeight(FS_NORMAL));
break; break;
case WID_NS_PRESET_LIST: { case WID_NS_PRESET_LIST: {
@ -780,16 +780,16 @@ struct NewGRFWindow : public Window, NewGRFScanCallback {
d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING)); d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING));
} }
d.width += padding.width; d.width += padding.width;
*size = maxdim(d, *size); size = maxdim(d, size);
break; break;
} }
case WID_NS_CONTENT_DOWNLOAD: case WID_NS_CONTENT_DOWNLOAD:
case WID_NS_CONTENT_DOWNLOAD2: { case WID_NS_CONTENT_DOWNLOAD2: {
Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON); Dimension d = GetStringBoundingBox(STR_NEWGRF_SETTINGS_FIND_MISSING_CONTENT_BUTTON);
*size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT)); size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT));
size->width += padding.width; size.width += padding.width;
size->height += padding.height; size.height += padding.height;
break; break;
} }
} }
@ -2099,18 +2099,18 @@ struct SavePresetWindow : public Window {
{ {
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SVP_PRESET_LIST: { case WID_SVP_PRESET_LIST: {
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
size->height = 0; size.height = 0;
for (uint i = 0; i < this->presets.size(); i++) { for (uint i = 0; i < this->presets.size(); i++) {
Dimension d = GetStringBoundingBox(this->presets[i]); Dimension d = GetStringBoundingBox(this->presets[i]);
size->width = std::max(size->width, d.width + padding.width); size.width = std::max(size.width, d.width + padding.width);
resize->height = std::max(resize->height, d.height); resize.height = std::max(resize.height, d.height);
} }
size->height = ClampU((uint)this->presets.size(), 5, 20) * resize->height + padding.height; size.height = ClampU((uint)this->presets.size(), 5, 20) * resize.height + padding.height;
break; break;
} }
} }
@ -2214,15 +2214,15 @@ struct ScanProgressWindow : public Window {
this->InitNested(1); this->InitNested(1);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SP_PROGRESS_BAR: { case WID_SP_PROGRESS_BAR: {
SetDParamMaxValue(0, 100); SetDParamMaxValue(0, 100);
*size = GetStringBoundingBox(STR_GENERATION_PROGRESS); size = GetStringBoundingBox(STR_GENERATION_PROGRESS);
/* We need some spacing for the 'border' */ /* We need some spacing for the 'border' */
size->height += WidgetDimensions::scaled.frametext.Horizontal(); size.height += WidgetDimensions::scaled.frametext.Horizontal();
size->width += WidgetDimensions::scaled.frametext.Vertical(); size.width += WidgetDimensions::scaled.frametext.Vertical();
break; break;
} }
@ -2231,8 +2231,8 @@ struct ScanProgressWindow : public Window {
SetDParamMaxDigits(1, 4); SetDParamMaxDigits(1, 4);
/* We really don't know the width. We could determine it by scanning the NewGRFs, /* We really don't know the width. We could determine it by scanning the NewGRFs,
* but this is the status window for scanning them... */ * but this is the status window for scanning them... */
size->width = std::max<uint>(size->width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width); size.width = std::max<uint>(size.width, GetStringBoundingBox(STR_NEWGRF_SCAN_STATUS).width + padding.width);
size->height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal; size.height = GetCharacterHeight(FS_NORMAL) * 2 + WidgetDimensions::scaled.vsep_normal;
break; break;
} }
} }

View File

@ -358,7 +358,7 @@ struct NewsWindow : Window {
return pt; return pt;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
StringID str = STR_NULL; StringID str = STR_NULL;
switch (widget) { switch (widget) {
@ -367,12 +367,12 @@ struct NewsWindow : Window {
* thus it doesn't get the default sizing of a caption. */ * thus it doesn't get the default sizing of a caption. */
Dimension d2 = GetStringBoundingBox(STR_NEWS_MESSAGE_CAPTION); Dimension d2 = GetStringBoundingBox(STR_NEWS_MESSAGE_CAPTION);
d2.height += WidgetDimensions::scaled.captiontext.Vertical(); d2.height += WidgetDimensions::scaled.captiontext.Vertical();
*size = maxdim(*size, d2); size = maxdim(size, d2);
return; return;
} }
case WID_N_MGR_FACE: case WID_N_MGR_FACE:
*size = maxdim(*size, GetScaledSpriteSize(SPR_GRADIENT)); size = maxdim(size, GetScaledSpriteSize(SPR_GRADIENT));
break; break;
case WID_N_MGR_NAME: case WID_N_MGR_NAME:
@ -406,15 +406,15 @@ struct NewsWindow : Window {
Dimension d2 = GetStringBoundingBox(this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP)->widget_data); Dimension d2 = GetStringBoundingBox(this->GetWidget<NWidgetCore>(WID_N_SHOW_GROUP)->widget_data);
d2.height += WidgetDimensions::scaled.captiontext.Vertical(); d2.height += WidgetDimensions::scaled.captiontext.Vertical();
d2.width += WidgetDimensions::scaled.captiontext.Horizontal(); d2.width += WidgetDimensions::scaled.captiontext.Horizontal();
*size = d2; size = d2;
} else { } else {
/* Hide 'Show group window' button if this news is not about a vehicle. */ /* Hide 'Show group window' button if this news is not about a vehicle. */
size->width = 0; size.width = 0;
size->height = 0; size.height = 0;
resize->width = 0; resize.width = 0;
resize->height = 0; resize.height = 0;
fill->width = 0; fill.width = 0;
fill->height = 0; fill.height = 0;
} }
return; return;
@ -423,13 +423,13 @@ struct NewsWindow : Window {
} }
/* Update minimal size with length of the multi-line string. */ /* Update minimal size with length of the multi-line string. */
Dimension d = *size; Dimension d = size;
d.width = (d.width >= padding.width) ? d.width - padding.width : 0; d.width = (d.width >= padding.width) ? d.width - padding.width : 0;
d.height = (d.height >= padding.height) ? d.height - padding.height : 0; d.height = (d.height >= padding.height) ? d.height - padding.height : 0;
d = GetStringMultiLineBoundingBox(str, d); d = GetStringMultiLineBoundingBox(str, d);
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
} }
void SetStringParameters(WidgetID widget) const override void SetStringParameters(WidgetID widget) const override
@ -1099,19 +1099,19 @@ struct MessageHistoryWindow : Window {
this->OnInvalidateData(0); this->OnInvalidateData(0);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_MH_BACKGROUND) { if (widget == WID_MH_BACKGROUND) {
this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
resize->height = this->line_height; resize.height = this->line_height;
/* Months are off-by-one, so it's actually 8. Not using /* Months are off-by-one, so it's actually 8. Not using
* month 12 because the 1 is usually less wide. */ * month 12 because the 1 is usually less wide. */
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::ORIGINAL_MAX_YEAR, 7, 30)); SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::ORIGINAL_MAX_YEAR, 7, 30));
this->date_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width + WidgetDimensions::scaled.hsep_wide; this->date_width = GetStringBoundingBox(STR_JUST_DATE_TINY).width + WidgetDimensions::scaled.hsep_wide;
size->height = 4 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible. size.height = 4 * resize.height + WidgetDimensions::scaled.framerect.Vertical(); // At least 4 lines are visible.
size->width = std::max(200u, size->width); // At least 200 pixels wide. size.width = std::max(200u, size.width); // At least 200 pixels wide.
} }
} }

View File

@ -212,25 +212,25 @@ public:
this->object_margin = ScaleGUITrad(4); this->object_margin = ScaleGUITrad(4);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BO_CLASS_LIST: { case WID_BO_CLASS_LIST: {
for (auto object_class_id : this->object_classes) { for (auto object_class_id : this->object_classes) {
ObjectClass *objclass = ObjectClass::Get(object_class_id); ObjectClass *objclass = ObjectClass::Get(object_class_id);
if (objclass->GetUISpecCount() == 0) continue; if (objclass->GetUISpecCount() == 0) continue;
size->width = std::max(size->width, GetStringBoundingBox(objclass->name).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(objclass->name).width + padding.width);
} }
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_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;
} }
case WID_BO_OBJECT_NAME: case WID_BO_OBJECT_NAME:
case WID_BO_OBJECT_SIZE: case WID_BO_OBJECT_SIZE:
/* We do not want the window to resize when selecting objects; better clip texts */ /* We do not want the window to resize when selecting objects; better clip texts */
size->width = 0; size.width = 0;
break; break;
case WID_BO_OBJECT_MATRIX: { case WID_BO_OBJECT_MATRIX: {
@ -238,11 +238,11 @@ public:
ObjectClass *objclass = ObjectClass::Get(_selected_object_class); ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
const ObjectSpec *spec = objclass->GetSpec(_selected_object_index); const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
if (spec != nullptr) { if (spec != nullptr) {
if (spec->views >= 2) size->width += resize->width; if (spec->views >= 2) size.width += resize.width;
if (spec->views >= 4) size->height += resize->height; if (spec->views >= 4) size.height += resize.height;
} }
resize->width = 0; resize.width = 0;
resize->height = 0; resize.height = 0;
break; break;
} }
@ -267,37 +267,37 @@ public:
* we want these columns to be slightly less wide. When there are two rows, then * we want these columns to be slightly less wide. When there are two rows, then
* determine the size of the widgets based on the maximum size for a single row * determine the size of the widgets based on the maximum size for a single row
* of widgets, or just the twice the widget height of the two row ones. */ * of widgets, or just the twice the widget height of the two row ones. */
size->height = std::max(height[0], height[1] * 2); size.height = std::max(height[0], height[1] * 2);
if (two_wide) { if (two_wide) {
size->width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2; size.width = (3 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin) * 2;
} else { } else {
size->width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin; size.width = 4 * ScaleGUITrad(TILE_PIXELS) + 2 * this->object_margin;
} }
/* Get the right size for the single widget based on the current spec. */ /* Get the right size for the single widget based on the current spec. */
ObjectClass *objclass = ObjectClass::Get(_selected_object_class); ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
const ObjectSpec *spec = objclass->GetSpec(_selected_object_index); const ObjectSpec *spec = objclass->GetSpec(_selected_object_index);
if (spec != nullptr) { if (spec != nullptr) {
if (spec->views <= 1) size->width += WidgetDimensions::scaled.hsep_normal; if (spec->views <= 1) size.width += WidgetDimensions::scaled.hsep_normal;
if (spec->views <= 2) size->height += WidgetDimensions::scaled.vsep_normal; if (spec->views <= 2) size.height += WidgetDimensions::scaled.vsep_normal;
if (spec->views >= 2) size->width /= 2; if (spec->views >= 2) size.width /= 2;
if (spec->views >= 4) size->height /= 2; if (spec->views >= 4) size.height /= 2;
} }
break; break;
} }
case WID_BO_INFO: case WID_BO_INFO:
size->height = this->info_height; size.height = this->info_height;
break; break;
case WID_BO_SELECT_MATRIX: case WID_BO_SELECT_MATRIX:
fill->height = 1; fill.height = 1;
resize->height = 1; resize.height = 1;
break; break;
case WID_BO_SELECT_IMAGE: case WID_BO_SELECT_IMAGE:
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
default: break; default: break;

View File

@ -836,12 +836,12 @@ public:
this->OnInvalidateData(VIWD_MODIFY_ORDERS); this->OnInvalidateData(VIWD_MODIFY_ORDERS);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_O_ORDER_LIST: case WID_O_ORDER_LIST:
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
size->height = 6 * resize->height + padding.height; size.height = 6 * resize.height + padding.height;
break; break;
case WID_O_COND_VARIABLE: { case WID_O_COND_VARIABLE: {
@ -851,7 +851,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -862,7 +862,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -1236,7 +1236,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BRAS_NEWST_LIST: { case WID_BRAS_NEWST_LIST: {
@ -1244,17 +1244,17 @@ public:
for (auto station_class : this->station_classes) { for (auto station_class : this->station_classes) {
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 = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_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;
} }
case WID_BRAS_SHOW_NEWST_TYPE: { case WID_BRAS_SHOW_NEWST_TYPE: {
if (!_railstation.newstations) { if (!_railstation.newstations) {
size->width = 0; size.width = 0;
size->height = 0; size.height = 0;
break; break;
} }
@ -1269,24 +1269,24 @@ public:
d = maxdim(d, GetStringBoundingBox(str)); d = maxdim(d, GetStringBoundingBox(str));
} }
} }
size->width = std::max(size->width, d.width + padding.width); size.width = std::max(size.width, d.width + padding.width);
break; break;
} }
case WID_BRAS_PLATFORM_DIR_X: case WID_BRAS_PLATFORM_DIR_X:
case WID_BRAS_PLATFORM_DIR_Y: case WID_BRAS_PLATFORM_DIR_Y:
case WID_BRAS_IMAGE: case WID_BRAS_IMAGE:
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
case WID_BRAS_COVERAGE_TEXTS: case WID_BRAS_COVERAGE_TEXTS:
size->height = this->coverage_height; size.height = this->coverage_height;
break; break;
case WID_BRAS_MATRIX: case WID_BRAS_MATRIX:
fill->height = 1; fill.height = 1;
resize->height = 1; resize.height = 1;
break; break;
} }
} }
@ -1752,14 +1752,14 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) { if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
/* Two digits for signals density. */ /* Two digits for signals density. */
size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal()); size.width = std::max(size.width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
} else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) { } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
size->width = std::max(size->width, this->sig_sprite_size.width + padding.width); size.width = std::max(size.width, this->sig_sprite_size.width + padding.width);
size->height = std::max(size->height, this->sig_sprite_size.height + padding.height); size.height = std::max(size.height, this->sig_sprite_size.height + padding.height);
} }
} }
@ -1951,12 +1951,12 @@ struct BuildRailDepotWindow : public PickerWindowBase {
this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction); this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return; if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -2106,21 +2106,21 @@ struct BuildRailWaypointWindow : PickerWindowBase {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BRW_WAYPOINT_MATRIX: case WID_BRW_WAYPOINT_MATRIX:
/* Two blobs high and three wide. */ /* Two blobs high and three wide. */
size->width += resize->width * 2; size.width += resize.width * 2;
size->height += resize->height * 1; size.height += resize.height * 1;
/* Resizing in X direction only at blob size, but at pixel level in Y. */ /* Resizing in X direction only at blob size, but at pixel level in Y. */
resize->height = 1; resize.height = 1;
break; break;
case WID_BRW_WAYPOINT: case WID_BRW_WAYPOINT:
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(58) + WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
} }
} }

View File

@ -1020,12 +1020,12 @@ struct BuildRoadDepotWindow : public PickerWindowBase {
this->FinishInitNested(TRANSPORT_ROAD); this->FinishInitNested(TRANSPORT_ROAD);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return; if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -1354,7 +1354,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_BROS_NEWST_LIST: { case WID_BROS_NEWST_LIST: {
@ -1362,10 +1362,10 @@ public:
for (auto rs_class : this->roadstop_classes) { for (auto rs_class : this->roadstop_classes) {
d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name)); d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_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 = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical(); this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
size->height = 5 * this->line_height; size.height = 5 * this->line_height;
resize->height = this->line_height; resize.height = this->line_height;
break; break;
} }
@ -1380,7 +1380,7 @@ public:
d = maxdim(d, GetStringBoundingBox(str)); d = maxdim(d, GetStringBoundingBox(str));
} }
} }
size->width = std::max(size->width, d.width + padding.width); size.width = std::max(size.width, d.width + padding.width);
break; break;
} }
@ -1391,17 +1391,17 @@ public:
case WID_BROS_STATION_X: case WID_BROS_STATION_X:
case WID_BROS_STATION_Y: case WID_BROS_STATION_Y:
case WID_BROS_IMAGE: case WID_BROS_IMAGE:
size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal(); size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical(); size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
break; break;
case WID_BROS_MATRIX: case WID_BROS_MATRIX:
fill->height = 1; fill.height = 1;
resize->height = 1; resize.height = 1;
break; break;
case WID_BROS_ACCEPTANCE: case WID_BROS_ACCEPTANCE:
size->height = this->coverage_height; size.height = this->coverage_height;
break; break;
} }
} }

View File

@ -103,15 +103,15 @@ struct ScriptListWindow : public Window {
SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI); SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_LIST_CAPTION_GAMESCRIPT : STR_AI_LIST_CAPTION_AI);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_SCRL_LIST) return; if (widget != WID_SCRL_LIST) return;
this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height; this->line_height = GetCharacterHeight(FS_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;
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -341,15 +341,15 @@ struct ScriptSettingsWindow : public Window {
SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI); SetDParam(0, (this->slot == OWNER_DEITY) ? STR_AI_SETTINGS_CAPTION_GAMESCRIPT : STR_AI_SETTINGS_CAPTION_AI);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_SCRS_BACKGROUND) return; if (widget != WID_SCRS_BACKGROUND) return;
this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)) + padding.height; this->line_height = std::max(SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_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;
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override
@ -823,11 +823,11 @@ struct ScriptDebugWindow : public Window {
ScriptDebugWindow::initial_state = this->filter; ScriptDebugWindow::initial_state = this->filter;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget == WID_SCRD_LOG_PANEL) { if (widget == WID_SCRD_LOG_PANEL) {
resize->height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal; resize.height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
size->height = 14 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); size.height = 14 * resize.height + WidgetDimensions::scaled.framerect.Vertical();
} }
} }

View File

@ -648,7 +648,7 @@ struct GameOptionsWindow : Window {
if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED); if (changed) this->ReInit(0, 0, this->flags & WF_CENTERED);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_GO_TEXT_SFX_VOLUME: case WID_GO_TEXT_SFX_VOLUME:
@ -656,7 +656,7 @@ struct GameOptionsWindow : Window {
Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME)); Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -669,7 +669,7 @@ struct GameOptionsWindow : Window {
case WID_GO_BASE_SFX_DROPDOWN: case WID_GO_BASE_SFX_DROPDOWN:
case WID_GO_BASE_MUSIC_DROPDOWN: { case WID_GO_BASE_MUSIC_DROPDOWN: {
int selected; int selected;
size->width = std::max(size->width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width); size.width = std::max(size.width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
break; break;
} }
} }
@ -2364,14 +2364,14 @@ struct GameSettingsWindow : Window {
_circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED)); _circle_size = maxdim(GetSpriteSize(SPR_CIRCLE_FOLDED), GetSpriteSize(SPR_CIRCLE_UNFOLDED));
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_GS_OPTIONSPANEL: case WID_GS_OPTIONSPANEL:
resize->height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal; resize.height = SETTING_HEIGHT = std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, GetCharacterHeight(FS_NORMAL)}) + WidgetDimensions::scaled.vsep_normal;
resize->width = 1; resize.width = 1;
size->height = 5 * resize->height + WidgetDimensions::scaled.framerect.Vertical(); size.height = 5 * resize.height + WidgetDimensions::scaled.framerect.Vertical();
break; break;
case WID_GS_HELP_TEXT: { case WID_GS_HELP_TEXT: {
@ -2382,16 +2382,16 @@ struct GameSettingsWindow : Window {
}; };
for (uint i = 0; i < lengthof(setting_types); i++) { for (uint i = 0; i < lengthof(setting_types); i++) {
SetDParam(0, setting_types[i]); SetDParam(0, setting_types[i]);
size->width = std::max(size->width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(STR_CONFIG_SETTING_TYPE).width + padding.width);
} }
size->height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal + size.height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal +
std::max(size->height, GetSettingsTree().GetMaxHelpHeight(size->width)); std::max(size.height, GetSettingsTree().GetMaxHelpHeight(size.width));
break; break;
} }
case WID_GS_RESTRICT_CATEGORY: case WID_GS_RESTRICT_CATEGORY:
case WID_GS_RESTRICT_TYPE: case WID_GS_RESTRICT_TYPE:
size->width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width); size.width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
break; break;
default: default:
@ -3010,7 +3010,7 @@ struct CustomCurrencyWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
/* Set the appropriate width for the up/down buttons. */ /* Set the appropriate width for the up/down buttons. */
@ -3018,21 +3018,21 @@ struct CustomCurrencyWindow : Window {
case WID_CC_RATE_UP: case WID_CC_RATE_UP:
case WID_CC_YEAR_DOWN: case WID_CC_YEAR_DOWN:
case WID_CC_YEAR_UP: case WID_CC_YEAR_UP:
*size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT}); size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH / 2, (uint)SETTING_BUTTON_HEIGHT});
break; break;
/* Set the appropriate width for the edit buttons. */ /* Set the appropriate width for the edit buttons. */
case WID_CC_SEPARATOR_EDIT: case WID_CC_SEPARATOR_EDIT:
case WID_CC_PREFIX_EDIT: case WID_CC_PREFIX_EDIT:
case WID_CC_SUFFIX_EDIT: case WID_CC_SUFFIX_EDIT:
*size = maxdim(*size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT}); size = maxdim(size, {(uint)SETTING_BUTTON_WIDTH, (uint)SETTING_BUTTON_HEIGHT});
break; break;
/* Make sure the window is wide enough for the widest exchange rate */ /* Make sure the window is wide enough for the widest exchange rate */
case WID_CC_RATE: case WID_CC_RATE:
SetDParam(0, 1); SetDParam(0, 1);
SetDParam(1, INT32_MAX); SetDParam(1, INT32_MAX);
*size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE); size = GetStringBoundingBox(STR_CURRENCY_EXCHANGE_RATE);
break; break;
} }
} }

View File

@ -263,23 +263,23 @@ struct SignListWindow : Window, SignList {
this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical()); this->vscroll->SetCapacityFromWidget(this, WID_SIL_LIST, WidgetDimensions::scaled.framerect.Vertical());
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SIL_LIST: { case WID_SIL_LIST: {
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON); Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text. this->text_offset = WidgetDimensions::scaled.frametext.left + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
resize->height = std::max<uint>(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2); resize.height = std::max<uint>(GetCharacterHeight(FS_NORMAL), spr_dim.height + 2);
Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize->height}; Dimension d = {(uint)(this->text_offset + WidgetDimensions::scaled.frametext.right), padding.height + 5 * resize.height};
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_SIL_CAPTION: case WID_SIL_CAPTION:
SetDParamMaxValue(0, Sign::GetPoolSize(), 3); SetDParamMaxValue(0, Sign::GetPoolSize(), 3);
*size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION); size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION);
size->height += padding.height; size.height += padding.height;
size->width += padding.width; size.width += padding.width;
break; break;
} }
} }

View File

@ -411,14 +411,14 @@ public:
CompanyStationsWindow::initial_state = this->filter; CompanyStationsWindow::initial_state = this->filter;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_STL_SORTBY: { case WID_STL_SORTBY: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -429,13 +429,13 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_STL_LIST: case WID_STL_LIST:
resize->height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3)); resize.height = std::max(GetCharacterHeight(FS_NORMAL), GetCharacterHeight(FS_SMALL) + ScaleGUITrad(3));
size->height = padding.height + 5 * resize->height; 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;
@ -1392,25 +1392,25 @@ struct StationViewWindow : public Window {
data->Update(count); data->Update(count);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_SV_WAITING: case WID_SV_WAITING:
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
size->height = 4 * resize->height + padding.height; size.height = 4 * resize.height + padding.height;
this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width); this->expand_shrink_width = std::max(GetStringBoundingBox("-").width, GetStringBoundingBox("+").width);
break; break;
case WID_SV_ACCEPT_RATING_LIST: case WID_SV_ACCEPT_RATING_LIST:
size->height = ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = ((this->GetWidget<NWidgetCore>(WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) ? this->accepts_lines : this->rating_lines) * GetCharacterHeight(FS_NORMAL) + padding.height;
break; break;
case WID_SV_CLOSE_AIRPORT: case WID_SV_CLOSE_AIRPORT:
if (!(Station::Get(this->window_number)->facilities & FACIL_AIRPORT)) { if (!(Station::Get(this->window_number)->facilities & FACIL_AIRPORT)) {
/* Hide 'Close Airport' button if no airport present. */ /* Hide 'Close Airport' button if no airport present. */
size->width = 0; size.width = 0;
resize->width = 0; resize.width = 0;
fill->width = 0; fill.width = 0;
} }
break; break;
} }
@ -2305,7 +2305,7 @@ struct SelectStationWindow : Window {
this->Window::Close(); this->Window::Close();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_JS_PANEL) return; if (widget != WID_JS_PANEL) return;
@ -2319,11 +2319,11 @@ struct SelectStationWindow : Window {
d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION)); d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION));
} }
resize->height = d.height; resize.height = d.height;
d.height *= 5; d.height *= 5;
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = d; size = d;
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -83,7 +83,7 @@ struct StatusBarWindow : Window {
Window::FindWindowPlacementAndResize(_toolbar_width, def_height); Window::FindWindowPlacementAndResize(_toolbar_width, def_height);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
Dimension d; Dimension d;
switch (widget) { switch (widget) {
@ -106,7 +106,7 @@ struct StatusBarWindow : Window {
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(d, *size); size = maxdim(d, size);
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -751,7 +751,7 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return; if (widget != WID_SB_SEL_PAGE && widget != WID_SB_PAGE_PANEL) return;
@ -780,14 +780,14 @@ public:
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_SB_PAGE_PANEL: { case WID_SB_PAGE_PANEL: {
d.height *= 5; d.height *= 5;
d.height += padding.height + WidgetDimensions::scaled.frametext.Vertical(); d.height += padding.height + WidgetDimensions::scaled.frametext.Vertical();
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -131,17 +131,17 @@ struct SubsidyListWindow : Window {
return 3 + num_awarded + num_not_awarded; return 3 + num_awarded + num_not_awarded;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_SUL_PANEL) return; if (widget != WID_SUL_PANEL) return;
Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE));
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
d.height *= 5; d.height *= 5;
d.width += WidgetDimensions::scaled.framerect.Horizontal(); d.width += WidgetDimensions::scaled.framerect.Horizontal();
d.height += WidgetDimensions::scaled.framerect.Vertical(); d.height += WidgetDimensions::scaled.framerect.Vertical();
*size = maxdim(*size, d); size = maxdim(size, d);
} }
void DrawCargoIcon(const Rect &r, int y_offset, CargoID cid) const void DrawCargoIcon(const Rect &r, int y_offset, CargoID cid) const

View File

@ -553,12 +553,12 @@ struct ScenarioEditorLandscapeGenerationWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
if (widget != WID_ETT_DOTS) return; if (widget != WID_ETT_DOTS) return;
size->width = std::max<uint>(size->width, ScaleGUITrad(59)); size.width = std::max<uint>(size.width, ScaleGUITrad(59));
size->height = std::max<uint>(size->height, ScaleGUITrad(31)); size.height = std::max<uint>(size.height, ScaleGUITrad(31));
} }
void DrawWidget(const Rect &r, WidgetID widget) const override void DrawWidget(const Rect &r, WidgetID widget) const override

View File

@ -133,14 +133,14 @@ uint TextfileWindow::GetContentHeight()
return this->lines.back().bottom; return this->lines.back().bottom;
} }
/* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) /* virtual */ void TextfileWindow::UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize)
{ {
switch (widget) { switch (widget) {
case WID_TF_BACKGROUND: case WID_TF_BACKGROUND:
resize->height = GetCharacterHeight(FS_MONO); resize.height = GetCharacterHeight(FS_MONO);
size->height = 4 * resize->height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible. size.height = 4 * resize.height + WidgetDimensions::scaled.frametext.Vertical(); // At least 4 lines are visible.
size->width = std::max(200u, size->width); // At least 200 pixels wide. size.width = std::max(200u, size.width); // At least 200 pixels wide.
break; break;
} }
} }

View File

@ -23,7 +23,7 @@ struct TextfileWindow : public Window, MissingGlyphSearcher {
Scrollbar *vscroll; ///< Vertical scrollbar. Scrollbar *vscroll; ///< Vertical scrollbar.
Scrollbar *hscroll; ///< Horizontal scrollbar. Scrollbar *hscroll; ///< Horizontal scrollbar.
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override; void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override;
void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override; void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override;
void DrawWidget(const Rect &r, WidgetID widget) const override; void DrawWidget(const Rect &r, WidgetID widget) const override;
void OnResize() override; void OnResize() override;

View File

@ -248,7 +248,7 @@ struct TimetableWindow : Window {
return (travelling && v->lateness_counter < 0); return (travelling && v->lateness_counter < 0);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_VT_ARRIVAL_DEPARTURE_PANEL: case WID_VT_ARRIVAL_DEPARTURE_PANEL:
@ -256,21 +256,21 @@ struct TimetableWindow : Window {
if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) { if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) {
/* A five-digit number would fit a timetable lasting 2.7 real-world hours, which should be plenty. */ /* A five-digit number would fit a timetable lasting 2.7 real-world hours, which should be plenty. */
SetDParamMaxDigits(1, 4, FS_SMALL); SetDParamMaxDigits(1, 4, FS_SMALL);
size->width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; size.width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE).width) + WidgetDimensions::scaled.hsep_wide + padding.width;
} else { } else {
SetDParamMaxValue(1, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR), 0, FS_SMALL); SetDParamMaxValue(1, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR), 0, FS_SMALL);
size->width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_DATE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_DATE).width) + WidgetDimensions::scaled.hsep_wide + padding.width; size.width = std::max(GetStringBoundingBox(STR_TIMETABLE_ARRIVAL_DATE).width, GetStringBoundingBox(STR_TIMETABLE_DEPARTURE_DATE).width) + WidgetDimensions::scaled.hsep_wide + padding.width;
} }
[[fallthrough]]; [[fallthrough]];
case WID_VT_ARRIVAL_DEPARTURE_SELECTION: case WID_VT_ARRIVAL_DEPARTURE_SELECTION:
case WID_VT_TIMETABLE_PANEL: case WID_VT_TIMETABLE_PANEL:
resize->height = GetCharacterHeight(FS_NORMAL); resize.height = GetCharacterHeight(FS_NORMAL);
size->height = 8 * resize->height + padding.height; size.height = 8 * resize.height + padding.height;
break; break;
case WID_VT_SUMMARY_PANEL: case WID_VT_SUMMARY_PANEL:
size->height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
break; break;
} }
} }

View File

@ -2339,16 +2339,16 @@ struct ScenarioEditorToolbarWindow : Window {
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_TE_SPACER: case WID_TE_SPACER:
size->width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width; size.width = std::max(GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_OPENTTD).width, GetStringBoundingBox(STR_SCENEDIT_TOOLBAR_SCENARIO_EDITOR).width) + padding.width;
break; break;
case WID_TE_DATE: case WID_TE_DATE:
SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1)); SetDParam(0, TimerGameCalendar::ConvertYMDToDate(CalendarTime::MAX_YEAR, 0, 1));
*size = GetStringBoundingBox(STR_JUST_DATE_LONG); size = GetStringBoundingBox(STR_JUST_DATE_LONG);
break; break;
} }
} }

View File

@ -256,34 +256,34 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_TA_ACTION_INFO: { case WID_TA_ACTION_INFO: {
assert(size->width > padding.width && size->height > padding.height); assert(size.width > padding.width && size.height > padding.height);
Dimension d = {0, 0}; Dimension d = {0, 0};
for (int i = 0; i < TACT_COUNT; i++) { for (int i = 0; i < TACT_COUNT; i++) {
SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8); SetDParam(0, _price[PR_TOWN_ACTION] * _town_action_costs[i] >> 8);
d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], *size)); d = maxdim(d, GetStringMultiLineBoundingBox(this->action_tooltips[i], size));
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_TA_COMMAND_LIST: case WID_TA_COMMAND_LIST:
size->height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = (TACT_COUNT + 1) * GetCharacterHeight(FS_NORMAL) + padding.height;
size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width; size.width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width;
for (uint i = 0; i < TACT_COUNT; i++ ) { for (uint i = 0; i < TACT_COUNT; i++ ) {
size->width = std::max(size->width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width); size.width = std::max(size.width, GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTION_SMALL_ADVERTISING_CAMPAIGN + i).width + padding.width);
} }
size->width += padding.width; size.width += padding.width;
break; break;
case WID_TA_RATING_INFO: case WID_TA_RATING_INFO:
resize->height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)}); resize.height = std::max({this->icon_size.height + WidgetDimensions::scaled.vsep_normal, this->exclusive_size.height + WidgetDimensions::scaled.vsep_normal, (uint)GetCharacterHeight(FS_NORMAL)});
size->height = 9 * resize->height + padding.height; size.height = 9 * resize.height + padding.height;
break; break;
} }
} }
@ -524,11 +524,11 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_TV_INFO: case WID_TV_INFO:
size->height = GetDesiredInfoHeight(size->width) + padding.height; size.height = GetDesiredInfoHeight(size.width) + padding.height;
break; break;
} }
} }
@ -878,14 +878,14 @@ public:
} }
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_TD_SORT_ORDER: { case WID_TD_SORT_ORDER: {
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_TD_SORT_CRITERIA: { case WID_TD_SORT_CRITERIA: {
@ -895,7 +895,7 @@ public:
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_TD_LIST: { case WID_TD_LIST: {
@ -912,11 +912,11 @@ public:
Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD); Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD);
d.width += icon_size.width + 2; d.width += icon_size.width + 2;
d.height = std::max(d.height, icon_size.height); d.height = std::max(d.height, icon_size.height);
resize->height = d.height; resize.height = d.height;
d.height *= 5; d.height *= 5;
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_TD_WORLD_POPULATION: { case WID_TD_WORLD_POPULATION: {
@ -924,7 +924,7 @@ public:
Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION); Dimension d = GetStringBoundingBox(STR_TOWN_POPULATION);
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }

View File

@ -152,13 +152,13 @@ public:
this->FinishInitNested(window_number); this->FinishInitNested(window_number);
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
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 + padding.width; size.width = d.width + padding.width;
size->height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space size.height = d.height + padding.height + ScaleGUITrad(BUTTON_BOTTOM_OFFSET); // we need some more space
} }
} }

View File

@ -916,20 +916,20 @@ struct RefitWindow : public Window {
this->DrawWidgets(); this->DrawWidgets();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_VR_MATRIX: case WID_VR_MATRIX:
resize->height = GetCharacterHeight(FS_NORMAL) + padding.height; resize.height = GetCharacterHeight(FS_NORMAL) + padding.height;
size->height = resize->height * 8; size.height = resize.height * 8;
break; break;
case WID_VR_VEHICLE_PANEL_DISPLAY: case WID_VR_VEHICLE_PANEL_DISPLAY:
size->height = ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type)); size.height = ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type));
break; break;
case WID_VR_INFO: case WID_VR_INFO:
size->width = this->information_width + padding.height; size.width = this->information_width + padding.height;
break; break;
} }
} }
@ -1901,20 +1901,20 @@ public:
*this->sorting = this->vehgroups.GetListing(); *this->sorting = this->vehgroups.GetListing();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_VL_LIST: case WID_VL_LIST:
resize->height = GetVehicleListHeight(this->vli.vtype, 1); resize.height = GetVehicleListHeight(this->vli.vtype, 1);
switch (this->vli.vtype) { switch (this->vli.vtype) {
case VEH_TRAIN: case VEH_TRAIN:
case VEH_ROAD: case VEH_ROAD:
size->height = 6 * resize->height; size.height = 6 * resize.height;
break; break;
case VEH_SHIP: case VEH_SHIP:
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
size->height = 4 * resize->height; size.height = 4 * resize.height;
break; break;
default: NOT_REACHED(); default: NOT_REACHED();
} }
@ -1924,31 +1924,31 @@ public:
Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data); Dimension d = GetStringBoundingBox(this->GetWidget<NWidgetCore>(widget)->widget_data);
d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better.
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
case WID_VL_GROUP_BY_PULLDOWN: case WID_VL_GROUP_BY_PULLDOWN:
size->width = GetStringListWidth(this->vehicle_group_by_names) + padding.width; size.width = GetStringListWidth(this->vehicle_group_by_names) + padding.width;
break; break;
case WID_VL_SORT_BY_PULLDOWN: case WID_VL_SORT_BY_PULLDOWN:
size->width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar); size.width = GetStringListWidth(this->vehicle_group_none_sorter_names_calendar);
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_none_sorter_names_wallclock));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_calendar));
size->width = std::max(size->width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock)); size.width = std::max(size.width, GetStringListWidth(this->vehicle_group_shared_orders_sorter_names_wallclock));
size->width += padding.width; size.width += padding.width;
break; break;
case WID_VL_FILTER_BY_CARGO: case WID_VL_FILTER_BY_CARGO:
size->width = std::max(size->width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width); size.width = std::max(size.width, GetDropDownListDimension(this->BuildCargoDropDownList(true)).width + padding.width);
break; break;
case WID_VL_MANAGE_VEHICLES_DROPDOWN: { case WID_VL_MANAGE_VEHICLES_DROPDOWN: {
Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false, true); Dimension d = this->GetActionDropdownSize(this->vli.type == VL_STANDARD, false, true);
d.height += padding.height; d.height += padding.height;
d.width += padding.width; d.width += padding.width;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
} }
@ -2424,12 +2424,12 @@ struct VehicleDetailsWindow : Window {
return desired_height; return desired_height;
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
switch (widget) { switch (widget) {
case WID_VD_TOP_DETAILS: { case WID_VD_TOP_DETAILS: {
Dimension dim = { 0, 0 }; Dimension dim = { 0, 0 };
size->height = 4 * GetCharacterHeight(FS_NORMAL) + padding.height; size.height = 4 * GetCharacterHeight(FS_NORMAL) + padding.height;
for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX); for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX);
static const StringID info_strings[] = { static const StringID info_strings[] = {
@ -2445,7 +2445,7 @@ struct VehicleDetailsWindow : Window {
} }
SetDParam(0, STR_VEHICLE_INFO_AGE); SetDParam(0, STR_VEHICLE_INFO_AGE);
dim = maxdim(dim, GetStringBoundingBox(TimerGameEconomy::UsingWallclockUnits() ? STR_VEHICLE_INFO_AGE_RUNNING_COST_PERIOD : STR_VEHICLE_INFO_AGE_RUNNING_COST_YR)); dim = maxdim(dim, GetStringBoundingBox(TimerGameEconomy::UsingWallclockUnits() ? STR_VEHICLE_INFO_AGE_RUNNING_COST_PERIOD : STR_VEHICLE_INFO_AGE_RUNNING_COST_YR));
size->width = dim.width + padding.width; size.width = dim.width + padding.width;
break; break;
} }
@ -2453,15 +2453,15 @@ struct VehicleDetailsWindow : Window {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
switch (v->type) { switch (v->type) {
case VEH_ROAD: case VEH_ROAD:
size->height = this->GetRoadVehDetailsHeight(v) + padding.height; size.height = this->GetRoadVehDetailsHeight(v) + padding.height;
break; break;
case VEH_SHIP: case VEH_SHIP:
size->height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; size.height = 4 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height;
break; break;
case VEH_AIRCRAFT: case VEH_AIRCRAFT:
size->height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height; size.height = 5 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal * 2 + padding.height;
break; break;
default: default:
@ -2471,8 +2471,8 @@ struct VehicleDetailsWindow : Window {
} }
case WID_VD_MATRIX: case WID_VD_MATRIX:
resize->height = std::max<uint>(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height); resize.height = std::max<uint>(ScaleGUITrad(14), GetCharacterHeight(FS_NORMAL) + padding.height);
size->height = 4 * resize->height; size.height = 4 * resize.height;
break; break;
case WID_VD_SERVICE_INTERVAL_DROPDOWN: { case WID_VD_SERVICE_INTERVAL_DROPDOWN: {
@ -2484,7 +2484,7 @@ struct VehicleDetailsWindow : Window {
} }
d.width += padding.width; d.width += padding.width;
d.height += padding.height; d.height += padding.height;
*size = maxdim(*size, d); size = maxdim(size, d);
break; break;
} }
@ -2501,11 +2501,11 @@ struct VehicleDetailsWindow : Window {
/*/ Vehicle was last serviced at year 0, and we're at max year */ /*/ Vehicle was last serviced at year 0, and we're at max year */
SetDParamMaxValue(2, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR)); SetDParamMaxValue(2, TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR));
} }
size->width = std::max( size.width = std::max(
GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width, GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_PERCENT).width,
GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width GetStringBoundingBox(STR_VEHICLE_DETAILS_SERVICING_INTERVAL_DAYS).width
) + padding.width; ) + padding.width;
size->height = GetCharacterHeight(FS_NORMAL) + padding.height; size.height = GetCharacterHeight(FS_NORMAL) + padding.height;
break; break;
} }
} }
@ -3037,24 +3037,24 @@ public:
this->Window::Close(); this->Window::Close();
} }
void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
{ {
const Vehicle *v = Vehicle::Get(this->window_number); const Vehicle *v = Vehicle::Get(this->window_number);
switch (widget) { switch (widget) {
case WID_VV_START_STOP: case WID_VV_START_STOP:
size->height = std::max<uint>({size->height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height; size.height = std::max<uint>({size.height, (uint)GetCharacterHeight(FS_NORMAL), GetScaledSpriteSize(SPR_WARNING_SIGN).height, GetScaledSpriteSize(SPR_FLAG_VEH_STOPPED).height, GetScaledSpriteSize(SPR_FLAG_VEH_RUNNING).height}) + padding.height;
break; break;
case WID_VV_FORCE_PROCEED: case WID_VV_FORCE_PROCEED:
if (v->type != VEH_TRAIN) { if (v->type != VEH_TRAIN) {
size->height = 0; size.height = 0;
size->width = 0; size.width = 0;
} }
break; break;
case WID_VV_VIEWPORT: case WID_VV_VIEWPORT:
size->width = VV_INITIAL_VIEWPORT_WIDTH; size.width = VV_INITIAL_VIEWPORT_WIDTH;
size->height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT; size.height = (v->type == VEH_TRAIN) ? VV_INITIAL_VIEWPORT_HEIGHT_TRAIN : VV_INITIAL_VIEWPORT_HEIGHT;
break; break;
} }
} }

View File

@ -1216,7 +1216,7 @@ void NWidgetStacked::SetupSmallestSize(Window *w)
Dimension fill = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)}; Dimension fill = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)};
Dimension resize = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)}; Dimension resize = {(this->shown_plane == SZSP_HORIZONTAL), (this->shown_plane == SZSP_VERTICAL)};
/* Here we're primarily interested in the value of resize */ /* Here we're primarily interested in the value of resize */
if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize);
this->smallest_x = size.width; this->smallest_x = size.width;
this->smallest_y = size.height; this->smallest_y = size.height;
@ -1833,7 +1833,7 @@ void NWidgetMatrix::SetupSmallestSize(Window *w)
Dimension fill = {0, 0}; Dimension fill = {0, 0};
Dimension resize = {this->pip_inter + this->children.front()->smallest_x, this->pip_inter + this->children.front()->smallest_y}; Dimension resize = {this->pip_inter + this->children.front()->smallest_x, this->pip_inter + this->children.front()->smallest_y};
if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize);
this->smallest_x = size.width; this->smallest_x = size.width;
this->smallest_y = size.height; this->smallest_y = size.height;
@ -2108,7 +2108,7 @@ void NWidgetBackground::SetupSmallestSize(Window *w)
case WWT_FRAME: padding = {WidgetDimensions::scaled.frametext.Horizontal(), WidgetDimensions::scaled.frametext.Vertical()}; break; case WWT_FRAME: padding = {WidgetDimensions::scaled.frametext.Horizontal(), WidgetDimensions::scaled.frametext.Vertical()}; break;
case WWT_INSET: padding = {WidgetDimensions::scaled.inset.Horizontal(), WidgetDimensions::scaled.inset.Vertical()}; break; case WWT_INSET: padding = {WidgetDimensions::scaled.inset.Horizontal(), WidgetDimensions::scaled.inset.Vertical()}; break;
} }
w->UpdateWidgetSize(this->index, &d, padding, &fill, &resize); w->UpdateWidgetSize(this->index, d, padding, fill, resize);
} }
} }
this->smallest_x = d.width; this->smallest_x = d.width;
@ -2730,7 +2730,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w)
NOT_REACHED(); NOT_REACHED();
} }
if (this->index >= 0) w->UpdateWidgetSize(this->index, &size, padding, &fill, &resize); if (this->index >= 0) w->UpdateWidgetSize(this->index, size, padding, fill, resize);
this->smallest_x = size.width; this->smallest_x = size.width;
this->smallest_y = size.height; this->smallest_y = size.height;

View File

@ -611,12 +611,12 @@ public:
* and \a resize is taken to contain the resize steps. For the convenience of the callee, \a padding contains the amount of * and \a resize is taken to contain the resize steps. For the convenience of the callee, \a padding contains the amount of
* padding between the content and the edge of the widget. This should be added to the returned size. * padding between the content and the edge of the widget. This should be added to the returned size.
* @param widget Widget number. * @param widget Widget number.
* @param size Size of the widget. * @param[in,out] size Size of the widget.
* @param padding Recommended amount of space between the widget content and the widget edge. * @param padding Recommended amount of space between the widget content and the widget edge.
* @param fill Fill step of the widget. * @param[in,out] fill Fill step of the widget.
* @param resize Resize step of the widget. * @param[in,out] resize Resize step of the widget.
*/ */
virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) {} virtual void UpdateWidgetSize([[maybe_unused]] WidgetID widget, [[maybe_unused]] Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) {}
/** /**
* Initialize string parameters for a widget. * Initialize string parameters for a widget.