Changeset - r26558:b1ff749a8dff
[Not reviewed]
master
0 5 0
Peter Nelson - 21 months ago 2022-09-28 18:05:36
peter1138@openttd.org
Change: Use RectPadding for widget padding/uz_padding.
5 files changed with 98 insertions and 106 deletions:
0 comments (0 inline, 0 general)
src/network/network_gui.cpp
Show inline comments
 
@@ -126,7 +126,7 @@ public:
 
		/* First initialise some variables... */
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			child_wid->SetupSmallestSize(w, init_array);
 
			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.top + child_wid->padding.bottom);
 
		}
 

	
 
		/* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */
src/newgrf_gui.cpp
Show inline comments
 
@@ -1613,13 +1613,13 @@ public:
 
		this->acs->SetupSmallestSize(w, init_array);
 
		this->inf->SetupSmallestSize(w, init_array);
 

	
 
		uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
 
		uint min_avs_width = this->avs->smallest_x + this->avs->padding.left + this->avs->padding.right;
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding.left + this->acs->padding.right;
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding.left + this->inf->padding.right;
 

	
 
		uint min_avs_height = this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom;
 
		uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
 
		uint min_inf_height = this->inf->smallest_y + this->inf->padding_top + this->inf->padding_bottom;
 
		uint min_avs_height = this->avs->smallest_y + this->avs->padding.top + this->avs->padding.bottom;
 
		uint min_acs_height = this->acs->smallest_y + this->acs->padding.top + this->acs->padding.bottom;
 
		uint min_inf_height = this->inf->smallest_y + this->inf->padding.top + this->inf->padding.bottom;
 

	
 
		/* Smallest window is in two column mode. */
 
		this->smallest_x = std::max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
 
@@ -1649,9 +1649,9 @@ public:
 
	{
 
		this->StoreSizePosition(sizing, x, y, given_width, given_height);
 

	
 
		uint min_avs_width = this->avs->smallest_x + this->avs->padding_left + this->avs->padding_right;
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding_left + this->acs->padding_right;
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding_left + this->inf->padding_right;
 
		uint min_avs_width = this->avs->smallest_x + this->avs->padding.left + this->avs->padding.right;
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding.left + this->acs->padding.right;
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding.left + this->inf->padding.right;
 

	
 
		uint min_list_width = std::max(min_avs_width, min_acs_width); // Smallest width of the lists such that they have equal width (incl padding).
 
		uint avs_extra_width = min_list_width - min_avs_width;   // Additional width needed for avs to reach min_list_width.
 
@@ -1687,10 +1687,10 @@ public:
 
			avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_width, this->avs->GetHorizontalStepSize(sizing));
 

	
 
			uint acs_width = given_width - // Remaining space, including horizontal padding.
 
					inf_width - this->inf->padding_left - this->inf->padding_right -
 
					avs_width - this->avs->padding_left - this->avs->padding_right - 2 * INTER_COLUMN_SPACING;
 
					inf_width - this->inf->padding.left - this->inf->padding.right -
 
					avs_width - this->avs->padding.left - this->avs->padding.right - 2 * INTER_COLUMN_SPACING;
 
			acs_width = ComputeMaxSize(min_acs_width, acs_width, this->acs->GetHorizontalStepSize(sizing)) -
 
					this->acs->padding_left - this->acs->padding_right;
 
					this->acs->padding.left - this->acs->padding.right;
 

	
 
			/* Never use fill_y on these; the minimal size is chosen, so that the 3 column view looks nice */
 
			uint avs_height = ComputeMaxSize(this->avs->smallest_y, given_height, this->avs->resize_y);
 
@@ -1698,25 +1698,25 @@ public:
 

	
 
			/* Assign size and position to the children. */
 
			if (rtl) {
 
				x += this->inf->padding_left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
 
				x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
 
				x += this->inf->padding.left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
 
				x += inf_width + this->inf->padding.right + INTER_COLUMN_SPACING;
 
			} else {
 
				x += this->avs->padding_left;
 
				this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
 
				x += avs_width + this->avs->padding_right + INTER_COLUMN_SPACING;
 
				x += this->avs->padding.left;
 
				this->avs->AssignSizePosition(sizing, x, y + this->avs->padding.top, avs_width, avs_height, rtl);
 
				x += avs_width + this->avs->padding.right + INTER_COLUMN_SPACING;
 
			}
 

	
 
			x += this->acs->padding_left;
 
			this->acs->AssignSizePosition(sizing, x, y + this->acs->padding_top, acs_width, acs_height, rtl);
 
			x += acs_width + this->acs->padding_right + INTER_COLUMN_SPACING;
 
			x += this->acs->padding.left;
 
			this->acs->AssignSizePosition(sizing, x, y + this->acs->padding.top, acs_width, acs_height, rtl);
 
			x += acs_width + this->acs->padding.right + INTER_COLUMN_SPACING;
 

	
 
			if (rtl) {
 
				x += this->avs->padding_left;
 
				this->avs->AssignSizePosition(sizing, x, y + this->avs->padding_top, avs_width, avs_height, rtl);
 
				x += this->avs->padding.left;
 
				this->avs->AssignSizePosition(sizing, x, y + this->avs->padding.top, avs_width, avs_height, rtl);
 
			} else {
 
				x += this->inf->padding_left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
 
				x += this->inf->padding.left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
 
			}
 
		} else {
 
			/* Two columns, all space in extra_width goes to both lists. Since the lists are underneath each other,
 
@@ -1726,8 +1726,8 @@ public:
 
			uint acs_width = ComputeMaxSize(this->acs->smallest_x, this->acs->smallest_x + acs_extra_width + extra_width,
 
					this->acs->GetHorizontalStepSize(sizing));
 

	
 
			uint min_avs_height = (!this->editable) ? 0 : this->avs->smallest_y + this->avs->padding_top + this->avs->padding_bottom + INTER_LIST_SPACING;
 
			uint min_acs_height = this->acs->smallest_y + this->acs->padding_top + this->acs->padding_bottom;
 
			uint min_avs_height = (!this->editable) ? 0 : this->avs->smallest_y + this->avs->padding.top + this->avs->padding.bottom + INTER_LIST_SPACING;
 
			uint min_acs_height = this->acs->smallest_y + this->acs->padding.top + this->acs->padding.bottom;
 
			uint extra_height = given_height - min_acs_height - min_avs_height;
 

	
 
			/* Never use fill_y on these; instead use the INTER_LIST_SPACING as filler */
 
@@ -1737,29 +1737,29 @@ public:
 

	
 
			/* Assign size and position to the children. */
 
			if (rtl) {
 
				x += this->inf->padding_left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
 
				x += inf_width + this->inf->padding_right + INTER_COLUMN_SPACING;
 
				x += this->inf->padding.left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
 
				x += inf_width + this->inf->padding.right + INTER_COLUMN_SPACING;
 

	
 
				this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
 
				this->acs->AssignSizePosition(sizing, x + this->acs->padding.left, y + this->acs->padding.top, acs_width, acs_height, rtl);
 
				if (this->editable) {
 
					this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
 
					this->avs->AssignSizePosition(sizing, x + this->avs->padding.left, y + given_height - avs_height - this->avs->padding.bottom, avs_width, avs_height, rtl);
 
				} else {
 
					this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
 
				}
 
			} else {
 
				this->acs->AssignSizePosition(sizing, x + this->acs->padding_left, y + this->acs->padding_top, acs_width, acs_height, rtl);
 
				this->acs->AssignSizePosition(sizing, x + this->acs->padding.left, y + this->acs->padding.top, acs_width, acs_height, rtl);
 
				if (this->editable) {
 
					this->avs->AssignSizePosition(sizing, x + this->avs->padding_left, y + given_height - avs_height - this->avs->padding_bottom, avs_width, avs_height, rtl);
 
					this->avs->AssignSizePosition(sizing, x + this->avs->padding.left, y + given_height - avs_height - this->avs->padding.bottom, avs_width, avs_height, rtl);
 
				} else {
 
					this->avs->AssignSizePosition(sizing, 0, 0, this->avs->smallest_x, this->avs->smallest_y, rtl);
 
				}
 
				uint dx = this->acs->current_x + this->acs->padding_left + this->acs->padding_right;
 
				uint dx = this->acs->current_x + this->acs->padding.left + this->acs->padding.right;
 
				if (this->editable) {
 
					dx = std::max(dx, this->avs->current_x + this->avs->padding_left + this->avs->padding_right);
 
					dx = std::max(dx, this->avs->current_x + this->avs->padding.left + this->avs->padding.right);
 
				}
 
				x += dx + INTER_COLUMN_SPACING + this->inf->padding_left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding_top, inf_width, inf_height, rtl);
 
				x += dx + INTER_COLUMN_SPACING + this->inf->padding.left;
 
				this->inf->AssignSizePosition(sizing, x, y + this->inf->padding.top, inf_width, inf_height, rtl);
 
			}
 
		}
 
	}
src/toolbar_gui.cpp
Show inline comments
 
@@ -1354,10 +1354,10 @@ public:
 
		/* First initialise some variables... */
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			child_wid->SetupSmallestSize(w, init_array);
 
			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.top + child_wid->padding.bottom);
 
			if (this->IsButton(child_wid->type)) {
 
				nbuttons++;
 
				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.left + child_wid->padding.right);
 
			} else if (child_wid->type == NWID_SPACER) {
 
				this->spacers++;
 
			}
src/widget.cpp
Show inline comments
 
@@ -831,10 +831,10 @@ NWidgetBase *NWidgetBase::GetWidgetOfTyp
 

	
 
void NWidgetBase::AdjustPaddingForZoom()
 
{
 
	this->padding_top    = ScaleGUITrad(this->uz_padding_top);
 
	this->padding_right  = ScaleGUITrad(this->uz_padding_right);
 
	this->padding_bottom = ScaleGUITrad(this->uz_padding_bottom);
 
	this->padding_left   = ScaleGUITrad(this->uz_padding_left);
 
	this->padding.left   = ScaleGUITrad(this->uz_padding.left);
 
	this->padding.top    = ScaleGUITrad(this->uz_padding.top);
 
	this->padding.right  = ScaleGUITrad(this->uz_padding.right);
 
	this->padding.bottom = ScaleGUITrad(this->uz_padding.bottom);
 
}
 

	
 
/**
 
@@ -1124,8 +1124,8 @@ void NWidgetStacked::SetupSmallestSize(W
 
	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.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->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,12 +1142,12 @@ void NWidgetStacked::AssignSizePosition(
 

	
 
	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_pos_x = (rtl ? child_wid->padding_right : child_wid->padding_left);
 
		uint child_width = ComputeMaxSize(child_wid->smallest_x, given_width - child_wid->padding.left - child_wid->padding.right, 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_pos_y = child_wid->padding_top;
 
		uint child_height = ComputeMaxSize(child_wid->smallest_y, given_height - child_wid->padding.top - child_wid->padding.bottom, 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::SetupSmallestSiz
 
		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.top + child_wid->padding.bottom);
 
	}
 
	/* 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::SetupSmallestSiz
 
	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.top + child_wid->padding.bottom;
 
			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.
 
@@ -1297,15 +1297,15 @@ void NWidgetHorizontal::SetupSmallestSiz
 
		}
 
	}
 
	/* 3. Move PIP space to the children, compute smallest, fill, and resize values of the container. */
 
	if (this->head != nullptr) this->head->padding_left += this->pip_pre;
 
	if (this->head != nullptr) this->head->padding.left += this->pip_pre;
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		if (child_wid->next != nullptr) {
 
			child_wid->padding_right += this->pip_inter;
 
			child_wid->padding.right += this->pip_inter;
 
		} else {
 
			child_wid->padding_right += this->pip_post;
 
			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.left + child_wid->padding.right;
 
		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::AssignSizePositi
 
	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.right + child_wid->padding.left;
 
		}
 
	} else {
 
		additional_length -= this->smallest_x;
 
@@ -1363,7 +1363,7 @@ void NWidgetHorizontal::AssignSizePositi
 
		}
 

	
 
		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.top - child_wid->padding.bottom, vert_step);
 
	}
 

	
 
	/* First.5 loop: count how many children are of the biggest step size. */
 
@@ -1411,11 +1411,11 @@ void NWidgetHorizontal::AssignSizePositi
 
	NWidgetBase *child_wid = this->head;
 
	while (child_wid != nullptr) {
 
		uint child_width = child_wid->current_x;
 
		uint child_x = x + (rtl ? position - child_width - child_wid->padding_left : position + child_wid->padding_left);
 
		uint child_y = y + child_wid->padding_top;
 
		uint child_x = x + (rtl ? position - child_width - child_wid->padding.left : position + child_wid->padding.left);
 
		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.right + child_wid->padding.left;
 
		position = rtl ? position - padded_child_width : position + padded_child_width;
 

	
 
		child_wid = child_wid->next;
 
@@ -1454,7 +1454,7 @@ void NWidgetVertical::SetupSmallestSize(
 
		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.left + child_wid->padding.right);
 
	}
 
	/* 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(
 
	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.left + child_wid->padding.right;
 
			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.
 
@@ -1482,15 +1482,15 @@ void NWidgetVertical::SetupSmallestSize(
 
		}
 
	}
 
	/* 3. Move PIP space to the child, compute smallest, fill, and resize values of the container. */
 
	if (this->head != nullptr) this->head->padding_top += this->pip_pre;
 
	if (this->head != nullptr) this->head->padding.top += this->pip_pre;
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		if (child_wid->next != nullptr) {
 
			child_wid->padding_bottom += this->pip_inter;
 
			child_wid->padding.bottom += this->pip_inter;
 
		} else {
 
			child_wid->padding_bottom += this->pip_post;
 
			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.top + child_wid->padding.bottom;
 
		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
 
	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.top + child_wid->padding.bottom;
 
		}
 
	} else {
 
		additional_length -= this->smallest_y;
 
@@ -1539,7 +1539,7 @@ void NWidgetVertical::AssignSizePosition
 
		}
 

	
 
		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.left - child_wid->padding.right, hor_step);
 
	}
 

	
 
	/* First.5 loop: count how many children are of the biggest step size. */
 
@@ -1585,11 +1585,11 @@ void NWidgetVertical::AssignSizePosition
 
	/* Third loop: Compute position and call the child. */
 
	uint position = 0; // Place to put next child relative to origin of the container.
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		uint child_x = x + (rtl ? child_wid->padding_right : child_wid->padding_left);
 
		uint child_x = x + (rtl ? child_wid->padding.right : child_wid->padding.left);
 
		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;
 
		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;
 
	}
 
}
 

	
 
@@ -1945,25 +1945,25 @@ void NWidgetBackground::SetupSmallestSiz
 

	
 
		if (this->type == WWT_FRAME) {
 
			/* Account for the size of the frame's text if that exists */
 
			this->child->padding_left   = WD_FRAMETEXT_LEFT;
 
			this->child->padding_right  = WD_FRAMETEXT_RIGHT;
 
			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->child->padding.left   = WD_FRAMETEXT_LEFT;
 
			this->child->padding.right  = WD_FRAMETEXT_RIGHT;
 
			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;
 

	
 
			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);
 
		} else if (this->type == WWT_INSET) {
 
			/* Apply automatic padding for bevel thickness. */
 
			this->child->padding_left   = WD_BEVEL_LEFT;
 
			this->child->padding_right  = WD_BEVEL_RIGHT;
 
			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->child->padding.left   = WD_BEVEL_LEFT;
 
			this->child->padding.right  = WD_BEVEL_RIGHT;
 
			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;
 
		}
 
	} else {
 
		Dimension d = {this->min_x, this->min_y};
 
@@ -1995,10 +1995,10 @@ void NWidgetBackground::AssignSizePositi
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
 

	
 
	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;
 
		this->child->AssignSizePosition(sizing, x + x_offset, y + this->child->padding_top, width, height, rtl);
 
		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;
 
		this->child->AssignSizePosition(sizing, x + x_offset, y + this->child->padding.top, width, height, rtl);
 
	}
 
}
 

	
src/widget_type.h
Show inline comments
 
@@ -149,10 +149,10 @@ public:
 
	 */
 
	inline void SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
 
	{
 
		this->uz_padding_top = top;
 
		this->uz_padding_right = right;
 
		this->uz_padding_bottom = bottom;
 
		this->uz_padding_left = left;
 
		this->uz_padding.top = top;
 
		this->uz_padding.right = right;
 
		this->uz_padding.bottom = bottom;
 
		this->uz_padding.left = left;
 
		this->AdjustPaddingForZoom();
 
	}
 

	
 
@@ -192,15 +192,8 @@ public:
 
	NWidgetBase *next;    ///< Pointer to next widget in container. Managed by parent container widget.
 
	NWidgetBase *prev;    ///< Pointer to previous widget in container. Managed by parent container widget.
 

	
 
	uint8 padding_top;    ///< Paddings added to the top of the widget. Managed by parent container widget.
 
	uint8 padding_right;  ///< Paddings added to the right of the widget. Managed by parent container widget. (parent container may swap this with padding_left for RTL)
 
	uint8 padding_bottom; ///< Paddings added to the bottom of the widget. Managed by parent container widget.
 
	uint8 padding_left;   ///< Paddings added to the left of the widget. Managed by parent container widget. (parent container may swap this with padding_right for RTL)
 

	
 
	uint8 uz_padding_top;    ///< Unscaled top padding, for resize calculation.
 
	uint8 uz_padding_right;  ///< Unscaled right padding, for resize calculation.
 
	uint8 uz_padding_bottom; ///< Unscaled bottom padding, for resize calculation.
 
	uint8 uz_padding_left;   ///< Unscaled left padding, for resize calculation.
 
	RectPadding padding;    ///< Padding added to the widget. Managed by parent container widget. (parent container may swap left and right for RTL)
 
	RectPadding uz_padding; ///< Unscaled padding, for resize calculation.
 

	
 
protected:
 
	inline void StoreSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height);
 
@@ -920,8 +913,7 @@ struct NWidgetPartWidget {
 
 * Widget part for storing padding.
 
 * @ingroup NestedWidgetParts
 
 */
 
struct NWidgetPartPaddings {
 
	uint8 top, right, bottom, left; ///< Paddings for all directions.
 
struct NWidgetPartPaddings : RectPadding {
 
};
 

	
 
/**
0 comments (0 inline, 0 general)