NWidgetStacked: Allow treating planes independentally for layout

pull/590/head
Jonathan G Rennison 9 months ago
parent 691e2dcc69
commit a1eefaecd5

@ -1360,7 +1360,10 @@ void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
this->fill_y = (this->head != nullptr) ? 1 : 0;
this->resize_x = (this->head != nullptr) ? 1 : 0;
this->resize_y = (this->head != nullptr) ? 1 : 0;
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
int plane = 0;
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) {
if (this->independent_planes && plane != this->shown_plane) continue;
child_wid->SetupSmallestSize(w, init_array);
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
@ -1379,7 +1382,10 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, uint x, uint y, uint
if (this->shown_plane >= SZSP_BEGIN) return;
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
int plane = 0;
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; plane++, child_wid = child_wid->next) {
if (this->independent_planes && plane != this->shown_plane) continue;
uint hor_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
uint child_width = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.Horizontal(), hor_step);
uint child_pos_x = (rtl ? child_wid->padding.right : child_wid->padding.left);

@ -481,6 +481,7 @@ public:
int shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
int index; ///< If non-negative, index in the #Window::nested_array.
bool independent_planes = false; ///< If true, treat planes as independent for layout purposes.
};
/** Nested widget container flags, */

Loading…
Cancel
Save