From e1652298a585ffc7cd26c7a57824d169fa48f7e2 Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Sun, 17 Oct 2021 09:34:08 +1100 Subject: frontend: Further improved behaviour of info box on system selection menu, and fixed alignment issues. --- src/frontend/mame/ui/selmenu.cpp | 36 ++++++++++++++++++------------------ src/frontend/mame/ui/text.cpp | 2 +- 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 -- cgit v1.2.3