diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2019-05-22 11:35:39 -0400 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2019-05-22 11:35:39 -0400 |
commit | b085fad792639d0da2e236ad45fdf71f740e8aa8 (patch) | |
tree | 5f680d0dec4042f92ea8642ace1d4636c76ad1a8 /src/frontend/mame/ui/menu.h | |
parent | aa724006054f7d7cd0c4bd66119ad7342f008649 (diff) |
ui/menu.cpp: Privatize a few variables (nw)
Diffstat (limited to 'src/frontend/mame/ui/menu.h')
-rw-r--r-- | src/frontend/mame/ui/menu.h | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index ffcb0ed71e8..0b472b80f0c 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -130,16 +130,6 @@ protected: render_bounds mouse; // mouse position if iptkey == IPT_CUSTOM }; - int hover; // which item is being hovered over - std::vector<menu_item> item; // array of items - - int top_line; // main box top line - int skip_main_items; - int selected; // which item is selected - - int m_visible_lines; // main box visible lines - int m_visible_items; // number of visible items - menu(mame_ui_manager &mui, render_container &container); mame_ui_manager &ui() const { return m_ui; } @@ -167,22 +157,31 @@ protected: const event *process(uint32_t flags, float x0 = 0.0f, float y0 = 0.0f); void process_parent() { m_parent->process(PROCESS_NOINPUT); } + menu_item &item(int index) { return m_items[index]; } + menu_item const &item(int index) const { return m_items[index]; } + int item_count() const { return m_items.size(); } + // retrieves the ref of the currently selected menu item or nullptr - void *get_selection_ref() const { return selection_valid() ? item[selected].ref : nullptr; } + void *get_selection_ref() const { return selection_valid() ? m_items[m_selected].ref : nullptr; } - menu_item &selected_item() { return item[selected]; } - menu_item const &selected_item() const { return item[selected]; } - int selected_index() const { return selected; } - bool selection_valid() const { return (0 <= selected) && (item.size() > selected); } - bool is_selected(int index) const { return selection_valid() && (selected == index); } - bool is_first_selected() const { return 0 == selected; } - bool is_last_selected() const { return (item.size() - 1) == selected; } + menu_item &selected_item() { return m_items[m_selected]; } + menu_item const &selected_item() const { return m_items[m_selected]; } + int selected_index() const { return m_selected; } + bool selection_valid() const { return (0 <= m_selected) && (m_items.size() > m_selected); } + bool is_selected(int index) const { return selection_valid() && (m_selected == index); } + bool is_first_selected() const { return 0 == m_selected; } + bool is_last_selected() const { return (m_items.size() - 1) == m_selected; } // changes the index of the currently selected menu item void set_selection(void *selected_itemref); + void set_selected_index(int index) { m_selected = index; } + + int hover() const { return m_hover; } + void set_hover(int index) { m_hover = index; } + void clear_hover() { m_hover = m_items.size() + 1; } // scroll position control - void centre_selection() { top_line = selected - (m_visible_lines / 2); } + void centre_selection() { top_line = m_selected - (m_visible_lines / 2); } // test if the given key is pressed and we haven't already reported a key bool exclusive_input_pressed(int &iptkey, int key, int repeat); @@ -356,7 +355,7 @@ private: void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction); bool first_item_visible() const { return top_line <= 0; } - bool last_item_visible() const { return (top_line + m_visible_lines) >= item.size(); } + bool last_item_visible() const { return (top_line + m_visible_lines) >= m_items.size(); } static void exit(running_machine &machine); static global_state_ptr get_global_state(running_machine &machine); @@ -364,6 +363,17 @@ private: static char const *get_c_str(std::string const &str) { return str.c_str(); } static char const *get_c_str(char const *str) { return str; } + int m_selected; // which item is selected + int m_hover; // which item is being hovered over + std::vector<menu_item> m_items; // array of items + +protected: // TODO: remove need to expose these + int top_line; // main box top line + int skip_main_items; + int m_visible_lines; // main box visible lines + int m_visible_items; // number of visible items + +private: global_state_ptr const m_global_state; bool m_special_main_menu; mame_ui_manager &m_ui; // UI we are attached to |