diff options
author | 2021-10-31 12:31:16 +1100 | |
---|---|---|
committer | 2021-10-31 12:31:16 +1100 | |
commit | d64ea5331b2312f81df464fb22dcef0191216d86 (patch) | |
tree | a3f3784371da401e6a675e5b6b9734b88281a08d /src/frontend/mame/ui/sliders.cpp | |
parent | cfffc54b61cabc5ef9533396bf87324eb5eeb63e (diff) |
-frontend: Refactored menu event handling and fixed a number of issues. (#8777)
* Moved common code for drawing about box, info viewer, and other text box menus to a base class; removed the last of the info viewer logic and the multi-line item hack from the base menu class.
* Added previous/next group navigation for general inputs and plugin input selection menus.
* Moved message catalog logic to lib/util, allowing osd and emu to use localised messages.
* Made the base menu class use the UI manager’s feature for holding session state rather than a static map and mutex.
* Improved menu event handling model, and fixed many issues, particularly with menus behaving badly when hidden/shown.
* Added better support for menus that don’t participate in the usual menu stack, like the menuless sliders and the save/load state menus.
* Made a number of menus refresh state when being shown after being hidden (fixes MT08121 among other issues).
* Fixed indication of mounted slot option in the slot option details menu.
* Improved appearance of background menus when emulation isn't running - draw all menus in the stack, and darken the background menus to make the edges of the active menu clearer.
* Fixed locale issues in -listxml.
-debugger: Made GUI debuggers more uniform.
* Added new memory view features to Win32 debugger.
* Fixed spelling of hexadecimal in Cocoa debugger and added decimal address option.
* Fixed duplicate keyboard shortcut in Cocoa debugger (Shift-Cmd-D was both new device window and 64-bit float format).
* Made keyboard shortcuts slightly more consistent across debuggers.
-plugins: Moved input selection menu and sequence polling code to a common library. Fixed the issue that prevented keyboard inputs being mapped with -steadykey on.
-docs: Started adding some documentation for MAME's internal UI, and updated the list of example front-ends.
-Regenerated message catalog sources. For translators, the new strings are mostly:
* The names of the inputs provided by the OS-dependent layer for things like fullscreen and video features. These show up in the user interface inputs menu.
* The names for automatically generated views. These show up in the video options menu - test with a system with a lot of screens to see more variants.
* The input macro plugin UI.
* A few format strings for analog input assignments.
* A few strings for the about box header.
Diffstat (limited to 'src/frontend/mame/ui/sliders.cpp')
-rw-r--r-- | src/frontend/mame/ui/sliders.cpp | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp index 99b3756bfec..e26b76e2302 100644 --- a/src/frontend/mame/ui/sliders.cpp +++ b/src/frontend/mame/ui/sliders.cpp @@ -19,9 +19,13 @@ namespace ui { -menu_sliders::menu_sliders(mame_ui_manager &mui, render_container &container, bool menuless_mode) : menu(mui, container) +menu_sliders::menu_sliders(mame_ui_manager &mui, render_container &container, bool menuless_mode) + : menu(mui, container) + , m_menuless_mode(menuless_mode) + , m_hidden(menuless_mode) { - m_menuless_mode = m_hidden = menuless_mode; + set_one_shot(menuless_mode); + set_process_flags(PROCESS_LR_REPEAT | (m_hidden ? PROCESS_CUSTOM_ONLY : 0)); } menu_sliders::~menu_sliders() @@ -32,32 +36,34 @@ menu_sliders::~menu_sliders() // menu_sliders - handle the sliders menu //------------------------------------------------- -void menu_sliders::handle() +void menu_sliders::handle(event const *ev) { - const event *menu_event; - // process the menu - menu_event = process(PROCESS_LR_REPEAT | (m_hidden ? PROCESS_CUSTOM_ONLY : 0)); - if (menu_event != nullptr) + if (ev) { // handle keys if there is a valid item selected - if (menu_event->itemref != nullptr && menu_event->type == menu_item_type::SLIDER) + if (ev->itemref && (ev->type == menu_item_type::SLIDER)) { - const slider_state *slider = (const slider_state *)menu_event->itemref; + const slider_state *slider = (const slider_state *)ev->itemref; int32_t curvalue = slider->update(nullptr, SLIDER_NOCHANGE); int32_t increment = 0; bool alt_pressed = machine().input().code_pressed(KEYCODE_LALT) || machine().input().code_pressed(KEYCODE_RALT); bool ctrl_pressed = machine().input().code_pressed(KEYCODE_LCONTROL) || machine().input().code_pressed(KEYCODE_RCONTROL); bool shift_pressed = machine().input().code_pressed(KEYCODE_LSHIFT) || machine().input().code_pressed(KEYCODE_RSHIFT); - switch (menu_event->iptkey) + switch (ev->iptkey) { // toggle visibility case IPT_UI_ON_SCREEN_DISPLAY: if (m_menuless_mode) + { stack_pop(); + } else + { m_hidden = !m_hidden; + set_process_flags(PROCESS_LR_REPEAT | (m_hidden ? PROCESS_CUSTOM_ONLY : 0)); + } break; // decrease value @@ -114,9 +120,9 @@ void menu_sliders::handle() // if we are selecting an invalid item and we are hidden, skip to the next one else if (m_hidden) { - // if we got here via up or page up, select the previous item - if (menu_event->iptkey == IPT_UI_UP || menu_event->iptkey == IPT_UI_PAGE_UP) + if (ev->iptkey == IPT_UI_UP || ev->iptkey == IPT_UI_PAGE_UP) { + // if we got here via up or page up, select the previous item if (is_first_selected()) select_last_item(); else @@ -125,10 +131,9 @@ void menu_sliders::handle() validate_selection(-1); } } - - // otherwise select the next item - else if (menu_event->iptkey == IPT_UI_DOWN || menu_event->iptkey == IPT_UI_PAGE_DOWN) + else if (ev->iptkey == IPT_UI_DOWN || ev->iptkey == IPT_UI_PAGE_DOWN) { + // otherwise select the next item if (is_last_selected()) select_first_item(); else @@ -157,7 +162,7 @@ void menu_sliders::populate(float &customtop, float &custombottom) { if (item.type == menu_item_type::SLIDER) { - slider_state* slider = reinterpret_cast<slider_state *>(item.ref); + slider_state *const slider = reinterpret_cast<slider_state *>(item.ref); bool display(true); #if 0 // FIXME: this test should be reimplemented in a dedicated menu @@ -286,30 +291,4 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo } } - -//------------------------------------------------- -// slider_ui_handler - pushes the slider -// menu on the stack and hands off to the -// standard menu handler -//------------------------------------------------- - -uint32_t menu_sliders::ui_handler(render_container &container, mame_ui_manager &mui) -{ - uint32_t result; - - // if this is the first call, push the sliders menu - if (topmost_menu<menu_sliders>(mui.machine()) == nullptr) - menu::stack_push<menu_sliders>(mui, container, true); - - // handle standard menus - result = menu::ui_handler(container, mui); - - // if we are cancelled, pop the sliders menu - if (result == UI_HANDLER_CANCEL) - menu::stack_pop(mui.machine()); - - menu_sliders *uim = topmost_menu<menu_sliders>(mui.machine()); - return uim && uim->m_menuless_mode ? 0 : UI_HANDLER_CANCEL; -} - } // namespace ui |