From 279a2d58db7cdfb559009e31fb1983a7e116dd56 Mon Sep 17 00:00:00 2001 From: natinusala Date: Wed, 27 Feb 2019 15:21:26 +0100 Subject: [PATCH] ozone: add a setting to have the sidebar always collapsed --- config.def.h | 4 ++++ configuration.c | 4 ++++ configuration.h | 3 +++ intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/ozone/ozone.c | 4 ++++ menu/drivers/ozone/ozone_sidebar.c | 6 +++--- menu/menu_displaylist.c | 4 ++++ menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + 11 files changed, 52 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 35ba2611ed..cc8890caee 100644 --- a/config.def.h +++ b/config.def.h @@ -282,6 +282,10 @@ static bool menu_use_preferred_system_color_theme = true; static bool menu_use_preferred_system_color_theme = false; #endif +#ifdef HAVE_OZONE +static bool ozone_collapse_sidebar = false; +#endif + static bool quick_menu_show_take_screenshot = true; static bool quick_menu_show_save_load_state = true; static bool quick_menu_show_undo_save_load_state = true; diff --git a/configuration.c b/configuration.c index 25c4818a21..bf21360c34 100644 --- a/configuration.c +++ b/configuration.c @@ -1586,6 +1586,10 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("quit_press_twice", &settings->bools.quit_press_twice, true, quit_press_twice, false); SETTING_BOOL("vibrate_on_keypress", &settings->bools.vibrate_on_keypress, true, vibrate_on_keypress, false); +#ifdef HAVE_OZONE + SETTING_BOOL("ozone_collapse_sidebar", &settings->bools.ozone_collapse_sidebar, true, ozone_collapse_sidebar, false); +#endif + *size = count; return tmp; diff --git a/configuration.h b/configuration.h index d26334807d..ee26c7f766 100644 --- a/configuration.h +++ b/configuration.h @@ -316,6 +316,9 @@ typedef struct settings bool quit_press_twice; bool vibrate_on_keypress; +#ifdef HAVE_OZONE + bool ozone_collapse_sidebar; +#endif } bools; struct diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index be4a3d666c..22c84fb042 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -657,6 +657,8 @@ MSG_HASH(MENU_ENUM_LABEL_RGUI_MENU_THEME_PRESET, "rgui_menu_theme_preset") MSG_HASH(MENU_ENUM_LABEL_OZONE_MENU_COLOR_THEME, "ozone_menu_color_theme") +MSG_HASH(MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR, + "ozone_collapse_sidebar") MSG_HASH(MENU_ENUM_LABEL_MATERIALUI_MENU_COLOR_THEME, "materialui_menu_color_theme") MSG_HASH(MENU_ENUM_LABEL_MATERIALUI_MENU_FOOTER_OPACITY, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index d5619cf3a0..a8df1293f7 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -8206,6 +8206,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME, "Select a different color theme." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_OZONE_COLLAPSE_SIDEBAR, + "Collapse the sidebar" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR, + "Have the left sidebar always collapsed." + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME, "Use preferred system color theme" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 2c168f2a4d..e873d644c1 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -393,6 +393,7 @@ default_sublabel_macro(action_bind_sublabel_xmb_shadows_enable, default_sublabel_macro(action_bind_sublabel_xmb_vertical_thumbnails, MENU_ENUM_SUBLABEL_XMB_VERTICAL_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_menu_color_theme, MENU_ENUM_SUBLABEL_MATERIALUI_MENU_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_ozone_menu_color_theme, MENU_ENUM_SUBLABEL_OZONE_MENU_COLOR_THEME) +default_sublabel_macro(action_bind_sublabel_ozone_collapse_sidebar, MENU_ENUM_SUBLABEL_OZONE_COLLAPSE_SIDEBAR) default_sublabel_macro(action_bind_sublabel_menu_use_preferred_system_color_theme, MENU_ENUM_SUBLABEL_MENU_USE_PREFERRED_SYSTEM_COLOR_THEME) default_sublabel_macro(action_bind_sublabel_menu_wallpaper_opacity, MENU_ENUM_SUBLABEL_MENU_WALLPAPER_OPACITY) default_sublabel_macro(action_bind_sublabel_menu_framebuffer_opacity, MENU_ENUM_SUBLABEL_MENU_FRAMEBUFFER_OPACITY) @@ -1348,6 +1349,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_OZONE_MENU_COLOR_THEME: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_menu_color_theme); break; + case MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_ozone_collapse_sidebar); + break; case MENU_ENUM_LABEL_MATERIALUI_MENU_COLOR_THEME: case MENU_ENUM_LABEL_XMB_MENU_COLOR_THEME: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_color_theme); diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 5564e96bd2..d3ad825f15 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -159,6 +159,8 @@ static void *ozone_init(void **userdata, bool video_is_threaded) ozone->sidebar_collapsed = false; ozone->animations.sidebar_text_alpha = 1.0f; + ozone_sidebar_update_collapse(ozone, false); + ozone->system_tab_end = 0; ozone->tabs[ozone->system_tab_end] = OZONE_SYSTEM_TAB_MAIN; if (settings->bools.menu_content_show_settings && !settings->bools.kiosk_mode_enable) @@ -1305,6 +1307,8 @@ static void ozone_list_open(ozone_handle_t *ozone) /* Sidebar animation */ if (ozone->depth == 1) { + ozone_sidebar_update_collapse(ozone, false); + ozone->draw_sidebar = true; entry.cb = NULL; diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 676f82e117..65e0a8ed7f 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -31,8 +31,6 @@ #include "../../../configuration.h" -/* TODO Add an always collapsed sidebar setting */ - enum msg_hash_enums ozone_system_tabs_value[OZONE_SYSTEM_TAB_LAST] = { MENU_ENUM_LABEL_VALUE_MAIN_MENU, MENU_ENUM_LABEL_VALUE_SETTINGS_TAB, @@ -334,6 +332,7 @@ static void ozone_sidebar_collapse_end(void *userdata) void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation) { /* Collapse sidebar if needed */ + settings_t *settings = config_get_ptr(); bool is_playlist = ozone_is_playlist(ozone, false); menu_animation_ctx_tag tag = (uintptr_t)NULL; @@ -344,7 +343,7 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation) entry.userdata = ozone; entry.duration = ANIMATION_CURSOR_DURATION; - if (is_playlist && !ozone->sidebar_collapsed) + if (settings->bools.ozone_collapse_sidebar || (is_playlist && !ozone->sidebar_collapsed)) { if (allow_animation) { @@ -393,6 +392,7 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation) { ozone->animations.sidebar_text_alpha = 1.0f; ozone->dimensions.sidebar_width = ozone->dimensions.sidebar_width_normal; + ozone->sidebar_collapsed = false; } } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a2baa6d05f..921a1bc8e2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6183,6 +6183,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_OZONE_MENU_COLOR_THEME, PARSE_ONLY_UINT, false) == 0) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR, + PARSE_ONLY_BOOL, false) == 0) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MATERIALUI_ICONS_ENABLE, PARSE_ONLY_BOOL, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index befaf5c327..bf96ee76ce 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -9123,6 +9123,21 @@ static bool setting_append_list( (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_ozone_menu_color_theme; menu_settings_list_current_add_range(list, list_info, 0, 1, 1, true, true); + + CONFIG_BOOL( + list, list_info, + &settings->bools.ozone_collapse_sidebar, + MENU_ENUM_LABEL_OZONE_COLLAPSE_SIDEBAR, + MENU_ENUM_LABEL_VALUE_OZONE_COLLAPSE_SIDEBAR, + ozone_collapse_sidebar, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); } #endif diff --git a/msg_hash.h b/msg_hash.h index 9fb10c2671..a926440d7d 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -907,6 +907,7 @@ enum msg_hash_enums MENU_LABEL(RGUI_MENU_THEME_PRESET), MENU_LABEL(XMB_MENU_COLOR_THEME), MENU_LABEL(OZONE_MENU_COLOR_THEME), + MENU_LABEL(OZONE_COLLAPSE_SIDEBAR), MENU_LABEL(MATERIALUI_MENU_COLOR_THEME), MENU_LABEL(QUICK_MENU_OVERRIDE_OPTIONS), MENU_LABEL(QUICK_MENU_SHOW_TAKE_SCREENSHOT),