void text_handler(int x, int y, int button) { int i; for (i = 0; i < dbn; i++) { if (mouse_in_rect(&db_rect[i], x, y) && db_entry[i].retval) dialog_close(db_entry[i].retval); } }
void do_help_mouse (int x, int y, int mbutton) { Rect* mw = &scr.main_win; if (mouse_in_rect(mw, x, y)) { do_help_buttons (x, y); return; } if (block_help_exit) return; help_flag = 0; #ifdef USE_EXPANDED_FONT Fgl_setwritemode (WRITEMODE_OVERWRITE | FONT_EXPANDED); #else Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR); #endif refresh_main_screen (); }
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_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; int const visible_items = item.size() - 2; // determine effective positions taking into account the hilighting arrows float const effective_width = visible_width - 2.0f * gutter_width; float const effective_left = visible_left + gutter_width; draw_background(); 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; m_visible_lines = int(std::trunc(visible_main_menu_height / line_height)); visible_main_menu_height = float(m_visible_lines) * line_height; // compute top/left of inner menu area by centering, if the menu is at the bottom of the extra, adjust float const visible_top = ((1.0f - (visible_main_menu_height + visible_extra_menu_height)) * 0.5f) + get_customtop(); // compute left box size float x1 = visible_left; 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 line = visible_top + float(m_visible_lines) * line_height; ui().draw_outlined_box(container(), x1, y1, x2, y2, UI_BACKGROUND_COLOR); m_visible_lines = (std::min)(visible_items, m_visible_lines); top_line = (std::max)(0, top_line); if (top_line + m_visible_lines >= visible_items) top_line = visible_items - m_visible_lines; hover = item.size() + 1; int const n_loop = (std::min)(visible_items, m_visible_lines); for (int linenum = 0; linenum < n_loop; linenum++) { float const line_y = visible_top + (float)linenum * line_height; int const itemnum = top_line + linenum; menu_item const &pitem = item[itemnum]; char const *const itemtext = pitem.text.c_str(); float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float const line_y0 = line_y; float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float const line_y1 = line_y + line_height; rgb_t fgcolor = UI_TEXT_COLOR; rgb_t bgcolor = UI_TEXT_BG_COLOR; if (!linenum && top_line) { // if we're on the top line, display the up arrow if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_UP; } draw_arrow( 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0); } else if ((linenum == m_visible_lines - 1) && (itemnum != visible_items - 1)) { // if we're on the bottom line, display the down arrow if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1)) { fgcolor = UI_MOUSEOVER_COLOR; bgcolor = UI_MOUSEOVER_BG_COLOR; highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); hover = HOVER_ARROW_DOWN; } draw_arrow( 0.5f * (x1 + x2) - 0.5f * ud_arrow_width, line_y + 0.25f * line_height, 0.5f * (x1 + x2) + 0.5f * ud_arrow_width, line_y + 0.75f * line_height, fgcolor, ROT0 ^ ORIENTATION_FLIP_Y); } else if (pitem.subtext.empty()) { // draw dats text ui().draw_text_full( container(), itemtext, effective_left, line_y, effective_width, ui::text_layout::LEFT, ui::text_layout::NEVER, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); } } for (size_t count = visible_items; count < item.size(); count++) { menu_item const &pitem = item[count]; char const *const itemtext = pitem.text.c_str(); float const line_x0 = x1 + 0.5f * UI_LINE_WIDTH; float const line_y0 = line; float const line_x1 = x2 - 0.5f * UI_LINE_WIDTH; float const line_y1 = line + line_height; rgb_t const fgcolor = UI_SELECTED_COLOR; rgb_t const bgcolor = UI_SELECTED_BG_COLOR; if (mouse_in_rect(line_x0, line_y0, line_x1, line_y1) && is_selectable(pitem)) hover = count; if (pitem.type == menu_item_type::SEPARATOR) { container().add_line( visible_left, line + 0.5f * line_height, visible_left + visible_width, line + 0.5f * line_height, UI_LINE_WIDTH, UI_TEXT_COLOR, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); } else { highlight(line_x0, line_y0, line_x1, line_y1, bgcolor); ui().draw_text_full( container(), itemtext, effective_left, line, effective_width, ui::text_layout::CENTER, ui::text_layout::TRUNCATE, mame_ui_manager::NORMAL, fgcolor, bgcolor, nullptr, nullptr); } line += line_height; } // 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); // return the number of visible lines, minus 1 for top arrow and 1 for bottom arrow m_visible_items = m_visible_lines - (top_line != 0) - (top_line + m_visible_lines != visible_items); }