Changeset - r28522:a0987065cc7d
[Not reviewed]
master
0 2 0
Rubidium - 11 months ago 2024-01-20 14:58:37
rubidium@openttd.org
Codechange: replace LeastCommonMultiple with std::lcm
2 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/newgrf_gui.cpp
Show inline comments
 
@@ -1639,26 +1639,26 @@ public:
 

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

	
 
		/* Filling. */
 
		this->fill_x = LeastCommonMultiple(this->avs->fill_x, this->acs->fill_x);
 
		this->fill_x = std::lcm(this->avs->fill_x, this->acs->fill_x);
 
		if (this->inf->fill_x > 0 && (this->fill_x == 0 || this->fill_x > this->inf->fill_x)) this->fill_x = this->inf->fill_x;
 

	
 
		this->fill_y = this->avs->fill_y;
 
		if (this->acs->fill_y > 0 && (this->fill_y == 0 || this->fill_y > this->acs->fill_y)) this->fill_y = this->acs->fill_y;
 
		this->fill_y = LeastCommonMultiple(this->fill_y, this->inf->fill_y);
 
		this->fill_y = std::lcm(this->fill_y, this->inf->fill_y);
 

	
 
		/* Resizing. */
 
		this->resize_x = LeastCommonMultiple(this->avs->resize_x, this->acs->resize_x);
 
		this->resize_x = std::lcm(this->avs->resize_x, this->acs->resize_x);
 
		if (this->inf->resize_x > 0 && (this->resize_x == 0 || this->resize_x > this->inf->resize_x)) this->resize_x = this->inf->resize_x;
 

	
 
		this->resize_y = this->avs->resize_y;
 
		if (this->acs->resize_y > 0 && (this->resize_y == 0 || this->resize_y > this->acs->resize_y)) this->resize_y = this->acs->resize_y;
 
		this->resize_y = LeastCommonMultiple(this->resize_y, this->inf->resize_y);
 
		this->resize_y = std::lcm(this->resize_y, this->inf->resize_y);
 

	
 
		/* Make sure the height suits the 3 column (resp. not-editable) format; the 2 column format can easily fill space between the lists */
 
		this->smallest_y = ComputeMaxSize(min_acs_height, this->smallest_y + this->resize_y - 1, this->resize_y);
 
	}
 

	
 
	void AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl) override
src/widget.cpp
Show inline comments
 
@@ -1236,16 +1236,16 @@ void NWidgetStacked::SetupSmallestSize(W
 
	this->resize_y = this->IsEmpty() ? 0 : 1;
 
	for (const auto &child_wid : this->children) {
 
		child_wid->SetupSmallestSize(w);
 

	
 
		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);
 
		this->fill_x = std::lcm(this->fill_x, child_wid->fill_x);
 
		this->fill_y = std::lcm(this->fill_y, child_wid->fill_y);
 
		this->resize_x = std::lcm(this->resize_x, child_wid->resize_x);
 
		this->resize_y = std::lcm(this->resize_y, child_wid->resize_y);
 
	}
 
}
 

	
 
void NWidgetStacked::AssignSizePosition(SizingType sizing, int x, int y, uint given_width, uint given_height, bool rtl)
 
{
 
	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 
@@ -1406,18 +1406,18 @@ void NWidgetHorizontal::SetupSmallestSiz
 
	/* 3. Compute smallest, fill, and resize values of the container. */
 
	for (const auto &child_wid : this->children) {
 
		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);
 
		this->fill_y = std::lcm(this->fill_y, child_wid->fill_y);
 

	
 
		if (child_wid->resize_x > 0) {
 
			if (this->resize_x == 0 || this->resize_x > child_wid->resize_x) this->resize_x = child_wid->resize_x;
 
		}
 
		this->resize_y = LeastCommonMultiple(this->resize_y, child_wid->resize_y);
 
		this->resize_y = std::lcm(this->resize_y, child_wid->resize_y);
 
	}
 
	if (this->fill_x == 0 && this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post > 0) this->fill_x = 1;
 
	/* 4. Increase by required PIP space. */
 
	this->smallest_x += this->pip_pre + this->gaps * this->pip_inter + this->pip_post;
 
}
 

	
 
@@ -1595,18 +1595,18 @@ void NWidgetVertical::SetupSmallestSize(
 
	/* 3. Compute smallest, fill, and resize values of the container. */
 
	for (const auto &child_wid : this->children) {
 
		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);
 
		this->fill_x = std::lcm(this->fill_x, child_wid->fill_x);
 

	
 
		if (child_wid->resize_y > 0) {
 
			if (this->resize_y == 0 || this->resize_y > child_wid->resize_y) this->resize_y = child_wid->resize_y;
 
		}
 
		this->resize_x = LeastCommonMultiple(this->resize_x, child_wid->resize_x);
 
		this->resize_x = std::lcm(this->resize_x, child_wid->resize_x);
 
	}
 
	if (this->fill_y == 0 && this->pip_ratio_pre + this->pip_ratio_inter + this->pip_ratio_post > 0) this->fill_y = 1;
 
	/* 4. Increase by required PIP space. */
 
	this->smallest_y += this->pip_pre + this->gaps * this->pip_inter + this->pip_post;
 
}
 

	
0 comments (0 inline, 0 general)