diff options
Diffstat (limited to 'src/emu/ui/uimain.h')
-rw-r--r-- | src/emu/ui/uimain.h | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/emu/ui/uimain.h b/src/emu/ui/uimain.h new file mode 100644 index 00000000000..23db7aae32c --- /dev/null +++ b/src/emu/ui/uimain.h @@ -0,0 +1,130 @@ +// license:BSD-3-Clause +// copyright-holders:Nicola Salmoria, Aaron Giles, Nathan Woods +/*************************************************************************** + + ui/menu.h + + Internal MAME menus for the user interface. + +***************************************************************************/ + +#pragma once + +#ifndef __BASIC_UI_H__ +#define __BASIC_UI_H__ + +#include "emu.h" +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +// flags for menu items +#define MENU_FLAG_LEFT_ARROW (1 << 0) +#define MENU_FLAG_RIGHT_ARROW (1 << 1) +#define MENU_FLAG_INVERT (1 << 2) +#define MENU_FLAG_MULTILINE (1 << 3) +#define MENU_FLAG_REDTEXT (1 << 4) +#define MENU_FLAG_DISABLE (1 << 5) +#define MENU_FLAG_UI (1 << 6) +#define MENU_FLAG_UI_DATS (1 << 7) +#define MENU_FLAG_UI_SWLIST (1 << 8) +#define MENU_FLAG_UI_FAVORITE (1 << 9) +#define MENU_FLAG_UI_PALETTE (1 << 10) +#define MENU_FLAG_UI_HEADING (1 << 11) + +// special menu item for separators +#define MENU_SEPARATOR_ITEM "---" + + +#define SLIDER_NOCHANGE 0x12345678 + + +typedef INT32(*slider_update)(running_machine &machine, void *arg, int id, std::string *str, INT32 newval); + +struct slider_state +{ + slider_state * next; /* pointer to next slider */ + slider_update update; /* callback */ + void * arg; /* argument */ + INT32 minval; /* minimum value */ + INT32 defval; /* default value */ + INT32 maxval; /* maximum value */ + INT32 incval; /* increment value */ + int id; + char description[1]; /* textual description */ +}; + +// types of menu items (TODO: please expand) +enum class ui_menu_item_type +{ + UNKNOWN, + SLIDER, + SEPARATOR +}; + + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +class ui_menu_item +{ +public: + const char *text; + const char *subtext; + UINT32 flags; + void *ref; + ui_menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*) + + inline bool is_selectable() const; +}; + +class ui_manager +{ +public: + // construction/destruction + ui_manager(running_machine &machine) : m_machine(machine),m_use_natural_keyboard(false),m_show_timecode_counter(false),m_show_timecode_total(false) { } + + virtual void set_startup_text(const char *text, bool force) { } + + virtual bool is_menu_active() { return false; } + + bool use_natural_keyboard() const { return m_use_natural_keyboard; } + + void set_show_timecode_counter(bool value) { m_show_timecode_counter = value; m_show_timecode_total = true; } + + bool show_timecode_counter() { return m_show_timecode_counter; } + bool show_timecode_total() { return m_show_timecode_total; } + + virtual void popup_time_string(int seconds, std::string message) { } + + virtual void image_display(const device_type &type, device_image_interface *image) { } + + template <typename Format, typename... Params> void popup_time(int seconds, Format &&fmt, Params &&... args); + +protected: + // instance variables + running_machine & m_machine; + bool m_use_natural_keyboard; + bool m_show_timecode_counter; + bool m_show_timecode_total; +}; + +/*************************************************************************** + MEMBER TEMPLATES +***************************************************************************/ + +//------------------------------------------------- +// popup_time - popup a message for a specific +// amount of time +//------------------------------------------------- + +template <typename Format, typename... Params> +inline void ui_manager::popup_time(int seconds, Format &&fmt, Params &&... args) +{ + // extract the text + popup_time_string(seconds, string_format(std::forward<Format>(fmt), std::forward<Params>(args)...)); +} + +#endif // __BASIC_UI_H__ |