|
|
|
@ -1124,8 +1124,8 @@ void NWidgetStacked::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
child_wid->SetupSmallestSize(w, init_array);
|
|
|
|
|
|
|
|
|
|
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.left + child_wid->padding.right);
|
|
|
|
|
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.top + child_wid->padding.bottom);
|
|
|
|
|
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
|
|
|
|
|
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
|
|
|
|
|
this->fill_x = LeastCommonMultiple(this->fill_x, child_wid->fill_x);
|
|
|
|
|
this->fill_y = LeastCommonMultiple(this->fill_y, child_wid->fill_y);
|
|
|
|
|
this->resize_x = LeastCommonMultiple(this->resize_x, child_wid->resize_x);
|
|
|
|
@ -1142,11 +1142,11 @@ void NWidgetStacked::AssignSizePosition(SizingType sizing, uint x, uint y, uint
|
|
|
|
|
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
uint hor_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
|
|
|
|
|
uint child_width = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.left - child_wid->padding.right, 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 vert_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
|
|
|
|
|
uint child_height = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.top - child_wid->padding.bottom, vert_step);
|
|
|
|
|
uint child_height = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.Vertical(), vert_step);
|
|
|
|
|
uint child_pos_y = child_wid->padding.top;
|
|
|
|
|
|
|
|
|
|
child_wid->AssignSizePosition(sizing, x + child_pos_x, y + child_pos_y, child_width, child_height, rtl);
|
|
|
|
@ -1269,7 +1269,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
child_wid->SetupSmallestSize(w, init_array);
|
|
|
|
|
longest = std::max(longest, child_wid->smallest_x);
|
|
|
|
|
max_vert_fill = std::max(max_vert_fill, child_wid->GetVerticalStepSize(ST_SMALLEST));
|
|
|
|
|
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.top + child_wid->padding.bottom);
|
|
|
|
|
this->smallest_y = std::max(this->smallest_y, child_wid->smallest_y + child_wid->padding.Vertical());
|
|
|
|
|
}
|
|
|
|
|
/* 1b. Make the container higher if needed to accommodate all children nicely. */
|
|
|
|
|
[[maybe_unused]] uint max_smallest = this->smallest_y + 3 * max_vert_fill; // Upper limit to computing smallest height.
|
|
|
|
@ -1277,7 +1277,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
for (;;) {
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
uint step_size = child_wid->GetVerticalStepSize(ST_SMALLEST);
|
|
|
|
|
uint child_height = child_wid->smallest_y + child_wid->padding.top + child_wid->padding.bottom;
|
|
|
|
|
uint child_height = child_wid->smallest_y + child_wid->padding.Vertical();
|
|
|
|
|
if (step_size > 1 && child_height < cur_height) { // Small step sizes or already fitting children are not interesting.
|
|
|
|
|
uint remainder = (cur_height - child_height) % step_size;
|
|
|
|
|
if (remainder > 0) { // Child did not fit entirely, widen the container.
|
|
|
|
@ -1305,7 +1305,7 @@ void NWidgetHorizontal::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
child_wid->padding.right += this->pip_post;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->smallest_x += child_wid->smallest_x + child_wid->padding.left + child_wid->padding.right;
|
|
|
|
|
this->smallest_x += child_wid->smallest_x + child_wid->padding.Horizontal();
|
|
|
|
|
if (child_wid->fill_x > 0) {
|
|
|
|
|
if (this->fill_x == 0 || this->fill_x > child_wid->fill_x) this->fill_x = child_wid->fill_x;
|
|
|
|
|
}
|
|
|
|
@ -1329,7 +1329,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui
|
|
|
|
|
if (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE)) {
|
|
|
|
|
/* For EQUALSIZE containers this does not sum to smallest_x during initialisation */
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
additional_length -= child_wid->smallest_x + child_wid->padding.right + child_wid->padding.left;
|
|
|
|
|
additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
additional_length -= this->smallest_x;
|
|
|
|
@ -1363,7 +1363,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint vert_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetVerticalStepSize(sizing);
|
|
|
|
|
child_wid->current_y = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.top - child_wid->padding.bottom, vert_step);
|
|
|
|
|
child_wid->current_y = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.Vertical(), vert_step);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* First.5 loop: count how many children are of the biggest step size. */
|
|
|
|
@ -1415,7 +1415,7 @@ void NWidgetHorizontal::AssignSizePosition(SizingType sizing, uint x, uint y, ui
|
|
|
|
|
uint child_y = y + child_wid->padding.top;
|
|
|
|
|
|
|
|
|
|
child_wid->AssignSizePosition(sizing, child_x, child_y, child_width, child_wid->current_y, rtl);
|
|
|
|
|
uint padded_child_width = child_width + child_wid->padding.right + child_wid->padding.left;
|
|
|
|
|
uint padded_child_width = child_width + child_wid->padding.Horizontal();
|
|
|
|
|
position = rtl ? position - padded_child_width : position + padded_child_width;
|
|
|
|
|
|
|
|
|
|
child_wid = child_wid->next;
|
|
|
|
@ -1454,7 +1454,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
child_wid->SetupSmallestSize(w, init_array);
|
|
|
|
|
highest = std::max(highest, child_wid->smallest_y);
|
|
|
|
|
max_hor_fill = std::max(max_hor_fill, child_wid->GetHorizontalStepSize(ST_SMALLEST));
|
|
|
|
|
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.left + child_wid->padding.right);
|
|
|
|
|
this->smallest_x = std::max(this->smallest_x, child_wid->smallest_x + child_wid->padding.Horizontal());
|
|
|
|
|
}
|
|
|
|
|
/* 1b. Make the container wider if needed to accommodate all children nicely. */
|
|
|
|
|
[[maybe_unused]] uint max_smallest = this->smallest_x + 3 * max_hor_fill; // Upper limit to computing smallest height.
|
|
|
|
@ -1462,7 +1462,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
for (;;) {
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
uint step_size = child_wid->GetHorizontalStepSize(ST_SMALLEST);
|
|
|
|
|
uint child_width = child_wid->smallest_x + child_wid->padding.left + child_wid->padding.right;
|
|
|
|
|
uint child_width = child_wid->smallest_x + child_wid->padding.Horizontal();
|
|
|
|
|
if (step_size > 1 && child_width < cur_width) { // Small step sizes or already fitting children are not interesting.
|
|
|
|
|
uint remainder = (cur_width - child_width) % step_size;
|
|
|
|
|
if (remainder > 0) { // Child did not fit entirely, widen the container.
|
|
|
|
@ -1490,7 +1490,7 @@ void NWidgetVertical::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
child_wid->padding.bottom += this->pip_post;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->smallest_y += child_wid->smallest_y + child_wid->padding.top + child_wid->padding.bottom;
|
|
|
|
|
this->smallest_y += child_wid->smallest_y + child_wid->padding.Vertical();
|
|
|
|
|
if (child_wid->fill_y > 0) {
|
|
|
|
|
if (this->fill_y == 0 || this->fill_y > child_wid->fill_y) this->fill_y = child_wid->fill_y;
|
|
|
|
|
}
|
|
|
|
@ -1514,7 +1514,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint
|
|
|
|
|
if (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE)) {
|
|
|
|
|
/* For EQUALSIZE containers this does not sum to smallest_y during initialisation */
|
|
|
|
|
for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
|
|
|
|
|
additional_length -= child_wid->smallest_y + child_wid->padding.top + child_wid->padding.bottom;
|
|
|
|
|
additional_length -= child_wid->smallest_y + child_wid->padding.Vertical();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
additional_length -= this->smallest_y;
|
|
|
|
@ -1539,7 +1539,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint hor_step = (sizing == ST_SMALLEST) ? 1 : child_wid->GetHorizontalStepSize(sizing);
|
|
|
|
|
child_wid->current_x = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.left - child_wid->padding.right, hor_step);
|
|
|
|
|
child_wid->current_x = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.Horizontal(), hor_step);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* First.5 loop: count how many children are of the biggest step size. */
|
|
|
|
@ -1589,7 +1589,7 @@ void NWidgetVertical::AssignSizePosition(SizingType sizing, uint x, uint y, uint
|
|
|
|
|
uint child_height = child_wid->current_y;
|
|
|
|
|
|
|
|
|
|
child_wid->AssignSizePosition(sizing, child_x, y + position + child_wid->padding.top, child_wid->current_x, child_height, rtl);
|
|
|
|
|
position += child_height + child_wid->padding.top + child_wid->padding.bottom;
|
|
|
|
|
position += child_height + child_wid->padding.Vertical();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1950,8 +1950,8 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
this->child->padding.top = std::max((int)WD_FRAMETEXT_TOP, this->widget_data != STR_NULL ? FONT_HEIGHT_NORMAL + WD_FRAMETEXT_TOP / 2 : 0);
|
|
|
|
|
this->child->padding.bottom = WD_FRAMETEXT_BOTTOM;
|
|
|
|
|
|
|
|
|
|
this->smallest_x += this->child->padding.left + this->child->padding.right;
|
|
|
|
|
this->smallest_y += this->child->padding.top + this->child->padding.bottom;
|
|
|
|
|
this->smallest_x += this->child->padding.Horizontal();
|
|
|
|
|
this->smallest_y += this->child->padding.Vertical();
|
|
|
|
|
|
|
|
|
|
if (this->index >= 0) w->SetStringParameters(this->index);
|
|
|
|
|
this->smallest_x = std::max(this->smallest_x, GetStringBoundingBox(this->widget_data).width + WD_FRAMETEXT_LEFT + WD_FRAMETEXT_RIGHT);
|
|
|
|
@ -1962,8 +1962,8 @@ void NWidgetBackground::SetupSmallestSize(Window *w, bool init_array)
|
|
|
|
|
this->child->padding.top = WD_BEVEL_TOP;
|
|
|
|
|
this->child->padding.bottom = WD_BEVEL_BOTTOM;
|
|
|
|
|
|
|
|
|
|
this->smallest_x += this->child->padding.left + this->child->padding.right;
|
|
|
|
|
this->smallest_y += this->child->padding.top + this->child->padding.bottom;
|
|
|
|
|
this->smallest_x += this->child->padding.Horizontal();
|
|
|
|
|
this->smallest_y += this->child->padding.Vertical();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Dimension d = {this->min_x, this->min_y};
|
|
|
|
@ -1996,8 +1996,8 @@ void NWidgetBackground::AssignSizePosition(SizingType sizing, uint x, uint y, ui
|
|
|
|
|
|
|
|
|
|
if (this->child != nullptr) {
|
|
|
|
|
uint x_offset = (rtl ? this->child->padding.right : this->child->padding.left);
|
|
|
|
|
uint width = given_width - this->child->padding.right - this->child->padding.left;
|
|
|
|
|
uint height = given_height - this->child->padding.top - this->child->padding.bottom;
|
|
|
|
|
uint width = given_width - this->child->padding.Horizontal();
|
|
|
|
|
uint height = given_height - this->child->padding.Vertical();
|
|
|
|
|
this->child->AssignSizePosition(sizing, x + x_offset, y + this->child->padding.top, width, height, rtl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2927,7 +2927,7 @@ static int MakeNWidget(const NWidgetPart *parts, int count, NWidgetBase **dest,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case WPT_PADDING:
|
|
|
|
|
if (*dest != nullptr) (*dest)->SetPadding(parts->u.padding.top, parts->u.padding.right, parts->u.padding.bottom, parts->u.padding.left);
|
|
|
|
|
if (*dest != nullptr) (*dest)->SetPadding(parts->u.padding);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case WPT_PIPSPACE: {
|
|
|
|
|