1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Introduce widget::textTop

This commit is contained in:
Aaron van Geffen
2020-06-26 19:33:04 +02:00
parent 2e153a7e95
commit 2cb5402069
2 changed files with 14 additions and 16 deletions

View File

@@ -345,12 +345,7 @@ static void widget_text_centred(rct_drawpixelinfo* dpi, rct_window* w, rct_widge
int32_t r = w->windowPos.x + widget->right;
if (widget->type == WWT_BUTTON || widget->type == WWT_TABLE_HEADER)
{
if (widget->height() >= 10)
topLeft.y += std::max<int32_t>(widget->top, widget->top + (widget->height() / 2) - 5);
else
topLeft.y += widget->top - 1;
}
topLeft.y += widget->textTop();
else
topLeft.y += widget->top;
@@ -390,10 +385,7 @@ static void widget_text(rct_drawpixelinfo* dpi, rct_window* w, rct_widgetindex w
if (widget->type == WWT_BUTTON || widget->type == WWT_DROPDOWN || widget->type == WWT_SPINNER
|| widget->type == WWT_TABLE_HEADER)
{
if (widget->height() >= 10)
t = w->windowPos.y + std::max<int32_t>(widget->top, widget->top + (widget->height() / 2) - 5);
else
t = w->windowPos.y + widget->top - 1;
t = w->windowPos.y + widget->textTop();
}
else
t = w->windowPos.y + widget->top;
@@ -1054,10 +1046,7 @@ static void widget_text_box_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg
gCurrentFontFlags = 0;
// Figure out where the text should be positioned vertically.
if (widget->height() >= 10)
t = w->windowPos.y + std::max<int32_t>(widget->top, widget->top + (widget->height() / 2) - 5);
else
t = w->windowPos.y + widget->top - 1;
t = w->windowPos.y + widget->textTop();
if (!active || gTextInput == nullptr)
{
@@ -1076,7 +1065,7 @@ static void widget_text_box_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg
// +13 for cursor when max length.
gfx_wrap_string(wrapped_string, r - l - 5 - 6, &no_lines, &font_height);
gfx_draw_string(dpi, wrapped_string, w->colours[1], { l + 2, t + 1 });
gfx_draw_string(dpi, wrapped_string, w->colours[1], { l + 2, t });
size_t string_length = get_string_size(wrapped_string) - 1;
@@ -1098,6 +1087,7 @@ static void widget_text_box_draw(rct_drawpixelinfo* dpi, rct_window* w, rct_widg
if (gTextBoxFrameNo <= 15)
{
colour = ColourMapA[w->colours[1]].mid_light;
gfx_fill_rect(dpi, cur_x, t + (widget->height() - 1), cur_x + width, t + (widget->height() - 1), colour + 5);
auto y = t + (widget->height() - 1);
gfx_fill_rect(dpi, cur_x, y, cur_x + width, y, colour + 5);
}
}