-osd/windows: Fixed stupid potential deadlock on exit.

-frontend: Some changes to menu item class that will make it possbile to
 reduce the number of menu rebuilds.
This commit is contained in:
Vas Crabb 2021-11-13 02:49:51 +11:00
parent 1364bd571e
commit 839192e769
20 changed files with 131 additions and 147 deletions

View File

@ -222,10 +222,10 @@ void menu_confswitch::handle(event const *ev)
{
if (!found_break)
{
if (!item(--current).ref)
if (!item(--current).ref())
found_break = true;
}
else if (!item(current - 1).ref)
else if (!item(current - 1).ref())
{
set_selected_index(current);
set_top_line(current - 1);
@ -245,9 +245,9 @@ void menu_confswitch::handle(event const *ev)
auto current = selected_index();
while (item_count() > ++current)
{
if (!item(current).ref)
if (!item(current).ref())
{
if ((item_count() > (current + 1)) && (uintptr_t(item(current + 1).ref) != 1))
if ((item_count() > (current + 1)) && (uintptr_t(item(current + 1).ref()) != 1))
{
set_selected_index(current + 1);
set_top_line(current);

View File

@ -559,7 +559,7 @@ void menu_colors_ui::handle(event const *ev)
{
if ((uintptr_t)ev->itemref != MUI_RESTORE)
{
menu::stack_push<menu_rgb_ui>(ui(), container(), &m_color_table[(uintptr_t)ev->itemref].color, selected_item().text);
menu::stack_push<menu_rgb_ui>(ui(), container(), &m_color_table[(uintptr_t)ev->itemref].color, selected_item().text());
}
else
{
@ -1080,7 +1080,7 @@ void menu_palette_sel::handle(event const *ev)
{
if (ev->iptkey == IPT_UI_SELECT)
{
m_original = rgb_t(uint32_t(strtoul(selected_item().subtext.c_str(), nullptr, 16)));
m_original = rgb_t(uint32_t(strtoul(selected_item().subtext().c_str(), nullptr, 16)));
reset_parent(reset_options::SELECT_FIRST);
stack_pop();
}

View File

@ -253,7 +253,7 @@ void menu_add_change_folder::handle(event const *ev)
const menu_item &pitem = item(index);
// go up to the parent path
if (pitem.text == "..")
if (pitem.text() == "..")
{
size_t first_sep = m_current_path.find_first_of(PATH_SEPARATOR[0]);
size_t last_sep = m_current_path.find_last_of(PATH_SEPARATOR[0]);
@ -263,15 +263,15 @@ void menu_add_change_folder::handle(event const *ev)
else
{
// if isn't a drive, appends the directory
if (pitem.subtext != "[DRIVE]")
if (pitem.subtext() != "[DRIVE]")
{
if (m_current_path[m_current_path.length() - 1] == PATH_SEPARATOR[0])
m_current_path.append(pitem.text);
m_current_path.append(pitem.text());
else
m_current_path.append(PATH_SEPARATOR).append(pitem.text);
m_current_path.append(PATH_SEPARATOR).append(pitem.text());
}
else
m_current_path = pitem.text;
m_current_path = pitem.text();
}
// reset the char buffer also in this case
@ -331,12 +331,12 @@ void menu_add_change_folder::handle(event const *ev)
// from current item to the end
for (entry = cur_selected; entry < item_count(); entry++)
if (item(entry).ref != nullptr && !m_search.empty())
if (item(entry).ref() && !m_search.empty())
{
int match = 0;
for (int i = 0; i < m_search.size() + 1; i++)
{
if (core_strnicmp(item(entry).text.c_str(), m_search.data(), i) == 0)
if (core_strnicmp(item(entry).text().c_str(), m_search.data(), i) == 0)
match = i;
}
@ -350,12 +350,12 @@ void menu_add_change_folder::handle(event const *ev)
// and from the first item to current one
for (entry = 0; entry < cur_selected; entry++)
{
if (item(entry).ref != nullptr && !m_search.empty())
if (item(entry).ref() && !m_search.empty())
{
int match = 0;
for (int i = 0; i < m_search.size() + 1; i++)
{
if (core_strnicmp(item(entry).text.c_str(), m_search.data(), i) == 0)
if (core_strnicmp(item(entry).text().c_str(), m_search.data(), i) == 0)
match = i;
}

View File

@ -321,12 +321,9 @@ void menu::item_append(menu_item_type type, uint32_t flags)
void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags, void *ref, menu_item_type type)
{
// allocate a new item and populate it
menu_item pitem;
pitem.text = std::move(text);
pitem.subtext = std::move(subtext);
pitem.flags = flags;
pitem.ref = ref;
pitem.type = type;
menu_item pitem(type, ref, flags);
pitem.set_text(std::move(text));
pitem.set_subtext(std::move(subtext));
// append to array
auto index = m_items.size();
@ -336,10 +333,12 @@ void menu::item_append(std::string &&text, std::string &&subtext, uint32_t flags
--index;
}
else
{
m_items.emplace_back(std::move(pitem));
}
// update the selection if we need to
if (m_resetpos == index || (m_resetref != nullptr && m_resetref == ref))
if ((m_resetpos == index) || (m_resetref && (m_resetref == ref)))
m_selected = index;
if (m_resetpos == (m_items.size() - 1))
m_selected = m_items.size() - 1;
@ -406,7 +405,7 @@ const menu::event *menu::process()
if ((m_event.iptkey != IPT_INVALID) && selection_valid())
{
m_event.itemref = get_selection_ref();
m_event.type = m_items[m_selected].type;
m_event.type = m_items[m_selected].type();
return &m_event;
}
else
@ -426,7 +425,7 @@ void menu::set_selection(void *selected_itemref)
m_selected = -1;
for (int itemnum = 0; itemnum < m_items.size(); itemnum++)
{
if (m_items[itemnum].ref == selected_itemref)
if (m_items[itemnum].ref() == selected_itemref)
{
m_selected = itemnum;
break;
@ -476,11 +475,11 @@ void menu::draw(uint32_t flags)
for (auto const &pitem : m_items)
{
// compute width of left hand side
float total_width = gutter_width + ui().get_string_width(pitem.text) + gutter_width;
float total_width = gutter_width + ui().get_string_width(pitem.text()) + gutter_width;
// add in width of right hand side
if (!pitem.subtext.empty())
total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext);
if (!pitem.subtext().empty())
total_width += 2.0f * gutter_width + ui().get_string_width(pitem.subtext());
// track the maximum
if (total_width > visible_width)
@ -556,7 +555,7 @@ void menu::draw(uint32_t flags)
{
auto const itemnum = top_line + linenum;
menu_item const &pitem = m_items[itemnum];
std::string_view const itemtext = pitem.text;
std::string_view const itemtext = pitem.text();
rgb_t fgcolor = ui().colors().text_color();
rgb_t bgcolor = ui().colors().text_bg_color();
rgb_t fgcolor2 = ui().colors().subitem_color();
@ -601,33 +600,33 @@ void menu::draw(uint32_t flags)
{
// if we're on the top line, display the up arrow
draw_arrow(
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y0 + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y0 + 0.75f * line_height,
fgcolor,
ROT0);
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y0 + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y0 + 0.75f * line_height,
fgcolor,
ROT0);
}
else if (downarrow)
{
// if we're on the bottom line, display the down arrow
draw_arrow(
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y0 + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y0 + 0.75f * line_height,
fgcolor,
ROT0 ^ ORIENTATION_FLIP_Y);
0.5f * (x1 + x2) - 0.5f * ud_arrow_width,
line_y0 + 0.25f * line_height,
0.5f * (x1 + x2) + 0.5f * ud_arrow_width,
line_y0 + 0.75f * line_height,
fgcolor,
ROT0 ^ ORIENTATION_FLIP_Y);
}
else if (pitem.type == menu_item_type::SEPARATOR)
else if (pitem.type() == menu_item_type::SEPARATOR)
{
// if we're just a divider, draw a line
container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + visible_width, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
else if (pitem.subtext.empty())
else if (pitem.subtext().empty())
{
// if we don't have a subitem, just draw the string centered
if (pitem.flags & FLAG_UI_HEADING)
if (pitem.flags() & FLAG_UI_HEADING)
{
float heading_width = ui().get_string_width(itemtext);
container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - lr_border, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
@ -644,7 +643,7 @@ void menu::draw(uint32_t flags)
else
{
// otherwise, draw the item on the left and the subitem text on the right
bool const subitem_invert(pitem.flags & FLAG_INVERT);
bool const subitem_invert(pitem.flags() & FLAG_INVERT);
float item_width, subitem_width;
// draw the left-side text
@ -656,9 +655,9 @@ void menu::draw(uint32_t flags)
mame_ui_manager::NORMAL, fgcolor, bgcolor,
&item_width, nullptr);
if (pitem.flags & FLAG_COLOR_BOX)
if (pitem.flags() & FLAG_COLOR_BOX)
{
rgb_t color = rgb_t((uint32_t)strtoul(pitem.subtext.c_str(), nullptr, 16));
rgb_t color = rgb_t((uint32_t)strtoul(pitem.subtext().c_str(), nullptr, 16));
// give 2 spaces worth of padding
subitem_width = ui().get_string_width("FF00FF00");
@ -671,7 +670,7 @@ void menu::draw(uint32_t flags)
}
else
{
std::string_view subitem_text(pitem.subtext);
std::string_view subitem_text(pitem.subtext());
// give 2 spaces worth of padding
item_width += 2.0f * gutter_width;
@ -685,13 +684,13 @@ void menu::draw(uint32_t flags)
}
// customize subitem text color
if (!core_stricmp(pitem.subtext.c_str(), _("On")))
if (!core_stricmp(pitem.subtext().c_str(), _("On")))
fgcolor2 = rgb_t(0x00,0xff,0x00);
if (!core_stricmp(pitem.subtext.c_str(), _("Off")))
if (!core_stricmp(pitem.subtext().c_str(), _("Off")))
fgcolor2 = rgb_t(0xff,0x00,0x00);
if (!core_stricmp(pitem.subtext.c_str(), _("Auto")))
if (!core_stricmp(pitem.subtext().c_str(), _("Auto")))
fgcolor2 = rgb_t(0xff,0xff,0x00);
// draw the subitem right-justified
@ -705,7 +704,7 @@ void menu::draw(uint32_t flags)
}
// apply arrows
if (is_selected(itemnum) && (pitem.flags & FLAG_LEFT_ARROW))
if (is_selected(itemnum) && (pitem.flags() & FLAG_LEFT_ARROW))
{
float const l = effective_left + effective_width - subitem_width - gutter_width;
float const r = l + lr_arrow_width;
@ -716,14 +715,14 @@ void menu::draw(uint32_t flags)
if (mouse_in_rect(l, line_y0 + 0.1f * line_height, r, line_y0 + 0.9f * line_height))
m_hover = HOVER_UI_LEFT;
}
if (is_selected(itemnum) && (pitem.flags & FLAG_RIGHT_ARROW))
if (is_selected(itemnum) && (pitem.flags() & FLAG_RIGHT_ARROW))
{
float const r = effective_left + effective_width + gutter_width;
float const l = r - lr_arrow_width;
draw_arrow(
l, line_y0 + 0.1f * line_height, r, line_y0 + 0.9f * line_height,
fgcolor,
ROT90);
l, line_y0 + 0.1f * line_height, r, line_y0 + 0.9f * line_height,
fgcolor,
ROT90);
if (mouse_in_rect(l, line_y0 + 0.1f * line_height, r, line_y0 + 0.9f * line_height))
m_hover = HOVER_UI_RIGHT;
}
@ -735,7 +734,7 @@ void menu::draw(uint32_t flags)
if (selected_subitem_too_big)
{
menu_item const &pitem = selected_item();
bool const subitem_invert(pitem.flags & FLAG_INVERT);
bool const subitem_invert(pitem.flags() & FLAG_INVERT);
auto const linenum = m_selected - top_line;
float const line_y = visible_top + (float)linenum * line_height;
float target_width, target_height;
@ -743,7 +742,7 @@ void menu::draw(uint32_t flags)
// compute the multi-line target width/height
ui().draw_text_full(
container(),
pitem.subtext,
pitem.subtext(),
0, 0, visible_width * 0.75f,
text_layout::text_justify::RIGHT, text_layout::word_wrapping::WORD,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(),
@ -764,7 +763,7 @@ void menu::draw(uint32_t flags)
ui().draw_text_full(
container(),
pitem.subtext,
pitem.subtext(),
target_x, target_y, target_width,
text_layout::text_justify::RIGHT, text_layout::word_wrapping::WORD,
mame_ui_manager::NORMAL, ui().colors().selected_color(), ui().colors().selected_bg_color(),
@ -1006,8 +1005,8 @@ void menu::handle_keys(uint32_t flags, int &iptkey)
validate_selection(1);
// swallow left/right keys if they are not appropriate
bool const ignoreleft = !(flags & PROCESS_LR_ALWAYS) && !(selected_item().flags & FLAG_LEFT_ARROW);
bool const ignoreright = !(flags & PROCESS_LR_ALWAYS) && !(selected_item().flags & FLAG_RIGHT_ARROW);
bool const ignoreleft = !(flags & PROCESS_LR_ALWAYS) && !(selected_item().flags() & FLAG_LEFT_ARROW);
bool const ignoreright = !(flags & PROCESS_LR_ALWAYS) && !(selected_item().flags() & FLAG_RIGHT_ARROW);
// accept left/right/prev/next keys as-is with repeat if appropriate
if (!ignoreleft && exclusive_input_pressed(iptkey, IPT_UI_LEFT, (flags & PROCESS_LR_REPEAT) ? 6 : 0))

View File

@ -54,7 +54,7 @@ public:
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) { item_append(item.text, item.subtext, item.flags, item.ref, item.type); }
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);
@ -150,7 +150,7 @@ protected:
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() ? m_items[m_selected].ref : nullptr; }
void *get_selection_ref() const { return selection_valid() ? m_items[m_selected].ref() : nullptr; }
menu_item &selected_item() { return m_items[m_selected]; }
menu_item const &selected_item() const { return m_items[m_selected]; }
@ -279,7 +279,7 @@ protected:
static bool is_selectable(menu_item const &item)
{
return (!(item.flags & menu::FLAG_DISABLE) && (item.type != menu_item_type::SEPARATOR));
return (!(item.flags() & menu::FLAG_DISABLE) && (item.type() != menu_item_type::SEPARATOR));
}
// get arrows status

View File

@ -15,6 +15,11 @@
#pragma once
#include <cstdint>
#include <string>
#include <utility>
namespace ui {
// special menu item for separators
@ -31,17 +36,32 @@ enum class menu_item_type
class menu_item
{
public:
menu_item() = default;
menu_item(menu_item const &) = default;
menu_item(menu_item &&) = default;
menu_item &operator=(menu_item const &) = default;
menu_item &operator=(menu_item &&) = default;
std::string text;
std::string subtext;
uint32_t flags;
void *ref;
menu_item_type type; // item type (eventually will go away when itemref is proper ui_menu_item class rather than void*)
menu_item(menu_item_type t = menu_item_type::UNKNOWN, void *r = nullptr, uint32_t f = 0) : m_ref(r), m_flags(f), m_type(t)
{ }
std::string const &text() const noexcept { return m_text; }
std::string const &subtext() const noexcept { return m_subtext; }
void *ref() const noexcept { return m_ref; }
uint32_t flags() const noexcept { return m_flags; }
unsigned generation() const noexcept { return m_generation; }
menu_item_type type() const noexcept { return m_type; }
template <typename... T> void set_text(T &&... args) { m_text.assign(std::forward<T>(args)...); ++m_generation; }
template <typename... T> void set_subtext(T &&... args) { m_subtext.assign(std::forward<T>(args)...); ++m_generation; }
void set_flags(uint32_t f) noexcept { m_flags = f; ++m_generation; }
private:
std::string m_text;
std::string m_subtext;
void *m_ref;
uint32_t m_flags;
unsigned m_generation = 0;
menu_item_type m_type;
};
} // namespace ui

View File

@ -167,7 +167,7 @@ void menu_select_game::menu_activated()
void menu_select_game::handle(event const *ev)
{
if (!m_prev_selected)
m_prev_selected = item(0).ref;
m_prev_selected = item(0).ref();
// if I have to select software, force software list submenu
if (reselect_last::get())

View File

@ -1980,7 +1980,7 @@ void menu_select_launch::draw(uint32_t flags)
float line_y = visible_top + (float(linenum) * line_height);
int itemnum = top_line + linenum;
const menu_item &pitem = item(itemnum);
const std::string_view itemtext = pitem.text;
const std::string_view itemtext = pitem.text();
rgb_t fgcolor = ui().colors().text_color();
rgb_t bgcolor = ui().colors().text_bg_color();
rgb_t fgcolor3 = ui().colors().clone_color();
@ -2012,7 +2012,7 @@ void menu_select_launch::draw(uint32_t flags)
bgcolor = ui().colors().mouseover_bg_color();
highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
}
else if (pitem.ref == m_prev_selected)
else if (pitem.ref() == m_prev_selected)
{
fgcolor = fgcolor3 = ui().options().mouseover_color();
bgcolor = ui().colors().mouseover_bg_color();
@ -2038,18 +2038,18 @@ void menu_select_launch::draw(uint32_t flags)
if (hover() == itemnum)
set_hover(HOVER_ARROW_DOWN);
}
else if (pitem.type == menu_item_type::SEPARATOR)
else if (pitem.type() == menu_item_type::SEPARATOR)
{
// if we're just a divider, draw a line
container().add_line(visible_left, line_y + 0.5f * line_height, visible_left + visible_width, line_y + 0.5f * line_height,
UI_LINE_WIDTH, ui().colors().text_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
else if (pitem.subtext.empty())
else if (pitem.subtext().empty())
{
// draw the item centered
int const item_invert = pitem.flags & FLAG_INVERT;
int const item_invert = pitem.flags() & FLAG_INVERT;
if (m_has_icons)
draw_icon(linenum, item(itemnum).ref, effective_left, line_y);
draw_icon(linenum, item(itemnum).ref(), effective_left, line_y);
ui().draw_text_full(
container(),
itemtext,
@ -2060,15 +2060,15 @@ void menu_select_launch::draw(uint32_t flags)
}
else
{
int const item_invert = pitem.flags & FLAG_INVERT;
std::string_view const subitem_text = pitem.subtext;
int const item_invert = pitem.flags() & FLAG_INVERT;
std::string_view const subitem_text = pitem.subtext();
float item_width, subitem_width;
// compute right space for subitem
ui().draw_text_full(
container(),
subitem_text,
effective_left + icon_offset, line_y, ui().get_string_width(pitem.subtext),
effective_left + icon_offset, line_y, ui().get_string_width(pitem.subtext()),
text_layout::text_justify::RIGHT, text_layout::word_wrapping::NEVER,
mame_ui_manager::NONE, item_invert ? fgcolor3 : fgcolor, bgcolor,
&subitem_width, nullptr);
@ -2076,7 +2076,7 @@ void menu_select_launch::draw(uint32_t flags)
// draw the item left-justified
if (m_has_icons)
draw_icon(linenum, item(itemnum).ref, effective_left, line_y);
draw_icon(linenum, item(itemnum).ref(), effective_left, line_y);
ui().draw_text_full(
container(),
itemtext,
@ -2099,7 +2099,7 @@ void menu_select_launch::draw(uint32_t flags)
for (size_t count = m_available_items; count < item_count(); count++)
{
const menu_item &pitem = item(count);
const std::string_view itemtext = pitem.text;
const std::string_view itemtext = pitem.text();
float line_x0 = x1 + 0.5f * UI_LINE_WIDTH;
float line_y0 = line;
float line_x1 = x2 - 0.5f * UI_LINE_WIDTH;
@ -2126,7 +2126,7 @@ void menu_select_launch::draw(uint32_t flags)
highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
}
if (pitem.type == menu_item_type::SEPARATOR)
if (pitem.type() == menu_item_type::SEPARATOR)
{
container().add_line(
visible_left, line + 0.5f * line_height,

View File

@ -257,7 +257,7 @@ private:
{
for (int x = 0; x < item_count(); ++x)
{
if (item(x).ref == m_prev_selected)
if (item(x).ref() == m_prev_selected)
{
set_selected_index(x);
break;

View File

@ -397,7 +397,7 @@ menu_select_software::~menu_select_software()
void menu_select_software::handle(event const *ev)
{
if (m_prev_selected == nullptr)
m_prev_selected = item(0).ref;
m_prev_selected = item(0).ref();
// FIXME: everything above here used run before events were processed

View File

@ -160,9 +160,9 @@ void menu_sliders::populate(float &customtop, float &custombottom)
std::vector<menu_item> ui_sliders = ui().get_slider_list();
for (const menu_item &item : ui_sliders)
{
if (item.type == menu_item_type::SLIDER)
if (item.type() == menu_item_type::SLIDER)
{
slider_state *const slider = reinterpret_cast<slider_state *>(item.ref);
slider_state *const slider = reinterpret_cast<slider_state *>(item.ref());
bool display(true);
#if 0
// FIXME: this test should be reimplemented in a dedicated menu
@ -192,9 +192,9 @@ void menu_sliders::populate(float &customtop, float &custombottom)
std::vector<menu_item> osd_sliders = machine().osd().get_slider_list();
for (const menu_item &item : osd_sliders)
{
if (item.type == menu_item_type::SLIDER)
if (item.type() == menu_item_type::SLIDER)
{
slider_state* slider = reinterpret_cast<slider_state *>(item.ref);
slider_state* slider = reinterpret_cast<slider_state *>(item.ref());
int32_t curval = slider->update(&tempstring, SLIDER_NOCHANGE);
uint32_t flags = 0;
if (curval > slider->minval)

View File

@ -420,7 +420,7 @@ void menu_load_save_state_base::custom_render(void *selectedref, float top, floa
text[count++] = m_footer;
// provide a prompt to delete if a state is selected
if (selected_item().ref)
if (selected_item().ref())
{
if (m_delete_prompt.empty())
m_delete_prompt = util::string_format(_("Press %1$s to delete"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_CLEAR)));

View File

@ -141,7 +141,7 @@ void menu_textbox::draw(uint32_t flags)
// get width required to draw the sole menu item
menu_item const &pitem = item(0);
std::string_view const itemtext = pitem.text;
std::string_view const itemtext = pitem.text();
float const itemwidth = gutter_width + ui().get_string_width(itemtext) + gutter_width;
float const draw_width = std::min(maximum_width, std::max(itemwidth, m_desired_width));

View File

@ -117,7 +117,6 @@ std::string mame_ui_manager::messagebox_poptext;
// slider info
std::vector<ui::menu_item> mame_ui_manager::slider_list;
slider_state *mame_ui_manager::slider_current;
/***************************************************************************
@ -345,14 +344,6 @@ void mame_ui_manager::initialize(running_machine &machine)
// initialize the on-screen display system
slider_list = slider_init(machine);
if (slider_list.size() > 0)
{
slider_current = reinterpret_cast<slider_state *>(slider_list[0].ref);
}
else
{
slider_current = nullptr;
}
// if no test switch found, assign its input sequence to a service mode DIP
if (!m_machine_info->has_test_switch() && m_machine_info->has_dips())
@ -1605,13 +1596,9 @@ std::vector<ui::menu_item> mame_ui_manager::slider_init(running_machine &machine
std::vector<ui::menu_item> items;
for (auto &slider : m_sliders)
{
ui::menu_item item;
item.text = slider->description;
item.subtext = "";
item.flags = 0;
item.ref = slider.get();
item.type = ui::menu_item_type::SLIDER;
items.push_back(item);
ui::menu_item item(ui::menu_item_type::SLIDER, slider.get());
item.set_text(slider->description);
items.emplace_back(std::move(item));
}
return items;

View File

@ -262,7 +262,6 @@ private:
static std::string messagebox_poptext;
static std::vector<ui::menu_item> slider_list;
static slider_state *slider_current;
// UI handlers
uint32_t handler_ingame(render_container &container);

View File

@ -75,7 +75,7 @@ void menu_video_targets::handle(event const *ev)
menu::stack_push<menu_video_options>(
ui(),
container(),
std::string(selected_item().text),
std::string(selected_item().text()),
*target,
&machine().video().snapshot_target() == target);
}

View File

@ -417,14 +417,10 @@ void chain_manager::create_selection_slider(uint32_t screen_index)
auto state = std::make_unique<slider_state>(std::move(description), minval, defval, maxval, incval,
std::bind(&chain_manager::slider_changed, this, screen_index, _1, _2));
ui::menu_item item;
item.text = state->description;
item.subtext = "";
item.flags = 0;
item.ref = state.get();
item.type = ui::menu_item_type::SLIDER;
m_selection_sliders.push_back(item);
m_core_sliders.push_back(std::move(state));
ui::menu_item item(ui::menu_item_type::SLIDER, state.get());
item.set_text(state->description);
m_selection_sliders.emplace_back(item);
m_core_sliders.emplace_back(std::move(state));
}
uint32_t chain_manager::update_screen_textures(uint32_t view, render_primitive *starting_prim, osd_window& window)
@ -685,7 +681,7 @@ std::vector<ui::menu_item> chain_manager::get_slider_list()
std::vector<ui::menu_item> input_sliders = input->get_slider_list();
for (ui::menu_item slider : input_sliders)
{
sliders.push_back(slider);
sliders.emplace_back(slider);
}
}
}
@ -695,27 +691,19 @@ std::vector<ui::menu_item> chain_manager::get_slider_list()
{
slider_state* core_slider = slider->core_slider();
ui::menu_item item;
item.text = core_slider->description;
item.subtext = "";
item.flags = 0;
item.ref = core_slider;
item.type = ui::menu_item_type::SLIDER;
m_selection_sliders.push_back(item);
ui::menu_item item(ui::menu_item_type::SLIDER, core_slider);
item.set_text(core_slider->description);
m_selection_sliders.emplace_back(item);
sliders.push_back(item);
sliders.emplace_back(std::move(item));
}
if (chain_sliders.size() > 0)
{
ui::menu_item item;
item.text = MENU_SEPARATOR_ITEM;
item.subtext = "";
item.flags = 0;
item.ref = nullptr;
item.type = ui::menu_item_type::SEPARATOR;
ui::menu_item item(ui::menu_item_type::SEPARATOR);
item.set_text(MENU_SEPARATOR_ITEM);
sliders.push_back(item);
sliders.emplace_back(std::move(item));
}
}

View File

@ -118,12 +118,8 @@ void bgfx_input_pair::create_selection_slider(uint32_t screen_index)
m_slider_state = std::make_unique<slider_state>(std::move(description), minval, defval, maxval, incval,
std::bind(&bgfx_input_pair::texture_changed, this, screen_index, _1, _2));
ui::menu_item item;
item.text = m_slider_state->description;
item.subtext = "";
item.flags = 0;
item.ref = m_slider_state.get();
item.type = ui::menu_item_type::SLIDER;
ui::menu_item item(ui::menu_item_type::SLIDER, m_slider_state.get());
item.set_text(m_slider_state->description);
m_selection_slider = item;
}

View File

@ -2371,14 +2371,10 @@ void shaders::init_slider_list()
std::unique_ptr<slider_state> core_slider = slider_alloc(std::move(name), desc->minval, desc->defval, desc->maxval, desc->step, slider_arg);
ui::menu_item item;
item.text = core_slider->description;
item.subtext = "";
item.flags = 0;
item.ref = core_slider.get();
item.type = ui::menu_item_type::SLIDER;
m_sliders.push_back(item);
m_core_sliders.push_back(std::move(core_slider));
ui::menu_item item(ui::menu_item_type::SLIDER, core_slider.get());
item.set_text(core_slider->description);
m_sliders.emplace_back(item);
m_core_sliders.emplace_back(std::move(core_slider));
}
}
}

View File

@ -64,7 +64,6 @@ private:
{
~ui_state()
{
std::lock_guard guard(mutex);
if (thread)
thread->join();
}