Changeset - r21718:9797fe8cc7c8
[Not reviewed]
master
0 1 0
peter1138 - 10 years ago 2014-09-20 12:25:36
peter1138@openttd.org
(svn r26861) -Codechange: Include height of dropdown image in dropdown widget. Draw vertically centred image in dropdown button.
1 file changed with 6 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/widget.cpp
Show inline comments
 
@@ -571,17 +571,19 @@ static inline void DrawButtonDropdown(co
 
{
 
	int text_offset = max(0, ((int)(r.bottom - r.top + 1) - FONT_HEIGHT_NORMAL) / 2); // Offset for rendering the text vertically centered
 

	
 
	int dd_width = NWidgetLeaf::dropdown_dimension.width;
 
	int dd_width  = NWidgetLeaf::dropdown_dimension.width;
 
	int dd_height = NWidgetLeaf::dropdown_dimension.height;
 
	int image_offset = max(0, ((int)(r.bottom - r.top + 1) - dd_height) / 2);
 

	
 
	if (_current_text_dir == TD_LTR) {
 
		DrawFrameRect(r.left, r.top, r.right - dd_width, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
		DrawFrameRect(r.right + 1 - dd_width, r.top, r.right, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 
		DrawString(r.right - dd_width + (clicked_dropdown ? 2 : 1), r.right, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
 
		DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.right - (dd_width - 2) + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
		if (str != STR_NULL) DrawString(r.left + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - dd_width - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK);
 
	} else {
 
		DrawFrameRect(r.left + dd_width, r.top, r.right, r.bottom, colour, clicked_button ? FR_LOWERED : FR_NONE);
 
		DrawFrameRect(r.left, r.top, r.left + dd_width - 1, r.bottom, colour, clicked_dropdown ? FR_LOWERED : FR_NONE);
 
		DrawString(r.left + (clicked_dropdown ? 2 : 1), r.left + dd_width, r.top + (clicked_dropdown ? 2 : 1), DOWNARROW, TC_BLACK, SA_HOR_CENTER);
 
		DrawSprite(SPR_ARROW_DOWN, PAL_NONE, r.left + 1 + clicked_dropdown, r.top + image_offset + clicked_dropdown);
 
		if (str != STR_NULL) DrawString(r.left + dd_width + WD_DROPDOWNTEXT_LEFT + clicked_button, r.right - WD_DROPDOWNTEXT_RIGHT + clicked_button, r.top + text_offset + clicked_button, str, TC_BLACK);
 
	}
 
}
 
@@ -2358,7 +2360,7 @@ void NWidgetLeaf::SetupSmallestSize(Wind
 
			if (this->index >= 0) w->SetStringParameters(this->index);
 
			Dimension d2 = GetStringBoundingBox(this->widget_data);
 
			d2.width += extra.width;
 
			d2.height += extra.height;
 
			d2.height = max(d2.height, NWidgetLeaf::dropdown_dimension.height) + extra.height;
 
			size = maxdim(size, d2);
 
			break;
 
		}
0 comments (0 inline, 0 general)