diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index d23f313b1e..664692b503 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -678,6 +678,7 @@ static void mui_compute_entries_box(mui_handle_t* mui, int width) for (i = 0; i < entries_end; i++) { + menu_entry_t entry; char sublabel_str[255]; unsigned lines = 0; mui_node_t *node = (mui_node_t*) @@ -685,11 +686,14 @@ static void mui_compute_entries_box(mui_handle_t* mui, int width) sublabel_str[0] = '\0'; + menu_entry_init(&entry); + menu_entry_get(&entry, 0, i, NULL, true); + /* set texture_switch2 */ if (node->texture_switch2_set) texture_switch2 = node->texture_switch2; - if (menu_entry_get_sublabel(i, sublabel_str, sizeof(sublabel_str))) + if (menu_entry_get_sublabel(&entry, sublabel_str, sizeof(sublabel_str))) { int icon_margin = texture_switch2 ? mui->icon_size : 0; @@ -814,6 +818,7 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, 1.00, 1.00, 1.00, 1.00, }; + menu_entry_t entry; menu_animation_ctx_ticker_t ticker; char label_str[255]; char sublabel_str[255]; @@ -831,6 +836,9 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, label_str[0] = value_str[0] = sublabel_str[0] = '\0'; + menu_entry_init(&entry); + menu_entry_get(&entry, 0, i, NULL, true); + if (value_len * mui->glyph_width > usable_width / 2) value_len = (int)((usable_width/2) / mui->glyph_width); @@ -917,7 +925,7 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, } /* Sublabel */ - if (menu_entry_get_sublabel(i, sublabel_str, sizeof(sublabel_str))) + if (menu_entry_get_sublabel(&entry, sublabel_str, sizeof(sublabel_str))) { int icon_margin = texture_switch2 ? mui->icon_size : 0; @@ -965,6 +973,8 @@ static void mui_render_label_value(mui_handle_t *mui, mui_node_t *node, 1, switch_is_on ? &label_color[0] : &pure_white[0] ); + + menu_entry_free(&entry); } static void mui_render_menu_list( diff --git a/menu/widgets/menu_entry.c b/menu/widgets/menu_entry.c index 7c0be8fb91..fd4782a7fb 100644 --- a/menu/widgets/menu_entry.c +++ b/menu/widgets/menu_entry.c @@ -113,17 +113,14 @@ void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len) strlcpy(s, entry->path, len); } -bool menu_entry_get_sublabel(uint32_t i, char *s, size_t len) +bool menu_entry_get_sublabel(menu_entry_t *entry, char *s, size_t len) { - menu_entry_t entry; - - menu_entry_init(&entry); - menu_entry_get(&entry, 0, i, NULL, true); - - if (string_is_empty(entry.sublabel)) + if (!entry) + return false; + if (string_is_empty(entry->sublabel)) return false; - strlcpy(s, entry.sublabel, len); + strlcpy(s, entry->sublabel, len); return true; } diff --git a/menu/widgets/menu_entry.h b/menu/widgets/menu_entry.h index 22cdc581ed..2fdd5d8f5b 100644 --- a/menu/widgets/menu_entry.h +++ b/menu/widgets/menu_entry.h @@ -95,7 +95,7 @@ void menu_entry_reset(uint32_t i); void menu_entry_get_rich_label(menu_entry_t *entry, char *s, size_t len); -bool menu_entry_get_sublabel(uint32_t i, char *s, size_t len); +bool menu_entry_get_sublabel(menu_entry_t *entry, char *s, size_t len); void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len);