MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / UpdateWidgetSize

Method UpdateWidgetSize

src/settings_gui.cpp:834–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832 }
833
834 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
835 {
836 switch (widget) {
837 case WID_GO_TEXT_SFX_VOLUME:
838 case WID_GO_TEXT_MUSIC_VOLUME: {
839 Dimension d = maxdim(GetStringBoundingBox(STR_GAME_OPTIONS_SFX_VOLUME), GetStringBoundingBox(STR_GAME_OPTIONS_MUSIC_VOLUME));
840 d.width += padding.width;
841 d.height += padding.height;
842 size = maxdim(size, d);
843 break;
844 }
845
846 case WID_GO_CURRENCY_DROPDOWN:
847 case WID_GO_AUTOSAVE_DROPDOWN:
848 case WID_GO_LANG_DROPDOWN:
849 case WID_GO_RESOLUTION_DROPDOWN:
850 case WID_GO_REFRESH_RATE_DROPDOWN:
851 case WID_GO_BASE_GRF_DROPDOWN:
852 case WID_GO_BASE_SFX_DROPDOWN:
853 case WID_GO_BASE_MUSIC_DROPDOWN: {
854 int selected;
855 size.width = std::max(size.width, GetDropDownListDimension(this->BuildDropDownList(widget, &selected)).width + padding.width);
856 break;
857 }
858
859 case WID_GO_OPTIONSPANEL:
860 fill.height = resize.height = BaseSettingEntry::line_height;
861 resize.width = 1;
862
863 size.height = 8 * resize.height + WidgetDimensions::scaled.framerect.Vertical();
864 break;
865
866 case WID_GO_SETTING_PROPERTIES: {
867 static const StringID setting_types[] = {
868 STR_CONFIG_SETTING_TYPE_CLIENT,
869 STR_CONFIG_SETTING_TYPE_COMPANY_MENU, STR_CONFIG_SETTING_TYPE_COMPANY_INGAME,
870 STR_CONFIG_SETTING_TYPE_GAME_MENU, STR_CONFIG_SETTING_TYPE_GAME_INGAME,
871 };
872 for (const auto &setting_type : setting_types) {
873 size.width = std::max(size.width, GetStringBoundingBox(GetString(STR_CONFIG_SETTING_TYPE, setting_type)).width + padding.width);
874 }
875 size.height = 2 * GetCharacterHeight(FS_NORMAL);
876 break;
877 }
878
879 case WID_GO_HELP_TEXT:
880 size.height = NUM_DESCRIPTION_LINES * GetCharacterHeight(FS_NORMAL);
881 break;
882
883 case WID_GO_RESTRICT_CATEGORY:
884 case WID_GO_RESTRICT_TYPE:
885 size.width = std::max(GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_CATEGORY).width, GetStringBoundingBox(STR_CONFIG_SETTING_RESTRICT_TYPE).width);
886 break;
887
888 default:
889 break;
890 }
891 }

Callers

nothing calls this directly

Calls 7

BuildDropDownListMethod · 0.95
maxdimFunction · 0.85
GetStringBoundingBoxFunction · 0.85
GetDropDownListDimensionFunction · 0.85
GetCharacterHeightFunction · 0.85
VerticalMethod · 0.80
GetStringFunction · 0.70

Tested by

no test coverage detected