From c0916c11af93858d75f94c2cbf43490541f60f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 17:23:04 +0700 Subject: [PATCH 1/6] (GLUI) Add a settings tab --- menu/drivers/glui.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index eb521c3dd4..7908a9d7ba 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -50,10 +50,11 @@ enum enum { GLUI_SYSTEM_TAB_MAIN = 0, - GLUI_SYSTEM_TAB_PLAYLISTS + GLUI_SYSTEM_TAB_PLAYLISTS, + GLUI_SYSTEM_TAB_SETTINGS }; -#define GLUI_SYSTEM_TAB_END GLUI_SYSTEM_TAB_PLAYLISTS +#define GLUI_SYSTEM_TAB_END GLUI_SYSTEM_TAB_SETTINGS struct glui_texture_item { @@ -720,6 +721,9 @@ static void glui_frame(void) case GLUI_SYSTEM_TAB_PLAYLISTS: strlcpy(tab_label, menu_hash_to_str(MENU_VALUE_PLAYLISTS_TAB), sizeof(tab_label)); break; + case GLUI_SYSTEM_TAB_SETTINGS: + strlcpy(tab_label, menu_hash_to_str(MENU_VALUE_SETTINGS_TAB), sizeof(tab_label)); + break; } strlcpy(tab_label, string_to_upper(tab_label), sizeof(tab_label)); @@ -1163,6 +1167,12 @@ static void glui_list_cache(menu_list_type_t type, unsigned action) menu_stack->list[stack_size - 1].type = MENU_PLAYLISTS_TAB; break; + case GLUI_SYSTEM_TAB_SETTINGS: + menu_stack->list[stack_size - 1].label = + strdup(menu_hash_to_str(MENU_VALUE_SETTINGS_TAB)); + menu_stack->list[stack_size - 1].type = + MENU_SETTINGS; + break; } break; } From 07ef7f23abdb9979a8f7049a23c7c402f0a5590b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 17:31:13 +0700 Subject: [PATCH 2/6] (GLUI) Move tabs to the bottom --- menu/drivers/glui.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 7908a9d7ba..33c6a52ee9 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -269,7 +269,7 @@ static void glui_draw_scrollbar(gl_t *gl, unsigned width, unsigned height, GRflo glui_render_quad(gl, width - scrollbar_width - (header_height / 12), - header_height + glui->tabs_height + y + (header_height / 12), + header_height + y + (header_height / 12), scrollbar_width, scrollbar_height, width, height, @@ -535,7 +535,7 @@ static void glui_render_menu_list(glui_handle_t *glui, gl_t *gl, if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) continue; - y = header_height + glui->tabs_height - menu->scroll_y + (glui->line_height * i); + y = header_height - menu->scroll_y + (glui->line_height * i); if (y > (int)height || ((y + (int)glui->line_height) < 0)) continue; @@ -681,7 +681,7 @@ static void glui_frame(void) /* highlighted entry */ glui_render_quad(gl, 0, - header_height + glui->tabs_height - menu->scroll_y + glui->line_height * + header_height - menu->scroll_y + glui->line_height * selection, width, glui->line_height, width, height, &lightblue_bg[0]); @@ -700,8 +700,8 @@ static void glui_frame(void) width, height, &blue_bg[0]); - /* shadow underneath header */ - glui_render_quad(gl, 0, header_height, width, + /* tabs background */ + glui_render_quad(gl, 0, height - glui->tabs_height, width, glui->tabs_height, width, height, &blue_bg[0]); @@ -728,19 +728,19 @@ static void glui_frame(void) strlcpy(tab_label, string_to_upper(tab_label), sizeof(tab_label)); glui_blit_line(width / (GLUI_SYSTEM_TAB_END+1) * (i+0.5), - header_height - header_height/8, + height - glui->tabs_height - header_height/8, width, height, tab_label, tab_color, TEXT_ALIGN_CENTER); } tab_width = width / (GLUI_SYSTEM_TAB_END+1); glui_render_quad(gl, glui->categories.selection_ptr * tab_width, - header_height + glui->tabs_height - (header_height/16), + height - (header_height/16), tab_width, header_height/16, width, height, &pure_white[0]); - glui_render_quad(gl, 0, header_height + glui->tabs_height, width, + glui_render_quad(gl, 0, header_height, width, header_height/12, width, height, &shadow_bg[0]); From 1eda4a094ff0a9748cba6221fa173df407ed572b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 17:40:06 +0700 Subject: [PATCH 3/6] (GLUI) Use a white theme for the tabs --- menu/drivers/glui.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 33c6a52ee9..9865746202 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -643,8 +643,8 @@ static void glui_frame(void) const uint32_t normal_color = 0x212121ff; const uint32_t hover_color = 0x212121ff; const uint32_t title_color = 0xffffffff; - const uint32_t activetab_color = 0xffffffff; - const uint32_t passivetab_color = 0xffffff88; + const uint32_t activetab_color = 0x0096f2ff; + const uint32_t passivetab_color = 0x9e9e9eff; if (!menu || !menu->userdata) return; @@ -704,7 +704,13 @@ static void glui_frame(void) glui_render_quad(gl, 0, height - glui->tabs_height, width, glui->tabs_height, width, height, - &blue_bg[0]); + &white_bg[0]); + + /* tabs separator */ + glui_render_quad(gl, 0, height - glui->tabs_height, width, + 1, + width, height, + &grey_bg[0]); for (i = 0; i <= GLUI_SYSTEM_TAB_END; i++) { @@ -738,7 +744,7 @@ static void glui_frame(void) tab_width, header_height/16, width, height, - &pure_white[0]); + &blue_bg[0]); glui_render_quad(gl, 0, header_height, width, header_height/12, From 2b1bbadc3b0ae10d2bb6d74724de2e03bf595cb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 18:24:37 +0700 Subject: [PATCH 4/6] (XMB) Use icons for tabs instead of labels --- menu/drivers/glui.c | 52 +++++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index 9865746202..ccffa27f07 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -44,6 +44,12 @@ enum GLUI_TEXTURE_BACK, GLUI_TEXTURE_SWITCH_ON, GLUI_TEXTURE_SWITCH_OFF, + GLUI_TEXTURE_TAB_MAIN_ACTIVE, + GLUI_TEXTURE_TAB_PLAYLISTS_ACTIVE, + GLUI_TEXTURE_TAB_SETTINGS_ACTIVE, + GLUI_TEXTURE_TAB_MAIN_PASSIVE, + GLUI_TEXTURE_TAB_PLAYLISTS_PASSIVE, + GLUI_TEXTURE_TAB_SETTINGS_PASSIVE, GLUI_TEXTURE_LAST }; @@ -135,6 +141,24 @@ static void glui_context_reset_textures(glui_handle_t *glui, const char *iconpat case GLUI_TEXTURE_SWITCH_OFF: fill_pathname_join(path, iconpath, "off.png", sizeof(path)); break; + case GLUI_TEXTURE_TAB_MAIN_ACTIVE: + fill_pathname_join(path, iconpath, "main_tab_active.png", sizeof(path)); + break; + case GLUI_TEXTURE_TAB_PLAYLISTS_ACTIVE: + fill_pathname_join(path, iconpath, "playlists_tab_active.png", sizeof(path)); + break; + case GLUI_TEXTURE_TAB_SETTINGS_ACTIVE: + fill_pathname_join(path, iconpath, "settings_tab_active.png", sizeof(path)); + break; + case GLUI_TEXTURE_TAB_MAIN_PASSIVE: + fill_pathname_join(path, iconpath, "main_tab_passive.png", sizeof(path)); + break; + case GLUI_TEXTURE_TAB_PLAYLISTS_PASSIVE: + fill_pathname_join(path, iconpath, "playlists_tab_passive.png", sizeof(path)); + break; + case GLUI_TEXTURE_TAB_SETTINGS_PASSIVE: + fill_pathname_join(path, iconpath, "settings_tab_passive.png", sizeof(path)); + break; } if (path[0] == '\0' || !path_file_exists(path)) @@ -714,28 +738,30 @@ static void glui_frame(void) for (i = 0; i <= GLUI_SYSTEM_TAB_END; i++) { - uint32_t tab_color = passivetab_color; - if (i == glui->categories.selection_ptr) - tab_color = activetab_color; - - char tab_label[PATH_MAX_LENGTH]; + unsigned tab_icon = GLUI_TEXTURE_TAB_MAIN_PASSIVE; switch (i) { case GLUI_SYSTEM_TAB_MAIN: - strlcpy(tab_label, menu_hash_to_str(MENU_VALUE_MAIN_MENU), sizeof(tab_label)); + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_MAIN_ACTIVE + : GLUI_TEXTURE_TAB_MAIN_PASSIVE; break; case GLUI_SYSTEM_TAB_PLAYLISTS: - strlcpy(tab_label, menu_hash_to_str(MENU_VALUE_PLAYLISTS_TAB), sizeof(tab_label)); + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_PLAYLISTS_ACTIVE + : GLUI_TEXTURE_TAB_PLAYLISTS_PASSIVE; break; case GLUI_SYSTEM_TAB_SETTINGS: - strlcpy(tab_label, menu_hash_to_str(MENU_VALUE_SETTINGS_TAB), sizeof(tab_label)); + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_SETTINGS_ACTIVE + : GLUI_TEXTURE_TAB_SETTINGS_PASSIVE; break; } - strlcpy(tab_label, string_to_upper(tab_label), sizeof(tab_label)); - glui_blit_line(width / (GLUI_SYSTEM_TAB_END+1) * (i+0.5), - height - glui->tabs_height - header_height/8, - width, height, tab_label, tab_color, TEXT_ALIGN_CENTER); + glui_draw_icon(gl, glui, glui->textures.list[tab_icon].id, + width / (GLUI_SYSTEM_TAB_END+1) * (i+0.5) - glui->icon_size/2, + height - glui->tabs_height, + width, height, 0, 1, &pure_white[0]); } tab_width = width / (GLUI_SYSTEM_TAB_END+1); @@ -851,7 +877,7 @@ static void glui_layout(menu_handle_t *menu, glui_handle_t *glui) new_header_height = scale_factor / 3; new_font_size = scale_factor / 9; - glui->tabs_height = scale_factor / 4; + glui->tabs_height = scale_factor / 3; glui->line_height = scale_factor / 3; glui->margin = scale_factor / 9; glui->icon_size = scale_factor / 3; From 0fa2e553b291c6f423cb6316e3d40ee893fa835f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 18:27:40 +0700 Subject: [PATCH 5/6] (XMB) Use pure white color when displaying an icon with GL --- menu/drivers/glui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index ccffa27f07..f6bea2af88 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -783,7 +783,7 @@ static void glui_frame(void) { title_margin = glui->icon_size; glui_draw_icon(gl, glui, glui->textures.list[GLUI_TEXTURE_BACK].id, - 0, 0, width, height, 0, 1, &white_bg[0]); + 0, 0, width, height, 0, 1, &pure_white[0]); } ticker_limit = (width - glui->margin*2) / glui->glyph_width; From cdfb274ac22f2ba8c42c611454802dfab4927b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 29 Oct 2015 18:36:57 +0700 Subject: [PATCH 6/6] (GLUI) Hide tabs if we're not on the root level of the navigation --- menu/drivers/glui.c | 125 ++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 58 deletions(-) diff --git a/menu/drivers/glui.c b/menu/drivers/glui.c index f6bea2af88..c0601cabf1 100644 --- a/menu/drivers/glui.c +++ b/menu/drivers/glui.c @@ -599,6 +599,22 @@ static void glui_draw_cursor(gl_t *gl, glui_handle_t *glui, MENU_DISPLAY_PRIM_TRIANGLESTRIP); } +static size_t glui_list_get_size(void *data, menu_list_type_t type) +{ + size_t list_size = 0; + menu_handle_t *menu = (menu_handle_t*)data; + glui_handle_t *glui = menu ? (glui_handle_t*)menu->userdata : NULL; + + /*switch (type) + { + case MENU_LIST_PLAIN:*/ + list_size = menu_entries_get_stack_size(0); + /*break; + }*/ + + return list_size; +} + static void glui_frame(void) { unsigned header_height; @@ -724,53 +740,62 @@ static void glui_frame(void) width, height, &blue_bg[0]); - /* tabs background */ - glui_render_quad(gl, 0, height - glui->tabs_height, width, - glui->tabs_height, - width, height, - &white_bg[0]); - - /* tabs separator */ - glui_render_quad(gl, 0, height - glui->tabs_height, width, - 1, - width, height, - &grey_bg[0]); - - for (i = 0; i <= GLUI_SYSTEM_TAB_END; i++) + /* display tabs if depth equal one, if not hide them */ + if (glui_list_get_size(menu, MENU_LIST_PLAIN) == 1) { - unsigned tab_icon = GLUI_TEXTURE_TAB_MAIN_PASSIVE; - switch (i) + /* tabs background */ + glui_render_quad(gl, 0, height - glui->tabs_height, width, + glui->tabs_height, + width, height, + &white_bg[0]); + + /* tabs separator */ + glui_render_quad(gl, 0, height - glui->tabs_height, width, + 1, + width, height, + &grey_bg[0]); + + for (i = 0; i <= GLUI_SYSTEM_TAB_END; i++) { - case GLUI_SYSTEM_TAB_MAIN: - tab_icon = (i == glui->categories.selection_ptr) - ? GLUI_TEXTURE_TAB_MAIN_ACTIVE - : GLUI_TEXTURE_TAB_MAIN_PASSIVE; - break; - case GLUI_SYSTEM_TAB_PLAYLISTS: - tab_icon = (i == glui->categories.selection_ptr) - ? GLUI_TEXTURE_TAB_PLAYLISTS_ACTIVE - : GLUI_TEXTURE_TAB_PLAYLISTS_PASSIVE; - break; - case GLUI_SYSTEM_TAB_SETTINGS: - tab_icon = (i == glui->categories.selection_ptr) - ? GLUI_TEXTURE_TAB_SETTINGS_ACTIVE - : GLUI_TEXTURE_TAB_SETTINGS_PASSIVE; - break; + unsigned tab_icon = GLUI_TEXTURE_TAB_MAIN_PASSIVE; + switch (i) + { + case GLUI_SYSTEM_TAB_MAIN: + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_MAIN_ACTIVE + : GLUI_TEXTURE_TAB_MAIN_PASSIVE; + break; + case GLUI_SYSTEM_TAB_PLAYLISTS: + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_PLAYLISTS_ACTIVE + : GLUI_TEXTURE_TAB_PLAYLISTS_PASSIVE; + break; + case GLUI_SYSTEM_TAB_SETTINGS: + tab_icon = (i == glui->categories.selection_ptr) + ? GLUI_TEXTURE_TAB_SETTINGS_ACTIVE + : GLUI_TEXTURE_TAB_SETTINGS_PASSIVE; + break; + } + + glui_draw_icon(gl, glui, glui->textures.list[tab_icon].id, + width / (GLUI_SYSTEM_TAB_END+1) * (i+0.5) - glui->icon_size/2, + height - glui->tabs_height, + width, height, 0, 1, &pure_white[0]); } - glui_draw_icon(gl, glui, glui->textures.list[tab_icon].id, - width / (GLUI_SYSTEM_TAB_END+1) * (i+0.5) - glui->icon_size/2, - height - glui->tabs_height, - width, height, 0, 1, &pure_white[0]); + /* active tab marker */ + tab_width = width / (GLUI_SYSTEM_TAB_END+1); + glui_render_quad(gl, glui->categories.selection_ptr * tab_width, + height - (header_height/16), + tab_width, + header_height/16, + width, height, + &blue_bg[0]); + } + else + { + glui->tabs_height = 0; } - - tab_width = width / (GLUI_SYSTEM_TAB_END+1); - glui_render_quad(gl, glui->categories.selection_ptr * tab_width, - height - (header_height/16), - tab_width, - header_height/16, - width, height, - &blue_bg[0]); glui_render_quad(gl, 0, header_height, width, header_height/12, @@ -1210,22 +1235,6 @@ static void glui_list_cache(menu_list_type_t type, unsigned action) } } -static size_t glui_list_get_size(void *data, menu_list_type_t type) -{ - size_t list_size = 0; - menu_handle_t *menu = (menu_handle_t*)data; - glui_handle_t *glui = menu ? (glui_handle_t*)menu->userdata : NULL; - - /*switch (type) - { - case MENU_LIST_PLAIN:*/ - list_size = menu_entries_get_stack_size(0); - /*break; - }*/ - - return list_size; -} - menu_ctx_driver_t menu_ctx_glui = { NULL, glui_get_message,