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

Method UpdateWidgetSize

src/timetable_gui.cpp:222–252  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220 }
221
222 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
223 {
224 switch (widget) {
225 case WID_VT_ARRIVAL_DEPARTURE_PANEL:
226 /* We handle this differently depending on the timetable mode. */
227 if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) {
228 /* A five-digit number would fit a timetable lasting 2.7 real-world hours, which should be plenty. */
229 uint64_t max_digits = GetParamMaxDigits(4, FS_SMALL);
230 size.width = std::max(
231 GetStringBoundingBox(GetString(STR_TIMETABLE_ARRIVAL_SECONDS_IN_FUTURE, TC_BLACK, max_digits)).width,
232 GetStringBoundingBox(GetString(STR_TIMETABLE_DEPARTURE_SECONDS_IN_FUTURE, TC_BLACK, max_digits)).width)
233 + WidgetDimensions::scaled.hsep_wide + padding.width;
234 } else {
235 uint64_t max_value = GetParamMaxValue(TimerGameEconomy::DateAtStartOfYear(EconomyTime::MAX_YEAR).base(), 0, FS_SMALL);
236 size.width = std::max(
237 GetStringBoundingBox(GetString(STR_TIMETABLE_ARRIVAL_DATE, TC_BLACK, max_value)).width,
238 GetStringBoundingBox(GetString(STR_TIMETABLE_DEPARTURE_DATE, TC_BLACK, max_value)).width)
239 + WidgetDimensions::scaled.hsep_wide + padding.width;
240 }
241 [[fallthrough]];
242
243 case WID_VT_TIMETABLE_PANEL:
244 fill.height = resize.height = GetCharacterHeight(FS_NORMAL);
245 size.height = 8 * resize.height + padding.height;
246 break;
247
248 case WID_VT_SUMMARY_PANEL:
249 size.height = 2 * GetCharacterHeight(FS_NORMAL) + padding.height;
250 break;
251 }
252 }
253
254 int GetOrderFromTimetableWndPt(int y, [[maybe_unused]] const Vehicle *v)
255 {

Callers

nothing calls this directly

Calls 6

GetParamMaxDigitsFunction · 0.85
GetStringBoundingBoxFunction · 0.85
GetParamMaxValueFunction · 0.85
GetCharacterHeightFunction · 0.85
GetStringFunction · 0.70
baseMethod · 0.45

Tested by

no test coverage detected