More UI enhancements/cleanup:

Made the headings in the info viewer clickable, so you can switch
between DATs with a mouse or trackball (or maybe a lightgun if that's
your thing).

Made the UI red/yellow/green traffic light status colours less
dirty-looking.  The "yellow" is more of an amber-brown than a cat puke
brown now, and red is brighter.  The contrast with white text is
definitely fine for red and green, but it's reduced a bit for yellow.
However there's a limit to how dark you can make a yellow or orange
colour before it looks muddy.

Reduced the number of places the UI uses red for things that aren't
errors.  The error colour should be used sparingly, for actual errors.

Improved the colour swatch display in the RGBA colour editor.  It now
has black/white underlay so alpha effects are move obvious.  Also fixed
a bug preventing the channels being run down to zero.

Fixed double-clicking configure machine causing MAME to exit from the
system selection menu.  Also slightly adjusted the colours of the
toolbar buttons again.
This commit is contained in:
Vas Crabb 2021-10-12 03:56:42 +11:00
parent 1668688eb4
commit f494a00024
9 changed files with 158 additions and 136 deletions

View File

@ -623,7 +623,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
std::begin(bottomtext), std::end(bottomtext), std::begin(bottomtext), std::end(bottomtext),
origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_RED_COLOR, 1.0f); ui().colors().text_color(), ui().colors().background_color(), 1.0f);
// compute maxwidth // compute maxwidth
char const *const topbuf = _("Menu Preview"); char const *const topbuf = _("Menu Preview");
@ -751,8 +751,6 @@ menu_rgb_ui::~menu_rgb_ui()
void menu_rgb_ui::handle() void menu_rgb_ui::handle()
{ {
bool changed = false;
// process the menu // process the menu
const event *menu_event; const event *menu_event;
@ -761,103 +759,63 @@ void menu_rgb_ui::handle()
else else
menu_event = process(PROCESS_ONLYCHAR); menu_event = process(PROCESS_ONLYCHAR);
if (menu_event != nullptr && menu_event->itemref != nullptr) if (menu_event && menu_event->itemref != nullptr)
{ {
switch ((uintptr_t)menu_event->itemref) bool changed = false;
switch (menu_event->iptkey)
{ {
case RGB_ALPHA: case IPT_UI_LEFT:
if (menu_event->iptkey == IPT_UI_LEFT && m_color->a() > 1) case IPT_UI_RIGHT:
{
int updated = (IPT_UI_LEFT == menu_event->iptkey) ? -1 : 1;
switch (uintptr_t(menu_event->itemref))
{ {
m_color->set_a(m_color->a() - 1); case RGB_ALPHA:
changed = true; updated += m_color->a();
if ((0 <= updated) && (255 >= updated))
{
m_color->set_a(updated);
changed = true;
}
break;
case RGB_RED:
updated += m_color->r();
if ((0 <= updated) && (255 >= updated))
{
m_color->set_r(updated);
changed = true;
}
break;
case RGB_GREEN:
updated += m_color->g();
if ((0 <= updated) && (255 >= updated))
{
m_color->set_g(updated);
changed = true;
}
break;
case RGB_BLUE:
updated += m_color->b();
if ((0 <= updated) && (255 >= updated))
{
m_color->set_b(updated);
changed = true;
}
break;
} }
}
break;
else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->a() < 255) case IPT_UI_SELECT:
{ case IPT_SPECIAL:
m_color->set_a(m_color->a() + 1); inkey_special(menu_event);
changed = true; changed = true;
} break;
else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL)
{
inkey_special(menu_event);
changed = true;
}
break;
case RGB_RED:
if (menu_event->iptkey == IPT_UI_LEFT && m_color->r() > 1)
{
m_color->set_r(m_color->r() - 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->r() < 255)
{
m_color->set_r(m_color->r() + 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL)
{
inkey_special(menu_event);
changed = true;
}
break;
case RGB_GREEN:
if (menu_event->iptkey == IPT_UI_LEFT && m_color->g() > 1)
{
m_color->set_g(m_color->g() - 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->g() < 255)
{
m_color->set_g(m_color->g() + 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL)
{
inkey_special(menu_event);
changed = true;
}
break;
case RGB_BLUE:
if (menu_event->iptkey == IPT_UI_LEFT && m_color->b() > 1)
{
m_color->set_b(m_color->b() - 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_RIGHT && m_color->b() < 255)
{
m_color->set_b(m_color->b() + 1);
changed = true;
}
else if (menu_event->iptkey == IPT_UI_SELECT || menu_event->iptkey == IPT_SPECIAL)
{
inkey_special(menu_event);
changed = true;
}
break;
case PALETTE_CHOOSE:
if (menu_event->iptkey == IPT_UI_SELECT)
menu::stack_push<menu_palette_sel>(ui(), container(), *m_color);
break;
} }
}
if (changed) if (changed)
reset(reset_options::REMEMBER_REF); reset(reset_options::REMEMBER_REF);
}
} }
//------------------------------------------------- //-------------------------------------------------
@ -940,12 +898,21 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
y1 += ui().box_tb_border(); y1 += ui().box_tb_border();
// draw the text within it // draw the text within it
ui().draw_text_full(container(), m_title, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color()); container(),
m_title,
x1, y1, x2 - x1,
ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
std::string sampletxt(_("Color preview =")); std::string sampletxt(_("Color preview:"));
ui().draw_text_full(container(), sampletxt, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width); container(),
sampletxt,
0.0f, 0.0f, 1.0f,
ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(),
&width);
width += 2 * lr_border; width += 2 * lr_border;
maxwidth = std::max(origx2 - origx1, width); maxwidth = std::max(origx2 - origx1, width);
@ -955,22 +922,28 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
y1 = origy2 + ui().box_tb_border(); y1 = origy2 + ui().box_tb_border();
y2 = origy2 + bottom; y2 = origy2 + bottom;
// draw a box // draw a box - force black to ensure the text is legible
ui().draw_outlined_box(container(), x1, y1, x1 + width, y2, UI_RED_COLOR); ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t::black());
// take off the borders // take off the borders
x1 += lr_border; x1 += lr_border;
y1 += ui().box_tb_border(); y1 += ui().box_tb_border();
// draw the normal text // draw the text label - force white to ensure it's legible
ui().draw_text_full(container(), sampletxt, x1, y1, width - lr_border, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(
mame_ui_manager::NORMAL, rgb_t::white(), rgb_t::black()); container(),
sampletxt,
x1, y1, width - lr_border,
ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, rgb_t::white(), rgb_t::black());
x1 += width + lr_border; x1 += width + (lr_border * 2.0f);
y1 -= ui().box_tb_border(); x2 -= lr_border;
y2 -= ui().box_tb_border();
// draw color box // add white under half the sample swatch to make alpha effects visible
ui().draw_outlined_box(container(), x1, y1, x2, y2, *m_color); container().add_rect((x1 + x2) * 0.5f, y1, x2, y2, rgb_t::white(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
container().add_rect(x1, y1, x2, y2, *m_color, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
} }
//------------------------------------------------- //-------------------------------------------------

View File

@ -317,14 +317,23 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
x2 -= lr_border; x2 -= lr_border;
y1 += ui().box_tb_border(); y1 += ui().box_tb_border();
ui().draw_text_full(container(), driver, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); container(),
driver,
x1, y1, x2 - x1,
ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
maxwidth = 0; maxwidth = 0;
for (auto & elem : m_items_list) for (auto const &elem : m_items_list)
{ {
ui().draw_text_full(container(), elem.label, 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::NEVER, ui().draw_text_full(
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr); container(),
elem.label,
0.0f, 0.0f, 1.0f,
ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(),
&width, nullptr);
maxwidth += width; maxwidth += width;
} }
@ -344,18 +353,38 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
// draw the text within it // draw the text within it
int x = 0; int x = 0;
for (auto & elem : m_items_list) for (auto const &elem : m_items_list)
{ {
x1 += space; x1 += space;
rgb_t fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : ui().colors().text_color(); if (mouse_in_rect(x1 - (space / 2), y1, x1 + width + (space / 2), y2))
rgb_t bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : ui().colors().text_bg_color(); set_hover(HOVER_INFO_TEXT + 1 + x);
ui().draw_text_full(container(), elem.label, x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NONE, fcolor, bcolor, &width, nullptr);
rgb_t const fcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0x00) : ui().colors().text_color();
rgb_t const bcolor = (m_actual == x) ? rgb_t(0xff, 0xff, 0xff, 0xff) : ui().colors().text_bg_color();
ui().draw_text_full(
container(),
elem.label,
x1, y1, 1.0f,
ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NONE, fcolor, bcolor,
&width, nullptr);
if (bcolor != ui().colors().text_bg_color()) if (bcolor != ui().colors().text_bg_color())
ui().draw_textured_box(container(), x1 - (space / 2), y1, x1 + width + (space / 2), y2, bcolor, rgb_t(255, 43, 43, 43), {
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1)); ui().draw_textured_box(
container(),
x1 - (space / 2), y1, x1 + width + (space / 2), y2,
bcolor, rgb_t(255, 43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
}
ui().draw_text_full(container(), elem.label, x1, y1, 1.0f, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fcolor, bcolor, &width, nullptr); ui().draw_text_full(
container(),
elem.label,
x1, y1, 1.0f,
ui::text_layout::LEFT, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, fcolor, bcolor,
&width, nullptr);
x1 += width + space; x1 += width + space;
++x; ++x;
} }
@ -382,8 +411,33 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
y1 += ui().box_tb_border(); y1 += ui().box_tb_border();
// draw the text within it // draw the text within it
ui().draw_text_full(container(), revision, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, ui().draw_text_full(
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr); container(),
revision,
x1, y1, x2 - x1,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color());
}
//-------------------------------------------------
// load data from DATs
//-------------------------------------------------
bool menu_dats_view::custom_mouse_down()
{
if ((hover() > HOVER_INFO_TEXT) && ((hover() - HOVER_INFO_TEXT) <= m_items_list.size()))
{
if ((hover() - HOVER_INFO_TEXT - 1) != m_actual)
{
m_actual = hover() - HOVER_INFO_TEXT - 1;
reset(reset_options::SELECT_FIRST);
}
return true;
}
else
{
return false;
}
} }
//------------------------------------------------- //-------------------------------------------------

View File

@ -37,6 +37,7 @@ public:
protected: protected:
virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override; virtual void custom_render(void *selectedref, float top, float bottom, float x, float y, float x2, float y2) override;
virtual bool custom_mouse_down() override;
private: private:
// draw dats menu // draw dats menu

View File

@ -434,7 +434,7 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
std::begin(bottomtext), std::end(bottomtext), std::begin(bottomtext), std::end(bottomtext),
origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_RED_COLOR, 1.0f); ui().colors().text_color(), ui().colors().background_color(), 1.0f);
} }
/************************************************** /**************************************************

View File

@ -128,7 +128,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
std::begin(tempbuf), std::end(tempbuf), std::begin(tempbuf), std::end(tempbuf),
origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
ui::text_layout::CENTER, ui::text_layout::NEVER, false, ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_RED_COLOR, 1.0f); ui().colors().text_color(), ui().colors().background_color(), 1.0f);
} }
//------------------------------------------------- //-------------------------------------------------

View File

@ -1799,12 +1799,6 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
set_selected_index(hover()); set_selected_index(hover());
ev.iptkey = IPT_UI_SELECT; ev.iptkey = IPT_UI_SELECT;
} }
if (is_last_selected())
{
ev.iptkey = IPT_UI_CANCEL;
stack_pop();
}
stop = true; stop = true;
break; break;

View File

@ -456,7 +456,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
std::begin(bottomtext), std::end(bottomtext), std::begin(bottomtext), std::end(bottomtext),
origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom, origx1, origx2, origy2 + ui().box_tb_border(), origy2 + bottom,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_RED_COLOR, 1.0f); ui().colors().text_color(), ui().colors().background_color(), 1.0f);
} }
} }
} }

View File

@ -37,21 +37,21 @@ char const *const toolbar_icons_svg[] = {
// info // info
u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>" "<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>"
"<circle cx='50' cy='50' r='47' fill='#001fff' stroke='#3f56ff' stroke-width='6' />" "<circle cx='50' cy='50' r='47' fill='#001fff' stroke='#3f56ff' stroke-width='6' stroke-opacity='0.8' />"
"<circle cx='50' cy='20' r='10' fill='#ffffff' />" "<circle cx='50' cy='20' r='10' fill='#ffffff' />"
"<path fill='#ffffff' d='m 59,38 v 34 a 10,4 0 0,0 10,4 v 8 h -36 v -8 a 10,4 0 0,0 10,-4 v -23 a 8,4 0 0,0 -8,-4 v -6 z' />" "<path fill='#ffffff' d='m 59,38 v 34 a 10,4 0 0,0 10,4 v 8 h -36 v -8 a 10,4 0 0,0 10,-4 v -23 a 8,4 0 0,0 -8,-4 v -6 z' />"
"</svg>", "</svg>",
// previous menu // previous menu
u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>" "<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>"
"<rect y='8' x='8' height='84' width='84' fill='#001bdf' stroke='#001bdf' stroke-width='16' stroke-linejoin='round' />" "<rect y='8' x='8' height='84' width='84' fill='#3f56ff' stroke='#3f56ff' stroke-width='16' stroke-opacity='0.8' stroke-linejoin='round' />"
"<rect y='10' x='10' height='80' width='80' fill='#001fff' stroke='#001fff' stroke-width='8' stroke-linejoin='round' />" "<rect y='10' x='10' height='80' width='80' fill='#001fff' stroke='#001fff' stroke-width='8' stroke-linejoin='round' />"
"<path fill='#ffffff' stroke='#ffffff' stroke-width='8' stroke-linejoin='round' d='m 16,46 28,-28 v 16 q 40,12 40,48 q -10,-24 -40,-24 v 16 z' />" "<path fill='#ffffff' stroke='#ffffff' stroke-width='8' stroke-linejoin='round' d='m 16,46 28,-28 v 16 q 40,12 40,48 q -10,-24 -40,-24 v 16 z' />"
"</svg>", "</svg>",
// exit // exit
u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>" u8"<?xml version='1.0' encoding='UTF-8' standalone='no'?>"
"<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>" "<svg xmlns:svg='http://www.w3.org/2000/svg' xmlns='http://www.w3.org/2000/svg' version='1.1' height='100' width='100'>"
"<rect y='8' x='8' height='84' width='84' fill='#df0000' stroke='#df0000' stroke-width='16' stroke-linejoin='round' />" "<rect y='8' x='8' height='84' width='84' fill='#ff3f3f' fill-opacity='0.8' stroke='#ff3f3f' stroke-opacity='0.8' stroke-width='16' stroke-linejoin='round' />"
"<rect y='10' x='10' height='80' width='80' fill='#ff0000' stroke='#ff0000' stroke-width='8' stroke-linejoin='round' />" "<rect y='10' x='10' height='80' width='80' fill='#ff0000' stroke='#ff0000' stroke-width='8' stroke-linejoin='round' />"
"<path fill='#ffffff' stroke='#ffffff' stroke-width='8' stroke-linejoin='round' d='m 16,24 8,-8 26,26 26,-26 8,8 -26,26 26,26 -8,8 -26,-26 -26,26 -8,-8 26,-26 z' />" "<path fill='#ffffff' stroke='#ffffff' stroke-width='8' stroke-linejoin='round' d='m 16,24 8,-8 26,26 26,-26 8,8 -26,26 26,26 -8,8 -26,-26 -26,26 -8,-8 26,-26 z' />"
"</svg>" }; "</svg>" };

View File

@ -54,9 +54,9 @@ class laserdisc_device;
#define UI_LINE_WIDTH (1.0f / 500.0f) #define UI_LINE_WIDTH (1.0f / 500.0f)
/* handy colors */ /* handy colors */
#define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10) #define UI_GREEN_COLOR rgb_t(0xef,0x0a,0x66,0x0a)
#define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10) #define UI_YELLOW_COLOR rgb_t(0xef,0xcc,0x7a,0x28)
#define UI_RED_COLOR rgb_t(0xf0,0x60,0x10,0x10) #define UI_RED_COLOR rgb_t(0xef,0xcc,0x14,0x14)
/* cancel return value for a UI handler */ /* cancel return value for a UI handler */
#define UI_HANDLER_CANCEL ((uint32_t)~0) #define UI_HANDLER_CANCEL ((uint32_t)~0)