Changeset - r28154:62053b8fa871
[Not reviewed]
master
0 1 0
Peter Nelson - 13 months ago 2023-11-19 00:36:53
peter1138@openttd.org
Fix: Extra space allocated to container-within-container may not get allocated to children. (#11471)

Always derive additional length from contained widgets instead of from the container, as the container's minimal length may have been adjusted by an NC_EQUALSIZE parent container.
1 file changed with 6 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/widget.cpp
Show inline comments
 
@@ -1593,15 +1593,9 @@ void NWidgetHorizontal::AssignSizePositi
 
	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 

	
 
	/* Compute additional width given to us. */
 
	uint additional_length = given_width;
 
	if (this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post != 0 || (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE))) {
 
		/* For EQUALSIZE containers this does not sum to smallest_x during initialisation */
 
		additional_length -= this->pip_pre + this->gaps * this->pip_inter + this->pip_post;
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal();
 
		}
 
	} else {
 
		additional_length -= this->smallest_x;
 
	uint additional_length = given_width - (this->pip_pre + this->gaps * this->pip_inter + this->pip_post);
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		if (child_wid->smallest_x != 0 || child_wid->fill_x != 0) additional_length -= child_wid->smallest_x + child_wid->padding.Horizontal();
 
	}
 

	
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
 
@@ -1791,15 +1785,9 @@ void NWidgetVertical::AssignSizePosition
 
	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 

	
 
	/* Compute additional height given to us. */
 
	uint additional_length = given_height;
 
	if (this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post != 0 || (sizing == ST_SMALLEST && (this->flags & NC_EQUALSIZE))) {
 
		/* For EQUALSIZE containers this does not sum to smallest_y during initialisation */
 
		additional_length -= this->pip_pre + this->gaps * this->pip_inter + this->pip_post;
 
		for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
			if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) additional_length -= child_wid->smallest_y + child_wid->padding.Vertical();
 
		}
 
	} else {
 
		additional_length -= this->smallest_y;
 
	uint additional_length = given_height - (this->pip_pre + this->gaps * this->pip_inter + this->pip_post);
 
	for (NWidgetBase *child_wid = this->head; child_wid != nullptr; child_wid = child_wid->next) {
 
		if (child_wid->smallest_y != 0 || child_wid->fill_y != 0) additional_length -= child_wid->smallest_y + child_wid->padding.Vertical();
 
	}
 

	
 
	this->StoreSizePosition(sizing, x, y, given_width, given_height);
0 comments (0 inline, 0 general)