From f68093a3e526ea71fc67bd764c2f1ef0e39b9438 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Sat, 22 Jun 2013 20:09:00 +0200 Subject: [PATCH 179/249] Functions for drawing vertically aligned strings. --- src/gfx_func.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gfx_func.h b/src/gfx_func.h index 3a59073..4750b3c 100644 --- a/src/gfx_func.h +++ b/src/gfx_func.h @@ -181,6 +181,18 @@ void UpdateMarginsWidth(int width, int &left, int &right, bool to_end_line); void DrawString2(int left, int right, int top, int &margin, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false); void DrawSprite2(int width, int left, int right, int top, int &margin, SpriteID img, PaletteID pal, bool to_end_line = false, SubSprite *sub = NULL); +/** + * Return where to start drawing a centered object inside a widget. + * @param top The top coordinate (or the left coordinate) of the widget. + * @param height The height (or width) of the widget. + * @param size The height (or width) of the object to draw. + * @return The coordinate where to start drawing the centered object. + */ +static inline int Center(int top, int height, uint size = FONT_HEIGHT_NORMAL) +{ + return top + (height - size) / 2; +} + extern DrawPixelInfo *_cur_dpi; TextColour GetContrastColour(uint8 background); -- 1.8.1.2