diff options
author | 2021-11-24 11:19:55 +1100 | |
---|---|---|
committer | 2021-11-24 11:19:55 +1100 | |
commit | 44a5a57d0eefc1aeafb00d42f91e2100e186a71c (patch) | |
tree | 2e7003802b9568c5820db3362a10a599b6074025 /src/frontend/mame/ui/selmenu.cpp | |
parent | ae8adeb04212102a7f8587ef4388156140e21ab0 (diff) | |
parent | 4518f0eadeb4482ba01ab5add75d6eae921ce571 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/frontend/mame/ui/selmenu.cpp')
-rw-r--r-- | src/frontend/mame/ui/selmenu.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp index fc20bc0c9ee..1b393edc91a 100644 --- a/src/frontend/mame/ui/selmenu.cpp +++ b/src/frontend/mame/ui/selmenu.cpp @@ -1419,7 +1419,6 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey) } else if (m_focus == focused_menu::LEFT) { - m_prev_selected = nullptr; filter_selected(); } return; @@ -1774,7 +1773,6 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev) } else if (hover() >= HOVER_FILTER_FIRST && hover() <= HOVER_FILTER_LAST) { - m_prev_selected = nullptr; m_filter_highlight = hover() - HOVER_FILTER_FIRST; filter_selected(); stop = true; @@ -1953,18 +1951,29 @@ void menu_select_launch::draw(uint32_t flags) // make sure the selection if (m_available_items < m_visible_lines) m_visible_lines = m_available_items; - if (top_line < 0 || is_first_selected()) + int selection; + if (selected_index() < m_available_items) + { + selection = selected_index(); + } + else + { + selection = 0; + while ((m_available_items > selection) && (item(selection).ref() != m_prev_selected)) + ++selection; + } + if (top_line < 0 || !selection) { top_line = 0; } - else if (selected_index() < m_available_items) + else if (selection < m_available_items) { - if (selected_index() >= (top_line + m_visible_lines)) - top_line = selected_index() - (m_visible_lines / 2); + if ((selection >= (top_line + m_visible_lines)) || (selection <= top_line)) + top_line = (std::max)(selection - (m_visible_lines / 2), 0); if ((top_line + m_visible_lines) >= m_available_items) top_line = m_available_items - m_visible_lines; - else if (selected_index() >= (top_line + m_visible_lines - 2)) - top_line = selected_index() - m_visible_lines + ((selected_index() == (m_available_items - 1)) ? 1: 2); + else if (selection >= (top_line + m_visible_lines - 2)) + top_line = selection - m_visible_lines + ((selection == (m_available_items - 1)) ? 1: 2); } // determine effective positions taking into account the hilighting arrows |