summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Nelson <peter1138@openttd.org>2021-04-23 10:18:44 +0100
committerPeterN <peter@fuzzle.org>2021-04-30 17:08:15 +0100
commit957beaaefcaac0fa0b90a0a8354d418e65f53e19 (patch)
tree5f932de089ecccb115f681ac28b7042530f644a4
parent617e85cc65c8dae6dbdaad99856e36e094f16a94 (diff)
downloadopenttd-957beaaefcaac0fa0b90a0a8354d418e65f53e19.tar.xz
Fix: Improved scaling and spacing of sign list window.
Both company icon sprite and text now centred within each row, and extra padding added to avoid the sprites running into each other.
-rw-r--r--src/signs_gui.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index ea55488cc..93c4dd431 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -194,14 +194,16 @@ struct SignListWindow : Window, SignList {
switch (widget) {
case WID_SIL_LIST: {
uint y = r.top + WD_FRAMERECT_TOP; // Offset from top of widget.
+ uint text_offset_y = (this->resize.step_height - FONT_HEIGHT_NORMAL + 1) / 2;
/* No signs? */
if (this->vscroll->GetCount() == 0) {
- DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_STATION_LIST_NONE);
+ DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y + text_offset_y, STR_STATION_LIST_NONE);
return;
}
+ Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
bool rtl = _current_text_dir == TD_RTL;
- int sprite_offset_y = (FONT_HEIGHT_NORMAL - 10) / 2 + 1;
+ int sprite_offset_y = (this->resize.step_height - d.height + 1) / 2;
uint icon_left = 4 + (rtl ? r.right - this->text_offset : r.left);
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
@@ -213,7 +215,7 @@ struct SignListWindow : Window, SignList {
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
SetDParam(0, si->index);
- DrawString(text_left, text_right, y, STR_SIGN_NAME, TC_YELLOW);
+ DrawString(text_left, text_right, y + text_offset_y, STR_SIGN_NAME, TC_YELLOW);
y += this->resize.step_height;
}
break;
@@ -264,7 +266,7 @@ struct SignListWindow : Window, SignList {
case WID_SIL_LIST: {
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
- resize->height = std::max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height);
+ resize->height = std::max<uint>(FONT_HEIGHT_NORMAL, spr_dim.height + 2);
Dimension d = {(uint)(this->text_offset + WD_FRAMETEXT_RIGHT), WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
*size = maxdim(*size, d);
break;
@@ -365,8 +367,8 @@ static const NWidgetPart _nested_sign_list_widgets[] = {
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(NWID_VERTICAL),
- NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 50),
- SetResize(1, 10), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + 255 + WD_FRAMETEXT_RIGHT, 0),
+ SetResize(1, 1), SetFill(1, 0), SetScrollbar(WID_SIL_SCROLLBAR), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_SIL_FILTER_TEXT), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),