diff options
author | AJR <ajrhacker@users.noreply.github.com> | 2020-12-08 21:19:17 -0500 |
---|---|---|
committer | AJR <ajrhacker@users.noreply.github.com> | 2020-12-08 21:24:46 -0500 |
commit | c22cb17f326b4939d8ff4219410909e32e70ab86 (patch) | |
tree | 8db68c201fa9673eeb6acab37a5d221c7a338ea6 /src/frontend/mame/ui/menu.h | |
parent | 6172111b187c1dd66329adb2b9bba2a82a0ce116 (diff) |
C++17 string handling updates (without charconv so as not to break GCC 7)
- render.cpp, rendlay.cpp, ui/ui.cpp, ui/menu.cpp: Change argument types for text processing functions from const char * to std::string_view
- ui/menu.cpp: Add overloads of item_append omitting the frequently empty subtext argument
- cheat.cpp: Remove some c_str() calls that became unnecessary a while ago
Diffstat (limited to 'src/frontend/mame/ui/menu.h')
-rw-r--r-- | src/frontend/mame/ui/menu.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index 5a7d4374bf6..eacbae32609 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -23,6 +23,7 @@ #include <map> #include <memory> #include <mutex> +#include <string_view> #include <vector> @@ -84,9 +85,11 @@ public: virtual ~menu(); // append a new item to the end of the menu - void item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); + void item_append(const std::string &text, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(std::string(text), std::string(), flags, ref, type); } + void item_append(const std::string &text, const std::string &subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(std::string(text), std::string(subtext), flags, ref, type); } + void item_append(std::string &&text, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN) { item_append(text, std::string(), flags, ref, type); } void item_append(std::string &&text, std::string &&subtext, uint32_t flags, void *ref, menu_item_type type = menu_item_type::UNKNOWN); - void item_append(menu_item item); + void item_append(menu_item item) { item_append(item.text, item.subtext, item.flags, item.ref, item.type); } 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); @@ -229,7 +232,7 @@ protected: void draw_arrow(float x0, float y0, float x1, float y1, rgb_t fgcolor, uint32_t orientation); // draw header and footer text - void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, const char *header, const char *footer); + void extra_text_render(float top, float bottom, float origx1, float origy1, float origx2, float origy2, std::string_view header, std::string_view footer); void extra_text_position(float origx1, float origx2, float origy, float yspan, text_layout &layout, int direction, float &x1, float &y1, float &x2, float &y2); @@ -248,7 +251,7 @@ protected: { float width; ui().draw_text_full( - container(), get_c_str(*it), + container(), std::string_view(*it), 0.0f, 0.0f, 1.0f, justify, wrap, mame_ui_manager::NONE, rgb_t::black(), rgb_t::white(), &width, nullptr, text_size); @@ -274,7 +277,7 @@ protected: for (Iter it = begin; it != end; ++it) { ui().draw_text_full( - container(), get_c_str(*it), + container(), std::string_view(*it), x1, y1, x2 - x1, justify, wrap, mame_ui_manager::NORMAL, fgcolor, ui().colors().text_bg_color(), nullptr, nullptr, text_size); @@ -377,7 +380,7 @@ private: // push a new menu onto the stack static void stack_push(std::unique_ptr<menu> &&menu) { get_global_state(menu->machine())->stack_push(std::move(menu)); } - void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, const char *text, int direction); + void extra_text_draw_box(float origx1, float origx2, float origy, float yspan, std::string_view text, int direction); bool first_item_visible() const { return top_line <= 0; } bool last_item_visible() const { return (top_line + m_visible_lines) >= m_items.size(); } @@ -385,9 +388,6 @@ private: static void exit(running_machine &machine); static global_state_ptr get_global_state(running_machine &machine); - 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 |