changeset 11963:de84ab2c6641 draft

(svn r16369) -Codechange: Renaming ComputeMinimalSize() to SetupSmallestSize(), and AssignMinimalPosition() to AssignSizePosition(), they do not compute minimal size anymore.
author alberth <alberth@openttd.org>
date Thu, 21 May 2009 16:14:04 +0000
parents 9de330e3b29b
children 9bbab6c40225
files src/widget.cpp src/widget_type.h
diffstat 2 files changed, 41 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -686,7 +686,7 @@
 /* ~NWidgetContainer() takes care of #next and #prev data members. */
 
 /**
- * @fn int NWidgetBase::ComputeMinimalSize()
+ * @fn int NWidgetBase::SetupSmallestSize()
  * @brief Compute smallest size needed by the widget.
  *
  * The smallest size of a widget is the smallest size that a widget needs to
@@ -698,8 +698,8 @@
  */
 
 /**
- * @fn void NWidgetBase::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
- * @brief Assign minimal size and position to the widget.
+ * @fn void NWidgetBase::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+ * @brief Assign size and position to the widget.
  * @param x              Horizontal offset of the widget relative to the left edge of the window.
  * @param y              Vertical offset of the widget relative to the top edge of the window.
  * @param given_width    Width allocated to the widget.
@@ -767,7 +767,7 @@
 	this->resize_y = resize_y;
 }
 
-void NWidgetResizeBase::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetResizeBase::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
 	this->pos_x = x;
 	this->pos_y = y;
@@ -815,7 +815,7 @@
 	this->tool_tip = tool_tip;
 }
 
-int NWidgetCore::ComputeMinimalSize()
+int NWidgetCore::SetupSmallestSize()
 {
 	this->smallest_x = this->min_x;
 	this->smallest_y = this->min_y;
@@ -906,7 +906,7 @@
 {
 }
 
-int NWidgetStacked::ComputeMinimalSize()
+int NWidgetStacked::SetupSmallestSize()
 {
 	/* First sweep, recurse down and compute minimal size and filling. */
 	int biggest_index = -1;
@@ -917,7 +917,7 @@
 	this->resize_x = (this->head != NULL) ? 1 : 0;
 	this->resize_y = (this->head != NULL) ? 1 : 0;
 	for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
-		int idx = child_wid->ComputeMinimalSize();
+		int idx = child_wid->SetupSmallestSize();
 		biggest_index = max(biggest_index, idx);
 
 		this->smallest_x = max(this->smallest_x, child_wid->smallest_x + child_wid->padding_left + child_wid->padding_right);
@@ -930,7 +930,7 @@
 	return biggest_index;
 }
 
-void NWidgetStacked::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetStacked::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
 	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 
@@ -963,7 +963,7 @@
 			child_height = child_wid->smallest_y;
 			child_pos_y = (given_height - child_wid->padding_top - child_wid->padding_bottom - child_height) / 2;
 		}
-		child_wid->AssignMinimalPosition(x + child_pos_x, y + child_pos_y, child_width, child_height, (this->resize_x > 0), (this->resize_y > 0), rtl);
+		child_wid->AssignSizePosition(x + child_pos_x, y + child_pos_y, child_width, child_height, (this->resize_x > 0), (this->resize_y > 0), rtl);
 	}
 }
 
@@ -999,7 +999,7 @@
 {
 }
 
-int NWidgetHorizontal::ComputeMinimalSize()
+int NWidgetHorizontal::SetupSmallestSize()
 {
 	int biggest_index = -1;
 	this->smallest_x = 0;      // Sum of minimal size of all childs.
@@ -1011,7 +1011,7 @@
 
 	if (this->head != NULL) this->head->padding_left += this->pip_pre;
 	for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
-		int idx = child_wid->ComputeMinimalSize();
+		int idx = child_wid->SetupSmallestSize();
 		biggest_index = max(biggest_index, idx);
 
 		if (child_wid->next != NULL) {
@@ -1036,7 +1036,7 @@
 	return biggest_index;
 }
 
-void NWidgetHorizontal::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetHorizontal::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
 	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 
@@ -1084,7 +1084,7 @@
 			child_width += increment;
 		}
 
-		child_wid->AssignMinimalPosition(x + position + (rtl ? child_wid->padding_right : child_wid->padding_left), y + child_pos_y, child_width, child_height, allow_resize_x, (this->resize_y > 0), rtl);
+		child_wid->AssignSizePosition(x + position + (rtl ? child_wid->padding_right : child_wid->padding_left), y + child_pos_y, child_width, child_height, allow_resize_x, (this->resize_y > 0), rtl);
 		position += child_width + child_wid->padding_right + child_wid->padding_left;
 		if (child_wid->resize_x > 0) allow_resize_x = false; // Widget array allows only one child resizing
 
@@ -1109,9 +1109,9 @@
 	this->type = NWID_HORIZONTAL_LTR;
 }
 
-void NWidgetHorizontalLTR::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetHorizontalLTR::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
-	NWidgetHorizontal::AssignMinimalPosition(x, y, given_width, given_height, allow_resize_x, allow_resize_y, false);
+	NWidgetHorizontal::AssignSizePosition(x, y, given_width, given_height, allow_resize_x, allow_resize_y, false);
 }
 
 void NWidgetHorizontalLTR::StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl)
@@ -1124,7 +1124,7 @@
 {
 }
 
-int NWidgetVertical::ComputeMinimalSize()
+int NWidgetVertical::SetupSmallestSize()
 {
 	int biggest_index = -1;
 	this->smallest_x = 0;      // Biggest child.
@@ -1136,7 +1136,7 @@
 
 	if (this->head != NULL) this->head->padding_top += this->pip_pre;
 	for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
-		int idx = child_wid->ComputeMinimalSize();
+		int idx = child_wid->SetupSmallestSize();
 		biggest_index = max(biggest_index, idx);
 
 		if (child_wid->next != NULL) {
@@ -1161,7 +1161,7 @@
 	return biggest_index;
 }
 
-void NWidgetVertical::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetVertical::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
 	assert(given_width >= this->smallest_x && given_height >= this->smallest_y);
 
@@ -1207,7 +1207,7 @@
 			child_height += increment;
 		}
 
-		child_wid->AssignMinimalPosition(x + child_pos_x, y + position + child_wid->padding_top, child_width, child_height, (this->resize_x > 0), allow_resize_y, rtl);
+		child_wid->AssignSizePosition(x + child_pos_x, y + position + child_wid->padding_top, child_width, child_height, (this->resize_x > 0), allow_resize_y, rtl);
 		position += child_height + child_wid->padding_top + child_wid->padding_bottom;
 		if (child_wid->resize_y > 0) allow_resize_y = false; // Widget array allows only one child resizing
 	}
@@ -1232,7 +1232,7 @@
 	this->SetResize(0, 0);
 }
 
-int NWidgetSpacer::ComputeMinimalSize()
+int NWidgetSpacer::SetupSmallestSize()
 {
 	this->smallest_x = this->min_x;
 	this->smallest_y = this->min_y;
@@ -1299,11 +1299,11 @@
 	this->child->SetPIP(pip_pre, pip_inter, pip_post);
 }
 
-int NWidgetBackground::ComputeMinimalSize()
+int NWidgetBackground::SetupSmallestSize()
 {
 	int biggest_index = this->index;
 	if (this->child != NULL) {
-		int idx = this->child->ComputeMinimalSize();
+		int idx = this->child->SetupSmallestSize();
 		biggest_index = max(biggest_index, idx);
 
 		this->smallest_x = this->child->smallest_x;
@@ -1320,7 +1320,7 @@
 	return biggest_index;
 }
 
-void NWidgetBackground::AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
+void NWidgetBackground::AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl)
 {
 	this->pos_x = x;
 	this->pos_y = y;
@@ -1333,7 +1333,7 @@
 		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->AssignMinimalPosition(x + x_offset, y + this->child->padding_top, width, height, (this->resize_x > 0), (this->resize_y > 0), rtl);
+		this->child->AssignSizePosition(x + x_offset, y + this->child->padding_top, width, height, (this->resize_x > 0), (this->resize_y > 0), rtl);
 	}
 }
 
@@ -1442,8 +1442,8 @@
 Widget *InitializeNWidgets(NWidgetBase *nwid, bool rtl)
 {
 	/* Initialize nested widgets. */
-	int biggest_index = nwid->ComputeMinimalSize();
-	nwid->AssignMinimalPosition(0, 0, nwid->smallest_x, nwid->smallest_y, (nwid->resize_x > 0), (nwid->resize_y > 0), rtl);
+	int biggest_index = nwid->SetupSmallestSize();
+	nwid->AssignSizePosition(0, 0, nwid->smallest_x, nwid->smallest_y, (nwid->resize_x > 0), (nwid->resize_y > 0), rtl);
 
 	/* Construct a local widget array and initialize all its types to #WWT_LAST. */
 	Widget *widgets = MallocT<Widget>(biggest_index + 2);
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -152,8 +152,8 @@
 public:
 	NWidgetBase(WidgetType tp);
 
-	virtual int ComputeMinimalSize() = 0;
-	virtual void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl) = 0;
+	virtual int SetupSmallestSize() = 0;
+	virtual void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl) = 0;
 
 	virtual void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl) = 0;
 
@@ -178,7 +178,7 @@
 	uint resize_x;        ///< Horizontal resize step (\c 0 means not resizable).
 	uint resize_y;        ///< Vertical resize step (\c 0 means not resizable).
 	/* Size of the widget in the smallest window possible.
-	 * Computed by #ComputeMinimalSize() followed by #AssignMinimalPosition().
+	 * Computed by #SetupSmallestSize() followed by #AssignSizePosition().
 	 */
 	uint smallest_x;      ///< Smallest horizontal size of the widget in a filled window.
 	uint smallest_y;      ///< Smallest vertical size of the widget in a filled window.
@@ -205,7 +205,7 @@
 	void SetFill(bool fill_x, bool fill_y);
 	void SetResize(uint resize_x, uint resize_y);
 
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 
 	uint min_x; ///< Minimal horizontal size of only this widget.
 	uint min_y; ///< Minimal vertical size of only this widget.
@@ -220,7 +220,7 @@
 	void SetIndex(int index);
 	void SetDataTip(uint16 widget_data, StringID tool_tip);
 
-	int ComputeMinimalSize();
+	int SetupSmallestSize();
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 
 	Colours colour;     ///< Colour of this widget.
@@ -253,8 +253,8 @@
 public:
 	NWidgetStacked(WidgetType tp);
 
-	int ComputeMinimalSize();
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	int SetupSmallestSize();
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 };
 
@@ -277,8 +277,8 @@
 public:
 	NWidgetHorizontal();
 
-	int ComputeMinimalSize();
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	int SetupSmallestSize();
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 };
@@ -289,7 +289,7 @@
 public:
 	NWidgetHorizontalLTR();
 
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 };
@@ -300,8 +300,8 @@
 public:
 	NWidgetVertical();
 
-	int ComputeMinimalSize();
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	int SetupSmallestSize();
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 };
@@ -313,7 +313,7 @@
 public:
 	NWidgetSpacer(int length, int height);
 
-	int ComputeMinimalSize();
+	int SetupSmallestSize();
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 };
 
@@ -327,8 +327,8 @@
 	void Add(NWidgetBase *nwid);
 	void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
 
-	int ComputeMinimalSize();
-	void AssignMinimalPosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
+	int SetupSmallestSize();
+	void AssignSizePosition(uint x, uint y, uint given_width, uint given_height, bool allow_resize_x, bool allow_resize_y, bool rtl);
 
 	void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
 private: