diff --git a/docs/source/commandline/commandline-all.rst b/docs/source/commandline/commandline-all.rst index aa91bd6307c9e..91c69ab8bc147 100644 --- a/docs/source/commandline/commandline-all.rst +++ b/docs/source/commandline/commandline-all.rst @@ -899,22 +899,24 @@ Example: - dinput - xinput - none - - sdl + - sdljoy + - sdlgame * - **SDL** - auto [#JIPAutoSDL]_. - - - - none - - sdl + - sdljoy + - sdlgame .. rubric:: Footnotes .. [#JIPAutoWindows] On Windows, auto will default to ``dinput``. -.. [#JIPAutoSDL] On SDL, auto will default to ``sdl``. +.. [#JIPAutoSDL] On SDL, auto will default to ``sdljoy``. -.. Tip:: Note that Microsoft XBox 360 and XBox One controllers connected to +.. Tip:: Note that Microsoft Xbox 360 and Xbox One controllers connected to Windows will work best with ``winhybrid`` or ``xinput``. The ``winhybrid`` option supports a mix of DirectInput and XInput controllers at the same time. diff --git a/docs/source/commandline/sdlconfig.rst b/docs/source/commandline/sdlconfig.rst index 0b52739e4c3e0..84f31bf89b923 100644 --- a/docs/source/commandline/sdlconfig.rst +++ b/docs/source/commandline/sdlconfig.rst @@ -70,8 +70,9 @@ SDL Joystick Mapping **-sixaxis** - Use special handling for PlayStation 3 SixAxis controllers. Default is OFF - (**-nosixaxis**) + Use special handling for PlayStation 3 SixAxis controllers. May cause + undesirable behaviour with other controllers. Only affects the ``sdljoy`` + joystick provider. Default is OFF (**-nosixaxis**) SDL Lightgun Mapping diff --git a/docs/source/conf.py b/docs/source/conf.py index 81385340ed9b6..15884fc9ff9f7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -63,9 +63,9 @@ # built documents. # # The short X.Y version. -version = '0.251' +version = '0.252' # The full version, including alpha/beta/rc tags. -release = '0.251' +release = '0.252' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/src/emu/render.cpp b/src/emu/render.cpp index 32aebcf8eb7e6..89281b11dd29b 100644 --- a/src/emu/render.cpp +++ b/src/emu/render.cpp @@ -1013,9 +1013,9 @@ void render_target::set_bounds(s32 width, s32 height, float pixel_aspect) m_width = width; m_height = height; m_bounds.x0 = m_bounds.y0 = 0; - m_bounds.x1 = (float)width; - m_bounds.y1 = (float)height; - m_pixel_aspect = pixel_aspect != 0.0? pixel_aspect : 1.0; + m_bounds.x1 = float(width); + m_bounds.y1 = float(height); + m_pixel_aspect = pixel_aspect != 0.0F ? pixel_aspect : 1.0F; } diff --git a/src/frontend/mame/ui/about.cpp b/src/frontend/mame/ui/about.cpp index 715815399f9d0..62d0a1c5241dd 100644 --- a/src/frontend/mame/ui/about.cpp +++ b/src/frontend/mame/ui/about.cpp @@ -63,6 +63,19 @@ menu_about::~menu_about() } +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_about::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu_textbox::recompute_metrics(width, height, aspect); + + // make space for the title and revision + set_custom_space((line_height() * m_header.size()) + (tb_border() * 3.0F), 0.0F); +} + + //------------------------------------------------- // perform our special rendering //------------------------------------------------- @@ -103,10 +116,8 @@ void menu_about::populate_text(std::optional &layout, float &width, // populate - populates the about modal //------------------------------------------------- -void menu_about::populate(float &customtop, float &custombottom) +void menu_about::populate() { - // make space for the title and revision - customtop = (line_height() * m_header.size()) + (tb_border() * 3.0f); } diff --git a/src/frontend/mame/ui/about.h b/src/frontend/mame/ui/about.h index 13fc8e3e84fa9..5e394ba5d9e70 100644 --- a/src/frontend/mame/ui/about.h +++ b/src/frontend/mame/ui/about.h @@ -29,12 +29,13 @@ class menu_about : public menu_textbox virtual ~menu_about() override; 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 populate_text(std::optional &layout, float &width, int &lines) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::vector const m_header; diff --git a/src/frontend/mame/ui/analogipt.cpp b/src/frontend/mame/ui/analogipt.cpp index 4e3b15aecc80f..520026ea47900 100644 --- a/src/frontend/mame/ui/analogipt.cpp +++ b/src/frontend/mame/ui/analogipt.cpp @@ -66,6 +66,15 @@ menu_analog::~menu_analog() } +void menu_analog::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + // space for live display + set_custom_space(0.0f, (line_height() * m_visible_fields) + (tb_border() * 3.0f)); +} + + void menu_analog::custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) { // work out how much space to use for field names @@ -331,7 +340,7 @@ void menu_analog::handle(event const *ev) } -void menu_analog::populate(float &customtop, float &custombottom) +void menu_analog::populate() { // loop over input ports if (m_item_data.empty()) @@ -401,7 +410,7 @@ void menu_analog::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); // space for live display - custombottom = (line_height() * m_visible_fields) + (tb_border() * 3.0f); + set_custom_space(0.0f, (line_height() * m_visible_fields) + (tb_border() * 3.0f)); } diff --git a/src/frontend/mame/ui/analogipt.h b/src/frontend/mame/ui/analogipt.h index f6807947ce6b4..26f2580318ae9 100644 --- a/src/frontend/mame/ui/analogipt.h +++ b/src/frontend/mame/ui/analogipt.h @@ -27,6 +27,7 @@ class menu_analog : public menu virtual ~menu_analog() override; 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; @@ -66,7 +67,7 @@ class menu_analog : public menu using item_data_vector = std::vector; using field_data_vector = std::vector; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void find_fields(); diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp index b8656d3163cce..bc01cbc4a2a91 100644 --- a/src/frontend/mame/ui/auditmenu.cpp +++ b/src/frontend/mame/ui/auditmenu.cpp @@ -74,6 +74,14 @@ menu_audit::~menu_audit() } +void menu_audit::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0F, (line_height() * 1.0F) + (tb_border() * 3.0F)); +} + + void menu_audit::custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) { switch (m_phase) @@ -107,7 +115,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float container(), std::move(text).str(), text_layout::text_justify::CENTER, - 0.5f, 0.5f, + 0.5F, 0.5F, ui().colors().background_color()); } break; @@ -120,7 +128,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float ui().get_general_input_setting(IPT_UI_SELECT), ui().get_general_input_setting(IPT_UI_CANCEL)), text_layout::text_justify::CENTER, - 0.5f, 0.5f, + 0.5F, 0.5F, UI_RED_COLOR); break; } @@ -133,13 +141,12 @@ bool menu_audit::custom_ui_cancel() } -void menu_audit::populate(float &customtop, float &custombottom) +void menu_audit::populate() { if (m_unavailable && (m_availablesorted.size() != m_unavailable)) item_append(util::string_format(_("Audit media for %1$u systems marked unavailable"), m_unavailable), 0, ITEMREF_START_FAST); item_append(util::string_format(_("Audit media for all %1$u systems"), m_availablesorted.size()), 0, ITEMREF_START_FULL); item_append(menu_item_type::SEPARATOR, 0); - custombottom = (line_height() * 1.0f) + (tb_border() * 3.0f); } void menu_audit::handle(event const *ev) diff --git a/src/frontend/mame/ui/auditmenu.h b/src/frontend/mame/ui/auditmenu.h index de42c33b6d15c..040316edb5b10 100644 --- a/src/frontend/mame/ui/auditmenu.h +++ b/src/frontend/mame/ui/auditmenu.h @@ -29,13 +29,14 @@ class menu_audit : public menu virtual ~menu_audit() override; 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 bool custom_ui_cancel() override; private: enum class phase { CONFIRMATION, AUDIT, CANCELLATION }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; bool do_audit(); diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp index a0e4791dfb6d6..31dcf768e78bc 100644 --- a/src/frontend/mame/ui/barcode.cpp +++ b/src/frontend/mame/ui/barcode.cpp @@ -54,7 +54,7 @@ menu_barcode_reader::~menu_barcode_reader() // populate - populates the barcode input menu //------------------------------------------------- -void menu_barcode_reader::populate(float &customtop, float &custombottom) +void menu_barcode_reader::populate() { if (current_device()) { diff --git a/src/frontend/mame/ui/barcode.h b/src/frontend/mame/ui/barcode.h index e171485cf792b..5f70fe65276a5 100644 --- a/src/frontend/mame/ui/barcode.h +++ b/src/frontend/mame/ui/barcode.h @@ -24,7 +24,7 @@ class menu_barcode_reader : public menu_device_control { virtual ~menu_barcode_reader() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::string m_barcode_buffer; diff --git a/src/frontend/mame/ui/cheatopt.cpp b/src/frontend/mame/ui/cheatopt.cpp index 9aae81134ef4e..193a3c9efd668 100644 --- a/src/frontend/mame/ui/cheatopt.cpp +++ b/src/frontend/mame/ui/cheatopt.cpp @@ -111,7 +111,7 @@ menu_cheat::menu_cheat(mame_ui_manager &mui, render_container &container) : menu set_process_flags(PROCESS_LR_REPEAT); } -void menu_cheat::populate(float &customtop, float &custombottom) +void menu_cheat::populate() { /* iterate over cheats */ std::string text; diff --git a/src/frontend/mame/ui/cheatopt.h b/src/frontend/mame/ui/cheatopt.h index c01ec15118964..ba0f144dbaf3f 100644 --- a/src/frontend/mame/ui/cheatopt.h +++ b/src/frontend/mame/ui/cheatopt.h @@ -24,7 +24,7 @@ class menu_cheat : public menu virtual ~menu_cheat() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/confswitch.cpp b/src/frontend/mame/ui/confswitch.cpp index f267d7fa725c0..ffeae2fff38b0 100644 --- a/src/frontend/mame/ui/confswitch.cpp +++ b/src/frontend/mame/ui/confswitch.cpp @@ -89,7 +89,7 @@ void menu_confswitch::menu_activated() } -void menu_confswitch::populate(float &customtop, float &custombottom) +void menu_confswitch::populate() { // locate relevant fields if necessary if (m_fields.empty()) @@ -320,6 +320,18 @@ menu_settings_dip_switches::~menu_settings_dip_switches() } +void menu_settings_dip_switches::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu_confswitch::recompute_metrics(width, height, aspect); + + set_custom_space( + 0.0f, + m_visible_switch_groups + ? ((m_visible_switch_groups * (DIP_SWITCH_HEIGHT * line_height())) + ((m_visible_switch_groups - 1) * (DIP_SWITCH_SPACING * line_height())) + (tb_border() * 3.0f)) + : 0.0f); +} + + void menu_settings_dip_switches::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { // catch if no DIP locations have to be drawn @@ -470,10 +482,10 @@ bool menu_settings_dip_switches::custom_mouse_down() } -void menu_settings_dip_switches::populate(float &customtop, float &custombottom) +void menu_settings_dip_switches::populate() { // let the base class add items - menu_confswitch::populate(customtop, custombottom); + menu_confswitch::populate(); // use up to about 70% of height for DIP switch display if (active_switch_groups()) @@ -485,12 +497,12 @@ void menu_settings_dip_switches::populate(float &customtop, float &custombottom) m_visible_switch_groups = unsigned(0.7f / (groupheight + groupspacing)); else m_visible_switch_groups = active_switch_groups(); - custombottom = (m_visible_switch_groups * groupheight) + ((m_visible_switch_groups - 1) * groupspacing) + (tb_border() * 3.0f); + set_custom_space(0.0f, (m_visible_switch_groups * groupheight) + ((m_visible_switch_groups - 1) * groupspacing) + (tb_border() * 3.0f)); } else { m_visible_switch_groups = 0U; - custombottom = 0.0f; + set_custom_space(0.0f, 0.0f); } } diff --git a/src/frontend/mame/ui/confswitch.h b/src/frontend/mame/ui/confswitch.h index 598b0208085e5..9094fb2dc22b4 100644 --- a/src/frontend/mame/ui/confswitch.h +++ b/src/frontend/mame/ui/confswitch.h @@ -57,7 +57,7 @@ class menu_confswitch : public menu menu_confswitch(mame_ui_manager &mui, render_container &container, uint32_t type); virtual void menu_activated() override; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; field_vector const &fields() { return m_fields; } switch_group_vector const &switch_groups() { return m_switch_groups; } @@ -82,11 +82,12 @@ class menu_settings_dip_switches : public menu_confswitch virtual ~menu_settings_dip_switches() override; 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 bool custom_mouse_down() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; std::vector m_switch_group_y; unsigned m_visible_switch_groups; diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp index 35c8bd29bd136..22740412ff9c7 100644 --- a/src/frontend/mame/ui/custui.cpp +++ b/src/frontend/mame/ui/custui.cpp @@ -209,7 +209,7 @@ void menu_custom_ui::handle(event const *ev) // populate //------------------------------------------------- -void menu_custom_ui::populate(float &customtop, float &custombottom) +void menu_custom_ui::populate() { uint32_t arrow_flags; item_append(_("Fonts"), 0, (void *)(uintptr_t)FONT_MENU); @@ -498,7 +498,7 @@ void menu_font_ui::handle(event const *ev) // populate //------------------------------------------------- -void menu_font_ui::populate(float &customtop, float &custombottom) +void menu_font_ui::populate() { // set filter arrow uint32_t arrow_flags; @@ -523,8 +523,17 @@ void menu_font_ui::populate(float &customtop, float &custombottom) item_append(_("Infos text size"), string_format("%.2f", m_info_size), arrow_flags, (void *)(uintptr_t)INFOS_SIZE); item_append(menu_item_type::SEPARATOR); +} - custombottom = line_height() + 3.0f * tb_border(); +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_font_ui::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0f, line_height() + 3.0f * tb_border()); } //------------------------------------------------- @@ -612,7 +621,7 @@ void menu_colors_ui::handle(event const *ev) // populate //------------------------------------------------- -void menu_colors_ui::populate(float &customtop, float &custombottom) +void menu_colors_ui::populate() { item_append(_("color-option", "Normal text"), 0, (void *)(uintptr_t)MUI_TEXT_COLOR); item_append(_("color-option", "Selected color"), 0, (void *)(uintptr_t)MUI_SELECTED_COLOR); @@ -634,8 +643,17 @@ void menu_colors_ui::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Restore default colors"), 0, (void *)(uintptr_t)MUI_RESTORE); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_colors_ui::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); - custombottom = line_height() + 3.0f * tb_border(); + set_custom_space(0.0f, line_height() + 3.0f * tb_border()); } //------------------------------------------------- @@ -876,7 +894,7 @@ void menu_rgb_ui::handle(event const *ev) // populate //------------------------------------------------- -void menu_rgb_ui::populate(float &customtop, float &custombottom) +void menu_rgb_ui::populate() { // set filter arrow std::string s_text = std::string(m_search).append("_"); @@ -917,8 +935,17 @@ void menu_rgb_ui::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); item_append(_("Choose from palette"), 0, (void *)(uintptr_t)PALETTE_CHOOSE); item_append(menu_item_type::SEPARATOR); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_rgb_ui::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); - custombottom = line_height() + 3.0f * tb_border(); + set_custom_space(0.0f, line_height() + 3.0f * tb_border()); } //------------------------------------------------- @@ -1065,7 +1092,7 @@ void menu_palette_sel::handle(event const *ev) // populate //------------------------------------------------- -void menu_palette_sel::populate(float &customtop, float &custombottom) +void menu_palette_sel::populate() { for (unsigned x = 0; x < std::size(s_palette); ++x) item_append(_("color-preset", s_palette[x].first), s_palette[x].second, FLAG_COLOR_BOX, (void *)(uintptr_t)(x + 1)); diff --git a/src/frontend/mame/ui/custui.h b/src/frontend/mame/ui/custui.h index f720318d8547c..c009a4eccf0d0 100644 --- a/src/frontend/mame/ui/custui.h +++ b/src/frontend/mame/ui/custui.h @@ -33,7 +33,7 @@ class menu_custom_ui : public menu virtual void menu_dismissed() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void find_languages(); @@ -57,11 +57,12 @@ class menu_font_ui : public menu menu_font_ui(mame_ui_manager &mui, render_container &container, std::function &&handler); 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_dismissed() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void list(); @@ -92,6 +93,7 @@ class menu_colors_ui : public menu menu_colors_ui(mame_ui_manager &mui, render_container &container); 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_dismissed() override; @@ -123,7 +125,7 @@ class menu_colors_ui : public menu const char *option; }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; s_color_table m_color_table[MUI_RESTORE]; @@ -140,6 +142,7 @@ class menu_rgb_ui : public menu menu_rgb_ui(mame_ui_manager &mui, render_container &container, rgb_t *color, std::string &&title); 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; private: @@ -152,7 +155,7 @@ class menu_rgb_ui : public menu PALETTE_CHOOSE }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void inkey_special(const event *menu_event); @@ -174,7 +177,7 @@ class menu_palette_sel : public menu menu_palette_sel(mame_ui_manager &mui, render_container &container, rgb_t &_color); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; static std::pair const s_palette[]; diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp index 2d65f2a848470..47ed1f2ca8f12 100644 --- a/src/frontend/mame/ui/datmenu.cpp +++ b/src/frontend/mame/ui/datmenu.cpp @@ -198,10 +198,19 @@ void menu_dats_view::handle(event const *ev) // populate //------------------------------------------------- -void menu_dats_view::populate(float &customtop, float &custombottom) +void menu_dats_view::populate() { - customtop = 2.0f * line_height() + 4.0f * tb_border(); - custombottom = line_height() + 3.0f * tb_border(); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_dats_view::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu_textbox::recompute_metrics(width, height, aspect); + + set_custom_space(2.0F * line_height() + 4.0F * tb_border(), line_height() + 3.0F * tb_border()); } //------------------------------------------------- @@ -219,10 +228,10 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f maxwidth = std::max(maxwidth, width); // compute our bounds - float x1 = 0.5f - 0.5f * maxwidth; + float x1 = 0.5F - 0.5F * maxwidth; float x2 = x1 + maxwidth; float y1 = origy1 - top; - float y2 = origy1 - 2.0f * tb_border() - line_height(); + float y2 = origy1 - 2.0F * tb_border() - line_height(); // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR); @@ -245,13 +254,13 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f maxwidth += width; } - float space = (1.0f - maxwidth) / (m_items_list.size() * 2); + float space = (1.0F - maxwidth) / (m_items_list.size() * 2); // compute our bounds x1 -= lr_border(); x2 += lr_border(); y1 = y2 + tb_border(); - y2 += line_height() + 2.0f * tb_border(); + y2 += line_height() + 2.0F * tb_border(); // draw a box ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color()); @@ -283,7 +292,7 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f ui().draw_text_full( container(), elem.label, - x1, y1, 1.0f, + x1, y1, 1.0F, text_layout::text_justify::LEFT, text_layout::word_wrapping::NEVER, mame_ui_manager::NORMAL, fcolor, bcolor, &width, nullptr, @@ -298,13 +307,13 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f std::string const revision(util::string_format(_("Revision: %1$s"), m_items_list[m_actual].revision)); width = get_text_width( revision, - 0.0f, 0.0f, 1.0f, + 0.0F, 0.0F, 1.0F, text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE); width += 2 * lr_border(); maxwidth = std::max(origx2 - origx1, width); // compute our bounds - x1 = 0.5f - 0.5f * maxwidth; + x1 = 0.5F - 0.5F * maxwidth; x2 = x1 + maxwidth; y1 = origy2 + tb_border(); y2 = origy2 + bottom; diff --git a/src/frontend/mame/ui/datmenu.h b/src/frontend/mame/ui/datmenu.h index 79b9bd8c1f66f..680e4f0f37ac2 100644 --- a/src/frontend/mame/ui/datmenu.h +++ b/src/frontend/mame/ui/datmenu.h @@ -43,6 +43,7 @@ class menu_dats_view : public menu_textbox static void add_info_text(text_layout &layout, std::string_view text, rgb_t color, float size = 1.0f); 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 bool custom_mouse_down() override; @@ -58,7 +59,7 @@ class menu_dats_view : public menu_textbox std::string revision; }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void get_data(std::string &buffer); diff --git a/src/frontend/mame/ui/devopt.cpp b/src/frontend/mame/ui/devopt.cpp index e03b8da904227..9886c4e941d78 100644 --- a/src/frontend/mame/ui/devopt.cpp +++ b/src/frontend/mame/ui/devopt.cpp @@ -355,7 +355,7 @@ void menu_device_config::populate_text(std::optional &layout, float width = layout->actual_width(); } -void menu_device_config::populate(float &customtop, float &custombottom) +void menu_device_config::populate() { } diff --git a/src/frontend/mame/ui/devopt.h b/src/frontend/mame/ui/devopt.h index 74c81a75809e4..05fef63240b49 100644 --- a/src/frontend/mame/ui/devopt.h +++ b/src/frontend/mame/ui/devopt.h @@ -28,7 +28,7 @@ class menu_device_config : public menu_textbox virtual void populate_text(std::optional &layout, float &width, int &lines) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; device_slot_interface::slot_option const *const m_option; diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp index 252b53a5aae26..2f77e98433c54 100644 --- a/src/frontend/mame/ui/dirmenu.cpp +++ b/src/frontend/mame/ui/dirmenu.cpp @@ -82,7 +82,7 @@ class menu_remove_folder : public menu menu_remove_folder(mame_ui_manager &mui, render_container &container, int ref); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::string m_searchpath; @@ -145,7 +145,7 @@ void menu_remove_folder::handle(event const *ev) // populate menu //------------------------------------------------- -void menu_remove_folder::populate(float &customtop, float &custombottom) +void menu_remove_folder::populate() { int folders_count = 0; for (auto & elem : m_folders) @@ -165,12 +165,13 @@ class menu_add_change_folder : public menu menu_add_change_folder(mame_ui_manager &mui, render_container &container, int ref, bool multipath); 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 bool custom_ui_cancel() override { return !m_search.empty(); } private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void update_search(); @@ -296,7 +297,7 @@ void menu_add_change_folder::handle(event const *ev) // populate //------------------------------------------------- -void menu_add_change_folder::populate(float &customtop, float &custombottom) +void menu_add_change_folder::populate() { int folders_count = 0; @@ -331,10 +332,18 @@ void menu_add_change_folder::populate(float &customtop, float &custombottom) item_append(name, "[DIR]", 0, (void *)(uintptr_t)++folders_count); item_append(menu_item_type::SEPARATOR); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_add_change_folder::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); // configure the custom rendering - customtop = 2.0f * line_height() + 3.0f * tb_border(); - custombottom = 1.0f * line_height() + 3.0f * tb_border(); + set_custom_space(2.0f * line_height() + 3.0f * tb_border(), 1.0f * line_height() + 3.0f * tb_border()); } //------------------------------------------------- @@ -431,6 +440,7 @@ class menu_display_actual : public menu } 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; private: @@ -440,7 +450,7 @@ class menu_display_actual : public menu REMOVE, }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; bool is_multipath(std::string_view folder) const; @@ -492,7 +502,7 @@ void menu_display_actual::handle(event const *ev) // populate //------------------------------------------------- -void menu_display_actual::populate(float &customtop, float &custombottom) +void menu_display_actual::populate() { auto const &folder = f_folders[m_ref]; auto option = ui().options().get_entry(folder.option); @@ -522,7 +532,18 @@ void menu_display_actual::populate(float &customtop, float &custombottom) item_append(menu_item_type::SEPARATOR); - customtop = (m_folders.size() + 1) * line_height() + 6.0f * tb_border(); + set_custom_space((m_folders.size() + 1) * line_height() + 6.0f * tb_border(), 0.0f); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_display_actual::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space((m_folders.size() + 1) * line_height() + 6.0f * tb_border(), 0.0f); } //------------------------------------------------- @@ -579,7 +600,7 @@ void menu_directory::handle(event const *ev) // populate //------------------------------------------------- -void menu_directory::populate(float &customtop, float &custombottom) +void menu_directory::populate() { for (auto & elem : f_folders) item_append(_("path-option", elem.name), 0, this); // need a non-null reference pointer - value is immaterial diff --git a/src/frontend/mame/ui/dirmenu.h b/src/frontend/mame/ui/dirmenu.h index 644a71ba564b0..209fb7953fe4b 100644 --- a/src/frontend/mame/ui/dirmenu.h +++ b/src/frontend/mame/ui/dirmenu.h @@ -31,7 +31,7 @@ class menu_directory : public menu virtual ~menu_directory() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp index 21622d3d179d6..341c19545babe 100644 --- a/src/frontend/mame/ui/filecreate.cpp +++ b/src/frontend/mame/ui/filecreate.cpp @@ -74,7 +74,7 @@ menu_confirm_save_as::~menu_confirm_save_as() // populate //------------------------------------------------- -void menu_confirm_save_as::populate(float &customtop, float &custombottom) +void menu_confirm_save_as::populate() { item_append(_("File Already Exists - Override?"), FLAG_DISABLE, nullptr); item_append(menu_item_type::SEPARATOR); @@ -133,6 +133,18 @@ menu_file_create::~menu_file_create() } +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_file_create::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(line_height() + 3.0F * tb_border(), 0.0F); +} + + //------------------------------------------------- // custom_render - perform our special rendering //------------------------------------------------- @@ -140,8 +152,8 @@ menu_file_create::~menu_file_create() void menu_file_create::custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) { extra_text_render(top, bottom, origx1, origy1, origx2, origy2, - m_current_directory, - std::string_view()); + m_current_directory, + std::string_view()); } @@ -149,7 +161,7 @@ void menu_file_create::custom_render(void *selectedref, float top, float bottom, // populate - populates the file creator menu //------------------------------------------------- -void menu_file_create::populate(float &customtop, float &custombottom) +void menu_file_create::populate() { std::string buffer; const image_device_format *format; @@ -178,8 +190,6 @@ void menu_file_create::populate(float &customtop, float &custombottom) // finish up the menu item_append(menu_item_type::SEPARATOR); item_append(_("Create"), 0, ITEMREF_CREATE); - - customtop = line_height() + 3.0f * tb_border(); } @@ -263,7 +273,7 @@ menu_select_format::~menu_select_format() // populate //------------------------------------------------- -void menu_select_format::populate(float &customtop, float &custombottom) +void menu_select_format::populate() { item_append(_("Select image format"), FLAG_DISABLE, nullptr); for (unsigned int i = 0; i != m_formats.size(); i++) @@ -322,7 +332,7 @@ menu_select_floppy_init::~menu_select_floppy_init() // populate //------------------------------------------------- -void menu_select_floppy_init::populate(float &customtop, float &custombottom) +void menu_select_floppy_init::populate() { item_append(_("Select initial contents"), FLAG_DISABLE, nullptr); int id = 0; diff --git a/src/frontend/mame/ui/filecreate.h b/src/frontend/mame/ui/filecreate.h index 9d47605f5a7a3..629bd24f3ec7f 100644 --- a/src/frontend/mame/ui/filecreate.h +++ b/src/frontend/mame/ui/filecreate.h @@ -31,7 +31,7 @@ class menu_confirm_save_as : public menu virtual ~menu_confirm_save_as() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; bool *m_yes; @@ -47,10 +47,11 @@ class menu_file_create : public menu virtual ~menu_file_create() override; 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; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; bool & m_ok; @@ -71,7 +72,7 @@ class menu_select_format : public menu virtual ~menu_select_format() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // internal state @@ -90,7 +91,7 @@ class menu_select_floppy_init : public menu virtual ~menu_select_floppy_init() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // internal state diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp index bbd38a9a411b5..81540b568b0d6 100644 --- a/src/frontend/mame/ui/filemngr.cpp +++ b/src/frontend/mame/ui/filemngr.cpp @@ -53,6 +53,18 @@ menu_file_manager::~menu_file_manager() } +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_file_manager::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0F, line_height() + 3.0F * tb_border()); +} + + //------------------------------------------------- // custom_render - perform our special rendering //------------------------------------------------- @@ -101,7 +113,7 @@ void menu_file_manager::fill_image_line(device_image_interface *img, std::string // populate //------------------------------------------------- -void menu_file_manager::populate(float &customtop, float &custombottom) +void menu_file_manager::populate() { std::string tmp_inst, tmp_name; @@ -152,8 +164,6 @@ void menu_file_manager::populate(float &customtop, float &custombottom) if (m_warnings.empty() || !missing_mandatory) item_append(m_warnings.empty() ? _("Reset System") : _("Start System"), 0, (void *)1); - - custombottom = line_height() + 3.0f * tb_border(); } diff --git a/src/frontend/mame/ui/filemngr.h b/src/frontend/mame/ui/filemngr.h index 379912c8dfb3d..a2368e5a95903 100644 --- a/src/frontend/mame/ui/filemngr.h +++ b/src/frontend/mame/ui/filemngr.h @@ -30,10 +30,11 @@ class menu_file_manager : public menu virtual ~menu_file_manager(); 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; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void fill_image_line(device_image_interface *img, std::string &instance, std::string &filename); diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp index 182e130dc6158..e12beadb8ebfa 100644 --- a/src/frontend/mame/ui/filesel.cpp +++ b/src/frontend/mame/ui/filesel.cpp @@ -72,6 +72,19 @@ menu_file_selector::~menu_file_selector() } +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_file_selector::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + // set up custom render proc + set_custom_space(line_height() + 3.0F * tb_border(), 0.0F); +} + + //------------------------------------------------- // custom_render - perform our special rendering //------------------------------------------------- @@ -347,7 +360,7 @@ void menu_file_selector::update_search() // populate //------------------------------------------------- -void menu_file_selector::populate(float &customtop, float &custombottom) +void menu_file_selector::populate() { const file_selector_entry *selected_entry = nullptr; @@ -426,9 +439,6 @@ void menu_file_selector::populate(float &customtop, float &custombottom) // set the selection (if we have one) if (selected_entry) set_selection((void *)selected_entry); - - // set up custom render proc - customtop = line_height() + 3.0f * tb_border(); } @@ -504,7 +514,7 @@ menu_select_rw::~menu_select_rw() // populate //------------------------------------------------- -void menu_select_rw::populate(float &customtop, float &custombottom) +void menu_select_rw::populate() { item_append(_("Select access mode"), FLAG_DISABLE, nullptr); item_append(_("Read-only"), 0, itemref_from_result(result::READONLY)); diff --git a/src/frontend/mame/ui/filesel.h b/src/frontend/mame/ui/filesel.h index 8fa309c2fb942..71b2b17e3ad5d 100644 --- a/src/frontend/mame/ui/filesel.h +++ b/src/frontend/mame/ui/filesel.h @@ -44,6 +44,7 @@ class menu_file_selector : public menu virtual ~menu_file_selector() override; 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 bool custom_ui_cancel() override { return !m_filename.empty(); } virtual bool custom_mouse_down() override; @@ -82,7 +83,7 @@ class menu_file_selector : public menu std::string m_hover_directory; std::string m_filename; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // methods @@ -119,7 +120,7 @@ class menu_select_rw : public menu static result result_from_itemref(void *itemref); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // internal state diff --git a/src/frontend/mame/ui/imgcntrl.cpp b/src/frontend/mame/ui/imgcntrl.cpp index 5708a4a832a02..174b8bab9e695 100644 --- a/src/frontend/mame/ui/imgcntrl.cpp +++ b/src/frontend/mame/ui/imgcntrl.cpp @@ -184,7 +184,7 @@ void menu_control_device_image::hook_load(const std::string &name) // populate //------------------------------------------------- -void menu_control_device_image::populate(float &customtop, float &custombottom) +void menu_control_device_image::populate() { throw emu_fatalerror("menu_control_device_image::populate: Shouldn't get here!"); } diff --git a/src/frontend/mame/ui/imgcntrl.h b/src/frontend/mame/ui/imgcntrl.h index 66a5ee5f81ae6..80b4548686abb 100644 --- a/src/frontend/mame/ui/imgcntrl.h +++ b/src/frontend/mame/ui/imgcntrl.h @@ -68,7 +68,7 @@ class menu_control_device_image : public menu std::string m_software_info_name; // methods - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; void test_create(bool &can_create, bool &need_confirm); void load_software_part(); }; diff --git a/src/frontend/mame/ui/info.cpp b/src/frontend/mame/ui/info.cpp index ce4999bb0fac5..32575133a2425 100644 --- a/src/frontend/mame/ui/info.cpp +++ b/src/frontend/mame/ui/info.cpp @@ -548,7 +548,7 @@ void menu_game_info::populate_text(std::optional &layout, float &wi width = layout->actual_width(); } -void menu_game_info::populate(float &customtop, float &custombottom) +void menu_game_info::populate() { } @@ -613,7 +613,7 @@ void menu_warn_info::populate_text(std::optional &layout, float &wi width = layout->actual_width(); } -void menu_warn_info::populate(float &customtop, float &custombottom) +void menu_warn_info::populate() { } @@ -642,7 +642,7 @@ void menu_image_info::menu_activated() reset(reset_options::REMEMBER_POSITION); } -void menu_image_info::populate(float &customtop, float &custombottom) +void menu_image_info::populate() { for (device_image_interface &image : image_interface_enumerator(machine().root_device())) image_info(&image); diff --git a/src/frontend/mame/ui/info.h b/src/frontend/mame/ui/info.h index 5c8f153d6ae5a..d36c476c7b5dc 100644 --- a/src/frontend/mame/ui/info.h +++ b/src/frontend/mame/ui/info.h @@ -100,7 +100,7 @@ class menu_game_info : public menu_textbox virtual void populate_text(std::optional &layout, float &width, int &lines) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; @@ -115,7 +115,7 @@ class menu_warn_info : public menu_textbox virtual void populate_text(std::optional &layout, float &width, int &lines) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; @@ -130,7 +130,7 @@ class menu_image_info : public menu virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void image_info(device_image_interface *image); }; diff --git a/src/frontend/mame/ui/info_pty.cpp b/src/frontend/mame/ui/info_pty.cpp index 1aadb85deb90c..018c3bc9b61d6 100644 --- a/src/frontend/mame/ui/info_pty.cpp +++ b/src/frontend/mame/ui/info_pty.cpp @@ -26,7 +26,7 @@ menu_pty_info::~menu_pty_info() { } -void menu_pty_info::populate(float &customtop, float &custombottom) +void menu_pty_info::populate() { for (device_pty_interface &pty : pty_interface_enumerator(machine().root_device())) { diff --git a/src/frontend/mame/ui/info_pty.h b/src/frontend/mame/ui/info_pty.h index 16f65435be27b..af384a5a92df9 100644 --- a/src/frontend/mame/ui/info_pty.h +++ b/src/frontend/mame/ui/info_pty.h @@ -24,7 +24,7 @@ class menu_pty_info : public menu virtual ~menu_pty_info() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/inputdevices.cpp b/src/frontend/mame/ui/inputdevices.cpp index 5c1a7a8931a9e..71d09a0b2800a 100644 --- a/src/frontend/mame/ui/inputdevices.cpp +++ b/src/frontend/mame/ui/inputdevices.cpp @@ -27,6 +27,7 @@ class menu_input_device : public menu menu_input_device(mame_ui_manager &mui, render_container &container, input_device &device) : menu(mui, container) , m_device(device) + , m_have_analog(false) { set_heading( util::string_format(_("menu-inputdev", "%1$s (%2$s %3$d)"), @@ -36,25 +37,54 @@ class menu_input_device : public menu } protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override + { + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0F, (line_height() * (m_have_analog ? 2.0F : 1.0F)) + (tb_border() * 3.0F)); + } + virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override { if (selectedref) { + // get the complete token for the highlighted input input_device_item &input = *reinterpret_cast(selectedref); + input_code code = input.code(); + if (!machine().input().device_class(m_device.devclass()).multi()) + code.set_device_index(0); + std::string const token = machine().input().code_to_token(code); + + // measure the name of the token string + float const tokenwidth = (std::min)(get_string_width(token) + (gutter_width() * 2.0F), 1.0F); + float const boxwidth = (std::max)(tokenwidth, x2 - x); + rgb_t const fgcolor(ui().colors().text_color()); + + // draw the outer box + ui().draw_outlined_box( + container(), + (1.0F - boxwidth) * 0.5F, y2 + tb_border(), + (1.0F + boxwidth) * 0.5F, y2 + bottom, + ui().colors().background_color()); + + // show the token + draw_text_normal( + token, + (1.0F - boxwidth) * 0.5F, y2 + (tb_border() * 2.0F), boxwidth, + text_layout::text_justify::CENTER, text_layout::word_wrapping::TRUNCATE, + fgcolor); + + // first show the token switch (input.itemclass()) { case ITEM_CLASS_ABSOLUTE: case ITEM_CLASS_RELATIVE: { - // draw the outer box - ui().draw_outlined_box(container(), x, y2 + tb_border(), x2, y2 + bottom, ui().colors().background_color()); - // draw the indicator - rgb_t const fgcolor(ui().colors().text_color()); - float const indleft = x + lr_border(); - float const indright = x2 - lr_border(); - float const indtop = y2 + (tb_border() * 2.0F) + (line_height() * 0.2F); - float const indbottom = y2 + (tb_border() * 2.0F) + (line_height() * 0.8F); + float const indleft = x + gutter_width(); + float const indright = x2 - gutter_width(); + float const indtop = y2 + (tb_border() * 2.0F) + (line_height() * 1.2F); + float const indbottom = y2 + (tb_border() * 2.0F) + (line_height() * 1.8F); float const indcentre = (x + x2) * 0.5F; s32 const value = (input.itemclass() == ITEM_CLASS_ABSOLUTE) ? input.read_as_absolute(ITEM_MODIFIER_NONE) : input.read_as_relative(ITEM_MODIFIER_NONE); if (0 < value) @@ -81,12 +111,11 @@ class menu_input_device : public menu } private: - virtual void populate(float &customtop, float &custombottom) override + virtual void populate() override { item_append(_("menu-inputdev", "Copy Device ID"), 0U, nullptr); item_append(menu_item_type::SEPARATOR); - bool haveanalog = false; for (input_item_id itemid = ITEM_ID_FIRST_VALID; m_device.maxitem() >= itemid; ++itemid) { input_device_item *const input = m_device.item(itemid); @@ -96,7 +125,7 @@ class menu_input_device : public menu { case ITEM_CLASS_ABSOLUTE: case ITEM_CLASS_RELATIVE: - haveanalog = true; + m_have_analog = true; break; default: break; @@ -107,8 +136,7 @@ class menu_input_device : public menu item_append(menu_item_type::SEPARATOR); - if (haveanalog) - custombottom = line_height() + (tb_border() * 3.0F); + set_custom_space(0.0F, (line_height() * (m_have_analog ? 2.0F : 1.0F)) + (tb_border() * 3.0F)); } virtual void handle(event const *ev) override @@ -148,6 +176,7 @@ class menu_input_device : public menu } input_device &m_device; + bool m_have_analog; }; } // anonymous namespace @@ -166,7 +195,7 @@ menu_input_devices::~menu_input_devices() } -void menu_input_devices::populate(float &customtop, float &custombottom) +void menu_input_devices::populate() { // iterate input device classes and devices within each class bool found = false; diff --git a/src/frontend/mame/ui/inputdevices.h b/src/frontend/mame/ui/inputdevices.h index cb81caaaf4738..39d2afda4e572 100644 --- a/src/frontend/mame/ui/inputdevices.h +++ b/src/frontend/mame/ui/inputdevices.h @@ -25,7 +25,7 @@ class menu_input_devices : public menu virtual ~menu_input_devices(); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp index 2fbc8aeb95d2b..387d3db742388 100644 --- a/src/frontend/mame/ui/inputmap.cpp +++ b/src/frontend/mame/ui/inputmap.cpp @@ -33,7 +33,7 @@ menu_input_groups::~menu_input_groups() { } -void menu_input_groups::populate(float &customtop, float &custombottom) +void menu_input_groups::populate() { // build up the menu item_append(_("User Interface"), 0, (void *)uintptr_t(IPG_UI + 1)); @@ -82,7 +82,7 @@ void menu_input_general::menu_activated() reset(reset_options::REMEMBER_POSITION); } -void menu_input_general::populate(float &customtop, float &custombottom) +void menu_input_general::populate() { if (data.empty()) { @@ -130,7 +130,7 @@ void menu_input_general::populate(float &customtop, float &custombottom) } // populate the menu in a standard fashion - populate_sorted(customtop, custombottom); + populate_sorted(); item_append(menu_item_type::SEPARATOR); } @@ -164,7 +164,7 @@ void menu_input_specific::menu_activated() reset(reset_options::REMEMBER_POSITION); } -void menu_input_specific::populate(float &customtop, float &custombottom) +void menu_input_specific::populate() { if (data.empty()) { @@ -249,7 +249,7 @@ void menu_input_specific::populate(float &customtop, float &custombottom) // populate the menu in a standard fashion if (!data.empty()) - populate_sorted(customtop, custombottom); + populate_sorted(); else item_append(_("[no assignable inputs are enabled]"), FLAG_DISABLE, nullptr); @@ -311,6 +311,16 @@ void menu_input::toggle_none_default(input_seq &selected_seq, input_seq &origina selected_seq.reset(); } + +void menu_input::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + // leave space for showing the input sequence below the menu + set_custom_space(0.0F, 2.0F * line_height() + 3.0F * tb_border()); +} + + void menu_input::custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) { if (pollingitem) @@ -554,7 +564,7 @@ void menu_input::handle(event const *ev) // menu from them //------------------------------------------------- -void menu_input::populate_sorted(float &customtop, float &custombottom) +void menu_input::populate_sorted() { const char *nameformat[INPUT_TYPE_TOTAL] = { nullptr }; @@ -608,9 +618,6 @@ void menu_input::populate_sorted(float &customtop, float &custombottom) appendprompt = util::string_format(_("Press %1$s to append\n"), ui().get_general_input_setting(IPT_UI_SELECT)); clearprompt = util::string_format(_("Press %1$s to clear\n"), ui().get_general_input_setting(IPT_UI_CLEAR)); defaultprompt = util::string_format(_("Press %1$s to restore default\n"), ui().get_general_input_setting(IPT_UI_CLEAR)); - - // leave space for showing the input sequence below the menu - custombottom = 2.0f * line_height() + 3.0f * tb_border(); } } // namespace ui diff --git a/src/frontend/mame/ui/inputmap.h b/src/frontend/mame/ui/inputmap.h index c651a8cc3d357..d512b6703459f 100644 --- a/src/frontend/mame/ui/inputmap.h +++ b/src/frontend/mame/ui/inputmap.h @@ -28,7 +28,7 @@ class menu_input_groups : public menu virtual ~menu_input_groups() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; @@ -64,7 +64,10 @@ class menu_input : public menu menu_input(mame_ui_manager &mui, render_container &container); - void populate_sorted(float &customtop, float &custombottom); + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) override; + + void populate_sorted(); void toggle_none_default(input_seq &selected_seq, input_seq &original_seq, const input_seq &selected_defseq); data_vector data; @@ -81,7 +84,6 @@ class menu_input : public menu osd_ticks_t modified_ticks; input_seq starting_seq; - virtual void custom_render(void *selectedref, float top, float bottom, float x1, float y1, float x2, float y2) override; virtual void handle(event const *ev) override; virtual void update_input(input_item_data &seqchangeditem) = 0; }; @@ -97,7 +99,7 @@ class menu_input_general : public menu_input virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void update_input(input_item_data &seqchangeditem) override; const int group; @@ -114,7 +116,7 @@ class menu_input_specific : public menu_input virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void update_input(input_item_data &seqchangeditem) override; }; diff --git a/src/frontend/mame/ui/inputopts.cpp b/src/frontend/mame/ui/inputopts.cpp index ff433e72e7eb3..e4802e8de8ff5 100644 --- a/src/frontend/mame/ui/inputopts.cpp +++ b/src/frontend/mame/ui/inputopts.cpp @@ -87,7 +87,7 @@ void menu_input_options::menu_activated() } -void menu_input_options::populate(float &customtop, float &custombottom) +void menu_input_options::populate() { bool inputmap, analog, toggle; scan_inputs(machine(), inputmap, analog, toggle); diff --git a/src/frontend/mame/ui/inputopts.h b/src/frontend/mame/ui/inputopts.h index 11432ce5035b8..7cff7713537ea 100644 --- a/src/frontend/mame/ui/inputopts.h +++ b/src/frontend/mame/ui/inputopts.h @@ -28,7 +28,7 @@ class menu_input_options : public menu virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/inputtoggle.cpp b/src/frontend/mame/ui/inputtoggle.cpp index b21cd572c1d86..e86d41b70311e 100644 --- a/src/frontend/mame/ui/inputtoggle.cpp +++ b/src/frontend/mame/ui/inputtoggle.cpp @@ -35,7 +35,7 @@ void menu_input_toggles::menu_activated() } -void menu_input_toggles::populate(float &customtop, float &custombottom) +void menu_input_toggles::populate() { // find toggle fields if (m_fields.empty()) diff --git a/src/frontend/mame/ui/inputtoggle.h b/src/frontend/mame/ui/inputtoggle.h index 7a3016f62541a..b4d48908d962f 100644 --- a/src/frontend/mame/ui/inputtoggle.h +++ b/src/frontend/mame/ui/inputtoggle.h @@ -31,7 +31,7 @@ class menu_input_toggles : public menu virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::vector > m_fields; diff --git a/src/frontend/mame/ui/keyboard.cpp b/src/frontend/mame/ui/keyboard.cpp index 7efebefd64c49..931ff96f04605 100644 --- a/src/frontend/mame/ui/keyboard.cpp +++ b/src/frontend/mame/ui/keyboard.cpp @@ -35,7 +35,7 @@ void menu_keyboard_mode::menu_activated() reset(reset_options::REMEMBER_POSITION); } -void menu_keyboard_mode::populate(float &customtop, float &custombottom) +void menu_keyboard_mode::populate() { natural_keyboard &natkbd(machine().natkeyboard()); diff --git a/src/frontend/mame/ui/keyboard.h b/src/frontend/mame/ui/keyboard.h index 36371f5711c8d..478d97a5a1138 100644 --- a/src/frontend/mame/ui/keyboard.h +++ b/src/frontend/mame/ui/keyboard.h @@ -27,7 +27,7 @@ class menu_keyboard_mode : public menu virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/mainmenu.cpp b/src/frontend/mame/ui/mainmenu.cpp index 0ef893dfd1ca1..7d53266e65b4b 100644 --- a/src/frontend/mame/ui/mainmenu.cpp +++ b/src/frontend/mame/ui/mainmenu.cpp @@ -108,7 +108,7 @@ void menu_main::menu_activated() populate - populate main menu items -------------------------------------------------*/ -void menu_main::populate(float &customtop, float &custombottom) +void menu_main::populate() { m_phase = machine().phase(); diff --git a/src/frontend/mame/ui/mainmenu.h b/src/frontend/mame/ui/mainmenu.h index 6671dd9f554db..de596716da686 100644 --- a/src/frontend/mame/ui/mainmenu.h +++ b/src/frontend/mame/ui/mainmenu.h @@ -28,7 +28,7 @@ class menu_main : public menu virtual void menu_activated() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; machine_phase m_phase; diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp index ba5767c794a01..69e7556398566 100644 --- a/src/frontend/mame/ui/menu.cpp +++ b/src/frontend/mame/ui/menu.cpp @@ -373,6 +373,18 @@ void menu::item_append_on_off(const std::string &text, bool state, uint32_t flag } +//------------------------------------------------- +// set_custom_space - set space required for +// custom rendering above and below menu +//------------------------------------------------- + +void menu::set_custom_space(float top, float bottom) +{ + m_customtop = top; + m_custombottom = bottom; +} + + //------------------------------------------------- // process - process a menu, drawing it // and returning any interesting events @@ -1260,7 +1272,7 @@ void menu::do_handle() item_append(_("Return to Previous Menu"), 0, nullptr); // let implementation add other items - populate(m_customtop, m_custombottom); + populate(); } catch (...) { diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index 85a2f935d868c..4126fa66cb5f5 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -70,6 +70,9 @@ class menu void item_append(menu_item_type type, uint32_t flags = 0); void item_append_on_off(const std::string &text, bool state, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); + // set space required for drawing extra content + void set_custom_space(float top, float bottom); + // reset the menus, clearing everything static void stack_reset(mame_ui_manager &ui) { get_global_state(ui).stack_reset(); } @@ -422,7 +425,7 @@ class menu void set_special_main_menu(bool disable); // to be implemented in derived classes - virtual void populate(float &customtop, float &custombottom) = 0; + virtual void populate() = 0; // to be implemented in derived classes virtual void handle(event const *ev) = 0; diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp index 057df11e17db4..9839d59a96654 100644 --- a/src/frontend/mame/ui/miscmenu.cpp +++ b/src/frontend/mame/ui/miscmenu.cpp @@ -54,7 +54,7 @@ menu_bios_selection::menu_bios_selection(mame_ui_manager &mui, render_container set_heading(_("BIOS Selection")); } -void menu_bios_selection::populate(float &customtop, float &custombottom) +void menu_bios_selection::populate() { // cycle through all devices for this system for (device_t &device : device_enumerator(machine().root_device())) @@ -159,7 +159,7 @@ menu_network_devices::~menu_network_devices() network device menu -------------------------------------------------*/ -void menu_network_devices::populate(float &customtop, float &custombottom) +void menu_network_devices::populate() { /* cycle through all devices for this system */ for (device_network_interface &network : network_interface_enumerator(machine().root_device())) @@ -268,7 +268,7 @@ void menu_bookkeeping::populate_text(std::optional &layout, float & width = layout->actual_width(); } -void menu_bookkeeping::populate(float &customtop, float &custombottom) +void menu_bookkeeping::populate() { } @@ -397,7 +397,7 @@ menu_crosshair::menu_crosshair(mame_ui_manager &mui, render_container &container set_heading(_("menu-crosshair", "Crosshair Options")); } -void menu_crosshair::populate(float &customtop, float &custombottom) +void menu_crosshair::populate() { if (m_data.empty()) { @@ -701,7 +701,7 @@ void menu_export::handle(event const *ev) // populate //------------------------------------------------- -void menu_export::populate(float &customtop, float &custombottom) +void menu_export::populate() { // add options items item_append(_("Export list in XML format (like -listxml)"), 0, (void *)(uintptr_t)1); @@ -811,7 +811,7 @@ void menu_machine_configure::handle(event const *ev) // populate //------------------------------------------------- -void menu_machine_configure::populate(float &customtop, float &custombottom) +void menu_machine_configure::populate() { // add options items item_append(_("BIOS"), FLAG_DISABLE | FLAG_UI_HEADING, nullptr); @@ -930,7 +930,7 @@ void menu_plugins_configure::handle(event const *ev) // populate //------------------------------------------------- -void menu_plugins_configure::populate(float &customtop, float &custombottom) +void menu_plugins_configure::populate() { plugin_options const &plugins = mame_machine_manager::instance()->plugins(); diff --git a/src/frontend/mame/ui/miscmenu.h b/src/frontend/mame/ui/miscmenu.h index 22a2d1dc135ae..ab763b7ed26d7 100644 --- a/src/frontend/mame/ui/miscmenu.h +++ b/src/frontend/mame/ui/miscmenu.h @@ -33,7 +33,7 @@ class menu_network_devices : public menu virtual ~menu_network_devices(); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; @@ -48,7 +48,7 @@ class menu_bookkeeping : public menu_textbox virtual void populate_text(std::optional &layout, float &width, int &lines) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; attotime prevtime; @@ -81,7 +81,7 @@ class menu_crosshair : public menu std::string next_name; }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::vector m_data; @@ -96,7 +96,7 @@ class menu_bios_selection : public menu virtual ~menu_bios_selection(); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; @@ -112,7 +112,7 @@ class menu_export : public menu virtual ~menu_export(); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::vector m_list; @@ -148,7 +148,7 @@ class menu_machine_configure : public menu LAST = ADVANCED }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void setup_bios(); @@ -174,7 +174,7 @@ class menu_plugins_configure : public menu virtual ~menu_plugins_configure(); protected: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp index bc9757a44a4e4..91e5fb52adb86 100644 --- a/src/frontend/mame/ui/optsmenu.cpp +++ b/src/frontend/mame/ui/optsmenu.cpp @@ -71,7 +71,7 @@ void menu_simple_game_options::handle(event const *ev) // populate //------------------------------------------------- -void menu_simple_game_options::populate(float &customtop, float &custombottom) +void menu_simple_game_options::populate() { item_append(_(submenu::video_options()[0].description), 0, (void *)(uintptr_t)DISPLAY_MENU); item_append(_("Sound Options"), 0, (void *)(uintptr_t)SOUND_MENU); @@ -85,8 +85,6 @@ void menu_simple_game_options::populate(float &customtop, float &custombottom) item_append(_("Input Devices"), 0, (void *)(uintptr_t)INPUTDEV_MENU); item_append(menu_item_type::SEPARATOR); item_append(_("Save Settings"), 0, (void *)(uintptr_t)SAVE_CONFIG); - - custombottom = 2.0f * line_height() + 3.0f * tb_border(); } //------------------------------------------------- @@ -174,7 +172,7 @@ void menu_game_options::handle(event const *ev) // populate //------------------------------------------------- -void menu_game_options::populate(float &customtop, float &custombottom) +void menu_game_options::populate() { // set filter arrow std::string fbuff; @@ -198,7 +196,7 @@ void menu_game_options::populate(float &customtop, float &custombottom) item_append(_("Configure Folders"), 0, (void *)(uintptr_t)CONF_DIR); // add the options that don't relate to the UI - menu_simple_game_options::populate(customtop, custombottom); + menu_simple_game_options::populate(); } //------------------------------------------------- diff --git a/src/frontend/mame/ui/optsmenu.h b/src/frontend/mame/ui/optsmenu.h index b10d6601926e2..d1779ede52a2d 100644 --- a/src/frontend/mame/ui/optsmenu.h +++ b/src/frontend/mame/ui/optsmenu.h @@ -29,7 +29,7 @@ class menu_simple_game_options : public menu protected: virtual void handle(event const *ev) override; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; void handle_item_event(event const &menu_event); @@ -63,7 +63,7 @@ class menu_game_options : public menu_simple_game_options protected: virtual void handle(event const *ev) override; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; void handle_item_event(event const &menu_event); diff --git a/src/frontend/mame/ui/pluginopt.cpp b/src/frontend/mame/ui/pluginopt.cpp index 08f7f84a75267..3ad7a2ec2c34e 100644 --- a/src/frontend/mame/ui/pluginopt.cpp +++ b/src/frontend/mame/ui/pluginopt.cpp @@ -35,7 +35,7 @@ menu_plugin::menu_plugin(mame_ui_manager &mui, render_container &container) : set_heading(_("Plugin Options")); } -void menu_plugin::populate(float &customtop, float &custombottom) +void menu_plugin::populate() { for (auto &curplugin : m_plugins) item_append(curplugin, 0, (void *)curplugin.c_str()); @@ -125,7 +125,7 @@ void menu_plugin_opt::handle(event const *ev) } } -void menu_plugin_opt::populate(float &customtop, float &custombottom) +void menu_plugin_opt::populate() { std::vector> menu_list; std::string flags; diff --git a/src/frontend/mame/ui/pluginopt.h b/src/frontend/mame/ui/pluginopt.h index 15196c1ca2de9..3779cf130c258 100644 --- a/src/frontend/mame/ui/pluginopt.h +++ b/src/frontend/mame/ui/pluginopt.h @@ -32,7 +32,7 @@ class menu_plugin : public menu virtual ~menu_plugin(); private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::vector &m_plugins; @@ -48,7 +48,7 @@ class menu_plugin_opt : public menu virtual bool custom_ui_cancel() override { return true; } private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; std::string const m_menu; diff --git a/src/frontend/mame/ui/quitmenu.cpp b/src/frontend/mame/ui/quitmenu.cpp index bb26f7e629009..29f12143831a1 100644 --- a/src/frontend/mame/ui/quitmenu.cpp +++ b/src/frontend/mame/ui/quitmenu.cpp @@ -45,7 +45,7 @@ void menu_confirm_quit::custom_render(void *selectedref, float top, float bottom } -void menu_confirm_quit::populate(float &customtop, float &custombottom) +void menu_confirm_quit::populate() { } diff --git a/src/frontend/mame/ui/quitmenu.h b/src/frontend/mame/ui/quitmenu.h index 81ca61e2892de..206ef1983ead5 100644 --- a/src/frontend/mame/ui/quitmenu.h +++ b/src/frontend/mame/ui/quitmenu.h @@ -27,7 +27,7 @@ class menu_confirm_quit : public autopause_menu<> virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; }; diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp index 71643f4bf4ea1..b3a579cd049d4 100644 --- a/src/frontend/mame/ui/selector.cpp +++ b/src/frontend/mame/ui/selector.cpp @@ -95,7 +95,7 @@ void menu_selector::handle(event const *ev) // populate //------------------------------------------------- -void menu_selector::populate(float &customtop, float &custombottom) +void menu_selector::populate() { set_heading(util::string_format(_("menu-selector", "%1$s - Search: %2$s_"), m_title, m_search)); @@ -124,10 +124,20 @@ void menu_selector::populate(float &customtop, float &custombottom) } item_append(menu_item_type::SEPARATOR); - custombottom = line_height() + 3.0f * tb_border(); m_initial = -1; } +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_selector::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0F, line_height() + 3.0F * tb_border()); +} + //------------------------------------------------- // perform our special rendering //------------------------------------------------- diff --git a/src/frontend/mame/ui/selector.h b/src/frontend/mame/ui/selector.h index 17fdb97234300..8d504a42e2d03 100644 --- a/src/frontend/mame/ui/selector.h +++ b/src/frontend/mame/ui/selector.h @@ -38,13 +38,14 @@ class menu_selector : public menu virtual ~menu_selector() override; 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 bool custom_ui_cancel() override { return !m_search.empty(); } private: enum { VISIBLE_SEARCH_ITEMS = 200 }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void find_matches(const char *str); diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp index 7b268f7ba972d..047e6f6f721b2 100644 --- a/src/frontend/mame/ui/selgame.cpp +++ b/src/frontend/mame/ui/selgame.cpp @@ -135,6 +135,9 @@ void menu_select_game::recompute_metrics(uint32_t width, uint32_t height, float menu_select_launch::recompute_metrics(width, height, aspect); m_icons.clear(); + + // configure the custom rendering + set_custom_space(3.0F * line_height() + 5.0F * tb_border(), 4.0F * line_height() + 3.0F * tb_border()); } @@ -346,7 +349,7 @@ void menu_select_game::handle(event const *ev) // populate //------------------------------------------------- -void menu_select_game::populate(float &customtop, float &custombottom) +void menu_select_game::populate() { for (auto &icon : m_icons) // TODO: why is this here? maybe better on resize or setting change? icon.second.texture.reset(); @@ -468,10 +471,6 @@ void menu_select_game::populate(float &customtop, float &custombottom) m_skip_main_items = 0; } - // configure the custom rendering - customtop = 3.0f * line_height() + 5.0f * tb_border(); - custombottom = 4.0f * line_height() + 3.0f * tb_border(); - // reselect prior game launched, if any if (old_item_selected != -1) { diff --git a/src/frontend/mame/ui/selgame.h b/src/frontend/mame/ui/selgame.h index 1f28052ff882c..af1dad248ac13 100644 --- a/src/frontend/mame/ui/selgame.h +++ b/src/frontend/mame/ui/selgame.h @@ -58,7 +58,7 @@ class menu_select_game : public menu_select_launch static bool s_first_start; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // drawing diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index 7cceaa6ccb8d8..f24eb7b3581e1 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -172,7 +172,7 @@ class menu_select_launch::software_parts : public menu virtual ~software_parts() override; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; ui_software_info const &m_uiinfo; @@ -189,7 +189,7 @@ class menu_select_launch::bios_selection : public menu private: bios_selection(mame_ui_manager &mui, render_container &container, s_bios &&biosname, void const *driver, bool software, bool inlist); - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; void const *m_driver; @@ -280,7 +280,7 @@ menu_select_launch::software_parts::~software_parts() // populate //------------------------------------------------- -void menu_select_launch::software_parts::populate(float &customtop, float &custombottom) +void menu_select_launch::software_parts::populate() { std::vector parts; parts.reserve(m_parts.size()); @@ -350,7 +350,7 @@ menu_select_launch::bios_selection::~bios_selection() // populate //------------------------------------------------- -void menu_select_launch::bios_selection::populate(float &customtop, float &custombottom) +void menu_select_launch::bios_selection::populate() { for (auto &elem : m_bios) item_append(elem.first, 0, (void *)&elem.first); diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp index 56590e9e7eef1..50822545dd110 100644 --- a/src/frontend/mame/ui/selsoft.cpp +++ b/src/frontend/mame/ui/selsoft.cpp @@ -525,6 +525,18 @@ void menu_select_software::handle(event const *ev) draw_error_text(); } +//------------------------------------------------- +// recompute_metrics +//------------------------------------------------- + +void menu_select_software::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu_select_launch::recompute_metrics(width, height, aspect); + + // configure the custom rendering + set_custom_space(4.0F * line_height() + 5.0F * tb_border(), 4.0F * line_height() + 4.0F * tb_border()); +} + //------------------------------------------------- // menu_deactivated //------------------------------------------------- @@ -545,7 +557,7 @@ void menu_select_software::menu_deactivated() // populate //------------------------------------------------- -void menu_select_software::populate(float &customtop, float &custombottom) +void menu_select_software::populate() { for (auto &icon : m_data->icons()) // TODO: why is this here? maybe better on resize or setting change? icon.second.texture.reset(); @@ -605,10 +617,7 @@ void menu_select_software::populate(float &customtop, float &custombottom) m_displaylist[curitem].get().parentname.empty() ? 0 : FLAG_INVERT, (void *)&m_displaylist[curitem].get()); } - // configure the custom rendering m_skip_main_items = 0; - customtop = 4.0f * line_height() + 5.0f * tb_border(); - custombottom = 4.0f * line_height() + 4.0f * tb_border(); if (old_software != -1) { diff --git a/src/frontend/mame/ui/selsoft.h b/src/frontend/mame/ui/selsoft.h index 4b22ebc6eafa5..1ac874ac93a2c 100644 --- a/src/frontend/mame/ui/selsoft.h +++ b/src/frontend/mame/ui/selsoft.h @@ -33,6 +33,8 @@ class menu_select_software : public menu_select_launch virtual ~menu_select_software() override; protected: + virtual void recompute_metrics(uint32_t width, uint32_t height, float aspect) override; + virtual void menu_deactivated() override; private: @@ -42,7 +44,7 @@ class menu_select_software : public menu_select_launch struct search_item; class machine_data; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // drawing diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp index be3e056c97f18..9fd0b5bb177ab 100644 --- a/src/frontend/mame/ui/simpleselgame.cpp +++ b/src/frontend/mame/ui/simpleselgame.cpp @@ -236,7 +236,7 @@ void simple_menu_select_game::inkey_special(const event &menu_event) // populate - populate the game select menu //------------------------------------------------- -void simple_menu_select_game::populate(float &customtop, float &custombottom) +void simple_menu_select_game::populate() { int matchcount; int curitem; @@ -282,10 +282,19 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom) { item_append(_("Return to Previous Menu"), 0, nullptr); } +} + + +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void simple_menu_select_game::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); // configure the custom rendering - customtop = line_height() + 3.0f * tb_border(); - custombottom = 4.0f * line_height() + 3.0f * tb_border(); + set_custom_space(line_height() + 3.0f * tb_border(), 4.0f * line_height() + 3.0f * tb_border()); } diff --git a/src/frontend/mame/ui/simpleselgame.h b/src/frontend/mame/ui/simpleselgame.h index e5ea310c7ecf1..4f1effa43051d 100644 --- a/src/frontend/mame/ui/simpleselgame.h +++ b/src/frontend/mame/ui/simpleselgame.h @@ -29,13 +29,14 @@ class simple_menu_select_game : public menu static void force_game_select(mame_ui_manager &mui, render_container &container); 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 bool custom_ui_cancel() override { return !m_search.empty(); } private: enum { VISIBLE_GAMES_IN_LIST = 15 }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; // internal methods diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index e95789500ca9f..e162ebeee1a1c 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -160,7 +160,7 @@ void menu_sliders::handle(event const *ev) // menu //------------------------------------------------- -void menu_sliders::populate(float &customtop, float &custombottom) +void menu_sliders::populate() { std::string tempstring; @@ -224,8 +224,18 @@ void menu_sliders::populate(float &customtop, float &custombottom) if (ref) set_selection(ref); } +} + + +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_sliders::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); - custombottom = 2.0f * line_height() + 2.0f * tb_border(); + set_custom_space(0.0f, 2.0f * line_height() + 2.0f * tb_border()); } diff --git a/src/frontend/mame/ui/sliders.h b/src/frontend/mame/ui/sliders.h index 99a5c6e9cfbef..645169189cc03 100644 --- a/src/frontend/mame/ui/sliders.h +++ b/src/frontend/mame/ui/sliders.h @@ -25,12 +25,13 @@ class menu_sliders : public menu virtual ~menu_sliders() override; 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; private: - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; bool const m_menuless_mode; diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp index f1419122f9810..1b30b6120c199 100644 --- a/src/frontend/mame/ui/slotopt.cpp +++ b/src/frontend/mame/ui/slotopt.cpp @@ -171,7 +171,7 @@ bool menu_slot_devices::try_refresh_current_options() // populate //------------------------------------------------- -void menu_slot_devices::populate(float &customtop, float &custombottom) +void menu_slot_devices::populate() { // we need to keep our own copy of the machine_config because we // can change this out from under the caller @@ -202,9 +202,19 @@ void menu_slot_devices::populate(float &customtop, float &custombottom) } item_append(menu_item_type::SEPARATOR); item_append(_("Reset System"), 0, ITEMREF_RESET); +} + + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void menu_slot_devices::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); // leave space for the name of the current option at the bottom - custombottom = line_height() + 3.0f * tb_border(); + set_custom_space(0.0F, line_height() + 3.0F * tb_border()); } diff --git a/src/frontend/mame/ui/slotopt.h b/src/frontend/mame/ui/slotopt.h index 449d22627aa31..6dae4ce062aae 100644 --- a/src/frontend/mame/ui/slotopt.h +++ b/src/frontend/mame/ui/slotopt.h @@ -25,6 +25,10 @@ class menu_slot_devices : public menu menu_slot_devices(mame_ui_manager &mui, render_container &container); virtual ~menu_slot_devices() override; +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 origx1, float origy1, float origx2, float origy2) override; + private: enum class step_t { @@ -32,8 +36,7 @@ class menu_slot_devices : public menu PREVIOUS }; - virtual void populate(float &customtop, float &custombottom) override; - virtual void custom_render(void *selectedref, float top, float bottom, float origx1, float origy1, float origx2, float origy2) override; + virtual void populate() override; virtual void handle(event const *ev) override; device_slot_interface::slot_option const *get_current_option(device_slot_interface &slot) const; diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp index 136cbcf98f47e..f389c128c078b 100644 --- a/src/frontend/mame/ui/sndmenu.cpp +++ b/src/frontend/mame/ui/sndmenu.cpp @@ -139,7 +139,7 @@ void menu_sound_options::handle(event const *ev) // populate //------------------------------------------------- -void menu_sound_options::populate(float &customtop, float &custombottom) +void menu_sound_options::populate() { uint32_t arrow_flags = get_arrow_flags(uint16_t(0), uint16_t(std::size(m_sound_rate) - 1), m_cur_rates); m_sample_rate = m_sound_rate[m_cur_rates]; diff --git a/src/frontend/mame/ui/sndmenu.h b/src/frontend/mame/ui/sndmenu.h index 48d85b7d1a577..6e79d4f6faae6 100644 --- a/src/frontend/mame/ui/sndmenu.h +++ b/src/frontend/mame/ui/sndmenu.h @@ -38,7 +38,7 @@ class menu_sound_options : public menu ENABLE_SAMPLES }; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; uint16_t m_cur_rates; diff --git a/src/frontend/mame/ui/state.cpp b/src/frontend/mame/ui/state.cpp index 3e3c460f20314..49412c8a24494 100644 --- a/src/frontend/mame/ui/state.cpp +++ b/src/frontend/mame/ui/state.cpp @@ -118,7 +118,7 @@ menu_load_save_state_base::~menu_load_save_state_base() // populate //------------------------------------------------- -void menu_load_save_state_base::populate(float &customtop, float &custombottom) +void menu_load_save_state_base::populate() { // build the "filename to code" map, if we have not already (if it were not for the // possibility that the system keyboard can be changed at runtime, I would put this @@ -224,9 +224,6 @@ void menu_load_save_state_base::populate(float &customtop, float &custombottom) if (is_one_shot()) item_append(_("Cancel"), 0, nullptr); - // set up custom render proc - custombottom = (2.0f * line_height()) + (3.0f * tb_border()); - // get ready to poll inputs m_switch_poller.reset(); m_keys_released = false; @@ -420,6 +417,19 @@ void menu_load_save_state_base::handle_keys(uint32_t flags, int &iptkey) } +//------------------------------------------------- +// recompute_metrics - recompute metrics +//------------------------------------------------- + +void menu_load_save_state_base::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + autopause_menu<>::recompute_metrics(width, height, aspect); + + // set up custom render proc + set_custom_space(0.0F, (2.0F * line_height()) + (3.0F * tb_border())); +} + + //------------------------------------------------- // custom_render - perform our special rendering //------------------------------------------------- @@ -446,14 +456,14 @@ void menu_load_save_state_base::custom_render(void *selectedref, float top, floa { draw_text_box( std::begin(text), std::next(std::begin(text), count), - origx1, origx2, origy2 + tb_border(), origy2 + (count * line_height()) + (3.0f * tb_border()), + origx1, origx2, origy2 + tb_border(), origy2 + (count * line_height()) + (3.0F * tb_border()), text_layout::text_justify::CENTER, text_layout::word_wrapping::NEVER, false, ui().colors().text_color(), ui().colors().background_color()); } // draw the confirmation prompt if necessary if (!m_confirm_prompt.empty()) - ui().draw_text_box(container(), m_confirm_prompt, text_layout::text_justify::CENTER, 0.5f, 0.5f, ui().colors().background_color()); + ui().draw_text_box(container(), m_confirm_prompt, text_layout::text_justify::CENTER, 0.5F, 0.5F, ui().colors().background_color()); } diff --git a/src/frontend/mame/ui/state.h b/src/frontend/mame/ui/state.h index c9594cf25cfd3..8d982678d7d96 100644 --- a/src/frontend/mame/ui/state.h +++ b/src/frontend/mame/ui/state.h @@ -36,9 +36,10 @@ class menu_load_save_state_base : public autopause_menu<> bool must_exist, bool one_shot); + 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 handle_keys(uint32_t flags, int &iptkey) override; - virtual void populate(float &customtop, float &custombottom) override; + virtual void populate() override; virtual void handle(event const *ev) override; virtual void process_file(std::string &&file_name) = 0; diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp index 3450504fc4cf3..82eb23d6a17f7 100644 --- a/src/frontend/mame/ui/submenu.cpp +++ b/src/frontend/mame/ui/submenu.cpp @@ -285,7 +285,7 @@ void submenu::handle(event const *ev) const char *minimum = sm_option.entry->minimum(); const char *maximum = sm_option.entry->maximum(); f_step = atof(minimum); - if (f_step <= 0.0f) { + if (f_step <= 0.0F) { int pmin = getprecisionchr(minimum); int pmax = getprecisionchr(maximum); tmptxt = '1' + std::string((pmin > pmax) ? pmin : pmax, '0'); @@ -339,7 +339,7 @@ void submenu::handle(event const *ev) // populate //------------------------------------------------- -void submenu::populate(float &customtop, float &custombottom) +void submenu::populate() { // add options for (auto sm_option = m_options.begin(); sm_option < m_options.end(); ++sm_option) @@ -405,7 +405,7 @@ void submenu::populate(float &customtop, float &custombottom) } else { - f_min = 0.0f; + f_min = 0.0F; f_max = std::numeric_limits::max(); } arrow_flags = get_arrow_flags(f_min, f_max, f_cur); @@ -446,7 +446,17 @@ void submenu::populate(float &customtop, float &custombottom) } item_append(menu_item_type::SEPARATOR); - custombottom = ui().get_line_height() + (3.0f * tb_border()); +} + +//------------------------------------------------- +// recompute metrics +//------------------------------------------------- + +void submenu::recompute_metrics(uint32_t width, uint32_t height, float aspect) +{ + menu::recompute_metrics(width, height, aspect); + + set_custom_space(0.0F, line_height() + (3.0F * tb_border())); } //------------------------------------------------- diff --git a/src/frontend/mame/ui/submenu.h b/src/frontend/mame/ui/submenu.h index fdcbfa2c7c2f7..c307f2209242c 100644 --- a/src/frontend/mame/ui/submenu.h +++ b/src/frontend/mame/ui/submenu.h @@ -60,10 +60,11 @@ class submenu : public menu //static std::vector