From 32ff1d77fae070b0b8a10a3249363830be81b38c Mon Sep 17 00:00:00 2001 From: James De Ricco Date: Tue, 21 Nov 2023 15:00:10 -0500 Subject: [PATCH] Anchor menu help text to the screen bottom to fix cropping of long text Fix cropping of more than 4 line menu item help texts by anchoring the bottom of the help text display to the bottom of the screen. This prevents the help text from growing off of the screen when the help text is long. --- src/gui/menu.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 9954e62cdb2..1e50ac08830 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -597,10 +597,12 @@ Menu::draw(DrawingContext& context) const int text_width = static_cast(Resources::normal_font->get_text_width(m_items[m_active_item]->get_help())); const int text_height = static_cast(Resources::normal_font->get_text_height(m_items[m_active_item]->get_help())); + const float margin_y = 16.0f; + const Rectf text_rect(m_pos.x - static_cast(text_width) / 2.0f - 8.0f, - static_cast(SCREEN_HEIGHT) - 48.0f - static_cast(text_height) / 2.0f - 4.0f, + static_cast(SCREEN_HEIGHT) - margin_y - static_cast(text_height) - 4.0f, m_pos.x + static_cast(text_width) / 2.0f + 8.0f, - static_cast(SCREEN_HEIGHT) - 48.0f + static_cast(text_height) / 2.0f + 4.0f); + static_cast(SCREEN_HEIGHT) - margin_y + 4.0f); context.color().draw_filled_rect(Rectf(text_rect.p1() - Vector(4,4), text_rect.p2() + Vector(4,4)), @@ -614,7 +616,7 @@ Menu::draw(DrawingContext& context) LAYER_GUI); context.color().draw_text(Resources::normal_font, m_items[m_active_item]->get_help(), - Vector(m_pos.x, static_cast(SCREEN_HEIGHT) - 48.0f - static_cast(text_height) / 2.0f), + Vector(m_pos.x, static_cast(SCREEN_HEIGHT) - margin_y - static_cast(text_height)), ALIGN_CENTER, LAYER_GUI); } }