Skip to content

Commit e00e8b3

Browse files
committed
ui menu: readjust visible width if heading width exceeds that of the menu
1 parent 7e48d03 commit e00e8b3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/frontend/mame/ui/menu.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ void menu::draw(uint32_t flags)
525525
{
526526
heading_layout.emplace(create_layout(max_width - (gutter_width() * 2.0F), text_layout::text_justify::CENTER));
527527
heading_layout->add_text(*m_heading, ui().colors().text_color());
528+
529+
// readjust visible width if heading width exceeds that of the menu
530+
visible_width = std::max(gutter_width() + heading_layout->actual_width() + gutter_width(), visible_width);
528531
}
529532

530533
// account for extra space at the top and bottom
@@ -558,17 +561,14 @@ void menu::draw(uint32_t flags)
558561
{
559562
if (heading_layout)
560563
{
561-
float const heading_width = heading_layout->actual_width();
562-
float const heading_left = (1.0F - heading_width) * 0.5F;
563-
float const hx1 = std::min(x1, heading_left - gutter_width() - lr_border());
564-
float const hx2 = std::max(x2, heading_left + heading_width + gutter_width() + lr_border());
565564
ui().draw_outlined_box(
566565
container(),
567-
hx1, y1 - top_extra_menu_height,
568-
hx2, y1 - m_customtop - tb_border(),
566+
x1, y1 - top_extra_menu_height,
567+
x2, y1 - m_customtop - tb_border(),
569568
UI_GREEN_COLOR);
570569
heading_layout->emit(container(), (1.0F - heading_layout->width()) * 0.5F, y1 - top_extra_menu_height + tb_border());
571570
}
571+
572572
ui().draw_outlined_box(
573573
container(),
574574
x1, y1,

0 commit comments

Comments
 (0)