summaryrefslogtreecommitdiffstatshomepage
path: root/src/frontend/mame/ui
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2021-10-17 09:34:08 +1100
committer Vas Crabb <vas@vastheman.com>2021-10-17 09:34:08 +1100
commite1652298a585ffc7cd26c7a57824d169fa48f7e2 (patch)
tree63b0f61f2ee0ec8087cfe2cb01af7f07f0719a62 /src/frontend/mame/ui
parent14fc0b2a76cc72a579ed547e03d4350ff4416266 (diff)
frontend: Further improved behaviour of info box on system selection menu, and fixed alignment issues.
Diffstat (limited to 'src/frontend/mame/ui')
-rw-r--r--src/frontend/mame/ui/selmenu.cpp36
-rw-r--r--src/frontend/mame/ui/text.cpp2
2 files changed, 19 insertions, 19 deletions
diff --git a/src/frontend/mame/ui/selmenu.cpp b/src/frontend/mame/ui/selmenu.cpp
index 11ddcf94ff0..a66212c020b 100644
--- a/src/frontend/mame/ui/selmenu.cpp
+++ b/src/frontend/mame/ui/selmenu.cpp
@@ -1527,7 +1527,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
// Infos
if (!rightclose && m_focus == focused_menu::RIGHTBOTTOM)
{
- m_topline_datsview -= m_right_visible_lines - 1;
+ m_topline_datsview -= m_right_visible_lines - 3;
return;
}
@@ -1545,7 +1545,7 @@ void menu_select_launch::handle_keys(uint32_t flags, int &iptkey)
// Infos
if (!rightclose && m_focus == focused_menu::RIGHTBOTTOM)
{
- m_topline_datsview += m_right_visible_lines - 1;
+ m_topline_datsview += m_right_visible_lines - 3;
return;
}
@@ -1715,9 +1715,9 @@ void menu_select_launch::handle_events(uint32_t flags, event &ev)
else if (hover() == HOVER_UI_LEFT)
ev.iptkey = IPT_UI_LEFT;
else if (hover() == HOVER_DAT_DOWN)
- m_topline_datsview += m_right_visible_lines - 1;
+ m_topline_datsview += m_right_visible_lines - 3;
else if (hover() == HOVER_DAT_UP)
- m_topline_datsview -= m_right_visible_lines - 1;
+ m_topline_datsview -= m_right_visible_lines - 3;
else if (hover() == HOVER_LPANEL_ARROW)
{
if (get_focus() == focused_menu::LEFT)
@@ -2850,31 +2850,31 @@ void menu_select_launch::infos_render(float origx1, float origy1, float origx2,
draw_common_arrow(origx1, origy1, origx2, origy2, m_info_view, 0, total - 1, title_size);
- int r_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
- if (m_total_lines < r_visible_lines)
- r_visible_lines = m_total_lines;
+ m_right_visible_lines = floor((origy2 - oy1) / (line_height * text_size));
+ if (m_total_lines < m_right_visible_lines)
+ m_right_visible_lines = m_total_lines;
if (m_topline_datsview < 0)
m_topline_datsview = 0;
- if (m_topline_datsview + r_visible_lines >= m_total_lines)
- m_topline_datsview = m_total_lines - r_visible_lines;
+ if ((m_topline_datsview + m_right_visible_lines) >= m_total_lines)
+ m_topline_datsview = m_total_lines - m_right_visible_lines;
- // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
- m_right_visible_lines = r_visible_lines
- - (m_topline_datsview ? 1 : 0)
- - ((m_topline_datsview + r_visible_lines < m_total_lines) ? 1 : 0);
+ // get the number of visible lines, minus 1 for top arrow and 1 for bottom arrow
+ bool const up_arrow = m_topline_datsview > 0;
+ bool const down_arrow = (m_topline_datsview + m_right_visible_lines) < m_total_lines;
+ int const r_visible_lines = m_right_visible_lines - (up_arrow ? 1 : 0) - (down_arrow ? 1 : 0);
if (mouse_in_rect(origx1 + gutter_width, oy1, origx2 - gutter_width, origy2))
set_hover(HOVER_INFO_TEXT);
- if (m_topline_datsview) // up arrow
+ if (up_arrow)
draw_info_arrow(0, origx1, origx2, oy1, line_height, text_size, ud_arrow_width);
- if (m_total_lines > (m_topline_datsview + r_visible_lines)) // bottom arrow
- draw_info_arrow(1, origx1, origx2, oy1 + (float(r_visible_lines - 1) * line_height), line_height, text_size, ud_arrow_width);
+ if (down_arrow)
+ draw_info_arrow(1, origx1, origx2, oy1 + (float(m_right_visible_lines - 1) * line_height * text_size), line_height, text_size, ud_arrow_width);
m_info_layout->emit(
container(),
- m_topline_datsview ? (m_topline_datsview + 1) : 0, m_right_visible_lines,
- origx1 + gutter_width, oy1 + (m_topline_datsview ? line_height : 0.0f));
+ m_topline_datsview ? (m_topline_datsview + 1) : 0, r_visible_lines,
+ origx1 + gutter_width, oy1 + (m_topline_datsview ? (line_height * text_size) : 0.0f));
}
diff --git a/src/frontend/mame/ui/text.cpp b/src/frontend/mame/ui/text.cpp
index f9ddecc3fa0..fa739126c36 100644
--- a/src/frontend/mame/ui/text.cpp
+++ b/src/frontend/mame/ui/text.cpp
@@ -537,7 +537,7 @@ void text_layout::word_wrap()
// find the beginning of the word to wrap
size_t position = last_break;
- while ((position + 1) < last_line->character_count() && is_space_character(last_line->character(position).character))
+ while ((last_line->character_count() > position) && is_space_character(last_line->character(position).character))
position++;
// carry over justification