summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-10-14 08:00:04 +1100
committer Vas Crabb <vas@vastheman.com>2021-10-14 08:00:04 +1100
commit96ca1dbd965df08ed4ab1f23053690c9ce540f94 (patch)
tree7c357aa9efe72e7e9c8b6e7084cec9fa859e214a /src/frontend/mame/ui
parent75f9660fa29d3d68a522fa96dbc92ef02baff2b8 (diff)
More user experience improvements:
frontend: Allow clicking the adjuster arrows on menu items. This allows things like video options and DIP switches to be configured using a mouse only. Also fixed a bug preventing paging menus with a mouse if the first item scrolled off the bottom is not selectable. debugger: Allow wplist and bplist to accept a CPU argument to list breakpoints/watchpoints for a single CPU only. debugger: Fixed some corner cases in address space syntax in memory accesses, and allowed memory region accesses to use tags relative to the visible CPU. emu/softlist.cpp: Ignore notes elements when loading software lists. It's effectively a comment that isn't a comment syntactically, it's being used for things that are not useful to display in the internal UI, and it slows down startup. docs: Updated three more pages of debugger documentation. Also updated more of the built-in debugger help. minimaws: Fixed up schema for software list notes, made sofware list notes display initially collapsed.
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r--src/frontend/mame/ui/menu.cpp65
-rw-r--r--src/frontend/mame/ui/submenu.cpp26
-rw-r--r--src/frontend/mame/ui/submenu.h3
3 files changed, 58 insertions, 36 deletions
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index 14a5c4ae0c1..d3caec1b2c2 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -556,20 +556,31 @@ void menu::draw(uint32_t flags)
float const line_y0 = visible_top + (float)linenum * line_height;
float const line_y1 = line_y0 + line_height;
+ // work out what we're dealing with
+ bool const uparrow = !linenum && show_top_arrow;
+ bool const downarrow = (linenum == (m_visible_lines - 1)) && show_bottom_arrow;
+
// set the hover if this is our item
- if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem))
- m_hover = itemnum;
+ bool const hovered = mouse_in_rect(line_x0, line_y0, line_x1, line_y1);
+ if (hovered)
+ {
+ if (uparrow)
+ m_hover = HOVER_ARROW_UP;
+ else if (downarrow)
+ m_hover = HOVER_ARROW_DOWN;
+ else if (is_selectable(pitem))
+ m_hover = itemnum;
+ }
- // if we're selected, draw with a different background
if (is_selected(itemnum))
{
+ // if we're selected, draw with a different background
fgcolor = fgcolor2 = fgcolor3 = ui().colors().selected_color();
bgcolor = ui().colors().selected_bg_color();
}
-
- // else if the mouse is over this item, draw with a different background
- else if (itemnum == m_hover)
+ else if (hovered && (uparrow || downarrow || is_selectable(pitem)))
{
+ // else if the mouse is over this item, draw with a different background
fgcolor = fgcolor2 = fgcolor3 = ui().colors().mouseover_color();
bgcolor = ui().colors().mouseover_bg_color();
}
@@ -578,7 +589,7 @@ void menu::draw(uint32_t flags)
if (bgcolor != ui().colors().text_bg_color())
highlight(line_x0, line_y0, line_x1, line_y1, bgcolor);
- if (linenum == 0 && show_top_arrow)
+ if (uparrow)
{
// if we're on the top line, display the up arrow
draw_arrow(
@@ -588,10 +599,8 @@ void menu::draw(uint32_t flags)
line_y0 + 0.75f * line_height,
fgcolor,
ROT0);
- if (m_hover == itemnum)
- m_hover = HOVER_ARROW_UP;
}
- else if (linenum == m_visible_lines - 1 && show_bottom_arrow)
+ else if (downarrow)
{
// if we're on the bottom line, display the down arrow
draw_arrow(
@@ -601,8 +610,6 @@ void menu::draw(uint32_t flags)
line_y0 + 0.75f * line_height,
fgcolor,
ROT0 ^ ORIENTATION_FLIP_Y);
- if (m_hover == itemnum)
- m_hover = HOVER_ARROW_DOWN;
}
else if (pitem.type == menu_item_type::SEPARATOR)
{
@@ -677,23 +684,25 @@ void menu::draw(uint32_t flags)
// apply arrows
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;
draw_arrow(
- effective_left + effective_width - subitem_width - gutter_width,
- line_y0 + 0.1f * line_height,
- effective_left + effective_width - subitem_width - gutter_width + lr_arrow_width,
- line_y0 + 0.9f * line_height,
+ l, line_y0 + 0.1f * line_height, r, line_y0 + 0.9f * line_height,
fgcolor,
ROT90 ^ ORIENTATION_FLIP_X);
+ 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))
{
+ float const r = effective_left + effective_width + gutter_width;
+ float const l = r - lr_arrow_width;
draw_arrow(
- effective_left + effective_width + gutter_width - lr_arrow_width,
- line_y0 + 0.1f * line_height,
- effective_left + effective_width + gutter_width,
- line_y0 + 0.9f * line_height,
+ 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;
}
}
}
@@ -856,13 +865,15 @@ void menu::handle_events(uint32_t flags, event &ev)
if (custom_mouse_down())
return;
- if ((flags & PROCESS_ONLYCHAR) == 0)
+ if (!(flags & PROCESS_ONLYCHAR))
{
if (m_hover >= 0 && m_hover < m_items.size())
+ {
m_selected = m_hover;
+ }
else if (m_hover == HOVER_ARROW_UP)
{
- if ((flags & FLAG_UI_DATS) != 0)
+ if (flags & FLAG_UI_DATS)
{
top_line -= m_visible_items - (last_item_visible() ? 1 : 0);
return;
@@ -884,6 +895,16 @@ void menu::handle_events(uint32_t flags, event &ev)
m_selected = m_items.size() - 1;
top_line += m_visible_lines - 2;
}
+ else if (m_hover == HOVER_UI_LEFT)
+ {
+ ev.iptkey = IPT_UI_LEFT;
+ stop = true;
+ }
+ else if (m_hover == HOVER_UI_RIGHT)
+ {
+ ev.iptkey = IPT_UI_RIGHT;
+ stop = true;
+ }
}
break;
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index d6d237cabd3..382524b636c 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -152,9 +152,9 @@ submenu::submenu(mame_ui_manager &mui, render_container &container, std::vector<
{
core_options *opts = nullptr;
if (m_driver == nullptr)
- opts = dynamic_cast<core_options*>(&mui.machine().options());
+ opts = dynamic_cast<core_options *>(&mui.machine().options());
else
- opts = dynamic_cast<core_options*>(options);
+ opts = dynamic_cast<core_options *>(options);
for (option & sm_option : m_options)
{
@@ -358,9 +358,9 @@ void submenu::populate(float &customtop, float &custombottom)
{
case OPTION_BOOLEAN:
item_append_on_off(_(sm_option->description),
- sm_option->options->bool_value(sm_option->name),
- 0,
- static_cast<void*>(&(*sm_option)));
+ sm_option->options->bool_value(sm_option->name),
+ 0,
+ static_cast<void*>(&(*sm_option)));
break;
case OPTION_INTEGER:
{
@@ -378,9 +378,9 @@ void submenu::populate(float &customtop, float &custombottom)
}
arrow_flags = get_arrow_flags(i_min, i_max, i_cur);
item_append(_(sm_option->description),
- sm_option->entry->value(),
- arrow_flags,
- static_cast<void*>(&(*sm_option)));
+ sm_option->entry->value(),
+ arrow_flags,
+ static_cast<void*>(&(*sm_option)));
}
break;
case OPTION_FLOAT:
@@ -400,9 +400,9 @@ void submenu::populate(float &customtop, float &custombottom)
arrow_flags = get_arrow_flags(f_min, f_max, f_cur);
std::string tmptxt = string_format("%g", f_cur);
item_append(_(sm_option->description),
- tmptxt,
- arrow_flags,
- static_cast<void*>(&(*sm_option)));
+ tmptxt,
+ arrow_flags,
+ static_cast<void*>(&(*sm_option)));
}
break;
case OPTION_STRING:
@@ -418,8 +418,8 @@ void submenu::populate(float &customtop, float &custombottom)
default:
arrow_flags = FLAG_RIGHT_ARROW;
item_append(_(sm_option->description),
- sm_option->options->value(sm_option->name),
- arrow_flags, static_cast<void*>(&(*sm_option)));
+ sm_option->options->value(sm_option->name),
+ arrow_flags, static_cast<void*>(&(*sm_option)));
break;
}
break;
diff --git a/src/frontend/mame/ui/submenu.h b/src/frontend/mame/ui/submenu.h
index 8c7744de391..f5c26c7eecb 100644
--- a/src/frontend/mame/ui/submenu.h
+++ b/src/frontend/mame/ui/submenu.h
@@ -12,9 +12,10 @@
#pragma once
-#include "emuopts.h"
#include "ui/menu.h"
+#include "emuopts.h"
+
#include <string>
#include <vector>