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

Method SetCapacityFromWidget

src/widget.cpp:2527–2535  ·  view source on GitHub ↗

* Set capacity of visible elements from the size and resize properties of a widget. * @param w Window. * @param widget Widget with size and resize properties. * @param padding Padding to subtract from the size. * @note Updates the position if needed. */

Source from the content-addressed store, hash-verified

2525 * @note Updates the position if needed.
2526 */
2527void Scrollbar::SetCapacityFromWidget(Window *w, WidgetID widget, int padding)
2528{
2529 NWidgetBase *nwid = w->GetWidget<NWidgetBase>(widget);
2530 if (this->IsVertical()) {
2531 this->SetCapacity(((int)nwid->current_y - padding) / (int)nwid->resize_y);
2532 } else {
2533 this->SetCapacity(((int)nwid->current_x - padding) / (int)nwid->resize_x);
2534 }
2535}
2536
2537/**
2538 * Apply 'scroll' to a rect to be drawn in.

Callers 15

OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80
OnResizeMethod · 0.80

Calls 3

IsVerticalMethod · 0.95
SetCapacityMethod · 0.95

Tested by

no test coverage detected