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

Method UpdateWidgetSize

src/misc_gui.cpp:94–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92 }
93
94 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
95 {
96 if (widget != WID_LI_BACKGROUND) return;
97
98 size.height = WidgetDimensions::scaled.frametext.Vertical();
99 for (size_t i = 0; i < this->landinfo_data.size(); i++) {
100 uint width = GetStringBoundingBox(this->landinfo_data[i]).width + WidgetDimensions::scaled.frametext.Horizontal();
101 size.width = std::max(size.width, width);
102
103 size.height += GetCharacterHeight(FS_NORMAL) + (i == 0 ? WidgetDimensions::scaled.vsep_wide : WidgetDimensions::scaled.vsep_normal);
104 }
105
106 if (!this->cargo_acceptance.empty()) {
107 uint width = GetStringBoundingBox(this->cargo_acceptance).width + WidgetDimensions::scaled.frametext.Horizontal();
108 size.width = std::max(size.width, std::min(static_cast<uint>(ScaleGUITrad(300)), width));
109 size.height += GetStringHeight(GetString(STR_JUST_RAW_STRING, this->cargo_acceptance), size.width - WidgetDimensions::scaled.frametext.Horizontal());
110 }
111 }
112
113 LandInfoWindow(Tile tile) : Window(_land_info_desc), tile(tile)
114 {

Callers

nothing calls this directly

Calls 9

GetStringBoundingBoxFunction · 0.85
GetCharacterHeightFunction · 0.85
GetStringHeightFunction · 0.85
VerticalMethod · 0.80
HorizontalMethod · 0.80
ScaleGUITradFunction · 0.70
GetStringFunction · 0.70
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected