diff options
author | Vas Crabb <vas@vastheman.com> | 2017-08-07 17:00:24 +1000 |
---|---|---|
committer | Vas Crabb <vas@vastheman.com> | 2017-08-07 17:00:24 +1000 |
commit | dd673e6fa64347e1ed8a58fd8408bf36898e07ba (patch) | |
tree | 0b85785faa945c22ac27d04eb25a5a64543c68e0 /src/frontend/mame/ui/menu.h | |
parent | 8a209caeeb4f339f471b3aea85b1c2188cc16201 (diff) |
internal UI improvements:
* Greatly reduce copy/paste code for drawing menu header/footer boxes
* Display full name of selected slot device below slots menu
* Fix up spacing on dircetory configuration menu
* Fix min/max for UI font rows per screen setting
Diffstat (limited to 'src/frontend/mame/ui/menu.h')
-rw-r--r-- | src/frontend/mame/ui/menu.h | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h index a4e4d8a7c26..478d62545c9 100644 --- a/src/frontend/mame/ui/menu.h +++ b/src/frontend/mame/ui/menu.h @@ -204,9 +204,60 @@ protected: 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); + // draw a box of text - used for the custom boxes above/below menus + template <typename Iter> + float draw_text_box( + Iter begin, Iter end, + float origx1, float origx2, float y1, float y2, + ui::text_layout::text_justify justify, ui::text_layout::word_wrapping wrap, bool scale, + rgb_t fgcolor, rgb_t bgcolor, float text_size) + { + // size up the text + float maxwidth(origx2 - origx1); + for (Iter it = begin; it != end; ++it) + { + float width; + ui().draw_text_full( + container(), get_c_str(*it), + 0.0f, 0.0f, 1.0f, justify, wrap, + mame_ui_manager::NONE, rgb_t::black(), rgb_t::white(), + &width, nullptr, text_size); + width += 2.0f * UI_BOX_LR_BORDER; + maxwidth = (std::max)(maxwidth, width); + } + if (scale && ((origx2 - origx1) < maxwidth)) + { + text_size *= ((origx2 - origx1) / maxwidth); + maxwidth = origx2 - origx1; + } + + // draw containing box + float x1(0.5f * (1.0f - maxwidth)); + float x2(x1 + maxwidth); + ui().draw_outlined_box(container(), x1, y1, x2, y2, bgcolor); + + // inset box and draw content + x1 += UI_BOX_LR_BORDER; + x2 -= UI_BOX_LR_BORDER; + y1 += UI_BOX_TB_BORDER; + y2 -= UI_BOX_TB_BORDER; + for (Iter it = begin; it != end; ++it) + { + ui().draw_text_full( + container(), get_c_str(*it), + x1, y1, x2 - x1, justify, wrap, + mame_ui_manager::NORMAL, fgcolor, UI_TEXT_BG_COLOR, + nullptr, nullptr, text_size); + y1 += ui().get_line_height(); + } + + // in case you want another box of similar width + return maxwidth; + } + void draw_background(); - // configure the menu for custom rendering + // draw additional menu content virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2); // map mouse to menu coordinates @@ -313,6 +364,9 @@ 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; } + global_state_ptr const m_global_state; bool m_special_main_menu; mame_ui_manager &m_ui; // UI we are attached to |