Changeset - r26559:f59be462257f
[Not reviewed]
master
0 5 0
Peter Nelson - 2 years ago 2022-09-28 21:40:17
peter1138@openttd.org
Change: Use RectPadding Horizontal()/Vertical() helpers.
5 files changed with 52 insertions and 42 deletions:
0 comments (0 inline, 0 general)
src/network/network_gui.cpp
Show inline comments
 
@@ -123,13 +123,13 @@ public:
 
		this->resize_x = 1; // We only resize in this direction
 
		this->resize_y = 0; // We never resize in this direction
 

	
 
		/* 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.Vertical());
 
		}
 

	
 
		/* ... then in a second pass make sure the 'current' sizes are set. Won't change for most widgets. */
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			child_wid->current_x = child_wid->smallest_x;
 
			child_wid->current_y = this->smallest_y;
src/newgrf_gui.cpp
Show inline comments
 
@@ -1610,19 +1610,19 @@ public:
 
		this->editable = ngw->editable;
 

	
 
		this->avs->SetupSmallestSize(w, init_array);
 
		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.Horizontal();
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding.Horizontal();
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding.Horizontal();
 

	
 
		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.Vertical();
 
		uint min_acs_height = this->acs->smallest_y + this->acs->padding.Vertical();
 
		uint min_inf_height = this->inf->smallest_y + this->inf->padding.Vertical();
 

	
 
		/* Smallest window is in two column mode. */
 
		this->smallest_x = std::max(min_avs_width, min_acs_width) + INTER_COLUMN_SPACING + min_inf_width;
 
		this->smallest_y = std::max(min_inf_height, min_acs_height + INTER_LIST_SPACING + min_avs_height);
 

	
 
		/* Filling. */
 
@@ -1646,15 +1646,15 @@ public:
 
	}
 

	
 
	void AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl) override
 
	{
 
		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.Horizontal();
 
		uint min_acs_width = this->acs->smallest_x + this->acs->padding.Horizontal();
 
		uint min_inf_width = this->inf->smallest_x + this->inf->padding.Horizontal();
 

	
 
		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.
 
		uint acs_extra_width = min_list_width - min_acs_width;   // Additional width needed for acs to reach min_list_width.
 

	
 
		/* Use 2 or 3 columns? */
 
@@ -1684,16 +1684,16 @@ public:
 
			extra_width -= std::min(acs_extra_width, extra_width);
 
			avs_width += extra_width / 2;
 

	
 
			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.Horizontal() -
 
					avs_width - this->avs->padding.Horizontal() - 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.Horizontal();
 

	
 
			/* 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);
 
			uint acs_height = ComputeMaxSize(this->acs->smallest_y, given_height, this->acs->resize_y);
 

	
 
			/* Assign size and position to the children. */
 
@@ -1723,14 +1723,14 @@ public:
 
			 * the column is min_list_width wide at least. */
 
			uint avs_width = ComputeMaxSize(this->avs->smallest_x, this->avs->smallest_x + avs_extra_width + extra_width,
 
					this->avs->GetHorizontalStepSize(sizing));
 
			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.Vertical() + INTER_LIST_SPACING;
 
			uint min_acs_height = this->acs->smallest_y + this->acs->padding.Vertical();
 
			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 */
 
			uint avs_height = ComputeMaxSize(this->avs->smallest_y, this->avs->smallest_y + extra_height / 2, this->avs->resize_y);
 
			if (this->editable) extra_height -= avs_height - this->avs->smallest_y;
 
			uint acs_height = ComputeMaxSize(this->acs->smallest_y, this->acs->smallest_y + extra_height, this->acs->resize_y);
 
@@ -1751,15 +1751,15 @@ public:
 
				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);
 
				} 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.Horizontal();
 
				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.Horizontal());
 
				}
 
				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
 
@@ -1351,16 +1351,16 @@ public:
 
		this->spacers = 0;
 

	
 
		uint nbuttons = 0;
 
		/* 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.Vertical());
 
			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.Horizontal());
 
			} else if (child_wid->type == NWID_SPACER) {
 
				this->spacers++;
 
			}
 
		}
 

	
 
		/* ... then in a second pass make sure the 'current' heights are set. Won't change ever. */
src/widget.cpp
Show inline comments
 
@@ -1121,14 +1121,14 @@ void NWidgetStacked::SetupSmallestSize(W
 
	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) {
 
		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);
 
		this->resize_y = LeastCommonMultiple(this->resize_y, child_wid->resize_y);
 
	}
 
}
 
@@ -1139,17 +1139,17 @@ void NWidgetStacked::AssignSizePosition(
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
 

	
 
	if (this->shown_plane >= SZSP_BEGIN) return;
 

	
 
	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);
 
	}
 
}
 

	
 
@@ -1266,21 +1266,21 @@ void NWidgetHorizontal::SetupSmallestSiz
 
	uint longest = 0; // Longest child found.
 
	uint max_vert_fill = 0; // Biggest vertical fill step.
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		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.
 
	uint cur_height = this->smallest_y;
 
	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.
 
					cur_height += step_size - remainder;
 
					assert(cur_height < max_smallest); // Safeguard against infinite height expansion.
 
					/* Remaining children will adapt to the new cur_height, thus speeding up the computation. */
 
@@ -1302,13 +1302,13 @@ void NWidgetHorizontal::SetupSmallestSiz
 
		if (child_wid->next != nullptr) {
 
			child_wid->padding.right += this->pip_inter;
 
		} else {
 
			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;
 
		}
 
		this->fill_y = LeastCommonMultiple(this->fill_y, child_wid->fill_y);
 

	
 
		if (child_wid->resize_x > 0) {
 
@@ -1326,13 +1326,13 @@ void NWidgetHorizontal::AssignSizePositi
 

	
 
	/* Compute additional width given to us. */
 
	uint additional_length = given_width;
 
	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;
 
	}
 

	
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
 
@@ -1360,13 +1360,13 @@ void NWidgetHorizontal::AssignSizePositi
 
			biggest_stepsize = std::max(biggest_stepsize, hor_step);
 
		} else {
 
			child_wid->current_x = child_wid->smallest_x;
 
		}
 

	
 
		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. */
 
	if ((flags & NC_BIGFIRST) && biggest_stepsize > 0) {
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			uint hor_step = child_wid->GetHorizontalStepSize(sizing);
 
@@ -1412,13 +1412,13 @@ void NWidgetHorizontal::AssignSizePositi
 
	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;
 

	
 
		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;
 
	}
 
}
 

	
 
@@ -1451,21 +1451,21 @@ void NWidgetVertical::SetupSmallestSize(
 
	uint highest = 0; // Highest child found.
 
	uint max_hor_fill = 0; // Biggest horizontal fill step.
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		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.
 
	uint cur_width = this->smallest_x;
 
	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.
 
					cur_width += step_size - remainder;
 
					assert(cur_width < max_smallest); // Safeguard against infinite width expansion.
 
					/* Remaining children will adapt to the new cur_width, thus speeding up the computation. */
 
@@ -1487,13 +1487,13 @@ void NWidgetVertical::SetupSmallestSize(
 
		if (child_wid->next != nullptr) {
 
			child_wid->padding.bottom += this->pip_inter;
 
		} else {
 
			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;
 
		}
 
		this->fill_x = LeastCommonMultiple(this->fill_x, child_wid->fill_x);
 

	
 
		if (child_wid->resize_y > 0) {
 
@@ -1511,13 +1511,13 @@ void NWidgetVertical::AssignSizePosition
 

	
 
	/* Compute additional height given to us. */
 
	uint additional_length = given_height;
 
	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;
 
	}
 

	
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
 
@@ -1536,13 +1536,13 @@ void NWidgetVertical::AssignSizePosition
 
			biggest_stepsize = std::max(biggest_stepsize, vert_step);
 
		} else {
 
			child_wid->current_y = child_wid->smallest_y;
 
		}
 

	
 
		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. */
 
	if ((this->flags & NC_BIGFIRST) && biggest_stepsize > 0) {
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			uint vert_step = child_wid->GetVerticalStepSize(sizing);
 
@@ -1586,13 +1586,13 @@ void NWidgetVertical::AssignSizePosition
 
	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_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();
 
	}
 
}
 

	
 
/**
 
 * Generic spacer widget.
 
 * @param width  Horizontal size of the spacer widget.
 
@@ -1947,26 +1947,26 @@ void NWidgetBackground::SetupSmallestSiz
 
			/* 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->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);
 
		} 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->smallest_x += this->child->padding.Horizontal();
 
			this->smallest_y += this->child->padding.Vertical();
 
		}
 
	} else {
 
		Dimension d = {this->min_x, this->min_y};
 
		Dimension fill = {this->fill_x, this->fill_y};
 
		Dimension resize  = {this->resize_x, this->resize_y};
 
		if (w != nullptr) { // A non-nullptr window pointer acts as switch to turn dynamic widget size on.
 
@@ -1993,14 +1993,14 @@ void NWidgetBackground::SetupSmallestSiz
 
void NWidgetBackground::AssignSizePosition(SizingType sizing, uint x, uint y, uint given_width, uint given_height, bool rtl)
 
{
 
	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;
 
		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);
 
	}
 
}
 

	
 
void NWidgetBackground::FillNestedArray(NWidgetBase **array, uint length)
 
{
 
@@ -2924,13 +2924,13 @@ static int MakeNWidget(const NWidgetPart
 
					nwc->tool_tip = parts->u.data_tip.tooltip;
 
				}
 
				break;
 
			}
 

	
 
			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: {
 
				NWidgetPIPContainer *nwc = dynamic_cast<NWidgetPIPContainer *>(*dest);
 
				if (nwc != nullptr) nwc->SetPIP(parts->u.pip.pre, parts->u.pip.inter, parts->u.pip.post);
 

	
src/widget_type.h
Show inline comments
 
@@ -153,12 +153,22 @@ public:
 
		this->uz_padding.right = right;
 
		this->uz_padding.bottom = bottom;
 
		this->uz_padding.left = left;
 
		this->AdjustPaddingForZoom();
 
	}
 

	
 
	/**
 
	 * Set additional space (padding) around the widget.
 
	 * @param padding Amount of padding around the widget.
 
	 */
 
	inline void SetPadding(const RectPadding &padding)
 
	{
 
		this->uz_padding = padding;
 
		this->AdjustPaddingForZoom();
 
	}
 

	
 
	inline uint GetHorizontalStepSize(SizingType sizing) const;
 
	inline uint GetVerticalStepSize(SizingType sizing) const;
 

	
 
	virtual void Draw(const Window *w) = 0;
 
	virtual void SetDirty(const Window *w) const;
 

	
0 comments (0 inline, 0 general)