diff options
author | peter1138 <peter1138@openttd.org> | 2011-10-11 13:22:31 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2011-10-11 13:22:31 +0000 |
commit | b0b93cd4a7986dd0a951ded77eb087c6d4535c64 (patch) | |
tree | e101c9730d21be72dd6e8abfbb7c2ee24468dc5d /src | |
parent | e11c39b60b93efac318602f1d1639810c176d746 (diff) | |
download | openttd-b0b93cd4a7986dd0a951ded77eb087c6d4535c64.tar.xz |
(svn r23020) -Codechange: Vertically centre caption text if the caption height is taller than the text.
Diffstat (limited to 'src')
-rw-r--r-- | src/widget.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/widget.cpp b/src/widget.cpp index c4c48d3da..5e02ed831 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -514,7 +514,11 @@ void DrawCaption(const Rect &r, Colours colour, Owner owner, StringID str) GfxFillRect(r.left + 2, r.top + 2, r.right - 2, r.bottom - 2, _colour_gradient[_company_colours[owner]][4]); } - if (str != STR_NULL) DrawString(r.left + WD_CAPTIONTEXT_LEFT, r.right - WD_CAPTIONTEXT_RIGHT, r.top + WD_CAPTIONTEXT_TOP, str, TC_FROMSTRING, SA_HOR_CENTER); + if (str != STR_NULL) { + Dimension d = GetStringBoundingBox(str); + int offset = max(0, ((int)(r.bottom - r.top + 1) - (int)d.height) / 2); // Offset for rendering the text vertically centered + DrawString(r.left + WD_CAPTIONTEXT_LEFT, r.right - WD_CAPTIONTEXT_RIGHT, r.top + offset, str, TC_FROMSTRING, SA_HOR_CENTER); + } } /** |