summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author npwoods <npwoods@alumni.cmu.edu>2019-06-30 12:16:44 -0400
committer R. Belmont <rb6502@users.noreply.github.com>2019-06-30 12:16:44 -0400
commit1047b8cafeab7a32eefec524ca0621573186c125 (patch)
tree4f0db565575ce5eee913bc1cc29c4bcf2a8cd164
parent66939696f1e68ec35964c3577b256131603fcc8a (diff)
Refactored UI font metrics (#5291)
* Changed the various usages of UI_*COLOR to be calls to src/frontend/mame/ui/moptions.h The various UI_*COLOR macros were implemented as calls to decode_ui_color, which cached the values for the various options in a static array, which was obviously a gross hack. This refactoring is strategic because I am trying to confine awareness of mame_ui_manager to code in src/frontend/mame/ui, and the implementation of decode_ui_color() relied on the ability to access mame_ui_manager as a singleton from outside this code. * Created a ui_colors object, so that queries for UI RGB values would not always require parsing strings * Replaced UI_TARGET_FONT_[ROWS|HEIGHT] and UI_BOX_[LR|TD]_BORDER macros with property calls These macros were implemented with a call to a function (get_font_rows()) that opportunistically stashed the results of option accesses in static variables; in other words, a gross hack Because get_font_rows() attempted to access mame_ui_manager as a singleton, it was an obstactle to providing an alternative implementation of ui_manager * Remove stray debugging cruft that found a way into the other PR
-rw-r--r--src/frontend/mame/cheat.cpp10
-rw-r--r--src/frontend/mame/ui/auditmenu.cpp4
-rw-r--r--src/frontend/mame/ui/barcode.cpp2
-rw-r--r--src/frontend/mame/ui/custui.cpp75
-rw-r--r--src/frontend/mame/ui/datmenu.cpp46
-rw-r--r--src/frontend/mame/ui/dirmenu.cpp22
-rw-r--r--src/frontend/mame/ui/filecreate.cpp2
-rw-r--r--src/frontend/mame/ui/filemngr.cpp2
-rw-r--r--src/frontend/mame/ui/filesel.cpp6
-rw-r--r--src/frontend/mame/ui/inputmap.cpp4
-rw-r--r--src/frontend/mame/ui/menu.cpp74
-rw-r--r--src/frontend/mame/ui/menu.h10
-rw-r--r--src/frontend/mame/ui/miscmenu.cpp8
-rw-r--r--src/frontend/mame/ui/optsmenu.cpp6
-rw-r--r--src/frontend/mame/ui/selector.cpp6
-rw-r--r--src/frontend/mame/ui/selgame.cpp4
-rw-r--r--src/frontend/mame/ui/selmenu.cpp88
-rw-r--r--src/frontend/mame/ui/selsoft.cpp4
-rw-r--r--src/frontend/mame/ui/simpleselgame.cpp8
-rw-r--r--src/frontend/mame/ui/sliders.cpp20
-rw-r--r--src/frontend/mame/ui/slotopt.cpp4
-rw-r--r--src/frontend/mame/ui/sndmenu.cpp4
-rw-r--r--src/frontend/mame/ui/state.cpp4
-rw-r--r--src/frontend/mame/ui/submenu.cpp6
-rw-r--r--src/frontend/mame/ui/ui.cpp46
-rw-r--r--src/frontend/mame/ui/ui.h16
-rw-r--r--src/frontend/mame/ui/utils.cpp8
27 files changed, 249 insertions, 240 deletions
diff --git a/src/frontend/mame/cheat.cpp b/src/frontend/mame/cheat.cpp
index 1ac5039fa7f..815c788e241 100644
--- a/src/frontend/mame/cheat.cpp
+++ b/src/frontend/mame/cheat.cpp
@@ -1061,8 +1061,14 @@ cheat_manager::cheat_manager(running_machine &machine)
if (!machine.options().cheat())
return;
- m_output.resize(UI_TARGET_FONT_ROWS * 2);
- m_justify.resize(UI_TARGET_FONT_ROWS * 2);
+ // in its current form, cheat_manager is tightly coupled to mame_ui_manager; therefore we
+ // expect this call to succeed
+ mame_ui_manager *ui = dynamic_cast<mame_ui_manager *>(&machine.ui());
+ assert(ui);
+
+ int target_font_rows = ui->options().font_rows();
+ m_output.resize(target_font_rows * 2);
+ m_justify.resize(target_font_rows * 2);
// request a callback
machine.add_notifier(MACHINE_NOTIFY_FRAME, machine_notify_delegate(&cheat_manager::frame_update, this));
diff --git a/src/frontend/mame/ui/auditmenu.cpp b/src/frontend/mame/ui/auditmenu.cpp
index 547fa298b21..2289762ae49 100644
--- a/src/frontend/mame/ui/auditmenu.cpp
+++ b/src/frontend/mame/ui/auditmenu.cpp
@@ -115,7 +115,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float
case phase::CONSENT:
draw_text_box(
std::begin(m_prompt), std::end(m_prompt),
- x, x2, y - top, y - UI_BOX_TB_BORDER,
+ x, x2, y - top, y - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
break;
@@ -140,7 +140,7 @@ void menu_audit::custom_render(void *selectedref, float top, float bottom, float
void menu_audit::populate(float &customtop, float &custombottom)
{
item_append(_("Start Audit"), "", 0, ITEMREF_START);
- customtop = (ui().get_line_height() * 2.0f) + (UI_BOX_TB_BORDER * 3.0f);
+ customtop = (ui().get_line_height() * 2.0f) + (ui().box_tb_border() * 3.0f);
}
void menu_audit::handle()
diff --git a/src/frontend/mame/ui/barcode.cpp b/src/frontend/mame/ui/barcode.cpp
index 7945e70fd07..2cda13f4a51 100644
--- a/src/frontend/mame/ui/barcode.cpp
+++ b/src/frontend/mame/ui/barcode.cpp
@@ -77,7 +77,7 @@ void menu_barcode_reader::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
item_append(_("Enter Code"), "", 0, ITEMREF_ENTER_BARCODE);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
}
diff --git a/src/frontend/mame/ui/custui.cpp b/src/frontend/mame/ui/custui.cpp
index cfd786dd6e3..65b1ad2fa5e 100644
--- a/src/frontend/mame/ui/custui.cpp
+++ b/src/frontend/mame/ui/custui.cpp
@@ -161,7 +161,7 @@ void menu_custom_ui::populate(float &customtop, float &custombottom)
item_append(_("Show side panels"), _(HIDE_STATUS[ui_globals::panels_status]), arrow_flags, (void *)(uintptr_t)HIDE_MENU);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -173,7 +173,7 @@ void menu_custom_ui::custom_render(void *selectedref, float top, float bottom, f
char const *const text[] = { _("Custom UI Settings") };
draw_text_box(
std::begin(text), std::end(text),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -245,6 +245,9 @@ menu_font_ui::~menu_font_ui()
machine().options().set_value(OPTION_UI_FONT, name, OPTION_PRIORITY_CMDLINE);
moptions.set_value(OPTION_INFOS_SIZE, m_info_size, OPTION_PRIORITY_CMDLINE);
moptions.set_value(OPTION_FONT_ROWS, m_font_size, OPTION_PRIORITY_CMDLINE);
+
+ // OPTION_FONT_ROWS was changed; update the font info
+ ui().update_target_font_height();
}
//-------------------------------------------------
@@ -349,7 +352,7 @@ void menu_font_ui::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
- custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -362,7 +365,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
char const *const toptext[] = { _("UI Fonts Settings") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
@@ -371,7 +374,7 @@ void menu_font_ui::custom_render(void *selectedref, float top, float bottom, flo
char const *const bottomtext[] = { _("Sample text - Lorem ipsum dolor sit amet, consectetur adipiscing elit.") };
draw_text_box(
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::LEFT, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_GREEN_COLOR, m_info_size);
}
@@ -471,7 +474,7 @@ void menu_colors_ui::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
item_append(_("Restore originals colors"), "", 0, (void *)(uintptr_t)MUI_RESTORE);
- custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -484,7 +487,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
char const *const toptext[] = { _("UI Colors Settings") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
@@ -493,7 +496,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
std::string const bottomtext[] = { util::string_format(_("Double click or press %1$s to change the color value"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD))) };
draw_text_box(
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().colors().text_color(), UI_RED_COLOR, 1.0f);
@@ -503,7 +506,7 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
float width;
ui().draw_text_full(container(), topbuf, 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);
- float maxwidth = width + 2.0f * UI_BOX_LR_BORDER;
+ float maxwidth = width + 2.0f * ui().box_lr_border();
std::string sampletxt[5];
@@ -517,24 +520,24 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
{
ui().draw_text_full(container(), elem.c_str(), 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);
- width += 2 * UI_BOX_LR_BORDER;
+ width += 2 * ui().box_lr_border();
maxwidth = std::max(maxwidth, width);
}
// compute our bounds for header
- float x1 = origx2 + 2.0f * UI_BOX_LR_BORDER;
+ float x1 = origx2 + 2.0f * ui().box_lr_border();
float x2 = x1 + maxwidth;
float y1 = origy1;
- float y2 = y1 + bottom - UI_BOX_TB_BORDER;
+ float y2 = y1 + bottom - ui().box_tb_border();
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
- y2 -= UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
+ y2 -= ui().box_tb_border();
// draw the text within it
ui().draw_text_full(container(), topbuf, x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
@@ -542,18 +545,18 @@ void menu_colors_ui::custom_render(void *selectedref, float top, float bottom, f
// compute our bounds for menu preview
float line_height = ui().get_line_height();
- x1 -= UI_BOX_LR_BORDER;
- x2 += UI_BOX_LR_BORDER;
- y1 = y2 + 2.0f * UI_BOX_TB_BORDER;
- y2 = y1 + 5.0f * line_height + 2.0f * UI_BOX_TB_BORDER;
+ x1 -= ui().box_lr_border();
+ x2 += ui().box_lr_border();
+ y1 = y2 + 2.0f * ui().box_tb_border();
+ y2 = y1 + 5.0f * line_height + 2.0f * ui().box_tb_border();
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, m_color_table[MUI_BACKGROUND_COLOR].color);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
// draw normal text
ui().draw_text_full(container(), sampletxt[0].c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
@@ -778,7 +781,7 @@ void menu_rgb_ui::populate(float &customtop, float &custombottom)
item_append(_("Choose from palette"), "", 0, (void *)(uintptr_t)PALETTE_CHOOSE);
item_append(menu_item_type::SEPARATOR);
- custombottom = customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -792,22 +795,22 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
// top text
ui().draw_text_full(container(), m_title.c_str(), 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 * UI_BOX_LR_BORDER;
+ width += 2 * ui().box_lr_border();
maxwidth = std::max(maxwidth, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
float x2 = x1 + maxwidth;
float y1 = origy1 - top;
- float y2 = origy1 - UI_BOX_TB_BORDER;
+ float y2 = origy1 - ui().box_tb_border();
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
// draw the text within it
ui().draw_text_full(container(), m_title.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::NEVER,
@@ -816,28 +819,28 @@ void menu_rgb_ui::custom_render(void *selectedref, float top, float bottom, floa
std::string sampletxt(_("Color preview ="));
ui().draw_text_full(container(), sampletxt.c_str(), 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 * UI_BOX_LR_BORDER;
+ width += 2 * ui().box_lr_border();
maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
- y1 = origy2 + UI_BOX_TB_BORDER;
+ y1 = origy2 + ui().box_tb_border();
y2 = origy2 + bottom;
// draw a box
ui().draw_outlined_box(container(), x1, y1, x1 + width, y2, UI_RED_COLOR);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ y1 += ui().box_tb_border();
// draw the normal text
- ui().draw_text_full(container(), sampletxt.c_str(), x1, y1, width - UI_BOX_LR_BORDER, ui::text_layout::CENTER, ui::text_layout::NEVER,
+ ui().draw_text_full(container(), sampletxt.c_str(), x1, y1, width - ui().box_lr_border(), ui::text_layout::CENTER, ui::text_layout::NEVER,
mame_ui_manager::NORMAL, rgb_t::white(), rgb_t::black());
- x1 += width + UI_BOX_LR_BORDER;
- y1 -= UI_BOX_TB_BORDER;
+ x1 += width + ui().box_lr_border();
+ y1 -= ui().box_tb_border();
// draw color box
ui().draw_outlined_box(container(), x1, y1, x2, y2, *m_color);
diff --git a/src/frontend/mame/ui/datmenu.cpp b/src/frontend/mame/ui/datmenu.cpp
index 0dc5600a068..7df7d2fe4b9 100644
--- a/src/frontend/mame/ui/datmenu.cpp
+++ b/src/frontend/mame/ui/datmenu.cpp
@@ -136,8 +136,8 @@ void menu_dats_view::populate(float &customtop, float &custombottom)
(m_issoft == true) ? get_data_sw() : get_data();
item_append(menu_item_type::SEPARATOR, (FLAG_UI_DATS | FLAG_LEFT_ARROW | FLAG_RIGHT_ARROW));
- customtop = 2.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
- custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = 2.0f * ui().get_line_height() + 4.0f * ui().box_tb_border();
+ custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
if (!paused)
machine().resume();
@@ -152,7 +152,7 @@ void menu_dats_view::draw(uint32_t flags)
float const line_height = ui().get_line_height();
float const ud_arrow_width = line_height * machine().render().ui_aspect();
float const gutter_width = 0.52f * line_height * machine().render().ui_aspect();
- float const visible_width = 1.0f - (2.0f * UI_BOX_LR_BORDER);
+ float const visible_width = 1.0f - (2.0f * ui().box_lr_border());
float const visible_left = (1.0f - visible_width) * 0.5f;
float const extra_height = 2.0f * line_height;
float const visible_extra_menu_height = get_customtop() + get_custombottom() + extra_height;
@@ -166,7 +166,7 @@ void menu_dats_view::draw(uint32_t flags)
map_mouse();
// account for extra space at the top and bottom
- float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;
+ float visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height;
m_visible_lines = int(std::trunc(visible_main_menu_height / line_height));
visible_main_menu_height = float(m_visible_lines) * line_height;
@@ -175,9 +175,9 @@ void menu_dats_view::draw(uint32_t flags)
// compute left box size
float x1 = visible_left;
- float y1 = visible_top - UI_BOX_TB_BORDER;
+ float y1 = visible_top - ui().box_tb_border();
float x2 = x1 + visible_width;
- float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height;
+ float y2 = visible_top + visible_main_menu_height + ui().box_tb_border() + extra_height;
float line = visible_top + float(m_visible_lines) * line_height;
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
@@ -297,22 +297,22 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
ui().draw_text_full(container(), driver.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
- width += 2 * UI_BOX_LR_BORDER;
+ width += 2 * ui().box_lr_border();
maxwidth = std::max(maxwidth, width);
// compute our bounds
float x1 = 0.5f - 0.5f * maxwidth;
float x2 = x1 + maxwidth;
float y1 = origy1 - top;
- float y2 = origy1 - 2.0f * UI_BOX_TB_BORDER - ui().get_line_height();
+ float y2 = origy1 - 2.0f * ui().box_tb_border() - ui().get_line_height();
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
ui().draw_text_full(container(), driver.c_str(), 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(), nullptr, nullptr);
@@ -328,16 +328,16 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
float space = (1.0f - maxwidth) / (m_items_list.size() * 2);
// compute our bounds
- x1 -= UI_BOX_LR_BORDER;
- x2 += UI_BOX_LR_BORDER;
- y1 = y2 + UI_BOX_TB_BORDER;
- y2 += ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
+ x1 -= ui().box_lr_border();
+ x2 += ui().box_lr_border();
+ y1 = y2 + ui().box_tb_border();
+ y2 += ui().get_line_height() + 2.0f * ui().box_tb_border();
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
// take off the borders
- y1 += UI_BOX_TB_BORDER;
+ y1 += ui().box_tb_border();
// draw the text within it
int x = 0;
@@ -361,22 +361,22 @@ void menu_dats_view::custom_render(void *selectedref, float top, float bottom, f
std::string revision;
revision.assign(_("Revision: ")).append(m_items_list[m_actual].revision);
ui().draw_text_full(container(), revision.c_str(), 0.0f, 0.0f, 1.0f, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &width, nullptr);
- width += 2 * UI_BOX_LR_BORDER;
+ width += 2 * ui().box_lr_border();
maxwidth = std::max(origx2 - origx1, width);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
- y1 = origy2 + UI_BOX_TB_BORDER;
+ y1 = origy2 + ui().box_tb_border();
y2 = origy2 + bottom;
// draw a box
ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_GREEN_COLOR);
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
// draw the text within it
ui().draw_text_full(container(), revision.c_str(), x1, y1, x2 - x1, ui::text_layout::CENTER, ui::text_layout::TRUNCATE,
@@ -395,7 +395,7 @@ void menu_dats_view::get_data()
float const line_height = ui().get_line_height();
float const gutter_width = 0.52f * line_height * machine().render().ui_aspect();
- float const visible_width = 1.0f - (2.0f * UI_BOX_LR_BORDER);
+ float const visible_width = 1.0f - (2.0f * ui().box_lr_border());
float const effective_width = visible_width - 2.0f * gutter_width;
auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, effective_width, xstart, xend);
@@ -417,7 +417,7 @@ void menu_dats_view::get_data_sw()
else
mame_machine_manager::instance()->lua()->call_plugin("data", m_items_list[m_actual].option - 1, buffer);
- auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * UI_BOX_LR_BORDER), xstart, xend);
+ auto lines = ui().wrap_text(container(), buffer.c_str(), 0.0f, 0.0f, 1.0f - (4.0f * ui().box_lr_border()), xstart, xend);
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
diff --git a/src/frontend/mame/ui/dirmenu.cpp b/src/frontend/mame/ui/dirmenu.cpp
index 8584edc359d..1d8166718f0 100644
--- a/src/frontend/mame/ui/dirmenu.cpp
+++ b/src/frontend/mame/ui/dirmenu.cpp
@@ -104,7 +104,7 @@ void menu_directory::populate(float &customtop, float &custombottom)
item_append(_(elem.name), "", 0, (void *)(uintptr_t)elem.action);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -116,7 +116,7 @@ void menu_directory::custom_render(void *selectedref, float top, float bottom, f
char const *const toptext[] = { _("Folders Setup") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -182,7 +182,7 @@ void menu_display_actual::populate(float &customtop, float &custombottom)
item_append(_("Remove Folder"), "", 0, (void *)REMOVE);
item_append(menu_item_type::SEPARATOR);
- customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * UI_BOX_TB_BORDER;
+ customtop = (m_folders.size() + 1) * ui().get_line_height() + 6.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -194,12 +194,12 @@ void menu_display_actual::custom_render(void *selectedref, float top, float bott
float const lineheight(ui().get_line_height());
float const maxwidth(draw_text_box(
std::begin(m_folders), std::end(m_folders),
- origx1, origx2, origy1 - (3.0f * UI_BOX_TB_BORDER) - (m_folders.size() * lineheight), origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - (3.0f * ui().box_tb_border()) - (m_folders.size() * lineheight), origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), ui().colors().background_color(), 1.0f));
draw_text_box(
std::begin(m_heading), std::end(m_heading),
- 0.5f * (1.0f - maxwidth), 0.5f * (1.0f + maxwidth), origy1 - top, origy1 - top + lineheight + (2.0f * UI_BOX_TB_BORDER),
+ 0.5f * (1.0f - maxwidth), 0.5f * (1.0f + maxwidth), origy1 - top, origy1 - top + lineheight + (2.0f * ui().box_tb_border()),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -403,8 +403,8 @@ void menu_add_change_folder::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
// configure the custom rendering
- customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
- custombottom = 1.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
+ custombottom = 1.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -421,7 +421,7 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
m_current_path };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
@@ -429,7 +429,7 @@ void menu_add_change_folder::custom_render(void *selectedref, float top, float b
char const *const bottomtext[] = { _("Press TAB to set") };
draw_text_box(
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().colors().text_color(), UI_RED_COLOR, 1.0f);
}
@@ -501,7 +501,7 @@ void menu_remove_folder::populate(float &customtop, float &custombottom)
item_append(elem, "", 0, (void *)(uintptr_t)++folders_count);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -513,7 +513,7 @@ void menu_remove_folder::custom_render(void *selectedref, float top, float botto
std::string const toptext[] = {string_format(_("Remove %1$s Folder"), _(s_folders[m_ref].name)) };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/filecreate.cpp b/src/frontend/mame/ui/filecreate.cpp
index 0cfef03b723..9928829ecf5 100644
--- a/src/frontend/mame/ui/filecreate.cpp
+++ b/src/frontend/mame/ui/filecreate.cpp
@@ -182,7 +182,7 @@ void menu_file_create::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
item_append(_("Create"), "", 0, ITEMREF_CREATE);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/filemngr.cpp b/src/frontend/mame/ui/filemngr.cpp
index 07842f423aa..cb3243e0544 100644
--- a/src/frontend/mame/ui/filemngr.cpp
+++ b/src/frontend/mame/ui/filemngr.cpp
@@ -158,7 +158,7 @@ void menu_file_manager::populate(float &customtop, float &custombottom)
if (m_warnings.empty() || m_curr_selected)
item_append("Reset", "", 0, (void *)1);
- custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/filesel.cpp b/src/frontend/mame/ui/filesel.cpp
index d9a6755bf74..49136d04f64 100644
--- a/src/frontend/mame/ui/filesel.cpp
+++ b/src/frontend/mame/ui/filesel.cpp
@@ -86,8 +86,8 @@ void menu_file_selector::custom_render(void *selectedref, float top, float botto
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ y1 += ui().box_tb_border();
size_t hit_start = 0, hit_span = 0;
if (is_mouse_hit()
@@ -464,7 +464,7 @@ void menu_file_selector::populate(float &customtop, float &custombottom)
set_selection((void *)selected_entry);
// set up custom render proc
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
diff --git a/src/frontend/mame/ui/inputmap.cpp b/src/frontend/mame/ui/inputmap.cpp
index 0170dc1d09d..a2bbf3b7a21 100644
--- a/src/frontend/mame/ui/inputmap.cpp
+++ b/src/frontend/mame/ui/inputmap.cpp
@@ -640,7 +640,7 @@ void menu_settings_dip_switches::custom_render(void *selectedref, float top, flo
return;
// add borders
- y1 = y2 + UI_BOX_TB_BORDER;
+ y1 = y2 + ui().box_tb_border();
y2 = y1 + bottom;
// draw extra menu area
@@ -693,7 +693,7 @@ void menu_settings_dip_switches::custom_render_one(float x1, float y1, float x2,
ui().draw_text_full(container(),
dip->name,
0,
- y1 + (DIP_SWITCH_HEIGHT - UI_TARGET_FONT_HEIGHT) / 2,
+ y1 + (DIP_SWITCH_HEIGHT - ui().target_font_height()) / 2,
x1 - ui().get_string_width(" "),
ui::text_layout::RIGHT,
ui::text_layout::NEVER,
diff --git a/src/frontend/mame/ui/menu.cpp b/src/frontend/mame/ui/menu.cpp
index f270712c73a..69e08b5489d 100644
--- a/src/frontend/mame/ui/menu.cpp
+++ b/src/frontend/mame/ui/menu.cpp
@@ -594,12 +594,12 @@ void menu::draw(uint32_t flags)
visible_main_menu_height += 0.01f;
// if we are too wide or too tall, clamp it down
- if (visible_width + 2.0f * UI_BOX_LR_BORDER > 1.0f)
- visible_width = 1.0f - 2.0f * UI_BOX_LR_BORDER;
+ if (visible_width + 2.0f * ui().box_lr_border() > 1.0f)
+ visible_width = 1.0f - 2.0f * ui().box_lr_border();
// if the menu and extra menu won't fit, take away part of the regular menu, it will scroll
- if (visible_main_menu_height + visible_extra_menu_height + 2.0f * UI_BOX_TB_BORDER > 1.0f)
- visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;
+ if (visible_main_menu_height + visible_extra_menu_height + 2.0f * ui().box_tb_border() > 1.0f)
+ visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height;
m_visible_lines = std::min(int(std::floor(visible_main_menu_height / line_height)), int(unsigned(m_items.size())));
visible_main_menu_height = float(m_visible_lines) * line_height;
@@ -609,10 +609,10 @@ void menu::draw(uint32_t flags)
float const visible_top = ((1.0f - visible_main_menu_height - visible_extra_menu_height) * 0.5f) + m_customtop;
// first add us a box
- float const x1 = visible_left - UI_BOX_LR_BORDER;
- float const y1 = visible_top - UI_BOX_TB_BORDER;
- float const x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
- float const y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER;
+ float const x1 = visible_left - ui().box_lr_border();
+ float const y1 = visible_top - ui().box_tb_border();
+ float const x2 = visible_left + visible_width + ui().box_lr_border();
+ float const y2 = visible_top + visible_main_menu_height + ui().box_tb_border();
if (!customonly)
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
@@ -718,8 +718,8 @@ void menu::draw(uint32_t flags)
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) - UI_BOX_LR_BORDER, line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- container().add_line(visible_left + visible_width - ((visible_width - heading_width) / 2) + UI_BOX_LR_BORDER, 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));
+ container().add_line(visible_left, line_y0 + 0.5f * line_height, visible_left + ((visible_width - heading_width) / 2) - ui().box_lr_border(), line_y0 + 0.5f * line_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ container().add_line(visible_left + visible_width - ((visible_width - heading_width) / 2) + ui().box_lr_border(), 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));
}
ui().draw_text_full(container(), itemtext, effective_left, line_y0, effective_width,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr);
@@ -812,16 +812,16 @@ void menu::draw(uint32_t flags)
ui::text_layout::RIGHT, ui::text_layout::WORD, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &target_width, &target_height);
// determine the target location
- float const target_x = visible_left + visible_width - target_width - UI_BOX_LR_BORDER;
- float target_y = line_y + line_height + UI_BOX_TB_BORDER;
- if (target_y + target_height + UI_BOX_TB_BORDER > visible_main_menu_height)
- target_y = line_y - target_height - UI_BOX_TB_BORDER;
+ float const target_x = visible_left + visible_width - target_width - ui().box_lr_border();
+ float target_y = line_y + line_height + ui().box_tb_border();
+ if (target_y + target_height + ui().box_tb_border() > visible_main_menu_height)
+ target_y = line_y - target_height - ui().box_tb_border();
// add a box around that
- ui().draw_outlined_box(container(), target_x - UI_BOX_LR_BORDER,
- target_y - UI_BOX_TB_BORDER,
- target_x + target_width + UI_BOX_LR_BORDER,
- target_y + target_height + UI_BOX_TB_BORDER,
+ ui().draw_outlined_box(container(), target_x - ui().box_lr_border(),
+ target_y - ui().box_tb_border(),
+ target_x + target_width + ui().box_lr_border(),
+ target_y + target_height + ui().box_tb_border(),
subitem_invert ? ui().colors().selected_bg_color() : ui().colors().background_color());
ui().draw_text_full(container(), pitem.subtext.c_str(), target_x, target_y, target_width,
@@ -853,11 +853,11 @@ void menu::draw_text_box()
float target_x, target_y;
// compute the multi-line target width/height
- ui().draw_text_full(container(), text, 0, 0, 1.0f - 2.0f * UI_BOX_LR_BORDER - 2.0f * gutter_width,
+ ui().draw_text_full(container(), text, 0, 0, 1.0f - 2.0f * ui().box_lr_border() - 2.0f * gutter_width,
ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), &target_width, &target_height);
target_height += 2.0f * line_height;
- if (target_height > 1.0f - 2.0f * UI_BOX_TB_BORDER)
- target_height = floorf((1.0f - 2.0f * UI_BOX_TB_BORDER) / line_height) * line_height;
+ if (target_height > 1.0f - 2.0f * ui().box_tb_border())
+ target_height = floorf((1.0f - 2.0f * ui().box_tb_border()) / line_height) * line_height;
// maximum against "return to prior menu" text
prior_width = ui().get_string_width(backtext) + 2.0f * gutter_width;
@@ -868,20 +868,20 @@ void menu::draw_text_box()
target_y = 0.5f - 0.5f * target_height;
// make sure we stay on-screen
- if (target_x < UI_BOX_LR_BORDER + gutter_width)
- target_x = UI_BOX_LR_BORDER + gutter_width;
- if (target_x + target_width + gutter_width + UI_BOX_LR_BORDER > 1.0f)
- target_x = 1.0f - UI_BOX_LR_BORDER - gutter_width - target_width;
- if (target_y < UI_BOX_TB_BORDER)
- target_y = UI_BOX_TB_BORDER;
- if (target_y + target_height + UI_BOX_TB_BORDER > 1.0f)
- target_y = 1.0f - UI_BOX_TB_BORDER - target_height;
+ if (target_x < ui().box_lr_border() + gutter_width)
+ target_x = ui().box_lr_border() + gutter_width;
+ if (target_x + target_width + gutter_width + ui().box_lr_border() > 1.0f)
+ target_x = 1.0f - ui().box_lr_border() - gutter_width - target_width;
+ if (target_y < ui().box_tb_border())
+ target_y = ui().box_tb_border();
+ if (target_y + target_height + ui().box_tb_border() > 1.0f)
+ target_y = 1.0f - ui().box_tb_border() - target_height;
// add a box around that
- ui().draw_outlined_box(container(), target_x - UI_BOX_LR_BORDER - gutter_width,
- target_y - UI_BOX_TB_BORDER,
- target_x + target_width + gutter_width + UI_BOX_LR_BORDER,
- target_y + target_height + UI_BOX_TB_BORDER,
+ ui().draw_outlined_box(container(), target_x - ui().box_lr_border() - gutter_width,
+ target_y - ui().box_tb_border(),
+ target_x + target_width + gutter_width + ui().box_lr_border(),
+ target_y + target_height + ui().box_tb_border(),
(m_items[0].flags & FLAG_REDTEXT) ? UI_RED_COLOR : ui().colors().background_color());
ui().draw_text_full(container(), text, target_x, target_y, target_width,
ui::text_layout::LEFT, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, nullptr);
@@ -1337,8 +1337,8 @@ void menu::extra_text_draw_box(float origx1, float origx2, float origy, float ys
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ y1 += ui().box_tb_border();
// draw the text within it
layout.emit(container(), x1, y1);
@@ -1361,14 +1361,14 @@ void menu::draw_background()
void menu::extra_text_position(float origx1, float origx2, float origy, float yspan, text_layout &layout,
int direction, float &x1, float &y1, float &x2, float &y2)
{
- float width = layout.actual_width() + (2 * UI_BOX_LR_BORDER);
+ float width = layout.actual_width() + (2 * ui().box_lr_border());
float maxwidth = std::max(width, origx2 - origx1);
// compute our bounds
x1 = 0.5f - 0.5f * maxwidth;
x2 = x1 + maxwidth;
y1 = origy + (yspan * direction);
- y2 = origy + (UI_BOX_TB_BORDER * direction);
+ y2 = origy + (ui().box_tb_border() * direction);
if (y1 > y2)
std::swap(y1, y2);
diff --git a/src/frontend/mame/ui/menu.h b/src/frontend/mame/ui/menu.h
index bacb4e88721..8df66a92882 100644
--- a/src/frontend/mame/ui/menu.h
+++ b/src/frontend/mame/ui/menu.h
@@ -222,7 +222,7 @@ protected:
0.0f, 0.0f, 1.0f, justify, wrap,
mame_ui_manager::NONE, rgb_t::black(), rgb_t::white(),
&width, nullptr, text_size);
- width += 2.0f * UI_BOX_LR_BORDER;
+ width += 2.0f * ui().box_lr_border();
maxwidth = (std::max)(maxwidth, width);
}
if (scale && ((origx2 - origx1) < maxwidth))
@@ -237,10 +237,10 @@ protected:
ui().draw_outlined_box(container(), x1, y1, x2, y2, bgcolor);
// inset box and draw content
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
- y2 -= UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
+ y2 -= ui().box_tb_border();
for (Iter it = begin; it != end; ++it)
{
ui().draw_text_full(
diff --git a/src/frontend/mame/ui/miscmenu.cpp b/src/frontend/mame/ui/miscmenu.cpp
index 2d5c18ced42..fbb84d0aec3 100644
--- a/src/frontend/mame/ui/miscmenu.cpp
+++ b/src/frontend/mame/ui/miscmenu.cpp
@@ -790,7 +790,7 @@ void menu_machine_configure::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
item_append(_("Save machine configuration"), "", 0, (void *)(uintptr_t)SAVE);
item_append(menu_item_type::SEPARATOR);
- customtop = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -802,7 +802,7 @@ void menu_machine_configure::custom_render(void *selectedref, float top, float b
char const *const text[] = { _("Configure machine:"), m_drv.type.fullname() };
draw_text_box(
std::begin(text), std::end(text),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -906,7 +906,7 @@ void menu_plugins_configure::populate(float &customtop, float &custombottom)
}
}
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
+ customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
}
//-------------------------------------------------
@@ -918,7 +918,7 @@ void menu_plugins_configure::custom_render(void *selectedref, float top, float b
char const *const toptext[] = { _("Plugins") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/optsmenu.cpp b/src/frontend/mame/ui/optsmenu.cpp
index c3da06bd297..497d527e6cf 100644
--- a/src/frontend/mame/ui/optsmenu.cpp
+++ b/src/frontend/mame/ui/optsmenu.cpp
@@ -77,8 +77,8 @@ void menu_simple_game_options::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR);
item_append(_("Save Configuration"), "", 0, (void *)(uintptr_t)SAVE_CONFIG);
- custombottom = 2.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = 2.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -141,7 +141,7 @@ void menu_simple_game_options::custom_render(void *selectedref, float top, float
char const *const toptext[] = { _("Settings") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/selector.cpp b/src/frontend/mame/ui/selector.cpp
index c6a87e8d672..e57012ca5af 100644
--- a/src/frontend/mame/ui/selector.cpp
+++ b/src/frontend/mame/ui/selector.cpp
@@ -102,7 +102,7 @@ void menu_selector::populate(float &customtop, float &custombottom)
}
item_append(menu_item_type::SEPARATOR);
- customtop = custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
m_initial = -1;
}
@@ -115,7 +115,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
std::string tempbuf[1] = { std::string(_("Selection List - Search: ")).append(m_search).append("_") };
draw_text_box(
std::begin(tempbuf), std::end(tempbuf),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
@@ -123,7 +123,7 @@ void menu_selector::custom_render(void *selectedref, float top, float bottom, fl
tempbuf[0] = string_format(_("Double click or press %1$s to select"), machine().input().seq_name(machine().ioport().type_seq(IPT_UI_SELECT, 0, SEQ_TYPE_STANDARD)));
draw_text_box(
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().colors().text_color(), UI_RED_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/selgame.cpp b/src/frontend/mame/ui/selgame.cpp
index b9a7fffed35..ae86b2e2f52 100644
--- a/src/frontend/mame/ui/selgame.cpp
+++ b/src/frontend/mame/ui/selgame.cpp
@@ -616,8 +616,8 @@ void menu_select_game::populate(float &customtop, float &custombottom)
skip_main_items = 0;
// configure the custom rendering
- customtop = 3.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
- custombottom = 5.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = 3.0f * ui().get_line_height() + 5.0f * ui().box_tb_border();
+ custombottom = 5.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
// reselect prior game launched, if any
if (old_item_selected != -1)
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 21568a4f34e..1833f61528c 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -228,7 +228,7 @@ void menu_select_launch::software_parts::populate(float &customtop, float &custo
item_append(elem->first, elem->second, 0, (void *)&*elem);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
+ customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
}
//-------------------------------------------------
@@ -261,7 +261,7 @@ void menu_select_launch::software_parts::custom_render(void *selectedref, float
char const *const text[] = { _("Software part selection:") };
draw_text_box(
std::begin(text), std::end(text),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -308,7 +308,7 @@ void menu_select_launch::bios_selection::populate(float &customtop, float &custo
item_append(elem.first, "", 0, (void *)&elem.first);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
+ customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
}
//-------------------------------------------------
@@ -367,7 +367,7 @@ void menu_select_launch::bios_selection::custom_render(void *selectedref, float
char const *const text[] = { _("BIOS selection:") };
draw_text_box(
std::begin(text), std::end(text),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -590,7 +590,7 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto
// determine the text for the header
make_topbox_text(tempbuf[0], tempbuf[1], tempbuf[2]);
- float const y1 = origy1 - 3.0f * UI_BOX_TB_BORDER - ui().get_line_height();
+ float const y1 = origy1 - 3.0f * ui().box_tb_border() - ui().get_line_height();
draw_text_box(
tempbuf, tempbuf + 3,
origx1, origx2, origy1 - top, y1,
@@ -598,7 +598,7 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto
ui().colors().text_color(), ui().colors().background_color(), 1.0f);
// draw toolbar
- draw_toolbar(origx1, y1, origx2, origy1 - UI_BOX_TB_BORDER);
+ draw_toolbar(origx1, y1, origx2, origy1 - ui().box_tb_border());
// determine the text to render below
ui_software_info const *swinfo;
@@ -704,13 +704,13 @@ void menu_select_launch::custom_render(void *selectedref, float top, float botto
// draw the footer
draw_text_box(
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, true,
ui().colors().text_color(), color, 1.0f);
// is favorite? draw the star
if (isstar)
- draw_star(origx1 + UI_BOX_LR_BORDER, origy2 + (2.0f * UI_BOX_TB_BORDER));
+ draw_star(origx1 + ui().box_lr_border(), origy2 + (2.0f * ui().box_tb_border()));
}
@@ -883,7 +883,7 @@ float menu_select_launch::draw_left_panel(
// calculate line height
float const line_height(ui().get_line_height());
float const text_size(ui().options().infos_size());
- float const sc(y2 - y1 - (2.0f * UI_BOX_TB_BORDER));
+ float const sc(y2 - y1 - (2.0f * ui().box_tb_border()));
float line_height_max(line_height * text_size);
if ((Filter::COUNT * line_height_max) > sc)
{
@@ -904,12 +904,12 @@ float menu_select_launch::draw_left_panel(
// outline the box and inset by the border width
float const origy1(y1);
float const origy2(y2);
- x2 = x1 + left_width + 2.0f * UI_BOX_LR_BORDER;
+ x2 = x1 + left_width + 2.0f * ui().box_lr_border();;
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
- y2 -= UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
+ y2 -= ui().box_tb_border();
// now draw the rows
auto const active_filter(filters.find(current));
@@ -964,8 +964,8 @@ float menu_select_launch::draw_left_panel(
y1 += line_height_max;
}
- x1 = x2 + UI_BOX_LR_BORDER;
- x2 = x1 + 2.0f * UI_BOX_LR_BORDER;
+ x1 = x2 + ui().box_lr_border();
+ x2 = x1 + 2.0f * ui().box_lr_border();
y1 = origy1;
y2 = origy2;
float const space = x2 - x1;
@@ -987,7 +987,7 @@ float menu_select_launch::draw_left_panel(
}
draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90 ^ ORIENTATION_FLIP_X);
- return x2 + UI_BOX_LR_BORDER;
+ return x2 + ui().box_lr_border();
}
@@ -1181,10 +1181,10 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2)
ui().draw_outlined_box(container(), x1, y1, x2, y2, rgb_t(0xEF, 0x12, 0x47, 0x7B));
// take off the borders
- x1 += UI_BOX_LR_BORDER;
- x2 -= UI_BOX_LR_BORDER;
- y1 += UI_BOX_TB_BORDER;
- y2 -= UI_BOX_TB_BORDER;
+ x1 += ui().box_lr_border();
+ x2 -= ui().box_lr_border();
+ y1 += ui().box_tb_border();
+ y2 -= ui().box_tb_border();
texture_ptr_vector const &t_texture(m_is_swlist ? m_cache->sw_toolbar_texture() : m_cache->toolbar_texture());
bitmap_vector const &t_bitmap(m_is_swlist ? m_cache->sw_toolbar_bitmap() : m_cache->toolbar_bitmap());
@@ -1205,7 +1205,7 @@ void menu_select_launch::draw_toolbar(float x1, float y1, float x2, float y2)
{
set_hover(HOVER_B_FAV + z);
color = rgb_t::white();
- float ypos = y2 + ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
+ float ypos = y2 + ui().get_line_height() + 2.0f * ui().box_tb_border();
ui().draw_text_box(container(), _(hover_msg[z]), ui::text_layout::CENTER, 0.5f, ypos, ui().colors().background_color());
}
@@ -1751,8 +1751,8 @@ void menu_select_launch::draw(uint32_t flags)
float const ud_arrow_width = line_height * machine().render().ui_aspect();
float const gutter_width = 0.52f * ud_arrow_width;
float const icon_offset = m_has_icons ? (1.5f * ud_arrow_width) : 0.0f;
- float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * UI_BOX_LR_BORDER : 0.3f;
- float visible_width = 1.0f - 4.0f * UI_BOX_LR_BORDER;
+ float right_panel_size = (ui_globals::panels_status == HIDE_BOTH || ui_globals::panels_status == HIDE_RIGHT_PANEL) ? 2.0f * ui().box_lr_border() : 0.3f;
+ float visible_width = 1.0f - 4.0f * ui().box_lr_border();
float primary_left = (1.0f - visible_width) * 0.5f;
float primary_width = visible_width;
@@ -1770,7 +1770,7 @@ void menu_select_launch::draw(uint32_t flags)
map_mouse();
// account for extra space at the top and bottom
- float visible_main_menu_height = 1.0f - 2.0f * UI_BOX_TB_BORDER - visible_extra_menu_height;
+ float visible_main_menu_height = 1.0f - 2.0f * ui().box_tb_border() - visible_extra_menu_height;
m_visible_lines = int(std::trunc(visible_main_menu_height / line_height));
visible_main_menu_height = float(m_visible_lines) * line_height;
@@ -1787,18 +1787,18 @@ void menu_select_launch::draw(uint32_t flags)
visible_top += get_customtop();
// compute left box size
- float x1 = visible_left - UI_BOX_LR_BORDER;
- float y1 = visible_top - UI_BOX_TB_BORDER;
- float x2 = x1 + 2.0f * UI_BOX_LR_BORDER;
- float y2 = visible_top + visible_main_menu_height + UI_BOX_TB_BORDER + extra_height;
+ float x1 = visible_left - ui().box_lr_border();
+ float y1 = visible_top - ui().box_tb_border();
+ float x2 = x1 + 2.0f * ui().box_lr_border();
+ float y2 = visible_top + visible_main_menu_height + ui().box_tb_border() + extra_height;
// add left box
visible_left = draw_left_panel(x1, y1, x2, y2);
- visible_width -= right_panel_size + visible_left - 2.0f * UI_BOX_LR_BORDER;
+ visible_width -= right_panel_size + visible_left - 2.0f * ui().box_lr_border();
// compute and add main box
- x1 = visible_left - UI_BOX_LR_BORDER;
- x2 = visible_left + visible_width + UI_BOX_LR_BORDER;
+ x1 = visible_left - ui().box_lr_border();
+ x2 = visible_left + visible_width + ui().box_lr_border();
float line = visible_top + (float(m_visible_lines) * line_height);
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
@@ -1986,8 +1986,8 @@ void menu_select_launch::draw(uint32_t flags)
draw_right_panel(x1, y1, x2, y2);
- x1 = primary_left - UI_BOX_LR_BORDER;
- x2 = primary_left + primary_width + UI_BOX_LR_BORDER;
+ x1 = primary_left - ui().box_lr_border();
+ x2 = primary_left + primary_width + ui().box_lr_border();
// if there is something special to add, do it by calling the virtual method
custom_render(get_selection_ref(), get_customtop(), get_custombottom(), x1, y1, x2, y2);
@@ -2014,7 +2014,7 @@ void menu_select_launch::draw(uint32_t flags)
void menu_select_launch::draw_right_panel(float origx1, float origy1, float origx2, float origy2)
{
bool const hide((ui_globals::panels_status == HIDE_RIGHT_PANEL) || (ui_globals::panels_status == HIDE_BOTH));
- float const x2(hide ? origx2 : (origx1 + 2.0f * UI_BOX_LR_BORDER));
+ float const x2(hide ? origx2 : (origx1 + 2.0f * ui().box_lr_border()));
float const space(x2 - origx1);
float const lr_arrow_width(0.4f * space * machine().render().ui_aspect());
@@ -2305,18 +2305,18 @@ std::string menu_select_launch::arts_render_common(float origx1, float origy1, f
{
ui().draw_textured_box(
container(),
- origx1 + ((middle - title_size) * 0.5f), origy1 + UI_BOX_TB_BORDER,
- origx1 + ((middle + title_size) * 0.5f), origy1 + UI_BOX_TB_BORDER + line_height,
+ origx1 + ((middle - title_size) * 0.5f), origy1 + ui().box_tb_border(),
+ origx1 + ((middle + title_size) * 0.5f), origy1 + ui().box_tb_border() + line_height,
bgcolor, rgb_t(43, 43, 43),
hilight_main_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXWRAP(1));
}
ui().draw_text_full(container(),
- snaptext.c_str(), origx1, origy1 + UI_BOX_TB_BORDER, origx2 - origx1,
+ snaptext.c_str(), origx1, origy1 + ui().box_tb_border(), origx2 - origx1,
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor,
nullptr, nullptr, tmp_size);
- draw_common_arrow(origx1, origy1 + UI_BOX_TB_BORDER, origx2, origy2, m_image_view, FIRST_VIEW, LAST_VIEW, title_size);
+ draw_common_arrow(origx1, origy1 + ui().box_tb_border(), origx2, origy2, m_image_view, FIRST_VIEW, LAST_VIEW, title_size);
return searchstr;
}
@@ -2348,7 +2348,7 @@ void menu_select_launch::arts_render_images(bitmap_argb32 &&tmp_bitmap, float or
if (tmp_bitmap.valid())
{
float panel_width = origx2 - origx1 - 0.02f;
- float panel_height = origy2 - origy1 - 0.02f - (3.0f * UI_BOX_TB_BORDER) - (2.0f * line_height);
+ float panel_height = origy2 - origy1 - 0.02f - (3.0f * ui().box_tb_border()) - (2.0f * line_height);
int screen_width = machine().render().ui_target().width();
int screen_height = machine().render().ui_target().height();
@@ -2426,8 +2426,8 @@ void menu_select_launch::draw_snapx(float origx1, float origy1, float origx2, fl
float const line_height = ui().get_line_height();
float const x1 = origx1 + 0.01f;
float const x2 = origx2 - 0.01f;
- float const y1 = origy1 + (2.0f * UI_BOX_TB_BORDER) + line_height;
- float const y2 = origy2 - UI_BOX_TB_BORDER - line_height;
+ float const y1 = origy1 + (2.0f * ui().box_tb_border()) + line_height;
+ float const y2 = origy2 - ui().box_tb_border() - line_height;
// apply texture
container().add_quad(x1, y1, x2, y2, rgb_t::white(), m_cache->snapx_texture(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
@@ -2508,7 +2508,7 @@ float menu_select_launch::draw_collapsed_left_panel(float x1, float y1, float x2
draw_arrow(ar_x0, ar_y0, ar_x1, ar_y1, fgcolor, ROT90);
- return x2 + UI_BOX_LR_BORDER;
+ return x2 + ui().box_lr_border();
}
@@ -2601,7 +2601,7 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
return;
}
- origy1 += UI_BOX_TB_BORDER;
+ origy1 += ui().box_tb_border();
float gutter_width = 0.4f * line_height * machine().render().ui_aspect() * 1.3f;
float ud_arrow_width = line_height * machine().render().ui_aspect();
float oy1 = origy1 + line_height;
diff --git a/src/frontend/mame/ui/selsoft.cpp b/src/frontend/mame/ui/selsoft.cpp
index a5b5a5bb594..4c86aaae9a4 100644
--- a/src/frontend/mame/ui/selsoft.cpp
+++ b/src/frontend/mame/ui/selsoft.cpp
@@ -321,8 +321,8 @@ void menu_select_software::populate(float &customtop, float &custombottom)
item_append(menu_item_type::SEPARATOR, flags_ui);
// configure the custom rendering
- customtop = 4.0f * ui().get_line_height() + 5.0f * UI_BOX_TB_BORDER;
- custombottom = 5.0f * ui().get_line_height() + 4.0f * UI_BOX_TB_BORDER;
+ customtop = 4.0f * ui().get_line_height() + 5.0f * ui().box_tb_border();
+ custombottom = 5.0f * ui().get_line_height() + 4.0f * ui().box_tb_border();
if (old_software != -1)
{
diff --git a/src/frontend/mame/ui/simpleselgame.cpp b/src/frontend/mame/ui/simpleselgame.cpp
index ae132679f65..a2334a3485d 100644
--- a/src/frontend/mame/ui/simpleselgame.cpp
+++ b/src/frontend/mame/ui/simpleselgame.cpp
@@ -279,8 +279,8 @@ void simple_menu_select_game::populate(float &customtop, float &custombottom)
}
// configure the custom rendering
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
- custombottom = 4.0f * ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
+ custombottom = 4.0f * ui().get_line_height() + 3.0f * ui().box_tb_border();
}
@@ -302,7 +302,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
// draw the top box
draw_text_box(
tempbuf, tempbuf + 1,
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), ui().colors().background_color(), 1.0f);
@@ -384,7 +384,7 @@ void simple_menu_select_game::custom_render(void *selectedref, float top, float
// draw the bottom box
draw_text_box(
tempbuf, tempbuf + 4,
- 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, true,
ui().colors().text_color(), driver ? m_cached_color : ui().colors().background_color(), 1.0f);
}
diff --git a/src/frontend/mame/ui/sliders.cpp b/src/frontend/mame/ui/sliders.cpp
index 560dd1096a5..12e15f1a19b 100644
--- a/src/frontend/mame/ui/sliders.cpp
+++ b/src/frontend/mame/ui/sliders.cpp
@@ -193,7 +193,7 @@ void menu_sliders::populate(float &customtop, float &custombottom)
}
}
- custombottom = 2.0f * ui().get_line_height() + 2.0f * UI_BOX_TB_BORDER;
+ custombottom = 2.0f * ui().get_line_height() + 2.0f * ui().box_tb_border();
}
//-------------------------------------------------
@@ -224,23 +224,23 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
tempstring.insert(0, " ").insert(0, curslider->description);
// move us to the bottom of the screen, and expand to full width
- y2 = 1.0f - UI_BOX_TB_BORDER;
+ y2 = 1.0f - ui().box_tb_border();
y1 = y2 - bottom;
- x1 = UI_BOX_LR_BORDER;
- x2 = 1.0f - UI_BOX_LR_BORDER;
+ x1 = ui().box_lr_border();
+ x2 = 1.0f - ui().box_lr_border();
// draw extra menu area
ui().draw_outlined_box(container(), x1, y1, x2, y2, ui().colors().background_color());
- y1 += UI_BOX_TB_BORDER;
-
+ y1 += ui().box_tb_border();
+
// determine the text height
- ui().draw_text_full(container(), tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
+ ui().draw_text_full(container(), tempstring.c_str(), 0, 0, x2 - x1 - 2.0f * ui().box_lr_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NONE, rgb_t::white(), rgb_t::black(), nullptr, &text_height);
// draw the thermometer
- bar_left = x1 + UI_BOX_LR_BORDER;
+ bar_left = x1 + ui().box_lr_border();
bar_area_top = y1;
- bar_width = x2 - x1 - 2.0f * UI_BOX_LR_BORDER;
+ bar_width = x2 - x1 - 2.0f * ui().box_lr_border();
bar_area_height = line_height;
// compute positions
@@ -261,7 +261,7 @@ void menu_sliders::custom_render(void *selectedref, float top, float bottom, flo
container().add_line(default_x, bar_bottom, default_x, bar_area_top + bar_area_height, UI_LINE_WIDTH, ui().colors().border_color(), PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
// draw the actual text
- ui().draw_text_full(container(), tempstring.c_str(), x1 + UI_BOX_LR_BORDER, y1 + line_height, x2 - x1 - 2.0f * UI_BOX_LR_BORDER,
+ ui().draw_text_full(container(), tempstring.c_str(), x1 + ui().box_lr_border(), y1 + line_height, x2 - x1 - 2.0f * ui().box_lr_border(),
ui::text_layout::CENTER, ui::text_layout::WORD, mame_ui_manager::NORMAL, ui().colors().text_color(), ui().colors().text_bg_color(), nullptr, &text_height);
}
}
diff --git a/src/frontend/mame/ui/slotopt.cpp b/src/frontend/mame/ui/slotopt.cpp
index 36fed77ae3c..01493173731 100644
--- a/src/frontend/mame/ui/slotopt.cpp
+++ b/src/frontend/mame/ui/slotopt.cpp
@@ -203,7 +203,7 @@ void menu_slot_devices::populate(float &customtop, float &custombottom)
item_append(_("Reset"), "", 0, ITEMREF_RESET);
// leave space for the name of the current option at the bottom
- custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
@@ -220,7 +220,7 @@ void menu_slot_devices::custom_render(void *selectedref, float top, float bottom
char const *const text[] = { option ? option->devtype().fullname() : _("[empty slot]") };
draw_text_box(
std::begin(text), std::end(text),
- 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().colors().text_color(), ui().colors().background_color(), 1.0f);
}
diff --git a/src/frontend/mame/ui/sndmenu.cpp b/src/frontend/mame/ui/sndmenu.cpp
index 4763bfe7226..01397bd8f74 100644
--- a/src/frontend/mame/ui/sndmenu.cpp
+++ b/src/frontend/mame/ui/sndmenu.cpp
@@ -137,7 +137,7 @@ void menu_sound_options::populate(float &customtop, float &custombottom)
item_append_on_off(_("Use External Samples"), m_samples, 0, (void *)(uintptr_t)ENABLE_SAMPLES);
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
+ customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
}
//-------------------------------------------------
@@ -149,7 +149,7 @@ void menu_sound_options::custom_render(void *selectedref, float top, float botto
char const *const toptext[] = { _("Sound Options") };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/state.cpp b/src/frontend/mame/ui/state.cpp
index 28d47040d60..f66b5af4a9a 100644
--- a/src/frontend/mame/ui/state.cpp
+++ b/src/frontend/mame/ui/state.cpp
@@ -203,8 +203,8 @@ void menu_load_save_state_base::populate(float &customtop, float &custombottom)
}
// set up custom render proc
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
- custombottom = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
+ custombottom = ui().get_line_height() + 3.0f * ui().box_tb_border();
// pause if appropriate
if (!m_pause_checked)
diff --git a/src/frontend/mame/ui/submenu.cpp b/src/frontend/mame/ui/submenu.cpp
index 4a6690cd443..a9134935f7a 100644
--- a/src/frontend/mame/ui/submenu.cpp
+++ b/src/frontend/mame/ui/submenu.cpp
@@ -415,7 +415,7 @@ void submenu::populate(float &customtop, float &custombottom)
}
item_append(menu_item_type::SEPARATOR);
- custombottom = customtop = ui().get_line_height() + (3.0f * UI_BOX_TB_BORDER);
+ custombottom = customtop = ui().get_line_height() + (3.0f * ui().box_tb_border());
}
//-------------------------------------------------
@@ -427,7 +427,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
char const *const toptext[] = { _(m_options[0].description) };
draw_text_box(
std::begin(toptext), std::end(toptext),
- origx1, origx2, origy1 - top, origy1 - UI_BOX_TB_BORDER,
+ origx1, origx2, origy1 - top, origy1 - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::TRUNCATE, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
@@ -439,7 +439,7 @@ void submenu::custom_render(void *selectedref, float top, float bottom, float or
char const *const bottomtext[] = { selected_sm_option.entry->description() };
draw_text_box(
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().colors().text_color(), UI_RED_COLOR, 1.0f);
}
diff --git a/src/frontend/mame/ui/ui.cpp b/src/frontend/mame/ui/ui.cpp
index 0062df95ac1..b27bae8b972 100644
--- a/src/frontend/mame/ui/ui.cpp
+++ b/src/frontend/mame/ui/ui.cpp
@@ -164,7 +164,8 @@ mame_ui_manager::mame_ui_manager(running_machine &machine)
, m_popup_text_end(0)
, m_mouse_bitmap(32, 32)
, m_mouse_arrow_texture(nullptr)
- , m_mouse_show(false) {}
+ , m_mouse_show(false)
+ , m_target_font_height(0) {}
mame_ui_manager::~mame_ui_manager()
{
@@ -177,9 +178,11 @@ void mame_ui_manager::init()
ui::menu::init(machine(), options());
ui_gfx_init(machine());
- get_font_rows(&machine());
m_ui_colors.refresh(options());
+ // update font row info from setting
+ update_target_font_height();
+
// more initialization
using namespace std::placeholders;
set_handler(ui_callback_type::GENERAL, std::bind(&mame_ui_manager::handler_messagebox, this, _1));
@@ -198,6 +201,16 @@ void mame_ui_manager::init()
//-------------------------------------------------
+// update_target_font_height
+//-------------------------------------------------
+
+void mame_ui_manager::update_target_font_height()
+{
+ m_target_font_height = 1.0f / options().font_rows();
+}
+
+
+//-------------------------------------------------
// exit - clean up ourselves on exit
//-------------------------------------------------
@@ -457,7 +470,7 @@ float mame_ui_manager::get_line_height()
one_to_one_line_height = (float)raw_font_pixel_height / (float)target_pixel_height;
// determine the scale factor
- scale_factor = UI_TARGET_FONT_HEIGHT / one_to_one_line_height;
+ scale_factor = target_font_height() / one_to_one_line_height;
// if our font is small-ish, do integral scaling
if (raw_font_pixel_height < 24)
@@ -583,7 +596,7 @@ void mame_ui_manager::draw_text_full(render_container &container, const char *or
void mame_ui_manager::draw_text_box(render_container &container, const char *text, ui::text_layout::text_justify justify, float xpos, float ypos, rgb_t backcolor)
{
// cap the maximum width
- float maximum_width = 1.0f - UI_BOX_LR_BORDER * 2;
+ float maximum_width = 1.0f - box_lr_border() * 2;
// create a layout
ui::text_layout layout = create_layout(container, maximum_width, justify);
@@ -607,15 +620,15 @@ void mame_ui_manager::draw_text_box(render_container &container, ui::text_layout
auto actual_left = layout.actual_left();
auto actual_width = layout.actual_width();
auto actual_height = layout.actual_height();
- auto x = std::min(std::max(xpos - actual_width / 2, UI_BOX_LR_BORDER), 1.0f - actual_width - UI_BOX_LR_BORDER);
- auto y = std::min(std::max(ypos - actual_height / 2, UI_BOX_TB_BORDER), 1.0f - actual_height - UI_BOX_TB_BORDER);
+ auto x = std::min(std::max(xpos - actual_width / 2, box_lr_border()), 1.0f - actual_width - box_lr_border());
+ auto y = std::min(std::max(ypos - actual_height / 2, box_tb_border()), 1.0f - actual_height - box_tb_border());
// add a box around that
draw_outlined_box(container,
- x - UI_BOX_LR_BORDER,
- y - UI_BOX_TB_BORDER,
- x + actual_width + UI_BOX_LR_BORDER,
- y + actual_height + UI_BOX_TB_BORDER, backcolor);
+ x - box_lr_border(),
+ y - box_tb_border(),
+ x + actual_width + box_lr_border(),
+ y + actual_height + box_tb_border(), backcolor);
// emit the text
layout.emit(container, x - actual_left, y);
@@ -1007,7 +1020,7 @@ void mame_ui_manager::image_handler_ingame()
if (!layout.empty())
{
float x = 0.2f;
- float y = 0.5f * get_line_height() + 2.0f * UI_BOX_TB_BORDER;
+ float y = 0.5f * get_line_height() + 2.0f * box_tb_border();
draw_text_box(machine().render().ui_container(), layout, x, y, colors().background_color());
}
}
@@ -2058,17 +2071,6 @@ void mame_ui_manager::draw_textured_box(render_container &container, float x0, f
container.add_line(x0, y1, x0, y0, UI_LINE_WIDTH, linecolor, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
-//-------------------------------------------------
-// get font rows from options
-//-------------------------------------------------
-
-int get_font_rows(running_machine *machine)
-{
- static int value;
-
- return ((machine != nullptr) ? value = mame_machine_manager::instance()->ui().options().font_rows() : value);
-}
-
void mame_ui_manager::popup_time_string(int seconds, std::string message)
{
// extract the text
diff --git a/src/frontend/mame/ui/ui.h b/src/frontend/mame/ui/ui.h
index 46c5c2220a7..64189344dcb 100644
--- a/src/frontend/mame/ui/ui.h
+++ b/src/frontend/mame/ui/ui.h
@@ -33,19 +33,11 @@ class machine_info;
CONSTANTS
***************************************************************************/
-/* preferred font height; use ui_get_line_height() to get actual height */
-#define UI_TARGET_FONT_ROWS get_font_rows()
-
-#define UI_TARGET_FONT_HEIGHT (1.0f / (float)UI_TARGET_FONT_ROWS)
#define UI_MAX_FONT_HEIGHT (1.0f / 15.0f)
/* width of lines drawn in the UI */
#define UI_LINE_WIDTH (1.0f / 500.0f)
-/* border between outlines and inner text on left/right and top/bottom sides */
-#define UI_BOX_LR_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f)
-#define UI_BOX_TB_BORDER (UI_TARGET_FONT_HEIGHT * 0.25f)
-
/* handy colors */
#define UI_GREEN_COLOR rgb_t(0xef,0x10,0x60,0x10)
#define UI_YELLOW_COLOR rgb_t(0xef,0x60,0x60,0x10)
@@ -246,6 +238,12 @@ public:
// slider controls
std::vector<ui::menu_item>& get_slider_list(void);
+ // metrics
+ float target_font_height() const { return m_target_font_height; }
+ float box_lr_border() const { return target_font_height() * 0.25f; }
+ float box_tb_border() const { return target_font_height() * 0.25f; }
+ void update_target_font_height();
+
// other
void process_natural_keyboard();
ui::text_layout create_layout(render_container &container, float width = 1.0, ui::text_layout::text_justify justify = ui::text_layout::LEFT, ui::text_layout::word_wrapping wrap = ui::text_layout::WORD);
@@ -276,6 +274,7 @@ private:
bool m_mouse_show;
ui_options m_ui_options;
ui_colors m_ui_colors;
+ float m_target_font_height;
std::unique_ptr<ui::machine_info> m_machine_info;
@@ -334,7 +333,6 @@ private:
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
-int get_font_rows(running_machine *machine = nullptr);
template <typename Format, typename... Params>
inline void mame_ui_manager::popup_time(int seconds, Format &&fmt, Params &&... args)
diff --git a/src/frontend/mame/ui/utils.cpp b/src/frontend/mame/ui/utils.cpp
index 0cf7c613b60..58ee1e09f8d 100644
--- a/src/frontend/mame/ui/utils.cpp
+++ b/src/frontend/mame/ui/utils.cpp
@@ -356,7 +356,7 @@ private:
char const *const text[] = { _("Select custom filters:") };
draw_text_box(
std::begin(text), std::end(text),
- x, x2, y - top, y - UI_BOX_TB_BORDER,
+ x, x2, y - top, y - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -525,7 +525,7 @@ void composite_filter_impl_base<Impl, Base, Type>::menu_configure::populate(floa
item_append(menu_item_type::SEPARATOR);
// leave space for heading
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
template <class Impl, class Base, typename Base::type Type>
@@ -966,7 +966,7 @@ private:
char const *const text[] = { _("Select category:") };
draw_text_box(
std::begin(text), std::end(text),
- x, x2, y - top, y - UI_BOX_TB_BORDER,
+ x, x2, y - top, y - ui().box_tb_border(),
ui::text_layout::CENTER, ui::text_layout::NEVER, false,
ui().colors().text_color(), UI_GREEN_COLOR, 1.0f);
}
@@ -1055,7 +1055,7 @@ void category_machine_filter::menu_configure::populate(float &customtop, float &
}
}
item_append(menu_item_type::SEPARATOR);
- customtop = ui().get_line_height() + 3.0f * UI_BOX_TB_BORDER;
+ customtop = ui().get_line_height() + 3.0f * ui().box_tb_border();
}
void category_machine_filter::menu_configure::handle()