summaryrefslogtreecommitdiffstats
path: root/src/frontend/mame/ui/menu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/mame/ui/menu.cpp')
-rw-r--r--src/frontend/mame/ui/menu.cpp65
1 files changed, 43 insertions, 22 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;
configured rather than Vas Crabb2018-04-301-1/+2 * Make devopt menu localisable. Vas Crabb2018-04-281-14/+51 * Sarayan made me do it. Vas Crabb2018-04-281-1/+17 * Remove commented code, nw mooglyguy2018-03-101-1/+0 * Remove first_screen() accessor from machine_config now that it is not used, nw mooglyguy2018-03-101-1/+1 * (nw) screw you macros and the horse you rode in on Vas Crabb2018-02-141-21/+0 * xtal.h is dead, long live to xtal.cpp [O. Galibert] Olivier Galibert2018-01-231-0/+2 * std::function and delegate both require runtime relocations, slowing down sta... Vas Crabb2018-01-181-2/+0 * std::function is too inefficient, use a device delegate instead (nw) AJR2018-01-171-0/+2 * API Change: Machine configs are now a method of the owner class, and the prot... Olivier Galibert2018-01-171-50/+14 * general cleanup: Vas Crabb2017-05-231-5/+0 * let's use Zaccaria as a demo for machine config in members Vas Crabb2017-05-221-0/+17 * There's no day like today. This just follows up on the last commit: game dri... Vas Crabb2017-05-221-1/+0 * Goodbye MACHINE_CONFIG_FRAGMENT, it was nice knowing you. Vas Crabb2017-05-221-21/+7 * Move static data out of devices into the device types. This is a significant... Vas Crabb2017-05-141-20/+3 * Self-registering devices prep: Vas Crabb2017-02-271-2/+2 * Introduce u8/u16/u32/u64/s8/s16/s32/s64 Vas Crabb2016-11-191-8/+8 * NOTICE (TYPE NAME CONSOLIDATION) Miodrag Milanovic2016-10-221-4/+4 * remove legacy calls (nw) Miodrag Milanovic2016-05-011-12/+0 * Make watchdog timer a separate device AJR2016-04-301-0/+4 * Various cleanups suggested by static analyzer (nw) Miodrag Milanovic2016-04-241-8/+8 * Revert software-installed slot/image options when changing software AJR2016-04-041-7/+0 * Conflict resolution (nw)