summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-01-05 03:45:00 +1100
committer Vas Crabb <vas@vastheman.com>2023-01-05 03:45:00 +1100
commitf8480ce3f64ef309dea2ad96321536ff032c0764 (patch)
tree3dc81fbcfb8c92f6eebc6f568779d8c05802c33a /src/frontend/mame/ui
parent6215cdca45304f559d2ec539b62488f815d437d6 (diff)
More UI cleanup:
* Got rid of more UI globals. * Cache more metrics in system/software selection menus. * Don't lose a BDF font specified on the command line when changing font size via the UI. * For win32 debugger, behave as though most recent history item was just entered when restoring session state.
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r--src/frontend/mame/ui/custui.cpp48
-rw-r--r--src/frontend/mame/ui/custui.h2
-rw-r--r--src/frontend/mame/ui/selgame.cpp14
-rw-r--r--src/frontend/mame/ui/selmenu.cpp199
-rw-r--r--src/frontend/mame/ui/selmenu.h17
-rw-r--r--src/frontend/mame/ui/selsoft.cpp2
-rw-r--r--src/frontend/mame/ui/utils.cpp3
-rw-r--r--src/frontend/mame/ui/utils.h4
8 files changed, 148 insertions, 141 deletions
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index c4d9e12ea70..35c8bd29bd1 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -78,6 +78,7 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container &container
, m_handler(std::move(handler))
, m_currlang(0)
, m_currsysnames(0)
+ , m_currpanels(ui().options().hide_panels())
{
set_process_flags(PROCESS_LR_REPEAT);
set_heading(_("Customize UI"));
@@ -92,7 +93,7 @@ menu_custom_ui::menu_custom_ui(mame_ui_manager &mui, render_container &container
void menu_custom_ui::menu_dismissed()
{
- ui().options().set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE);
+ ui().options().set_value(OPTION_HIDE_PANELS, m_currpanels, OPTION_PRIORITY_CMDLINE);
machine().options().set_value(OPTION_LANGUAGE, m_currlang ? m_languages[m_currlang] : "", OPTION_PRIORITY_CMDLINE);
load_translation(machine().options());
@@ -178,23 +179,23 @@ void menu_custom_ui::handle(event const *ev)
if ((ev->iptkey == IPT_UI_LEFT) || (ev->iptkey == IPT_UI_RIGHT) || (ev->iptkey == IPT_UI_CLEAR))
{
if (ev->iptkey == IPT_UI_LEFT)
- --ui_globals::panels_status;
+ --m_currpanels;
else if (ev->iptkey == IPT_UI_RIGHT)
- ++ui_globals::panels_status;
+ ++m_currpanels;
else
- ui_globals::panels_status = 0;
- ev->item->set_subtext(_(HIDE_STATUS[ui_globals::panels_status]));
- ev->item->set_flags(get_arrow_flags<uint16_t>(0, HIDE_BOTH, ui_globals::panels_status));
+ m_currpanels = 0;
+ ev->item->set_subtext(_(HIDE_STATUS[m_currpanels]));
+ ev->item->set_flags(get_arrow_flags<uint16_t>(0, HIDE_BOTH, m_currpanels));
}
else if (ev->iptkey == IPT_UI_SELECT)
{
std::vector<std::string> s_sel(std::size(HIDE_STATUS));
std::transform(std::begin(HIDE_STATUS), std::end(HIDE_STATUS), s_sel.begin(), [](auto &s) { return _(s); });
menu::stack_push<menu_selector>(
- ui(), container(), _("Show Side Panels"), std::move(s_sel), ui_globals::panels_status,
- [item = ev->item] (int selection)
+ ui(), container(), _("Show Side Panels"), std::move(s_sel), m_currpanels,
+ [this, item = ev->item] (int selection)
{
- ui_globals::panels_status = selection;
+ m_currpanels = selection;
item->set_subtext(_(HIDE_STATUS[selection]));
item->set_flags(get_arrow_flags<uint16_t>(0, HIDE_BOTH, selection));
});
@@ -220,8 +221,8 @@ void menu_custom_ui::populate(float &customtop, float &custombottom)
arrow_flags = get_arrow_flags<std::size_t>(0, m_sysnames.size() - 1, m_currsysnames);
item_append(_("System Names"), m_sysnames[m_currsysnames], arrow_flags, (void *)(uintptr_t)SYSNAMES_MENU);
- arrow_flags = get_arrow_flags<uint16_t>(0, HIDE_BOTH, ui_globals::panels_status);
- item_append(_("Show Side Panels"), _(HIDE_STATUS[ui_globals::panels_status]), arrow_flags, (void *)(uintptr_t)HIDE_MENU);
+ arrow_flags = get_arrow_flags<uint16_t>(0, HIDE_BOTH, m_currpanels);
+ item_append(_("Show Side Panels"), _(HIDE_STATUS[m_currpanels]), arrow_flags, (void *)(uintptr_t)HIDE_MENU);
item_append(menu_item_type::SEPARATOR);
}
@@ -328,6 +329,7 @@ menu_font_ui::menu_font_ui(mame_ui_manager &mui, render_container &container, st
, m_info_min(parse_number<float>(mui.options().get_entry(OPTION_INFOS_SIZE)->minimum()))
, m_info_max(parse_number<float>(mui.options().get_entry(OPTION_INFOS_SIZE)->maximum()))
, m_info_size(mui.options().infos_size())
+ , m_face_changed(false)
, m_changed(false)
, m_actual(0U)
{
@@ -374,17 +376,20 @@ void menu_font_ui::menu_dismissed()
{
ui_options &moptions = ui().options();
- std::string name(m_fonts[m_actual].first);
-#ifdef UI_WINDOWS
- if (name != "default")
+ if (m_face_changed)
{
- if (m_italic)
- name.insert(0, "[I]");
- if (m_bold)
- name.insert(0, "[B]");
- }
+ std::string name(m_fonts[m_actual].first);
+#ifdef UI_WINDOWS
+ if (name != "default")
+ {
+ if (m_italic)
+ name.insert(0, "[I]");
+ if (m_bold)
+ name.insert(0, "[B]");
+ }
#endif
- machine().options().set_value(OPTION_UI_FONT, name, OPTION_PRIORITY_CMDLINE);
+ machine().options().set_value(OPTION_UI_FONT, name, OPTION_PRIORITY_CMDLINE);
+ }
moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE);
moptions.set_value(OPTION_FONT_ROWS, m_font_size, OPTION_PRIORITY_CMDLINE);
@@ -440,6 +445,7 @@ void menu_font_ui::handle(event const *ev)
case MUI_FNT:
if ((ev->iptkey == IPT_UI_LEFT) || (ev->iptkey == IPT_UI_RIGHT) || (ev->iptkey == IPT_UI_CLEAR))
{
+ m_face_changed = true;
m_changed = true;
if (ev->iptkey == IPT_UI_LEFT)
--m_actual;
@@ -459,6 +465,7 @@ void menu_font_ui::handle(event const *ev)
ui(), container(), _("UI Font"), std::move(display_names), m_actual,
[this] (int selection)
{
+ m_face_changed = true;
m_changed = true;
m_actual = selection;
reset(reset_options::REMEMBER_REF);
@@ -471,6 +478,7 @@ void menu_font_ui::handle(event const *ev)
case MUI_ITALIC:
if ((ev->iptkey == IPT_UI_LEFT) || (ev->iptkey == IPT_UI_RIGHT) || (ev->iptkey == IPT_UI_SELECT) || (ev->iptkey == IPT_UI_CLEAR))
{
+ m_face_changed = true;
m_changed = true;
bool &val = ((uintptr_t)ev->itemref == MUI_BOLD) ? m_bold : m_italic;
if (ev->iptkey == IPT_UI_CLEAR)
diff --git a/src/frontend/mame/ui/custui.h b/src/frontend/mame/ui/custui.h
index 6a5e09ae954..f720318d854 100644
--- a/src/frontend/mame/ui/custui.h
+++ b/src/frontend/mame/ui/custui.h
@@ -44,6 +44,7 @@ private:
std::vector<std::string> m_sysnames;
std::size_t m_currlang;
std::size_t m_currsysnames;
+ u8 m_currpanels;
};
//-------------------------------------------------
@@ -71,6 +72,7 @@ private:
int m_font_size;
float const m_info_min, m_info_max;
float m_info_size;
+ bool m_face_changed;
bool m_changed;
std::uint16_t m_actual;
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index 9ca733bef99..7b268f7ba97 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -112,7 +112,6 @@ menu_select_game::menu_select_game(mame_ui_manager &mui, render_container &conta
set_right_image(moptions.system_right_image());
ui_globals::curdats_view = 0;
- ui_globals::panels_status = moptions.hide_panels();
ui_globals::curdats_total = 1;
}
@@ -145,6 +144,8 @@ void menu_select_game::recompute_metrics(uint32_t width, uint32_t height, float
void menu_select_game::menu_activated()
{
+ menu_select_launch::menu_activated();
+
// if I have to load datfile, perform a hard reset
if (ui_globals::reset)
{
@@ -155,11 +156,6 @@ void menu_select_game::menu_activated()
ui_globals::reset = false;
machine().schedule_hard_reset();
stack_reset();
- return;
- }
- else
- {
- menu_select_launch::menu_activated();
}
}
@@ -185,7 +181,6 @@ void menu_select_game::menu_deactivated()
std::string const filter(m_persistent_data.filter_data().get_config_string());
ui_options &mopt = ui().options();
- mopt.set_value(OPTION_HIDE_PANELS, ui_globals::panels_status, OPTION_PRIORITY_CMDLINE);
mopt.set_value(OPTION_LAST_USED_MACHINE, last_driver, OPTION_PRIORITY_CMDLINE);
mopt.set_value(OPTION_LAST_USED_FILTER, filter, OPTION_PRIORITY_CMDLINE);
mopt.set_value(OPTION_SYSTEM_RIGHT_PANEL, right_panel_config_string(), OPTION_PRIORITY_CMDLINE);
@@ -481,10 +476,7 @@ void menu_select_game::populate(float &customtop, float &custombottom)
if (old_item_selected != -1)
{
set_selected_index(old_item_selected);
- if (ui_globals::visible_main_lines == 0)
- top_line = (selected_index() != 0) ? selected_index() - 1 : 0;
- else
- top_line = selected_index() - (ui_globals::visible_main_lines / 2);
+ centre_selection();
if (reselect_last::software().empty())
reselect_last::reset();
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index ff11e43d32d..7cceaa6ccb8 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -164,8 +164,6 @@ void load_driver_image(bitmap_argb32 &bitmap, emu_file &file, game_driver const
} // anonymous namespace
-constexpr std::size_t menu_select_launch::MAX_VISIBLE_SEARCH; // stupid non-inline semantics
-
class menu_select_launch::software_parts : public menu
{
@@ -254,6 +252,10 @@ void menu_select_launch::reselect_last::set_software(game_driver const &driver,
}
+inline bool menu_select_launch::show_left_panel() const { return !(m_panels_status & HIDE_LEFT_PANEL); }
+inline bool menu_select_launch::show_right_panel() const { return !(m_panels_status & HIDE_RIGHT_PANEL); }
+
+
//-------------------------------------------------
// ctor
//-------------------------------------------------
@@ -500,12 +502,19 @@ menu_select_launch::menu_select_launch(mame_ui_manager &mui, render_container &c
, m_items_list()
, m_info_buffer()
, m_info_layout()
+ , m_icon_width(0)
+ , m_icon_height(0)
+ , m_divider_width(0.0F)
+ , m_divider_arrow_width(0.0F)
+ , m_divider_arrow_height(0.0F)
+ , m_info_line_height(0.0F)
, m_cache(mui.get_session_data<menu_select_launch, cache_wrapper>(machine()))
, m_is_swlist(is_swlist)
, m_focus(focused_menu::MAIN)
, m_pressed(false)
, m_repeat(0)
, m_right_visible_lines(0)
+ , m_panels_status(SHOW_PANELS)
, m_right_panel(RP_FIRST)
, m_has_icons(false)
, m_switch_image(false)
@@ -619,6 +628,23 @@ void menu_select_launch::recompute_metrics(uint32_t width, uint32_t height, floa
{
menu::recompute_metrics(width, height, aspect);
+ // calculate icon size in pixels
+ render_target const &target(machine().render().ui_target());
+ bool const rotated((target.orientation() & ORIENTATION_SWAP_XY) != 0);
+ m_icon_width = int((rotated ? height : width) * line_height() * aspect);
+ m_icon_height = int((rotated ? width : height) * line_height());
+
+ // force info text to be laid out again
+ m_info_layout = std::nullopt;
+
+ // calculate size of dividers between panes
+ m_divider_width = 2.0F * lr_border();
+ m_divider_arrow_width = 0.4F * m_divider_width;
+ m_divider_arrow_height = 2.0F * tb_border();
+
+ // calculate info text size
+ m_info_line_height = ui().get_line_height(ui().options().infos_size());
+
// force right panel images to be redrawn
m_cache.set_snapx_driver(nullptr);
m_cache.set_snapx_software(nullptr);
@@ -756,6 +782,18 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto
}
+void menu_select_launch::menu_activated()
+{
+ m_panels_status = ui().options().hide_panels();
+}
+
+
+void menu_select_launch::menu_deactivated()
+{
+ ui().options().set_value(OPTION_HIDE_PANELS, m_panels_status, OPTION_PRIORITY_CMDLINE);
+}
+
+
void menu_select_launch::rotate_focus(int dir)
{
switch (get_focus())
@@ -763,30 +801,30 @@ void menu_select_launch::rotate_focus(int dir)
case focused_menu::MAIN:
if (selected_index() > m_available_items)
{
- if ((0 > dir) || (ui_globals::panels_status == HIDE_BOTH))
+ if ((0 > dir) || (m_panels_status == HIDE_BOTH))
select_prev();
- else if (ui_globals::panels_status == HIDE_LEFT_PANEL)
+ else if (m_panels_status == HIDE_LEFT_PANEL)
set_focus(focused_menu::RIGHTTOP);
else
set_focus(focused_menu::LEFT);
}
- else if (m_skip_main_items || (ui_globals::panels_status != HIDE_BOTH))
+ else if (m_skip_main_items || (m_panels_status != HIDE_BOTH))
{
m_prev_selected = get_selection_ref();
if (0 < dir)
{
if (m_skip_main_items)
set_selected_index(m_available_items + 1);
- else if (ui_globals::panels_status == HIDE_LEFT_PANEL)
+ else if (m_panels_status == HIDE_LEFT_PANEL)
set_focus(focused_menu::RIGHTTOP);
else
set_focus(focused_menu::LEFT);
}
- else if (ui_globals::panels_status == HIDE_RIGHT_PANEL)
+ else if (m_panels_status == HIDE_RIGHT_PANEL)
{
set_focus(focused_menu::LEFT);
}
- else if (ui_globals::panels_status != HIDE_BOTH)
+ else if (m_panels_status != HIDE_BOTH)
{
set_focus(focused_menu::RIGHTBOTTOM);
}
@@ -806,7 +844,7 @@ void menu_select_launch::rotate_focus(int dir)
else
select_prev();
}
- else if (ui_globals::panels_status != HIDE_RIGHT_PANEL)
+ else if (m_panels_status != HIDE_RIGHT_PANEL)
{
set_focus(focused_menu::RIGHTTOP);
}
@@ -822,7 +860,7 @@ void menu_select_launch::rotate_focus(int dir)
{
set_focus(focused_menu::RIGHTBOTTOM);
}
- else if (ui_globals::panels_status != HIDE_LEFT_PANEL)
+ else if (m_panels_status != HIDE_LEFT_PANEL)
{
set_focus(focused_menu::LEFT);
}
@@ -957,13 +995,12 @@ float menu_select_launch::draw_left_panel(
std::map<typename Filter::type, typename Filter::ptr> const &filters,
float x1, float y1, float x2, float y2)
{
- if ((ui_globals::panels_status != SHOW_PANELS) && (ui_globals::panels_status != HIDE_RIGHT_PANEL))
+ if (!show_left_panel())
return draw_collapsed_left_panel(x1, y1, x2, y2);
// calculate line height
- float const target_height(ui().get_line_height(ui().options().infos_size()));
float const sc(y2 - y1 - (2.0F * tb_border()));
- float line_height_max(target_height);
+ float line_height_max(m_info_line_height);
if ((Filter::COUNT * line_height_max) > sc)
{
float const lm(sc / Filter::COUNT);
@@ -972,12 +1009,12 @@ float menu_select_launch::draw_left_panel(
// calculate horizontal offset for unadorned names
std::string tmp(convert_command_glyph("_# "));
- float const text_sign = ui().get_string_width(tmp, target_height);
+ float const text_sign = ui().get_string_width(tmp, m_info_line_height);
// get the maximum width of a filter name
float left_width(0.0F);
for (typename Filter::type x = Filter::FIRST; Filter::COUNT > x; ++x)
- left_width = std::max(ui().get_string_width(Filter::display_name(x), target_height) + text_sign, left_width);
+ left_width = std::max(ui().get_string_width(Filter::display_name(x), m_info_line_height) + text_sign, left_width);
left_width = std::min(left_width, 0.25F);
// outline the box and inset by the border width
@@ -1037,22 +1074,20 @@ float menu_select_launch::draw_left_panel(
text_layout::text_justify::LEFT, text_layout::word_wrapping::TRUNCATE,
mame_ui_manager::NORMAL, fgcolor, bgcolor,
nullptr, nullptr,
- target_height);
+ m_info_line_height);
y1 += line_height_max;
}
x1 = x2 + lr_border();
- x2 = x1 + 2.0F * lr_border();
+ x2 = x1 + m_divider_width;
y1 = origy1;
y2 = origy2;
- float const space = x2 - x1;
- float const lr_arrow_width = 0.4F * space;
// set left-right arrows dimension
- float const ar_x0 = 0.5F * (x2 + x1 - lr_arrow_width);
- float const ar_y0 = 0.5F * (y2 + y1) - tb_border();
- float const ar_x1 = ar_x0 + lr_arrow_width;
- float const ar_y1 = ar_y0 + 2.0F * tb_border();
+ float const ar_x0 = 0.5F * (x2 + x1 - m_divider_arrow_width);
+ float const ar_y0 = 0.5F * (y2 + y1 - m_divider_arrow_height);
+ float const ar_x1 = ar_x0 + m_divider_arrow_width;
+ float const ar_y1 = ar_y0 + m_divider_arrow_height;
ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xef, 0x12, 0x47, 0x7b));
@@ -1162,19 +1197,9 @@ bool menu_select_launch::scale_icon(bitmap_argb32 &&src, texture_and_bitmap &dst
assert(dst.texture);
if (src.valid())
{
- // calculate available space for the icon in pixels
- float const height(line_height());
- float const width(height * container().manager().ui_aspect(&container()));
- render_target const &target(machine().render().ui_target());
- u32 const dst_height(target.height());
- u32 const dst_width(target.width());
- bool const rotated((target.orientation() & ORIENTATION_SWAP_XY) != 0);
- int const max_height(int((rotated ? dst_width : dst_height) * height));
- int const max_width(int((rotated ? dst_height : dst_width) * width));
-
// reduce the source bitmap if it's too big
bitmap_argb32 tmp;
- float const ratio((std::min)({ float(max_height) / src.height(), float(max_width) / src.width(), 1.0F }));
+ float const ratio((std::min)({ float(m_icon_height) / src.height(), float(m_icon_width) / src.width(), 1.0F }));
if (1.0F > ratio)
{
float const pix_height(std::ceil(src.height() * ratio));
@@ -1188,7 +1213,7 @@ bool menu_select_launch::scale_icon(bitmap_argb32 &&src, texture_and_bitmap &dst
}
// copy into the destination
- dst.bitmap.allocate(max_width, max_height);
+ dst.bitmap.allocate(m_icon_width, m_icon_height);
for (int y = 0; tmp.height() > y; ++y)
for (int x = 0; tmp.width() > x; ++x)
dst.bitmap.pix(y, x) = tmp.pix(y, x);
@@ -1450,10 +1475,6 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
// validate the current selection
validate_selection(1);
- // swallow left/right keys if they are not appropriate
- bool const leftclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_LEFT_PANEL);
- bool const rightclose = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL);
-
// accept left/right keys as-is with repeat
if (exclusive_input_pressed(iptkey, IPT_UI_LEFT, (flags & PROCESS_LR_REPEAT) ? 6 : 0))
{
@@ -1469,6 +1490,7 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
}
}
+ // swallow left/right keys if they are not appropriate
if (exclusive_input_pressed(iptkey, IPT_UI_RIGHT, (flags & PROCESS_LR_REPEAT) ? 6 : 0))
{
if (m_focus == focused_menu::RIGHTTOP)
@@ -1486,11 +1508,11 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
// up backs up by one item
if (exclusive_input_pressed(iptkey, IPT_UI_UP, 6))
{
- if (!leftclose && m_focus == focused_menu::LEFT)
+ if (show_left_panel() && m_focus == focused_menu::LEFT)
{
return;
}
- else if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ else if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview--;
return;
@@ -1509,11 +1531,11 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
// down advances by one item
if (exclusive_input_pressed(iptkey, IPT_UI_DOWN, 6))
{
- if (!leftclose && m_focus == focused_menu::LEFT)
+ if (show_left_panel() && m_focus == focused_menu::LEFT)
{
return;
}
- else if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ else if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview++;
return;
@@ -1532,7 +1554,7 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
if (exclusive_input_pressed(iptkey, IPT_UI_PAGE_UP, 6))
{
// Infos
- if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview -= m_right_visible_lines - 3;
return;
@@ -1550,7 +1572,7 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
if (exclusive_input_pressed(iptkey, IPT_UI_PAGE_DOWN, 6))
{
// Infos
- if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview += m_right_visible_lines - 3;
return;
@@ -1567,11 +1589,11 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
// home goes to the start
if (exclusive_input_pressed(iptkey, IPT_UI_HOME, 0))
{
- if (!leftclose && m_focus == focused_menu::LEFT)
+ if (show_left_panel() && m_focus == focused_menu::LEFT)
{
return;
}
- else if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ else if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview = 0;
return;
@@ -1584,11 +1606,11 @@ void menu_select_launch::handle_keys(u32 flags, int &iptkey)
// end goes to the last
if (exclusive_input_pressed(iptkey, IPT_UI_END, 0))
{
- if (!leftclose && m_focus == focused_menu::LEFT)
+ if (show_left_panel() && m_focus == focused_menu::LEFT)
{
return;
}
- else if (!rightclose && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
+ else if (show_right_panel() && ((m_focus == focused_menu::RIGHTTOP) || (m_focus == focused_menu::RIGHTBOTTOM)))
{
m_topline_datsview = m_total_lines;
return;
@@ -1723,14 +1745,7 @@ void menu_select_launch::handle_events(u32 flags, event &ev)
select_prev();
}
- if (ui_globals::panels_status == HIDE_LEFT_PANEL)
- ui_globals::panels_status = SHOW_PANELS;
- else if (ui_globals::panels_status == HIDE_BOTH)
- ui_globals::panels_status = HIDE_RIGHT_PANEL;
- else if (ui_globals::panels_status == SHOW_PANELS)
- ui_globals::panels_status = HIDE_LEFT_PANEL;
- else if (ui_globals::panels_status == HIDE_RIGHT_PANEL)
- ui_globals::panels_status = HIDE_BOTH;
+ m_panels_status ^= HIDE_LEFT_PANEL;
}
else if (hover() == HOVER_RPANEL_ARROW)
{
@@ -1740,14 +1755,7 @@ void menu_select_launch::handle_events(u32 flags, event &ev)
select_prev();
}
- if (ui_globals::panels_status == HIDE_RIGHT_PANEL)
- ui_globals::panels_status = SHOW_PANELS;
- else if (ui_globals::panels_status == HIDE_BOTH)
- ui_globals::panels_status = HIDE_LEFT_PANEL;
- else if (ui_globals::panels_status == SHOW_PANELS)
- ui_globals::panels_status = HIDE_RIGHT_PANEL;
- else if (ui_globals::panels_status == HIDE_LEFT_PANEL)
- ui_globals::panels_status = HIDE_BOTH;
+ m_panels_status ^= HIDE_RIGHT_PANEL;
}
else if (hover() == HOVER_B_FAV)
{
@@ -1903,7 +1911,7 @@ void menu_select_launch::draw(u32 flags)
{
bool noinput = (flags & PROCESS_NOINPUT);
float const icon_offset = m_has_icons ? (1.5f * ud_arrow_width()) : 0.0f;
- float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * lr_border() : 0.3f;
+ float right_panel_size = show_right_panel() ? 0.3f : m_divider_width;
float visible_width = 1.0f - 4.0f * lr_border();
float primary_left = (1.0f - visible_width) * 0.5f;
float primary_width = visible_width;
@@ -1926,11 +1934,6 @@ void menu_select_launch::draw(u32 flags)
m_visible_lines = int(std::trunc(visible_main_menu_height / line_height()));
visible_main_menu_height = float(m_visible_lines) * line_height();
- if (!m_is_swlist)
- ui_globals::visible_main_lines = m_visible_lines;
- else
- ui_globals::visible_sw_lines = m_visible_lines;
-
// compute top/left of inner menu area by centering
float visible_left = primary_left;
float visible_top = (1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f;
@@ -2193,16 +2196,13 @@ void menu_select_launch::draw(u32 flags)
void menu_select_launch::draw_right_panel(float origx1, float origy1, float origx2, float origy2)
{
- bool const hide((ui_globals::panels_status == HIDE_RIGHT_PANEL) || (ui_globals::panels_status == HIDE_BOTH));
- float const x2(hide ? origx2 : (origx1 + 2.0F * lr_border()));
- float const space(x2 - origx1);
- float const lr_arrow_width(0.4F * space);
+ float const x2(!show_right_panel() ? origx2 : (origx1 + m_divider_width));
// set left-right arrows dimension
- float const ar_x0(0.5F * (x2 + origx1 - lr_arrow_width));
- float const ar_y0(0.5F * (origy2 + origy1) - tb_border());
- float const ar_x1(ar_x0 + lr_arrow_width);
- float const ar_y1(ar_y0 + 2.0F * tb_border());
+ float const ar_x0(0.5F * (x2 + origx1 - m_divider_arrow_width));
+ float const ar_y0(0.5F * (origy2 + origy1 - m_divider_arrow_height));
+ float const ar_x1(ar_x0 + m_divider_arrow_width);
+ float const ar_y1(ar_y0 + m_divider_arrow_height);
ui().draw_outlined_box(container(), origx1, origy1, origx2, origy2, rgb_t(0xef, 0x12, 0x47, 0x7b));
@@ -2213,19 +2213,20 @@ void menu_select_launch::draw_right_panel(float origx1, float origy1, float orig
set_hover(HOVER_RPANEL_ARROW);
}
- if (hide)
+ if (!show_right_panel())
{
draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90 ^ ORIENTATION_FLIP_X);
- return;
}
-
- draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90);
- origy1 = draw_right_box_title(x2, origy1, origx2, origy2);
-
- if (m_right_panel == RP_IMAGES)
- arts_render(x2, origy1, origx2, origy2);
else
- infos_render(x2, origy1, origx2, origy2);
+ {
+ draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90);
+ origy1 = draw_right_box_title(x2, origy1, origx2, origy2);
+
+ if (m_right_panel == RP_IMAGES)
+ arts_render(x2, origy1, origx2, origy2);
+ else
+ infos_render(x2, origy1, origx2, origy2);
+ }
}
@@ -2702,14 +2703,11 @@ bool menu_select_launch::has_multiple_bios(game_driver const &driver, s_bios &bi
float menu_select_launch::draw_collapsed_left_panel(float x1, float y1, float x2, float y2)
{
- float const space = x2 - x1;
- float const lr_arrow_width = 0.4F * space;
-
// set left-right arrows dimension
- float const ar_x0 = 0.5F * (x2 + x1 - lr_arrow_width);
- float const ar_y0 = 0.5f * (y2 + y1) - tb_border();
- float const ar_x1 = ar_x0 + lr_arrow_width;
- float const ar_y1 = ar_y0 + 2.0F * tb_border();
+ float const ar_x0 = 0.5F * (x2 + x1 - m_divider_arrow_width);
+ float const ar_y0 = 0.5F * (y2 + y1 - m_divider_arrow_height);
+ float const ar_x1 = ar_x0 + m_divider_arrow_width;
+ float const ar_y1 = ar_y0 + m_divider_arrow_height;
ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xef, 0x12, 0x47, 0x7b)); // FIXME: magic numbers in colour?
@@ -2865,13 +2863,12 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr,
line_height() * tmp_size);
- float const info_line_height = ui().get_line_height(ui().options().infos_size());
sc = origx2 - origx1 - (2.0f * gutter_width);
if (!m_info_layout || (m_info_layout->width() != sc))
{
m_info_layout.emplace(
*ui().get_font(),
- machine().render().ui_aspect(&container()) * info_line_height, info_line_height,
+ machine().render().ui_aspect(&container()) * m_info_line_height, m_info_line_height,
sc,
text_layout::text_justify::LEFT, text_layout::word_wrapping::WORD);
menu_dats_view::add_info_text(*m_info_layout, m_info_buffer, ui().colors().text_color());
@@ -2880,7 +2877,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
draw_common_arrow(origx1, origy1, origx2, origy2, m_info_view, 0, total - 1, title_size);
- m_right_visible_lines = floor((origy2 - oy1) / info_line_height);
+ m_right_visible_lines = floor((origy2 - oy1) / m_info_line_height);
if (m_total_lines < m_right_visible_lines)
m_right_visible_lines = m_total_lines;
if (m_topline_datsview < 0)
@@ -2897,14 +2894,14 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
set_hover(HOVER_INFO_TEXT);
if (up_arrow)
- draw_info_arrow(0, origx1, origx2, oy1, info_line_height, info_line_height * aspect);
+ draw_info_arrow(0, origx1, origx2, oy1, m_info_line_height, m_info_line_height * aspect);
if (down_arrow)
- draw_info_arrow(1, origx1, origx2, oy1 + (float(m_right_visible_lines - 1) * info_line_height), info_line_height, info_line_height * aspect);
+ draw_info_arrow(1, origx1, origx2, oy1 + (float(m_right_visible_lines - 1) * m_info_line_height), m_info_line_height, m_info_line_height * aspect);
m_info_layout->emit(
container(),
m_topline_datsview ? (m_topline_datsview + 1) : 0, r_visible_lines,
- origx1 + gutter_width, oy1 + (m_topline_datsview ? info_line_height : 0.0f));
+ origx1 + gutter_width, oy1 + (m_topline_datsview ? m_info_line_height : 0.0f));
}
diff --git a/src/frontend/mame/ui/selmenu.h b/src/frontend/mame/ui/selmenu.h
index 86d579b26cd..42edf8a773a 100644
--- a/src/frontend/mame/ui/selmenu.h
+++ b/src/frontend/mame/ui/selmenu.h
@@ -39,8 +39,8 @@ public:
virtual ~menu_select_launch() override;
protected:
- static constexpr std::size_t MAX_ICONS_RENDER = 128;
- static constexpr std::size_t MAX_VISIBLE_SEARCH = 200;
+ static inline constexpr std::size_t MAX_ICONS_RENDER = 128;
+ static inline constexpr std::size_t MAX_VISIBLE_SEARCH = 200;
// tab navigation
enum class focused_menu
@@ -128,6 +128,8 @@ protected:
virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override;
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
+ virtual void menu_activated() override;
+ virtual void menu_deactivated() override;
// handlers
virtual void inkey_export() = 0;
@@ -314,6 +316,9 @@ private:
static bool has_multiple_bios(ui_software_info const &swinfo, s_bios &biosname);
static bool has_multiple_bios(game_driver const &driver, s_bios &biosname);
+ bool show_left_panel() const;
+ bool show_right_panel() const;
+
bool m_ui_error;
std::string m_error_text;
@@ -324,6 +329,13 @@ private:
std::string m_info_buffer;
std::optional<text_layout> m_info_layout;
+ int m_icon_width;
+ int m_icon_height;
+ float m_divider_width;
+ float m_divider_arrow_width;
+ float m_divider_arrow_height;
+ float m_info_line_height;
+
cache &m_cache;
bool m_is_swlist;
focused_menu m_focus;
@@ -332,6 +344,7 @@ private:
int m_right_visible_lines; // right box lines
+ u8 m_panels_status;
u8 m_right_panel;
bool m_has_icons;
bool m_switch_image;
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index 68fc26cd98e..56590e9e7ee 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -613,7 +613,7 @@ void menu_select_software::populate(float &customtop, float &custombottom)
if (old_software != -1)
{
set_selected_index(old_software);
- top_line = selected_index() - (ui_globals::visible_sw_lines / 2);
+ centre_selection();
}
reselect_last::reset();
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index 423e8b111e2..6a3d95d2139 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -1956,9 +1956,6 @@ uint8_t ui_globals::cur_sw_dats_total = 0;
uint8_t ui_globals::curdats_total = 0;
uint8_t ui_globals::cur_sw_dats_view = 0;
bool ui_globals::reset = false;
-int ui_globals::visible_main_lines = 0;
-int ui_globals::visible_sw_lines = 0;
-uint16_t ui_globals::panels_status = 0;
char* chartrimcarriage(char str[])
{
diff --git a/src/frontend/mame/ui/utils.h b/src/frontend/mame/ui/utils.h
index e5bed5deee4..69390a6bc01 100644
--- a/src/frontend/mame/ui/utils.h
+++ b/src/frontend/mame/ui/utils.h
@@ -399,9 +399,7 @@ enum
struct ui_globals
{
static uint8_t curdats_view, curdats_total, cur_sw_dats_view, cur_sw_dats_total;
- static bool default_image, reset;
- static int visible_main_lines, visible_sw_lines;
- static uint16_t panels_status;
+ static bool reset;
};
// GLOBAL FUNCTIONS