NWidgetStacked: Allow treating planes independentally for layout
This commit is contained in:
@@ -1360,7 +1360,10 @@ void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
|
|||||||
this->fill_y = (this->head != nullptr) ? 1 : 0;
|
this->fill_y = (this->head != nullptr) ? 1 : 0;
|
||||||
this->resize_x = (this->head != nullptr) ? 1 : 0;
|
this->resize_x = (this->head != nullptr) ? 1 : 0;
|
||||||
this->resize_y = (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);
|
child_wid->SetupSmallestSize(w, init_array);
|
||||||
|
|
||||||
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
|
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;
|
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 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_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);
|
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 shown_plane; ///< Plane being displayed (for #NWID_SELECTION only).
|
||||||
int index; ///< If non-negative, index in the #Window::nested_array.
|
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, */
|
/** Nested widget container flags, */
|
||||||
|
Reference in New Issue
Block a user