summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2014-09-20 12:25:36 +0000
committerpeter1138 <peter1138@openttd.org>2014-09-20 12:25:36 +0000
commit34551da87983c372b52bab966ecb4f4508f9f894 (patch)
treee4f9c135f4e72749f304f67946b8ce2d12d4ab15
parent4c45db295e9a59f0a2604b40aea462d277e2a499 (diff)
downloadopenttd-34551da87983c372b52bab966ecb4f4508f9f894.tar.xz
(svn r26861) -Codechange: Include height of dropdown image in dropdown widget. Draw vertically centred image in dropdown button.
-rw-r--r--src/widget.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index 8de44dbfc..a1bd7a3c7 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -571,17 +571,19 @@ static inline void DrawButtonDropdown(const Rect &r, Colours colour, bool clicke
{
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(Window *w, bool init_array)
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;
}