summaryrefslogtreecommitdiff
path: root/src/gfx_func.h
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2017-03-23 22:00:00 +0000
committerpeter1138 <peter1138@openttd.org>2017-03-23 22:00:00 +0000
commitbcc5c9f81d2c3fb3f31ba1dce647c7974d46cbd2 (patch)
tree977fd4ee0d891ade919492072aafc4d303bdf14e /src/gfx_func.h
parent902663176d468781d01269eed98879989cdb8a70 (diff)
downloadopenttd-bcc5c9f81d2c3fb3f31ba1dce647c7974d46cbd2.tar.xz
(svn r27821) -Change: Draw images in centre of buttons (inspired by Juanjo)
Diffstat (limited to 'src/gfx_func.h')
-rw-r--r--src/gfx_func.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/gfx_func.h b/src/gfx_func.h
index 566f91b2d..44f5e5059 100644
--- a/src/gfx_func.h
+++ b/src/gfx_func.h
@@ -142,6 +142,18 @@ void CheckBlitter();
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
+/**
+ * Determine where to draw a centred object inside a widget.
+ * @param min The top or left coordinate.
+ * @param max The bottom or right coordinate.
+ * @param size The height or width of the object to draw.
+ * @return Offset of where to start drawing the object.
+ */
+static inline int CenterBounds(int min, int max, uint size)
+{
+ return min + (max - min - size + 1) / 2;
+}
+
/* window.cpp */
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);