From 9d9528b14e2a163b4fa0b7b504168c6490101053 Mon Sep 17 00:00:00 2001 From: Sergii Pylypenko Date: Fri, 7 May 2021 22:52:01 +0300 Subject: [PATCH] Renamed GetMinSizing() to GetMinButtonSize(), we do not use it for anything but button size --- src/ai/ai_gui.cpp | 16 ++++++-------- src/airport_gui.cpp | 4 ++-- src/bridge_gui.cpp | 2 +- src/build_confirmation_gui.cpp | 4 ++-- src/build_vehicle_gui.cpp | 4 ++-- src/company_gui.cpp | 6 +++--- src/depot_gui.cpp | 2 +- src/fios_gui.cpp | 2 +- src/genworld_gui.cpp | 6 +++--- src/group_gui.cpp | 2 +- src/industry_gui.cpp | 14 ++++++------ src/misc_gui.cpp | 12 +++++------ src/music_gui.cpp | 2 +- src/network/network_chat_gui.cpp | 6 +++--- src/network/network_content_gui.cpp | 2 +- src/network/network_gui.cpp | 10 ++++----- src/newgrf_debug_gui.cpp | 2 +- src/newgrf_gui.cpp | 8 +++---- src/news_gui.cpp | 6 +++--- src/order_gui.cpp | 2 +- src/rail_gui.cpp | 4 ++-- src/settings_gui.cpp | 2 +- src/signs_gui.cpp | 2 +- src/smallmap_gui.cpp | 2 +- src/station_gui.cpp | 6 +++--- src/statusbar_gui.cpp | 2 +- src/subsidy_gui.cpp | 16 +++++++------- src/timetable_gui.cpp | 2 +- src/toolbar_gui.cpp | 2 +- src/town_gui.cpp | 6 +++--- src/vehicle_gui.cpp | 6 +++--- src/widget.cpp | 33 +++++++++++------------------ src/widget_type.h | 2 +- src/widgets/dropdown_type.h | 2 +- src/window.cpp | 26 +++++++++++------------ 35 files changed, 106 insertions(+), 119 deletions(-) diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp index eb663ba353..d9e666d0e1 100644 --- a/src/ai/ai_gui.cpp +++ b/src/ai/ai_gui.cpp @@ -111,7 +111,7 @@ struct AIListWindow : public Window { { if (widget == WID_AIL_LIST) { this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - this->line_height = GetMinSizing(NWST_BUTTON, this->line_height); + this->line_height = GetMinButtonSize(this->line_height); resize->width = 1; resize->height = this->line_height; @@ -352,7 +352,7 @@ struct AISettingsWindow : public Window { { if (widget == WID_AIS_BACKGROUND) { this->line_height = std::max(SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - this->line_height = GetMinSizing(NWST_BUTTON, this->line_height); + this->line_height = GetMinButtonSize(this->line_height); resize->width = 1; resize->height = this->line_height; @@ -692,11 +692,7 @@ static const NWidgetPart _nested_ai_config_widgets[] = { EndContainer(), NWidget(NWID_VERTICAL), SetPIP(4, 4, 4), NWidget(WWT_FRAME, COLOUR_MAUVE), SetDataTip(STR_AI_CONFIG_GAMESCRIPT, STR_NULL), SetPadding(0, 5, 4, 5), -<<<<<<< HEAD NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIC_GAMELIST), SetMinimalSize(288, 14), SetFill(1, 0), SetMatrixDataTip(1, 1, STR_AI_CONFIG_GAMELIST_TOOLTIP), -======= - NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIC_GAMELIST), SetSizingType(NWST_BUTTON), SetMinimalSize(288, 14), SetFill(1, 0), SetMatrixDataTip(1, 1, STR_AI_CONFIG_GAMELIST_TOOLTIP), ->>>>>>> e80df6ae8... Removed NWST_STEP and min_step, we don't need two variables doing the same thing EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), SetPIP(7, 0, 7), NWidget(WWT_PUSHTXTBTN, COLOUR_YELLOW, WID_AIC_CHANGE), SetFill(1, 0), SetMinimalSize(93, 0), SetDataTip(STR_AI_CONFIG_CHANGE, STR_AI_CONFIG_CHANGE_TOOLTIP), @@ -775,13 +771,13 @@ struct AIConfigWindow : public Window { { switch (widget) { case WID_AIC_GAMELIST: - this->line_height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM); + this->line_height = GetMinButtonSize(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM); size->height = this->line_height; break; case WID_AIC_LIST: this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - this->line_height = GetMinSizing(NWST_BUTTON, this->line_height); + this->line_height = GetMinButtonSize(NWST_BUTTON, this->line_height); resize->height = this->line_height; size->height = 8 * this->line_height; break; @@ -1104,7 +1100,7 @@ struct AIDebugWindow : public Window { void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_AID_LOG_PANEL) { - resize->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL); + resize->height = GetMinButtonSize(FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL); size->height = 14 * resize->height + this->top_offset + this->bottom_offset; } } @@ -1121,7 +1117,7 @@ struct AIDebugWindow : public Window { bool dirty = false; Dimension d = GetSpriteSize(SPR_COMPANY_ICON); - uint offset_y = Center(0, GetMinSizing(NWST_BUTTON, d.height + WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1), d.height); + uint offset_y = Center(0, GetMinButtonSize(d.height + WD_MATRIX_TOP + WD_MATRIX_BOTTOM + 1), d.height); /* Paint the company icons */ for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) { NWidgetCore *button = this->GetWidget(i + WID_AID_COMPANY_BUTTON_START); diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index b461b19435..3231a72787 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -335,7 +335,7 @@ public: d.width += padding.width; d.height += padding.height; *size = maxdim(*size, d); - size->height = GetMinSizing(NWST_BUTTON, size->height); + size->height = GetMinButtonSize(size->height); break; } @@ -347,7 +347,7 @@ public: size->width = std::max(size->width, GetStringBoundingBox(as->name).width); } - this->line_height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM); + this->line_height = GetMinButtonSize(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM); size->height = 5 * this->line_height; break; } diff --git a/src/bridge_gui.cpp b/src/bridge_gui.cpp index 2f3dfd03ad..b223ace385 100644 --- a/src/bridge_gui.cpp +++ b/src/bridge_gui.cpp @@ -199,7 +199,7 @@ public: sprite_dim.height++; // Sprite is rendered one pixel down in the matrix field. text_dim.height++; // Allowing the bottom row pixels to be rendered on the edge of the matrix field. resize->height = std::max(sprite_dim.height, text_dim.height) + 2; // Max of both sizes + account for matrix edges. - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); this->bridgetext_offset = WD_MATRIX_LEFT + sprite_dim.width + 1; // Left edge of text, 1 pixel distance from the sprite. size->width = this->bridgetext_offset + text_dim.width + WD_MATRIX_RIGHT; diff --git a/src/build_confirmation_gui.cpp b/src/build_confirmation_gui.cpp index 6467fef1e2..9175244902 100644 --- a/src/build_confirmation_gui.cpp +++ b/src/build_confirmation_gui.cpp @@ -188,8 +188,8 @@ struct BuildConfirmationWindow : Window { { switch (widget) { case WID_BC_OK: - size->width = GetMinSizing(NWST_BUTTON) * 2; - size->height = GetMinSizing(NWST_BUTTON) * 3; + size->width = GetMinButtonSize() * 2; + size->height = GetMinButtonSize() * 3; break; } } diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index d91df2118d..d7f544b539 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -45,7 +45,7 @@ uint GetEngineListHeight(VehicleType type) { uint size = std::max(FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM, GetVehicleImageCellSize(type, EIT_PURCHASE).height); - return GetMinSizing(NWST_BUTTON, size); + return GetMinButtonSize(size); } static const NWidgetPart _nested_build_vehicle_widgets[] = { @@ -1566,7 +1566,7 @@ struct BuildVehicleWindow : Window { Dimension d = GetStringBoundingBox(this->GetWidget(widget)->widget_data); d.width += padding.width + Window::SortButtonWidth() * 2; // Doubled since the string is centred and it also looks better. d.height += padding.height; - d.height = GetMinSizing(NWST_BUTTON, d.height); + d.height = GetMinButtonSize(d.height); *size = maxdim(*size, d); break; } diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 525b7290c2..571dd3a7a8 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -524,7 +524,7 @@ public: uint Height(uint width) const override { - return GetMinSizing(NWST_BUTTON, std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + 2)); + return GetMinButtonSize(std::max(FONT_HEIGHT_NORMAL, ScaleGUITrad(12) + 2)); } bool Selectable() const override @@ -1385,8 +1385,8 @@ public: yesno_dim.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; yesno_dim.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; - yesno_dim.width = GetMinSizing(NWST_BUTTON, yesno_dim.width); - yesno_dim.height = GetMinSizing(NWST_BUTTON, yesno_dim.height); + yesno_dim.width = GetMinButtonSize(yesno_dim.width); + yesno_dim.height = GetMinButtonSize(yesno_dim.height); /* Size of the number button + arrows. */ Dimension number_dim = {0, 0}; diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 5a6cdb790e..1525b08fce 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -678,7 +678,7 @@ struct DepotWindow : Window { int base_width = this->count_width + this->header_width; resize->height = std::max(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height); - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); if (this->type == VEH_TRAIN) { resize->width = 1; size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp index f53fc92034..737e89c08c 100644 --- a/src/fios_gui.cpp +++ b/src/fios_gui.cpp @@ -569,7 +569,7 @@ public: break; case WID_SL_DRIVES_DIRECTORIES_LIST: - resize->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + resize->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); size->height = resize->height * 5 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; break; case WID_SL_SORT_BYNAME: diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 2ffa1110c1..5dd1684574 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -530,7 +530,7 @@ struct GenerateLandscapeWindow : public Window { case WID_GL_MAPSIZE_Y_PULLDOWN: SetDParamMaxValue(0, MAX_MAP_SIZE); *size = maxdim(*size, GetStringBoundingBox(STR_JUST_INT)); - size->width = size->width + GetMinSizing(NWST_BUTTON); + size->width = size->width + GetMinButtonSize(); break; case WID_GL_SNOW_COVERAGE_TEXT: @@ -1079,9 +1079,9 @@ struct CreateScenarioWindow : public Window } *size = maxdim(*size, GetStringBoundingBox(str)); size->width += padding.width; - size->width = GetMinSizing(NWST_BUTTON, size->width); + size->width = GetMinButtonSize(size->width); size->height += padding.height; - size->height = GetMinSizing(NWST_BUTTON, size->height); + size->height = GetMinButtonSize(size->height); } void OnClick(Point pt, int widget, int click_count) override diff --git a/src/group_gui.cpp b/src/group_gui.cpp index c49998525b..2a276317cc 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -230,7 +230,7 @@ private: this->tiny_step_height = std::max(this->tiny_step_height, this->column_size[VGC_NUMBER].height); this->tiny_step_height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; - this->tiny_step_height = GetMinSizing(NWST_BUTTON, this->tiny_step_height); + this->tiny_step_height = GetMinButtonSize(this->tiny_step_height); return WD_FRAMERECT_LEFT + 8 + this->column_size[VGC_FOLD].width + 2 + diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 186fb948dc..44d6684dc9 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -428,7 +428,7 @@ public: d = maxdim(d, GetStringBoundingBox(GetIndustrySpec(this->index[i])->name)); } resize->height = std::max(this->legend.height, FONT_HEIGHT_NORMAL) + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); d.width += this->legend.width + ScaleFontTrad(7) + padding.width; d.height = 5 * resize->height; *size = maxdim(*size, d); @@ -941,7 +941,7 @@ public: if (first) { if (has_accept) y += WD_PAR_VSEP_WIDE; DrawString(left + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LAST_MONTH_TITLE); - y += this->editable == EA_RATE ? GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL) : FONT_HEIGHT_NORMAL; + y += this->editable == EA_RATE ? GetMinButtonSize(FONT_HEIGHT_NORMAL) : FONT_HEIGHT_NORMAL; if (this->editable == EA_RATE) this->production_offset_y = y; first = false; } @@ -956,7 +956,7 @@ public: if (this->editable == EA_RATE) { DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_RATE1 + j) ? this->clicked_button : 0, i->production_rate[j] > 0, i->production_rate[j] < 255); - y += GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + y += GetMinButtonSize(FONT_HEIGHT_NORMAL); } else { y += FONT_HEIGHT_NORMAL; } @@ -971,7 +971,7 @@ public: DrawString(x, right - WD_FRAMERECT_RIGHT, y, STR_INDUSTRY_VIEW_PRODUCTION_LEVEL); DrawArrowButtons(left + WD_FRAMETEXT_LEFT, y, COLOUR_YELLOW, (this->clicked_line == IL_MULTIPLIER) ? this->clicked_button : 0, i->prod_level > PRODLEVEL_MINIMUM, i->prod_level < PRODLEVEL_MAXIMUM); - y += GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + y += GetMinButtonSize(FONT_HEIGHT_NORMAL); } /* Get the extra message for the GUI */ @@ -1031,9 +1031,9 @@ public: case EA_RATE: if (pt.y >= this->production_offset_y) { - if ((pt.y - this->production_offset_y) % GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL) > (uint)SETTING_BUTTON_HEIGHT) break;; + if ((pt.y - this->production_offset_y) % GetMinButtonSize(FONT_HEIGHT_NORMAL) > (uint)SETTING_BUTTON_HEIGHT) break;; - int row = (pt.y - this->production_offset_y) / GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + int row = (pt.y - this->production_offset_y) / GetMinButtonSize(FONT_HEIGHT_NORMAL); for (uint j = 0; j < lengthof(i->produced_cargo); j++) { if (i->produced_cargo[j] == CT_INVALID) continue; row--; @@ -1683,7 +1683,7 @@ public: for (uint i = 0; i < this->industries.size(); i++) { d = maxdim(d, GetStringBoundingBox(this->GetIndustryString(this->industries[i]))); } - resize->height = d.height = GetMinSizing(NWST_BUTTON, d.height); + resize->height = d.height = GetMinButtonSize(d.height); d.height *= 5; d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.height += padding.height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp index 849077a9d1..41a3a5284d 100644 --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -734,15 +734,15 @@ struct TooltipsWindow : public Window /* Correctly position the tooltip position, watch out for window and cursor size * Clamp value to below main toolbar and above statusbar. If tooltip would * go below window, flip it so it is shown above the cursor */ - pt.y = std::min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height - GetMinSizing(NWST_BUTTON); - if (pt.y < scr_top) pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot) + GetMinSizing(NWST_BUTTON); + pt.y = std::min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height - GetMinButtonSize(); + if (pt.y < scr_top) pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot) + GetMinButtonSize(); pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width); if (_settings_client.gui.windows_titlebars) { // Move it to the top of the screen, away from mouse cursor, so it won't steal screen taps on Android pt.y = GetMainViewTop(); - if (_cursor.pos.y < pt.y + (int)GetMinSizing(NWST_BUTTON)) { - pt.x = _cursor.pos.x > _screen.width / 2 ? GetMinSizing(NWST_BUTTON) : _screen.width - sm_width - GetMinSizing(NWST_BUTTON); + if (_cursor.pos.y < pt.y + (int)GetMinButtonSize()) { + pt.x = _cursor.pos.x > _screen.width / 2 ? GetMinButtonSize() : _screen.width - sm_width - GetMinButtonSize(); } } @@ -841,7 +841,7 @@ void QueryString::DrawEditBox(const Window *w, int wid) const bool rtl = _current_text_dir == TD_RTL; Dimension sprite_size = GetSpriteSize(rtl ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT); - int clearbtn_width = GetMinSizing(NWST_BUTTON, sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT); + int clearbtn_width = GetMinButtonSize(sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT); clearbtn_width = 0; // Touch interface has it's own keyboard input, and it won't leave space for edit field int clearbtn_left = wi->pos_x + (rtl ? 0 : wi->current_x - clearbtn_width); @@ -1234,7 +1234,7 @@ struct QueryWindow : public Window { { if (widget != WID_Q_TEXT) return; - size->width = std::max(GetMinSizing(NWST_BUTTON) * 8, size->width); + size->width = std::max(GetMinButtonSize() * 8, size->width); Dimension d = GetStringMultiLineBoundingBox(this->message, *size); d.width += WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT; d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; diff --git a/src/music_gui.cpp b/src/music_gui.cpp index 80080b7917..42b7de320b 100644 --- a/src/music_gui.cpp +++ b/src/music_gui.cpp @@ -528,7 +528,7 @@ struct MusicTrackSelectionWindow : public Window { SetDParamStr(2, song->songname); d = maxdim(d, GetStringBoundingBox(STR_PLAYLIST_TRACK_NAME)); } - resize->height = GetMinSizing(NWST_BUTTON, d.height); + resize->height = GetMinButtonSize(d.height); d.width += WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; d.height = 7 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; *size = maxdim(*size, d); diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp index 9f9beefb75..04ffc13fe2 100644 --- a/src/network/network_chat_gui.cpp +++ b/src/network/network_chat_gui.cpp @@ -114,7 +114,7 @@ void CDECL NetworkAddChatMessage(TextColour colour, uint duration, const char *m /** Initialize all font-dependent chat box sizes. */ void NetworkReInitChatBoxSize() { - _chatmsg_box.y = GetMinSizing(NWST_BUTTON, 10) + 5; + _chatmsg_box.y = GetMinButtonSize(10) + 5; _chatmsg_box.height = MAX_CHAT_MESSAGES * (FONT_HEIGHT_NORMAL + NETWORK_CHAT_LINE_SPACING) + 4; _chatmessage_backup = ReallocT(_chatmessage_backup, _chatmsg_box.width * _chatmsg_box.height * BlitterFactory::GetCurrentBlitter()->GetBytesPerPixel()); } @@ -125,7 +125,7 @@ void NetworkInitChatMessage() MAX_CHAT_MESSAGES = _settings_client.gui.network_chat_box_height; _chatmsg_list.clear(); - _chatmsg_box.x = GetMinSizing(NWST_BUTTON, 10) + 5; + _chatmsg_box.x = GetMinButtonSize(10) + 5; _chatmsg_box.width = _settings_client.gui.network_chat_box_width_pct * _screen.width / 100; NetworkReInitChatBoxSize(); _chatmessage_visible = false; @@ -458,7 +458,7 @@ struct NetworkChatWindow : public Window { Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number) override { - Point pt = { (int)GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL) * 2, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; + Point pt = { (int)GetMinButtonSize(FONT_HEIGHT_NORMAL) * 2, _screen.height - sm_height - FindWindowById(WC_STATUS_BAR, 0)->height }; return pt; } diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp index ace3e35f66..a4da317f0d 100644 --- a/src/network/network_content_gui.cpp +++ b/src/network/network_content_gui.cpp @@ -565,7 +565,7 @@ public: break; case WID_NCL_CHECKBOX: - size->width = GetMinSizing(NWST_BUTTON, this->checkbox_size.width) + WD_MATRIX_RIGHT + WD_MATRIX_LEFT; + size->width = GetMinButtonSize(this->checkbox_size.width) + WD_MATRIX_RIGHT + WD_MATRIX_LEFT; break; case WID_NCL_TYPE: { diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 816c705dc1..338182a836 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -496,14 +496,14 @@ public: switch (widget) { case WID_NG_MATRIX: resize->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM; - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); fill->height = resize->height; size->height = 5 * resize->height; break; case WID_NG_LASTJOINED: size->height = WD_MATRIX_TOP + std::max(GetSpriteSize(SPR_BLOT).height, (uint)FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM; - size->height = GetMinSizing(NWST_BUTTON, size->height); + size->height = GetMinButtonSize(size->height); break; case WID_NG_LASTJOINED_SPACER: @@ -1023,9 +1023,9 @@ struct NetworkStartServerWindow : public Window { case WID_NSS_CONNTYPE_BTN: *size = maxdim(GetStringBoundingBox(_server_visibility_dropdown[0]), GetStringBoundingBox(_server_visibility_dropdown[1])); size->width += padding.width; - size->width = GetMinSizing(NWST_BUTTON, size->width); + size->width = GetMinButtonSize(size->width); size->height += padding.height; - size->height = GetMinSizing(NWST_BUTTON, size->height); + size->height = GetMinButtonSize(size->height); break; } } @@ -1303,7 +1303,7 @@ struct NetworkLobbyWindow : public Window { case WID_NL_MATRIX: resize->height = WD_MATRIX_TOP + std::max(std::max(GetSpriteSize(SPR_LOCK).height, GetSpriteSize(SPR_PROFIT_LOT).height), FONT_HEIGHT_NORMAL) + WD_MATRIX_BOTTOM; - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); size->height = 6 * resize->height; break; diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp index 847f66fd1b..6020058445 100644 --- a/src/newgrf_debug_gui.cpp +++ b/src/newgrf_debug_gui.cpp @@ -864,7 +864,7 @@ struct SpriteAlignerWindow : Window { break; case WID_SA_LIST: resize->height = FONT_HEIGHT_NORMAL + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); resize->width = 1; fill->height = resize->height; break; diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp index 7c75dfe163..d0ec55bf6b 100644 --- a/src/newgrf_gui.cpp +++ b/src/newgrf_gui.cpp @@ -726,14 +726,14 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { { Dimension d = maxdim(GetSpriteSize(SPR_SQUARE), GetSpriteSize(SPR_WARNING_SIGN)); resize->height = std::max(d.height + 2U, FONT_HEIGHT_NORMAL + 2U); - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); size->height = std::max(size->height, WD_FRAMERECT_TOP + 4 * resize->height + WD_FRAMERECT_BOTTOM); break; } case WID_NS_AVAIL_LIST: resize->height = std::max(12, FONT_HEIGHT_NORMAL + 2); - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); size->height = std::max(size->height, WD_FRAMERECT_TOP + 4 * resize->height + WD_FRAMERECT_BOTTOM); break; @@ -755,7 +755,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { d = maxdim(d, GetStringBoundingBox(STR_JUST_RAW_STRING)); } d.width += padding.width; - d.height = GetMinSizing(NWST_BUTTON, d.height); + d.height = GetMinButtonSize(d.height); *size = maxdim(d, *size); break; } @@ -766,7 +766,7 @@ struct NewGRFWindow : public Window, NewGRFScanCallback { *size = maxdim(d, GetStringBoundingBox(STR_INTRO_ONLINE_CONTENT)); size->width += padding.width; size->height += padding.height; - size->height = GetMinSizing(NWST_BUTTON, size->height); + size->height = GetMinButtonSize(size->height); break; } } diff --git a/src/news_gui.cpp b/src/news_gui.cpp index 24cdb857c1..8f4d3c060b 100644 --- a/src/news_gui.cpp +++ b/src/news_gui.cpp @@ -362,7 +362,7 @@ struct NewsWindow : Window { break; case WID_N_MESSAGE: - size->width = std::max(GetMinSizing(NWST_BUTTON) * 8, size->width); + size->width = std::max(GetMinButtonSize() * 8, size->width); CopyInDParam(0, this->ni->params, lengthof(this->ni->params)); str = this->ni->string_id; break; @@ -388,7 +388,7 @@ struct NewsWindow : Window { Dimension d2 = GetStringBoundingBox(this->GetWidget(WID_N_SHOW_GROUP)->widget_data); d2.height += WD_CAPTIONTEXT_TOP + WD_CAPTIONTEXT_BOTTOM; d2.width += WD_CAPTIONTEXT_LEFT + WD_CAPTIONTEXT_RIGHT; - d2.width = std::max(d2.width, GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL)); + d2.width = std::max(d2.width, GetMinButtonSize(FONT_HEIGHT_NORMAL)); *size = d2; } else { /* Hide 'Show group window' button if this news is not about a vehicle. */ @@ -1141,7 +1141,7 @@ struct MessageHistoryWindow : Window { void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override { if (widget == WID_MH_BACKGROUND) { - this->line_height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL + 2); + this->line_height = GetMinButtonSize(FONT_HEIGHT_NORMAL + 2); resize->height = this->line_height; /* Months are off-by-one, so it's actually 8. Not using diff --git a/src/order_gui.cpp b/src/order_gui.cpp index a2381b15d5..2e567d9039 100644 --- a/src/order_gui.cpp +++ b/src/order_gui.cpp @@ -793,7 +793,7 @@ public: { switch (widget) { case WID_O_ORDER_LIST: - resize->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + resize->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); size->height = 4 * resize->height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; break; diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 156d7bb5ce..c82fd1c218 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1248,7 +1248,7 @@ public: } size->width = std::max(size->width, d.width + padding.width); this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM; - this->line_height = GetMinSizing(NWST_BUTTON, this->line_height); + this->line_height = GetMinButtonSize(this->line_height); size->height = 3 * this->line_height; resize->height = this->line_height; break; @@ -1295,7 +1295,7 @@ public: case WID_BRAS_NEWST_SPACER: size->height = 0; if (_railstation.newstations) { - size->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + size->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); } break; } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 117968eea5..2faf7c8598 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -2035,7 +2035,7 @@ struct GameSettingsWindow : Window { { switch (widget) { case WID_GS_OPTIONSPANEL: - resize->height = SETTING_HEIGHT = GetMinSizing(NWST_BUTTON, std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1); + resize->height = SETTING_HEIGHT = GetMinButtonSize(std::max({(int)_circle_size.height, SETTING_BUTTON_HEIGHT, FONT_HEIGHT_NORMAL}) + 1); resize->width = 1; size->height = 5 * resize->height + SETTINGTREE_TOP_OFFSET + SETTINGTREE_BOTTOM_OFFSET; diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp index 09a7df46d4..9947a1c1b9 100644 --- a/src/signs_gui.cpp +++ b/src/signs_gui.cpp @@ -268,7 +268,7 @@ struct SignListWindow : Window, SignList { Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON); this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text. resize->height = std::max(FONT_HEIGHT_NORMAL, spr_dim.height + 2); - resize->height = std::max(GetMinSizing(NWST_BUTTON), resize->height); + resize->height = std::max(GetMinButtonSize(), resize->height); Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM}; *size = maxdim(*size, d); break; diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index ddef1d66bf..4fafd62803 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -1078,7 +1078,7 @@ void SmallMapWindow::SetupWidgetData() SmallMapWindow::SmallMapWindow(WindowDesc *desc, int window_number) : Window(desc), - row_height(std::max(GetMinSizing(NWST_BUTTON, FONT_HEIGHT_SMALL) * 2 / 3, uint(FONT_HEIGHT_SMALL))), // Default spacing makes legend too tall - shrink it by 1/3 + row_height(std::max(GetMinButtonSize(FONT_HEIGHT_SMALL) * 2 / 3, uint(FONT_HEIGHT_SMALL))), // Default spacing makes legend too tall - shrink it by 1/3 show_legend(false), refresh(GUITimer(FORCE_REFRESH_PERIOD)) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index f3a84704e7..fa45370cee 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -392,7 +392,7 @@ public: case WID_STL_LIST: resize->height = std::max(FONT_HEIGHT_NORMAL, FONT_HEIGHT_SMALL + ScaleFontTrad(3)); - resize->height = GetMinSizing(NWST_BUTTON, resize->height); + resize->height = GetMinButtonSize(resize->height); size->height = WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM; /* Determine appropriate width for mini station rating graph */ @@ -447,7 +447,7 @@ public: int max = std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->stations.size()); int y = r.top + WD_FRAMERECT_TOP; uint line_height = this->GetWidget(widget)->resize_y; - line_height = GetMinSizing(NWST_BUTTON, line_height); + line_height = GetMinButtonSize(line_height); /* Spacing between station name and first rating graph. */ int text_spacing = ScaleFontTrad(5); /* Spacing between additional rating graphs. */ @@ -2313,7 +2313,7 @@ struct SelectStationWindow : Window { d = maxdim(d, GetStringBoundingBox(T::EXPECTED_FACIL == FACIL_WAYPOINT ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION)); } - resize->height = GetMinSizing(NWST_BUTTON, d.height); + resize->height = GetMinButtonSize(d.height); d.height = 5 * resize->height; d.width += WD_FRAMERECT_RIGHT + WD_FRAMERECT_LEFT; d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM; diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp index e14e4d637c..806b600f23 100644 --- a/src/statusbar_gui.cpp +++ b/src/statusbar_gui.cpp @@ -107,7 +107,7 @@ struct StatusBarWindow : Window { void FindWindowPlacementAndResize(int def_width, int def_height) override { - Window::FindWindowPlacementAndResize(std::min(_toolbar_width, _screen.width * 2 / 3 - GetMinSizing(NWST_BUTTON) * 2), def_height); + Window::FindWindowPlacementAndResize(std::min(_toolbar_width, _screen.width * 2 / 3 - GetMinButtonSize() * 2), def_height); } void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp index 5b563feeaa..badc33cc81 100644 --- a/src/subsidy_gui.cpp +++ b/src/subsidy_gui.cpp @@ -129,7 +129,7 @@ struct SubsidyListWindow : Window { { if (widget != WID_SUL_PANEL) return; Dimension d = maxdim(GetStringBoundingBox(STR_SUBSIDIES_OFFERED_TITLE), GetStringBoundingBox(STR_SUBSIDIES_SUBSIDISED_TITLE)); - d.height = GetMinSizing(NWST_BUTTON, d.height); + d.height = GetMinButtonSize(d.height); resize->height = d.height; @@ -149,13 +149,13 @@ struct SubsidyListWindow : Window { int right = r.right - WD_FRAMERECT_RIGHT; int y = r.top + WD_FRAMERECT_TOP; int x = r.left + WD_FRAMERECT_LEFT; - y = Center(y, GetMinSizing(NWST_BUTTON)); + y = Center(y, GetMinButtonSize()); int pos = -this->vscroll->GetPosition(); const int cap = this->vscroll->GetCapacity(); /* Section for drawing the offered subsidies */ - if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_OFFERED_TITLE); + if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_OFFERED_TITLE); pos++; uint num = 0; @@ -165,7 +165,7 @@ struct SubsidyListWindow : Window { /* Displays the two offered towns */ SetupSubsidyDecodeParam(s, true); SetDParam(7, _date - ymd.day + s->remaining * 32); - DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_OFFERED_FROM_TO); + DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_OFFERED_FROM_TO); } pos++; num++; @@ -173,13 +173,13 @@ struct SubsidyListWindow : Window { } if (num == 0) { - if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_NONE); + if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_NONE); pos++; } /* Section for drawing the already granted subsidies */ pos++; - if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_SUBSIDISED_TITLE); + if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_SUBSIDISED_TITLE); pos++; num = 0; @@ -191,7 +191,7 @@ struct SubsidyListWindow : Window { SetDParam(8, _date - ymd.day + s->remaining * 32); /* Displays the two connected stations */ - DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_SUBSIDISED_FROM_TO); + DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_SUBSIDISED_FROM_TO); } pos++; num++; @@ -199,7 +199,7 @@ struct SubsidyListWindow : Window { } if (num == 0) { - if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinSizing(NWST_BUTTON), STR_SUBSIDIES_NONE); + if (IsInsideMM(pos, 0, cap)) DrawString(x, right, y + pos * GetMinButtonSize(), STR_SUBSIDIES_NONE); pos++; } } diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp index b2f3e066f6..8570e97d85 100644 --- a/src/timetable_gui.cpp +++ b/src/timetable_gui.cpp @@ -199,7 +199,7 @@ struct TimetableWindow : Window { case WID_VT_ARRIVAL_DEPARTURE_SELECTION: case WID_VT_TIMETABLE_PANEL: - resize->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + resize->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); size->height = WD_FRAMERECT_TOP + 4 * resize->height + WD_FRAMERECT_BOTTOM; break; diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 036f111962..a10e1c1758 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -144,7 +144,7 @@ public: uint Height(uint width) const override { - return GetMinSizing(NWST_BUTTON, std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL)); + return GetMinButtonSize(std::max(std::max(this->icon_size.height, this->lock_size.height) + 2U, (uint)FONT_HEIGHT_NORMAL)); } void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const override diff --git a/src/town_gui.cpp b/src/town_gui.cpp index 33c7c79f69..5f73390ac8 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -100,7 +100,7 @@ public: this->town = Town::Get(window_number); this->InitNested(window_number); this->vscroll = this->GetScrollbar(WID_TA_SCROLLBAR); - this->actions_step = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + this->actions_step = GetMinButtonSize(FONT_HEIGHT_NORMAL); this->vscroll->SetCapacity((this->GetWidget(WID_TA_COMMAND_LIST)->current_y - WD_FRAMERECT_TOP - WD_FRAMERECT_BOTTOM) / this->actions_step); } @@ -244,7 +244,7 @@ public: } case WID_TA_COMMAND_LIST: - resize->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + resize->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); size->height = WD_FRAMERECT_TOP + 3 * resize->height + WD_FRAMERECT_BOTTOM; size->width = GetStringBoundingBox(STR_LOCAL_AUTHORITY_ACTIONS_TITLE).width; for (uint i = 0; i < TACT_COUNT; i++ ) { @@ -868,7 +868,7 @@ public: Dimension icon_size = GetSpriteSize(SPR_TOWN_RATING_GOOD); d.width += icon_size.width + 2; d.height = std::max(d.height, icon_size.height); - d.height = GetMinSizing(NWST_BUTTON, d.height); + d.height = GetMinButtonSize(d.height); resize->height = d.height; d.height *= 5; d.width += padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index e6e2384860..603c184219 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -743,17 +743,17 @@ struct RefitWindow : public Window { { switch (widget) { case WID_VR_MATRIX: - resize->height = GetMinSizing(NWST_BUTTON, WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM); + resize->height = GetMinButtonSize(WD_MATRIX_TOP + FONT_HEIGHT_NORMAL + WD_MATRIX_BOTTOM); size->height = resize->height * 4; break; case WID_VR_VEHICLE_PANEL_DISPLAY: - size->height = std::max(GetMinSizing(NWST_BUTTON), ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type))); + size->height = std::max(GetMinButtonSize(), ScaleGUITrad(GetVehicleHeight(Vehicle::Get(this->window_number)->type))); break; case WID_VR_INFO: size->width = WD_FRAMERECT_LEFT + this->information_width + WD_FRAMERECT_RIGHT; - size->height = GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); + size->height = GetMinButtonSize(FONT_HEIGHT_NORMAL); break; } } diff --git a/src/widget.cpp b/src/widget.cpp index d7a9625e36..7b8ef2220f 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -627,8 +627,8 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke { int text_offset = std::max(0, ((int)(r.bottom - r.top + 1) - FONT_HEIGHT_NORMAL) / 2); // Offset for rendering the text vertically centered - int dd_width = GetMinSizing(NWST_BUTTON, NWidgetLeaf::dropdown_dimension.width); - int dd_height = GetMinSizing(NWST_BUTTON, NWidgetLeaf::dropdown_dimension.height); + int dd_width = GetMinButtonSize(NWidgetLeaf::dropdown_dimension.width); + int dd_height = GetMinButtonSize(NWidgetLeaf::dropdown_dimension.height); int image_offset = std::max(0, ((int)(r.bottom - r.top + 1) - dd_height) / 2); if (_current_text_dir == TD_LTR) { @@ -2506,9 +2506,9 @@ void NWidgetScrollbar::Draw(const Window *w) if (vertical_dimension.width == 0) { vertical_dimension = maxdim(GetSpriteSize(SPR_ARROW_UP), GetSpriteSize(SPR_ARROW_DOWN)); vertical_dimension.width += extra.width; - vertical_dimension.width = GetMinSizing(NWST_BUTTON, vertical_dimension.width); + vertical_dimension.width = GetMinButtonSize(vertical_dimension.width); vertical_dimension.height += extra.height; - vertical_dimension.height = GetMinSizing(NWST_BUTTON, vertical_dimension.height); + vertical_dimension.height = GetMinButtonSize(vertical_dimension.height); } return vertical_dimension; } @@ -2519,9 +2519,9 @@ void NWidgetScrollbar::Draw(const Window *w) if (horizontal_dimension.width == 0) { horizontal_dimension = maxdim(GetSpriteSize(SPR_ARROW_LEFT), GetSpriteSize(SPR_ARROW_RIGHT)); horizontal_dimension.width += extra.width; - horizontal_dimension.width = GetMinSizing(NWST_BUTTON, horizontal_dimension.width); + horizontal_dimension.width = GetMinButtonSize(horizontal_dimension.width); horizontal_dimension.height += extra.height; - horizontal_dimension.height = GetMinSizing(NWST_BUTTON, horizontal_dimension.height); + horizontal_dimension.height = GetMinButtonSize(horizontal_dimension.height); } return horizontal_dimension; } @@ -2787,7 +2787,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array) Dimension sprite_size = GetSpriteSize(_current_text_dir == TD_RTL ? SPR_IMG_DELETE_RIGHT : SPR_IMG_DELETE_LEFT); size.width = std::max(size.width, 30 + sprite_size.width); size.height = std::max(sprite_size.height, GetStringBoundingBox("_").height + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM); - size.height = GetMinSizing(NWST_BUTTON, size.height); + size.height = GetMinButtonSize(size.height); } FALLTHROUGH; case WWT_PUSHBTN: { @@ -2854,7 +2854,7 @@ void NWidgetLeaf::SetupSmallestSize(Window *w, bool init_array) padding = &extra; if (this->index >= 0) w->SetStringParameters(this->index); Dimension d2 = GetStringBoundingBox(this->widget_data); - d2.width += extra.width + GetMinSizing(NWST_BUTTON, 11U); + d2.width += extra.width + GetMinButtonSize(11U); d2.height += extra.height; size = maxdim(size, d2); break; @@ -3037,7 +3037,7 @@ void NWidgetLeaf::Draw(const Window *w) */ bool NWidgetLeaf::ButtonHit(const Point &pt) { - uint button_size = GetMinSizing(NWST_BUTTON, 12); + uint button_size = GetMinButtonSize(12); if (_current_text_dir == TD_LTR) { int button_width = this->pos_x + this->current_x - button_size; return pt.x < button_width; @@ -3442,21 +3442,12 @@ NWidgetBase *MakeCompanyButtonRows(int *biggest_index, int widget_first, int wid /** * Return the minimal automatic size for a widget. - * @param type The automatic sizing type to use. * @param min_1 Minimal passed value. - * @return At least the passed value, or the minimal size for the associated sizing type. + * @return At least the passed value. */ -uint GetMinSizing(NWidSizingType type, uint min_1) +uint GetMinButtonSize(uint min_1) { - uint min_sizing; - switch (type) { - case NWST_NONE: - return min_1; - case NWST_BUTTON: - min_sizing = _settings_client.gui.min_button; - break; - default: NOT_REACHED(); - } + uint min_sizing = _settings_client.gui.min_button; min_sizing = RescaleFrom854x480(min_sizing); return std::max(min_sizing, min_1); diff --git a/src/widget_type.h b/src/widget_type.h index 9b1a4b0385..dce21099ec 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -1032,7 +1032,7 @@ static inline NWidgetPart SetSizingType(NWidSizingType type) return part; } -uint GetMinSizing(NWidSizingType type, uint min_1 = 0); +uint GetMinButtonSize(uint min_1 = 0); /** * Widget part function for setting the minimal size. diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h index d825cb19c9..f5915491a0 100644 --- a/src/widgets/dropdown_type.h +++ b/src/widgets/dropdown_type.h @@ -29,7 +29,7 @@ public: virtual ~DropDownListItem() {} virtual bool Selectable() const { return false; } - virtual uint Height(uint width) const { return GetMinSizing(NWST_BUTTON, FONT_HEIGHT_NORMAL); } + virtual uint Height(uint width) const { return GetMinButtonSize(FONT_HEIGHT_NORMAL); } virtual uint Width() const { return 0; } virtual void Draw(int left, int right, int top, int bottom, bool sel, Colours bg_colour) const; }; diff --git a/src/window.cpp b/src/window.cpp index 83baba36b4..22b74c3072 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1988,7 +1988,7 @@ int SETTING_BUTTON_HEIGHT = 10; */ void CheckWindowMinSizings() { - SETTING_BUTTON_HEIGHT = GetMinSizing(NWST_BUTTON); + SETTING_BUTTON_HEIGHT = GetMinButtonSize(); SETTING_BUTTON_WIDTH = 2 * SETTING_BUTTON_HEIGHT; } @@ -2112,7 +2112,7 @@ static void HandleMouseDragNoTitlebars() !_left_button_down || _focused_window == NULL || _dragging_widget || _focused_window->mouse_capture_widget != -1) return; unsigned distance = abs(_cursor.pos.x - _left_button_down_pos.x) + abs(_cursor.pos.y - _left_button_down_pos.y); - if (distance * 2 > GetMinSizing(NWST_BUTTON) && + if (distance * 2 > GetMinButtonSize() && _focused_window->window_class != WC_SELECT_GAME && _focused_window->window_class != WC_STATUS_BAR && _focused_window->window_class != WC_MAIN_TOOLBAR && @@ -2368,19 +2368,19 @@ bool GetWindowDraggedOffScreen(const Window *w) if (_settings_client.gui.windows_titlebars) return false; Rect edge = { 0, GetMainViewTop(), _screen.width, _screen.height }; if (_settings_client.gui.vertical_toolbar && _game_mode != GM_EDITOR && _game_mode != GM_MENU) { - edge.left += GetMinSizing(NWST_BUTTON); - edge.right -= GetMinSizing(NWST_BUTTON); + edge.left += GetMinButtonSize(); + edge.right -= GetMinButtonSize(); } - Rect visible = { edge.left + (int)GetMinSizing(NWST_BUTTON) * 4, edge.top + (int)GetMinSizing(NWST_BUTTON) * 2, - edge.right - (int)GetMinSizing(NWST_BUTTON) * 4, edge.bottom - (int)GetMinSizing(NWST_BUTTON) * 2 }; + Rect visible = { edge.left + (int)GetMinButtonSize() * 4, edge.top + (int)GetMinButtonSize() * 2, + edge.right - (int)GetMinButtonSize() * 4, edge.bottom - (int)GetMinButtonSize() * 2 }; // 1/4 of the window must be hidden to close it when flicking it off to the left/right - if (w->width >= (int)GetMinSizing(NWST_BUTTON) * 4) { - edge.left -= GetMinSizing(NWST_BUTTON) * 2; - edge.right += GetMinSizing(NWST_BUTTON) * 2; + if (w->width >= (int)GetMinButtonSize() * 4) { + edge.left -= GetMinButtonSize() * 2; + edge.right += GetMinButtonSize() * 2; } - if (w->height >= (int)GetMinSizing(NWST_BUTTON) * 4) { - edge.top -= GetMinSizing(NWST_BUTTON); - edge.bottom += GetMinSizing(NWST_BUTTON); + if (w->height >= (int)GetMinButtonSize() * 4) { + edge.top -= GetMinButtonSize(); + edge.bottom += GetMinButtonSize(); } if (w->left < edge.left && w->left + w->width < visible.right) return true; if (w->left + w->width > edge.right && w->left > visible.left) return true; @@ -2691,7 +2691,7 @@ static EventState HandleViewportScroll() if (_left_button_down) { oldDx += _cursor.delta.x; oldDy += _cursor.delta.y; - if (!_left_button_dragged && (abs(oldDx) + abs(oldDy)) * 2 > (int)GetMinSizing(NWST_BUTTON, 10)) { + if (!_left_button_dragged && (abs(oldDx) + abs(oldDy)) * 2 > (int)GetMinButtonSize(10)) { _left_button_dragged = true; } } else {