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

Method AssignSizePosition

src/smallmap_gui.cpp:1939–1962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1937 }
1938
1939 void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
1940 {
1941 this->pos_x = x;
1942 this->pos_y = y;
1943 this->current_x = given_width;
1944 this->current_y = given_height;
1945
1946 assert(this->children.size() == 2);
1947 NWidgetBase *display = this->children.front().get();
1948 NWidgetBase *bar = this->children.back().get();
1949
1950 if (sizing == ST_SMALLEST) {
1951 this->smallest_x = given_width;
1952 this->smallest_y = given_height;
1953 /* Make display and bar exactly equal to their minimal size. */
1954 display->AssignSizePosition(ST_SMALLEST, x, y, display->smallest_x, display->smallest_y, rtl);
1955 bar->AssignSizePosition(ST_SMALLEST, x, y + display->smallest_y, bar->smallest_x, bar->smallest_y, rtl);
1956 }
1957
1958 uint bar_height = std::max(bar->smallest_y, this->smallmap_window->GetLegendHeight(this->smallmap_window->GetNumberColumnsLegend(given_width - bar->smallest_x)));
1959 uint display_height = given_height - bar_height;
1960 display->AssignSizePosition(ST_RESIZE, x, y, given_width, display_height, rtl);
1961 bar->AssignSizePosition(ST_RESIZE, x, y + display_height, given_width, bar_height, rtl);
1962 }
1963};
1964
1965/** Widget parts of the smallmap display. */

Callers

nothing calls this directly

Calls 4

GetLegendHeightMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected