diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 57cfe26c94..4310e01a2f 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -67,7 +67,7 @@ typedef struct unsigned texture_switch2_index; float line_height; float y; -} mui_node_t; +} materialui_node_t; /* Textures used for the tabs and the switches */ enum @@ -138,7 +138,7 @@ enum #define MUI_SYSTEM_TAB_END MUI_SYSTEM_TAB_SETTINGS -typedef struct mui_handle +typedef struct materialui_handle { bool need_compute; bool mouse_show; @@ -181,7 +181,7 @@ typedef struct mui_handle video_font_raster_block_t raster_block; video_font_raster_block_t raster_block2; -} mui_handle_t; +} materialui_handle_t; static void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha) { @@ -191,7 +191,7 @@ static void hex32_to_rgba_normalized(uint32_t hex, float* rgba, float alpha) rgba[3] = rgba[7] = rgba[11] = rgba[15] = alpha; } -static const char *mui_texture_path(unsigned id) +static const char *materialui_texture_path(unsigned id) { switch (id) { @@ -304,7 +304,7 @@ static const char *mui_texture_path(unsigned id) return NULL; } -static void mui_context_reset_textures(mui_handle_t *mui) +static void materialui_context_reset_textures(materialui_handle_t *mui) { unsigned i; char *iconpath = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); @@ -316,11 +316,11 @@ static void mui_context_reset_textures(mui_handle_t *mui) APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_ICONS); for (i = 0; i < MUI_TEXTURE_LAST; i++) - menu_display_reset_textures_list(mui_texture_path(i), iconpath, &mui->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); + menu_display_reset_textures_list(materialui_texture_path(i), iconpath, &mui->textures.list[i], TEXTURE_FILTER_MIPMAP_LINEAR); free(iconpath); } -static void mui_draw_icon( +static void materialui_draw_icon( video_frame_info_t *video_info, unsigned icon_size, uintptr_t texture, @@ -366,8 +366,8 @@ static void mui_draw_icon( } /* Draw a single tab */ -static void mui_draw_tab( - mui_handle_t *mui, +static void materialui_draw_tab( + materialui_handle_t *mui, video_frame_info_t *video_info, unsigned i, unsigned width, unsigned height, @@ -395,7 +395,7 @@ static void mui_draw_tab( break; } - mui_draw_icon(video_info, + materialui_draw_icon(video_info, mui->icon_size, mui->textures.list[tab_icon], width / (MUI_SYSTEM_TAB_END+1) * (i+0.5) - mui->icon_size/2, @@ -408,7 +408,7 @@ static void mui_draw_tab( } /* Draw the onscreen keyboard */ -static void mui_render_keyboard(mui_handle_t *mui, +static void materialui_render_keyboard(materialui_handle_t *mui, video_frame_info_t *video_info, const char *grid[], unsigned id) { @@ -471,12 +471,12 @@ static void mui_render_keyboard(mui_handle_t *mui, } /* Returns the OSK key at a given position */ -static int mui_osk_ptr_at_pos(void *data, int x, int y, +static int materialui_osk_ptr_at_pos(void *data, int x, int y, unsigned width, unsigned height) { unsigned i; int ptr_width, ptr_height; - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return -1; @@ -502,8 +502,8 @@ static int mui_osk_ptr_at_pos(void *data, int x, int y, } /* Draw the tabs background */ -static void mui_draw_tab_begin( - mui_handle_t *mui, +static void materialui_draw_tab_begin( + materialui_handle_t *mui, video_frame_info_t *video_info, unsigned width, unsigned height, float *tabs_bg_color, float *tabs_separator_color) @@ -530,7 +530,7 @@ static void mui_draw_tab_begin( } /* Draw the active tab */ -static void mui_draw_tab_end(mui_handle_t *mui, +static void materialui_draw_tab_end(materialui_handle_t *mui, video_frame_info_t *video_info, unsigned width, unsigned height, unsigned header_height, @@ -550,7 +550,7 @@ static void mui_draw_tab_end(mui_handle_t *mui, } /* Draw the scrollbar */ -static void mui_draw_scrollbar(mui_handle_t *mui, +static void materialui_draw_scrollbar(materialui_handle_t *mui, video_frame_info_t *video_info, unsigned width, unsigned height, float *coord_color) { @@ -581,9 +581,9 @@ static void mui_draw_scrollbar(mui_handle_t *mui, coord_color); } -static void mui_get_message(void *data, const char *message) +static void materialui_get_message(void *data, const char *message) { - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui || !message || !*message) return; @@ -594,7 +594,7 @@ static void mui_get_message(void *data, const char *message) } /* Draw the modal */ -static void mui_render_messagebox(mui_handle_t *mui, +static void materialui_render_messagebox(materialui_handle_t *mui, video_frame_info_t *video_info, const char *message, float *body_bg_color, uint32_t font_color) { @@ -661,7 +661,7 @@ static void mui_render_messagebox(mui_handle_t *mui, } if (menu_input_dialog_get_display_kb()) - mui_render_keyboard(mui, + materialui_render_keyboard(mui, video_info, menu_event_get_osk_grid(), menu_event_get_osk_ptr()); @@ -671,7 +671,7 @@ end: } /* Used for the sublabels */ -static unsigned mui_count_lines(const char *str) +static unsigned materialui_count_lines(const char *str) { unsigned c = 0; unsigned lines = 1; @@ -681,8 +681,8 @@ static unsigned mui_count_lines(const char *str) return lines; } -/* Compute the line height for each menu entries. */ -static void mui_compute_entries_box(mui_handle_t* mui, int width) +/* Compute the line height for each menu entry. */ +static void materialui_compute_entries_box(materialui_handle_t* mui, int width) { unsigned i; size_t usable_width = width - (mui->margin * 2); @@ -690,25 +690,18 @@ static void mui_compute_entries_box(mui_handle_t* mui, int width) float sum = 0; size_t entries_end = menu_entries_get_size(); float scale_factor = menu_display_get_dpi(); - uintptr_t texture_switch2 = 0; - - if (!mui->font) - return; for (i = 0; i < entries_end; i++) { menu_entry_t entry; - char *sublabel_str = NULL; - unsigned lines = 0; - mui_node_t *node = (mui_node_t*) + char *sublabel_str = NULL; + unsigned lines = 0; + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, i); menu_entry_init(&entry); menu_entry_get(&entry, 0, i, NULL, true); - /* set texture_switch2 */ - if (node->texture_switch2_set) - texture_switch2 = mui->textures.list[node->texture_switch2_index]; sublabel_str = menu_entry_get_sublabel(&entry); menu_entry_free(&entry); @@ -717,10 +710,16 @@ static void mui_compute_entries_box(mui_handle_t* mui, int width) { if (!string_is_empty(sublabel_str)) { - int icon_margin = texture_switch2 ? mui->icon_size : 0; + int icon_margin = 0; - word_wrap(sublabel_str, sublabel_str, (int)((usable_width - icon_margin) / mui->glyph_width2), false); - lines = mui_count_lines(sublabel_str); + if (node->texture_switch2_set) + if (mui->textures.list[node->texture_switch2_index]) + icon_margin = mui->icon_size; + + word_wrap(sublabel_str, sublabel_str, + (int)((usable_width - icon_margin) / mui->glyph_width2), + false); + lines = materialui_count_lines(sublabel_str); } free(sublabel_str); } @@ -735,15 +734,15 @@ static void mui_compute_entries_box(mui_handle_t* mui, int width) /* Called on each frame. We use this callback to implement the touch scroll with acceleration */ -static void mui_render(void *data, bool is_idle) +static void materialui_render(void *data, bool is_idle) { menu_animation_ctx_delta_t delta; float delta_time; unsigned bottom, width, height, header_height; - size_t i = 0; - mui_handle_t *mui = (mui_handle_t*)data; - settings_t *settings = config_get_ptr(); - file_list_t *list = menu_entries_get_selection_buf_ptr(0); + size_t i = 0; + materialui_handle_t *mui = (materialui_handle_t*)data; + settings_t *settings = config_get_ptr(); + file_list_t *list = menu_entries_get_selection_buf_ptr(0); if (!mui) return; @@ -752,7 +751,8 @@ static void mui_render(void *data, bool is_idle) if (mui->need_compute) { - mui_compute_entries_box(mui, width); + if (mui->font) + materialui_compute_entries_box(mui, width); mui->need_compute = false; } @@ -777,7 +777,7 @@ static void mui_render(void *data, bool is_idle) for (ii = 0; ii < entries_end; ii++) { - mui_node_t *node = (mui_node_t*) + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, ii); if (pointer_y > (-mui->scroll_y + header_height + node->y) @@ -803,7 +803,7 @@ static void mui_render(void *data, bool is_idle) for (ii = 0; ii < entries_end; ii++) { - mui_node_t *node = (mui_node_t*) + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, ii); if (mouse_y > (-mui->scroll_y + header_height + node->y) @@ -828,10 +828,10 @@ static void mui_render(void *data, bool is_idle) } /* Display an entry value on the right of the screen. */ -static void mui_render_label_value( - mui_handle_t *mui, +static void materialui_render_label_value( + materialui_handle_t *mui, video_frame_info_t *video_info, - mui_node_t *node, + materialui_node_t *node, int i, int y, unsigned width, unsigned height, uint64_t index, uint32_t color, bool selected, const char *label, const char *value, float *label_color, @@ -857,6 +857,7 @@ static void mui_render_label_value( uintptr_t texture_switch2 = 0; bool do_draw_text = false; size_t usable_width = width - (mui->margin * 2); + int icon_margin = 0; enum msg_file_type hash_type = msg_hash_to_file_type(msg_hash_calculate(value)); float scale_factor = menu_display_get_dpi(); @@ -952,26 +953,29 @@ static void mui_render_label_value( sublabel_str = menu_entry_get_sublabel(&entry); + if (texture_switch2) + icon_margin = mui->icon_size; + /* Sublabel */ if (sublabel_str) { - if (!string_is_empty(sublabel_str)) + if (!string_is_empty(sublabel_str) && mui->font) { - int icon_margin = texture_switch2 ? mui->icon_size : 0; + word_wrap(sublabel_str, sublabel_str, + (int)((usable_width - icon_margin) / mui->glyph_width2), + false); - word_wrap(sublabel_str, sublabel_str, (int)((usable_width - icon_margin) / mui->glyph_width2), false); - - if (mui->font) - menu_display_draw_text(mui->font2, sublabel_str, - mui->margin + (texture_switch2 ? mui->icon_size : 0), + menu_display_draw_text(mui->font2, sublabel_str, + mui->margin + icon_margin, y + (scale_factor / 4) + mui->font->size, - width, height, sublabel_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); + width, height, sublabel_color, TEXT_ALIGN_LEFT, + 1.0f, false, 0); } free(sublabel_str); } menu_display_draw_text(mui->font, label_str, - mui->margin + (texture_switch2 ? mui->icon_size : 0), + mui->margin + icon_margin, y + (scale_factor / 5), width, height, color, TEXT_ALIGN_LEFT, 1.0f, false, 0); @@ -982,7 +986,7 @@ static void mui_render_label_value( width, height, color, TEXT_ALIGN_RIGHT, 1.0f, false, 0); if (texture_switch2) - mui_draw_icon(video_info, + materialui_draw_icon(video_info, mui->icon_size, (uintptr_t)texture_switch2, 0, @@ -995,10 +999,10 @@ static void mui_render_label_value( ); if (texture_switch) - mui_draw_icon(video_info, + materialui_draw_icon(video_info, mui->icon_size, (uintptr_t)texture_switch, - width - mui->margin - mui->icon_size, + width - mui->margin - mui->icon_size, y + (scale_factor / 6) - mui->icon_size/2, width, height, @@ -1010,9 +1014,9 @@ static void mui_render_label_value( menu_entry_free(&entry); } -static void mui_render_menu_list( +static void materialui_render_menu_list( video_frame_info_t *video_info, - mui_handle_t *mui, + materialui_handle_t *mui, unsigned width, unsigned height, uint32_t font_normal_color, uint32_t font_hover_color, @@ -1041,12 +1045,13 @@ static void mui_render_menu_list( { menu_entry_t entry; char entry_value[255]; - char *rich_label = NULL; - bool entry_selected = false; - mui_node_t *node = (mui_node_t*) + char *rich_label = NULL; + bool entry_selected = false; + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, i); - size_t selection = menu_navigation_get_selection(); - int y = header_height - mui->scroll_y + sum; + size_t selection = menu_navigation_get_selection(); + int y = header_height - mui->scroll_y + sum; + entry_value[0] = '\0'; sum += node->line_height; @@ -1065,7 +1070,7 @@ static void mui_render_menu_list( /* Render label, value, and associated icons */ - mui_render_label_value( + materialui_render_label_value( mui, video_info, node, @@ -1088,7 +1093,7 @@ static void mui_render_menu_list( } -static size_t mui_list_get_size(void *data, enum menu_list_type type) +static size_t materialui_list_get_size(void *data, enum menu_list_type type) { switch (type) { @@ -1103,16 +1108,14 @@ static size_t mui_list_get_size(void *data, enum menu_list_type type) return 0; } -static int mui_get_core_title(char *s, size_t len) +static int materialui_get_core_title(char *s, size_t len) { - settings_t *settings = config_get_ptr(); - const char *core_name = NULL; - const char *core_version = NULL; - rarch_system_info_t *info = runloop_get_system_info(); - struct retro_system_info *system = &info->info; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *info = runloop_get_system_info(); + struct retro_system_info *system = &info->info; - core_name = system->library_name; - core_version = system->library_version; + const char *core_name = system->library_name; + const char *core_version = system->library_version; if (!settings->bools.menu_core_enable) return -1; @@ -1135,7 +1138,7 @@ static int mui_get_core_title(char *s, size_t len) return 0; } -static void mui_draw_bg(menu_display_ctx_draw_t *draw, +static void materialui_draw_bg(menu_display_ctx_draw_t *draw, video_frame_info_t *video_info) { bool add_opacity = false; @@ -1162,7 +1165,7 @@ static void mui_draw_bg(menu_display_ctx_draw_t *draw, /* Main function of the menu driver. Takes care of drawing the header, the tabs, and the menu list */ -static void mui_frame(void *data, video_frame_info_t *video_info) +static void materialui_frame(void *data, video_frame_info_t *video_info) { /* This controls the main background color */ menu_display_ctx_clearcolor_t clearcolor; @@ -1173,32 +1176,31 @@ static void mui_frame(void *data, video_frame_info_t *video_info) char title[255]; char title_buf[255]; char title_msg[255]; - float black_bg[16] = { + float black_bg[16] = { 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, 0, 0, 0, 0.75, }; - - float pure_white[16]= { + float pure_white[16] = { 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00, }; - float white_bg[16]= { + float white_bg[16] = { 0.98, 0.98, 0.98, 1.00, 0.98, 0.98, 0.98, 1.00, 0.98, 0.98, 0.98, 1.00, 0.98, 0.98, 0.98, 1.00, }; - float white_transp_bg[16]= { + float white_transp_bg[16] = { 0.98, 0.98, 0.98, 0.90, 0.98, 0.98, 0.98, 0.90, 0.98, 0.98, 0.98, 0.90, 0.98, 0.98, 0.98, 0.90, }; - float grey_bg[16]= { + float grey_bg[16] = { 0.78, 0.78, 0.78, 0.90, 0.78, 0.78, 0.78, 0.90, 0.78, 0.78, 0.78, 0.90, @@ -1248,7 +1250,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) float header_bg_color_real[16] = {0}; file_list_t *list = NULL; - mui_node_t *node = NULL; + materialui_node_t *node = NULL; unsigned width = video_info->width; unsigned height = video_info->height; unsigned ticker_limit = 0; @@ -1256,7 +1258,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) unsigned header_height = 0; size_t selection = 0; size_t title_margin = 0; - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; bool background_rendered = false; bool libretro_running = video_info->libretro_running; @@ -1272,6 +1274,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) uint32_t font_normal_color = 0; uint32_t font_hover_color = 0; uint32_t font_header_color = 0; + size_t usable_width = width - (mui->margin * 2); if (!mui) return; @@ -1455,7 +1458,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) draw.pipeline.active = false; draw.pipeline.backend_data = NULL; - mui_draw_bg(&draw, video_info); + materialui_draw_bg(&draw, video_info); } else { @@ -1487,7 +1490,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) if (draw.texture) draw.color = &white_bg[0]; - mui_draw_bg(&draw, video_info); + materialui_draw_bg(&draw, video_info); /* Restore opacity of transposed white background */ menu_display_set_alpha(white_transp_bg, 0.90); @@ -1505,7 +1508,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) /* highlighted entry */ list = menu_entries_get_selection_buf_ptr(0); - node = (mui_node_t*)file_list_get_userdata_at_offset( + node = (materialui_node_t*)file_list_get_userdata_at_offset( list, selection); if (node) @@ -1524,7 +1527,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) font_driver_bind_block(mui->font2, &mui->raster_block2); if (menu_display_get_update_pending()) - mui_render_menu_list( + materialui_render_menu_list( video_info, mui, width, @@ -1559,18 +1562,18 @@ static void mui_frame(void *data, video_frame_info_t *video_info) mui->tabs_height = 0; /* display tabs if depth equal one, if not hide them */ - if (mui_list_get_size(mui, MENU_LIST_PLAIN) == 1) + if (materialui_list_get_size(mui, MENU_LIST_PLAIN) == 1) { - mui_draw_tab_begin(mui, + materialui_draw_tab_begin(mui, video_info, width, height, &footer_bg_color[0], &grey_bg[0]); for (i = 0; i <= MUI_SYSTEM_TAB_END; i++) - mui_draw_tab(mui, video_info, + materialui_draw_tab(mui, video_info, i, width, height, &passive_tab_icon_color[0], &active_tab_marker_color[0]); - mui_draw_tab_end(mui, + materialui_draw_tab_end(mui, video_info, width, height, header_height, &active_tab_marker_color[0]); } @@ -1590,7 +1593,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) if (menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL)) { title_margin = mui->icon_size; - mui_draw_icon(video_info, + materialui_draw_icon(video_info, mui->icon_size, mui->textures.list[MUI_TEXTURE_BACK], 0, @@ -1603,7 +1606,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) ); } - ticker_limit = (width - mui->margin*2) / mui->glyph_width; + ticker_limit = usable_width / mui->glyph_width; ticker.s = title_buf; ticker.len = ticker_limit; @@ -1614,12 +1617,11 @@ static void mui_frame(void *data, video_frame_info_t *video_info) menu_animation_ticker(&ticker); /* Title */ - if (mui_get_core_title(title_msg, sizeof(title_msg)) == 0) + if (materialui_get_core_title(title_msg, sizeof(title_msg)) == 0) { int ticker_limit, value_len; char title_buf_msg_tmp[255]; char title_buf_msg[255]; - size_t usable_width = width - (mui->margin * 2); title_buf_msg_tmp[0] = title_buf_msg[0] = '\0'; @@ -1645,7 +1647,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) header_height / 2 + mui->font->size / 3, width, height, font_header_color, TEXT_ALIGN_LEFT, 1.0f, false, 0); - mui_draw_scrollbar(mui, video_info, width, height, &grey_bg[0]); + materialui_draw_scrollbar(mui, video_info, width, height, &grey_bg[0]); if (menu_input_dialog_get_display_kb()) { @@ -1656,7 +1658,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) 0, 0, width, height, width, height, &black_bg[0]); snprintf(msg, sizeof(msg), "%s\n%s", label, str); - mui_render_messagebox(mui, video_info, + materialui_render_messagebox(mui, video_info, msg, &body_bg_color[0], font_hover_color); } @@ -1665,7 +1667,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) menu_display_draw_quad(video_info, 0, 0, width, height, width, height, &black_bg[0]); - mui_render_messagebox(mui, video_info, + materialui_render_messagebox(mui, video_info, mui->box_message, &body_bg_color[0], font_hover_color); free(mui->box_message); @@ -1688,7 +1690,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info) } /* Compute the positions of the widgets */ -static void mui_layout(mui_handle_t *mui, bool video_is_threaded) +static void materialui_layout(materialui_handle_t *mui, bool video_is_threaded) { float scale_factor; int new_font_size, new_font_size2; @@ -1715,18 +1717,18 @@ static void mui_layout(mui_handle_t *mui, bool video_is_threaded) mui->margin = scale_factor / 9; mui->icon_size = scale_factor / 3; + /* we assume the average glyph aspect ratio is close to 3:4 */ + mui->glyph_width = new_font_size * 3/4; + mui->glyph_width2 = new_font_size2 * 3/4; + menu_display_set_header_height(new_header_height); - /* we assume the average glyph aspect ratio is close to 3:4 */ - mui->glyph_width = new_font_size * 3/4; - mui->glyph_width2 = new_font_size2 * 3/4; - - mui->font = menu_display_font( + mui->font = menu_display_font( APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT, new_font_size, video_is_threaded); - mui->font2 = menu_display_font( + mui->font2 = menu_display_font( APPLICATION_SPECIAL_DIRECTORY_ASSETS_MATERIALUI_FONT, new_font_size2, video_is_threaded); @@ -1750,9 +1752,9 @@ static void mui_layout(mui_handle_t *mui, bool video_is_threaded) } } -static void *mui_init(void **userdata, bool video_is_threaded) +static void *materialui_init(void **userdata, bool video_is_threaded) { - mui_handle_t *mui = NULL; + materialui_handle_t *mui = NULL; menu_handle_t *menu = (menu_handle_t*) calloc(1, sizeof(*menu)); @@ -1762,13 +1764,12 @@ static void *mui_init(void **userdata, bool video_is_threaded) if (!menu_display_init_first_driver(video_is_threaded)) goto error; - mui = (mui_handle_t*)calloc(1, sizeof(mui_handle_t)); + mui = (materialui_handle_t*)calloc(1, sizeof(materialui_handle_t)); if (!mui) goto error; - *userdata = mui; - + *userdata = mui; mui->cursor_size = 64.0; mui->need_compute = false; @@ -1779,9 +1780,9 @@ error: return NULL; } -static void mui_free(void *data) +static void materialui_free(void *data) { - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; @@ -1792,7 +1793,7 @@ static void mui_free(void *data) font_driver_bind_block(NULL, NULL); } -static void mui_context_bg_destroy(mui_handle_t *mui) +static void materialui_context_bg_destroy(materialui_handle_t *mui) { if (!mui) return; @@ -1801,10 +1802,10 @@ static void mui_context_bg_destroy(mui_handle_t *mui) video_driver_texture_unload(&menu_display_white_texture); } -static void mui_context_destroy(void *data) +static void materialui_context_destroy(void *data) { unsigned i; - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; @@ -1815,20 +1816,20 @@ static void mui_context_destroy(void *data) menu_display_font_free(mui->font); menu_display_font_free(mui->font2); - mui_context_bg_destroy(mui); + materialui_context_bg_destroy(mui); } /* Upload textures to the gpu */ -static bool mui_load_image(void *userdata, void *data, enum menu_image_type type) +static bool materialui_load_image(void *userdata, void *data, enum menu_image_type type) { - mui_handle_t *mui = (mui_handle_t*)userdata; + materialui_handle_t *mui = (materialui_handle_t*)userdata; switch (type) { case MENU_IMAGE_NONE: break; case MENU_IMAGE_WALLPAPER: - mui_context_bg_destroy(mui); + materialui_context_bg_destroy(mui); video_driver_texture_unload(&mui->textures.bg); video_driver_texture_load(data, TEXTURE_FILTER_MIPMAP_LINEAR, &mui->textures.bg); @@ -1843,7 +1844,7 @@ static bool mui_load_image(void *userdata, void *data, enum menu_image_type type } /* Compute the scroll value depending on the highlighted entry */ -static float mui_get_scroll(mui_handle_t *mui) +static float materialui_get_scroll(materialui_handle_t *mui) { unsigned width, height, half = 0; size_t selection = menu_navigation_get_selection(); @@ -1864,11 +1865,11 @@ static float mui_get_scroll(mui_handle_t *mui) /* The navigation pointer has been updated (for example by pressing up or down on the keyboard). We use this function to animate the scroll. */ -static void mui_navigation_set(void *data, bool scroll) +static void materialui_navigation_set(void *data, bool scroll) { menu_animation_ctx_entry_t entry; - mui_handle_t *mui = (mui_handle_t*)data; - float scroll_pos = mui ? mui_get_scroll(mui) : 0.0f; + materialui_handle_t *mui = (materialui_handle_t*)data; + float scroll_pos = mui ? materialui_get_scroll(mui) : 0.0f; if (!mui || !scroll) return; @@ -1885,16 +1886,16 @@ static void mui_navigation_set(void *data, bool scroll) menu_animation_push(&entry); } -static void mui_list_set_selection(void *data, file_list_t *list) +static void materialui_list_set_selection(void *data, file_list_t *list) { - mui_navigation_set(data, true); + materialui_navigation_set(data, true); } /* The navigation pointer is set back to zero */ -static void mui_navigation_clear(void *data, bool pending_push) +static void materialui_navigation_clear(void *data, bool pending_push) { size_t i = 0; - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; @@ -1902,51 +1903,51 @@ static void mui_navigation_clear(void *data, bool pending_push) mui->scroll_y = 0; } -static void mui_navigation_set_last(void *data) +static void materialui_navigation_set_last(void *data) { - mui_navigation_set(data, true); + materialui_navigation_set(data, true); } -static void mui_navigation_alphabet(void *data, size_t *unused) +static void materialui_navigation_alphabet(void *data, size_t *unused) { - mui_navigation_set(data, true); + materialui_navigation_set(data, true); } /* A new list had been pushed. We update the scroll value */ -static void mui_populate_entries( +static void materialui_populate_entries( void *data, const char *path, const char *label, unsigned i) { - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; mui->need_compute = true; - mui->scroll_y = mui_get_scroll(mui); + mui->scroll_y = materialui_get_scroll(mui); } /* Context reset is called on launch or when a core is launched */ -static void mui_context_reset(void *data, bool is_threaded) +static void materialui_context_reset(void *data, bool is_threaded) { - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; settings_t *settings = config_get_ptr(); if (!mui || !settings) return; - mui_layout(mui, is_threaded); - mui_context_bg_destroy(mui); + materialui_layout(mui, is_threaded); + materialui_context_bg_destroy(mui); menu_display_allocate_white_texture(); - mui_context_reset_textures(mui); + materialui_context_reset_textures(mui); if (filestream_exists(settings->paths.path_menu_wallpaper)) task_push_image_load(settings->paths.path_menu_wallpaper, menu_display_handle_wallpaper_upload, NULL); } -static int mui_environ(enum menu_environ_cb type, void *data, void *userdata) +static int materialui_environ(enum menu_environ_cb type, void *data, void *userdata) { - mui_handle_t *mui = (mui_handle_t*)userdata; + materialui_handle_t *mui = (materialui_handle_t*)userdata; switch (type) { @@ -1969,7 +1970,7 @@ static int mui_environ(enum menu_environ_cb type, void *data, void *userdata) } /* Called before we push the new list after clicking on a tab */ -static void mui_preswitch_tabs(mui_handle_t *mui, unsigned action) +static void materialui_preswitch_tabs(materialui_handle_t *mui, unsigned action) { size_t stack_size = 0; file_list_t *menu_stack = NULL; @@ -2009,11 +2010,11 @@ static void mui_preswitch_tabs(mui_handle_t *mui, unsigned action) /* This callback is not caching anything. We use it to navigate the tabs with the keyboard */ -static void mui_list_cache(void *data, +static void materialui_list_cache(void *data, enum menu_list_type type, unsigned action) { size_t list_size; - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return; @@ -2050,7 +2051,7 @@ static void mui_list_cache(void *data, break; } - mui_preswitch_tabs(mui, action); + materialui_preswitch_tabs(mui, action); break; default: break; @@ -2059,7 +2060,7 @@ static void mui_list_cache(void *data, /* A new list has been pushed. We use this callback to customize a few lists for this menu driver */ -static int mui_list_push(void *data, void *userdata, +static int materialui_list_push(void *data, void *userdata, menu_displaylist_info_t *info, unsigned type) { menu_displaylist_ctx_parse_entry_t entry; @@ -2220,9 +2221,9 @@ static int mui_list_push(void *data, void *userdata, } /* Returns the active tab id */ -static size_t mui_list_get_selection(void *data) +static size_t materialui_list_get_selection(void *data) { - mui_handle_t *mui = (mui_handle_t*)data; + materialui_handle_t *mui = (materialui_handle_t*)data; if (!mui) return 0; @@ -2232,7 +2233,7 @@ static size_t mui_list_get_selection(void *data) /* The pointer or the mouse is pressed down. We use this callback to highlight the entry that has been pressed */ -static int mui_pointer_down(void *userdata, +static int materialui_pointer_down(void *userdata, unsigned x, unsigned y, unsigned ptr, menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) @@ -2240,7 +2241,7 @@ static int mui_pointer_down(void *userdata, unsigned width, height; unsigned header_height; size_t entries_end = menu_entries_get_size(); - mui_handle_t *mui = (mui_handle_t*)userdata; + materialui_handle_t *mui = (materialui_handle_t*)userdata; if (!mui) return 0; @@ -2263,7 +2264,7 @@ static int mui_pointer_down(void *userdata, for (ii = 0; ii < entries_end; ii++) { - mui_node_t *node = (mui_node_t*) + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, ii); if (y > (-mui->scroll_y + header_height + node->y) @@ -2282,7 +2283,7 @@ static int mui_pointer_down(void *userdata, If we clicked on the header, we perform a cancel action. If we clicked on the tabs, we switch to a new list. If we clicked on a menu entry, we call the entry action callback. */ -static int mui_pointer_up(void *userdata, +static int materialui_pointer_up(void *userdata, unsigned x, unsigned y, unsigned ptr, menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) @@ -2290,7 +2291,7 @@ static int mui_pointer_up(void *userdata, unsigned width, height; unsigned header_height, i; size_t entries_end = menu_entries_get_size(); - mui_handle_t *mui = (mui_handle_t*)userdata; + materialui_handle_t *mui = (materialui_handle_t*)userdata; if (!mui) return 0; @@ -2317,7 +2318,7 @@ static int mui_pointer_up(void *userdata, { mui->categories_selection_ptr = i; - mui_preswitch_tabs(mui, action); + materialui_preswitch_tabs(mui, action); if (cbs && cbs->action_content_list_switch) return cbs->action_content_list_switch(selection_buf, menu_stack, @@ -2332,7 +2333,7 @@ static int mui_pointer_up(void *userdata, for (ii = 0; ii < entries_end; ii++) { - mui_node_t *node = (mui_node_t*) + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, ii); if (y > (-mui->scroll_y + header_height + node->y) @@ -2352,9 +2353,9 @@ static int mui_pointer_up(void *userdata, * It is used in the shaders UI, the wifi UI, * the netplay lobby, etc. * - * This function allocates the mui_node_t + * This function allocates the materialui_node_t *for the new entry. */ -static void mui_list_insert(void *userdata, +static void materialui_list_insert(void *userdata, file_list_t *list, const char *path, const char *fullpath, @@ -2363,19 +2364,19 @@ static void mui_list_insert(void *userdata, unsigned type) { float scale_factor; - int i = (int)list_size; - mui_node_t *node = NULL; - settings_t *settings = config_get_ptr(); - mui_handle_t *mui = (mui_handle_t*)userdata; + int i = (int)list_size; + materialui_node_t *node = NULL; + settings_t *settings = config_get_ptr(); + materialui_handle_t *mui = (materialui_handle_t*)userdata; if (!mui || !list) return; mui->need_compute = true; - node = (mui_node_t*)file_list_get_userdata_at_offset(list, i); + node = (materialui_node_t*)file_list_get_userdata_at_offset(list, i); if (!node) - node = (mui_node_t*)calloc(1, sizeof(mui_node_t)); + node = (materialui_node_t*)calloc(1, sizeof(materialui_node_t)); if (!node) { @@ -2769,16 +2770,16 @@ static void mui_list_insert(void *userdata, } /* Clearing the current menu list */ -static void mui_list_clear(file_list_t *list) +static void materialui_list_clear(file_list_t *list) { size_t i; - size_t size = list->size; + size_t size = list ? list->size : 0; for (i = 0; i < size; ++i) { menu_animation_ctx_subject_t subject; float *subjects[2]; - mui_node_t *node = (mui_node_t*) + materialui_node_t *node = (materialui_node_t*) file_list_get_userdata_at_offset(list, i); if (!node) @@ -2798,46 +2799,46 @@ static void mui_list_clear(file_list_t *list) menu_ctx_driver_t menu_ctx_mui = { NULL, - mui_get_message, + materialui_get_message, generic_menu_iterate, - mui_render, - mui_frame, - mui_init, - mui_free, - mui_context_reset, - mui_context_destroy, - mui_populate_entries, + materialui_render, + materialui_frame, + materialui_init, + materialui_free, + materialui_context_reset, + materialui_context_destroy, + materialui_populate_entries, NULL, - mui_navigation_clear, + materialui_navigation_clear, NULL, NULL, - mui_navigation_set, - mui_navigation_set_last, - mui_navigation_alphabet, - mui_navigation_alphabet, + materialui_navigation_set, + materialui_navigation_set_last, + materialui_navigation_alphabet, + materialui_navigation_alphabet, generic_menu_init_list, - mui_list_insert, + materialui_list_insert, NULL, NULL, - mui_list_clear, - mui_list_cache, - mui_list_push, - mui_list_get_selection, - mui_list_get_size, + materialui_list_clear, + materialui_list_cache, + materialui_list_push, + materialui_list_get_selection, + materialui_list_get_size, NULL, - mui_list_set_selection, + materialui_list_set_selection, NULL, - mui_load_image, + materialui_load_image, "glui", - mui_environ, + materialui_environ, NULL, NULL, NULL, NULL, NULL, - mui_osk_ptr_at_pos, + materialui_osk_ptr_at_pos, NULL, NULL, - mui_pointer_down, - mui_pointer_up, + materialui_pointer_down, + materialui_pointer_up, };