Changeset - r18181:94a95ed05f19
[Not reviewed]
master
0 1 0
peter1138 - 13 years ago 2011-10-11 13:22:31
peter1138@openttd.org
(svn r23020) -Codechange: Vertically centre caption text if the caption height is taller than the text.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/widget.cpp
Show inline comments
 
@@ -514,7 +514,11 @@ void DrawCaption(const Rect &r, Colours 
 
		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);
 
	}
 
}
 

	
 
/**
0 comments (0 inline, 0 general)