summaryrefslogtreecommitdiff
path: root/src/widget_type.h
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-05-16 19:13:31 +0000
committeralberth <alberth@openttd.org>2010-05-16 19:13:31 +0000
commitb3be440d78f155f6aa0d69cfe7824d65b1394381 (patch)
tree7264f37f1750ebc75ad7ce8123f3241b7dda0274 /src/widget_type.h
parenta774a286623378fe114a9769f75ee1b142aac8e5 (diff)
downloadopenttd-b3be440d78f155f6aa0d69cfe7824d65b1394381.tar.xz
(svn r19843) -Codechange: Move ComputeMaxSize() to widget_type.h to make it globally accessible.
Diffstat (limited to 'src/widget_type.h')
-rw-r--r--src/widget_type.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/widget_type.h b/src/widget_type.h
index fca5f3c56..29cb13acd 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -486,6 +486,22 @@ private:
};
/**
+ * Return the biggest possible size of a nested widget.
+ * @param base Base size of the widget.
+ * @param max_space Available space for the widget.
+ * @param step Stepsize of the widget.
+ * @return Biggest possible size of the widget, assuming that \a base may only be incremented by \a step size steps.
+ */
+static FORCEINLINE uint ComputeMaxSize(uint base, uint max_space, uint step)
+{
+ if (base >= max_space || step == 0) return base;
+ if (step == 1) return max_space;
+ uint increment = max_space - base;
+ increment -= increment % step;
+ return base + increment;
+}
+
+/**
* @defgroup NestedWidgetParts Hierarchical widget parts
* To make nested widgets easier to enter, nested widget parts have been created. They allow the tree to be defined in a flat array of parts.
*