From e00e8b3f6460ccd940e620672028add78c44cab1 Mon Sep 17 00:00:00 2001 From: hap Date: Sat, 3 Feb 2024 12:54:00 +0100 Subject: ui menu: readjust visible width if heading width exceeds that of the menu --- src/frontend/mame/ui/menu.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index 9c2ffebd951..da39179fb60 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -525,6 +525,9 @@ void menu::draw(uint32_t flags) { heading_layout.emplace(create_layout(max_width - (gutter_width() * 2.0F), text_layout::text_justify::CENTER)); heading_layout->add_text(*m_heading, ui().colors().text_color()); + + // readjust visible width if heading width exceeds that of the menu + visible_width = std::max(gutter_width() + heading_layout->actual_width() + gutter_width(), visible_width); } // account for extra space at the top and bottom @@ -558,17 +561,14 @@ void menu::draw(uint32_t flags) { if (heading_layout) { - float const heading_width = heading_layout->actual_width(); - float const heading_left = (1.0F - heading_width) * 0.5F; - float const hx1 = std::min(x1, heading_left - gutter_width() - lr_border()); - float const hx2 = std::max(x2, heading_left + heading_width + gutter_width() + lr_border()); ui().draw_outlined_box( container(), - hx1, y1 - top_extra_menu_height, - hx2, y1 - m_customtop - tb_border(), + x1, y1 - top_extra_menu_height, + x2, y1 - m_customtop - tb_border(), UI_GREEN_COLOR); heading_layout->emit(container(), (1.0F - heading_layout->width()) * 0.5F, y1 - top_extra_menu_height + tb_border()); } + ui().draw_outlined_box( container(), x1, y1, -- cgit v1.2.3