From 448b780a8b230d4ab2528a3fbe7421fd76517d73 Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Mon, 25 Feb 2019 12:24:59 +0000 Subject: [PATCH] (RGUI) Add 'full width' layout option --- config.def.h | 4 ++-- configuration.c | 7 ++++--- configuration.h | 1 + intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_us.h | 8 ++++++++ menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/drivers/rgui.c | 40 +++++++++++++++++++++++++----------- menu/menu_displaylist.c | 4 ++++ menu/menu_setting.c | 15 ++++++++++++++ msg_hash.h | 1 + 10 files changed, 69 insertions(+), 17 deletions(-) diff --git a/config.def.h b/config.def.h index 52d67d0a3a..e1c5e15638 100644 --- a/config.def.h +++ b/config.def.h @@ -378,12 +378,12 @@ static unsigned menu_shader_pipeline = 2; #endif static bool show_advanced_settings = false; + static unsigned rgui_color_theme = RGUI_THEME_CLASSIC_GREEN; static unsigned rgui_thumbnail_downscaler = RGUI_THUMB_SCALE_POINT; - static bool rgui_lock_aspect = false; - static unsigned rgui_internal_upscale_level = RGUI_UPSCALE_NONE; +static bool rgui_full_width_layout = true; #else static bool default_block_config_read = false; diff --git a/configuration.c b/configuration.c index 9e7c96302b..9327732352 100644 --- a/configuration.c +++ b/configuration.c @@ -1459,7 +1459,6 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("menu_use_preferred_system_color_theme", &settings->bools.menu_use_preferred_system_color_theme, true, menu_use_preferred_system_color_theme, false); SETTING_BOOL("content_show_settings", &settings->bools.menu_content_show_settings, true, content_show_settings, false); SETTING_BOOL("content_show_favorites", &settings->bools.menu_content_show_favorites, true, content_show_favorites, false); - SETTING_BOOL("menu_rgui_lock_aspect", &settings->bools.menu_rgui_lock_aspect, true, rgui_lock_aspect, false); #ifdef HAVE_IMAGEVIEWER SETTING_BOOL("content_show_images", &settings->bools.menu_content_show_images, true, content_show_images, false); #endif @@ -1498,9 +1497,11 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, SETTING_BOOL("materialui_icons_enable", &settings->bools.menu_materialui_icons_enable, true, materialui_icons_enable, false); #endif #ifdef HAVE_RGUI - SETTING_BOOL("rgui_background_filler_thickness_enable", &settings->bools.menu_rgui_background_filler_thickness_enable, true, true, false); + SETTING_BOOL("rgui_background_filler_thickness_enable", &settings->bools.menu_rgui_background_filler_thickness_enable, true, true, false); SETTING_BOOL("rgui_border_filler_thickness_enable", &settings->bools.menu_rgui_border_filler_thickness_enable, true, true, false); - SETTING_BOOL("rgui_border_filler_enable", &settings->bools.menu_rgui_border_filler_enable, true, true, false); + SETTING_BOOL("rgui_border_filler_enable", &settings->bools.menu_rgui_border_filler_enable, true, true, false); + SETTING_BOOL("menu_rgui_lock_aspect", &settings->bools.menu_rgui_lock_aspect, true, rgui_lock_aspect, false); + SETTING_BOOL("menu_rgui_full_width_layout", &settings->bools.menu_rgui_full_width_layout, true, rgui_full_width_layout, false); #endif #ifdef HAVE_XMB SETTING_BOOL("xmb_shadows_enable", &settings->bools.menu_xmb_shadows_enable, true, xmb_shadows_enable, false); diff --git a/configuration.h b/configuration.h index 995e41fb3a..3b55f2cffc 100644 --- a/configuration.h +++ b/configuration.h @@ -172,6 +172,7 @@ typedef struct settings bool menu_rgui_border_filler_thickness_enable; bool menu_rgui_border_filler_enable; bool menu_rgui_lock_aspect; + bool menu_rgui_full_width_layout; bool menu_xmb_shadows_enable; bool menu_xmb_vertical_thumbnails; bool menu_content_show_settings; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index afd9c20522..31fba11c18 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1603,6 +1603,8 @@ MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_LOCK_ASPECT, "menu_rgui_lock_aspect") MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_INTERNAL_UPSCALE_LEVEL, "rgui_internal_upscale_level") +MSG_HASH(MENU_ENUM_LABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, + "menu_rgui_full_width_layout") MSG_HASH(MENU_ENUM_LABEL_CONTENT_SHOW_REWIND, "menu_show_rewind_settings") MSG_HASH(MENU_ENUM_LABEL_CONTENT_SHOW_LATENCY, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 9799ea400b..6efa6135b8 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -6772,6 +6772,14 @@ MSG_HASH( MENU_ENUM_SUBLABEL_MENU_RGUI_INTERNAL_UPSCALE_LEVEL, "Upscale menu interface before drawing to screen. When used with 'Menu Linear Filter' enabled, removes scaling artefacts (uneven pixels) while maintaining a sharp image. Has a significant performance impact that increases with upscaling level." ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_RGUI_FULL_WIDTH_LAYOUT, + "Use Full-Width Layout" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, + "Resize and position menu entries to make best use of available screen space. Disable this to use classic fixed-width two column layout." + ) MSG_HASH( MENU_ENUM_SUBLABEL_CRT_SWITCH_RESOLUTION, "For CRT displays only. Attempts to use exact core/game resolution and refresh rate." diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 75cb730eab..bb979f7d82 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -526,6 +526,7 @@ default_sublabel_macro(action_bind_sublabel_menu_ticker_type, default_sublabel_macro(action_bind_sublabel_menu_ticker_speed, MENU_ENUM_SUBLABEL_MENU_TICKER_SPEED) default_sublabel_macro(action_bind_sublabel_playlist_show_core_name, MENU_ENUM_SUBLABEL_PLAYLIST_SHOW_CORE_NAME) default_sublabel_macro(action_bind_sublabel_playlist_sort_alphabetical, MENU_ENUM_SUBLABEL_PLAYLIST_SORT_ALPHABETICAL) +default_sublabel_macro(action_bind_sublabel_menu_rgui_full_width_layout, MENU_ENUM_SUBLABEL_MENU_RGUI_FULL_WIDTH_LAYOUT) static int action_bind_sublabel_systeminfo_controller_entry( file_list_t *list, @@ -2367,6 +2368,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_PLAYLIST_SORT_ALPHABETICAL: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_playlist_sort_alphabetical); break; + case MENU_ENUM_LABEL_MENU_RGUI_FULL_WIDTH_LAYOUT: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_rgui_full_width_layout); + break; default: case MSG_UNKNOWN: return -1; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 3d7581f84e..eb9e375161 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -62,6 +62,8 @@ #define RGUI_TERM_WIDTH(width) (((width - RGUI_TERM_START_X(width) - RGUI_TERM_START_X(width)) / (FONT_WIDTH_STRIDE))) #define RGUI_TERM_HEIGHT(width, height) (((height - RGUI_TERM_START_Y(height) - RGUI_TERM_START_X(width)) / (FONT_HEIGHT_STRIDE)) - 1) +#define RGUI_ENTRY_VALUE_MAXLEN 19 + #define RGUI_TICKER_SPACER " | " typedef struct @@ -1671,11 +1673,10 @@ static void rgui_render(void *data, bool is_idle) char type_str_buf[255]; menu_entry_t entry; char *entry_path = NULL; - unsigned entry_spacing = 0; size_t entry_title_max_len = 0; size_t entry_title_buf_utf8len = 0; size_t entry_title_buf_len = 0; - bool has_value = false; + unsigned entry_value_len = 0; bool entry_selected = menu_entry_is_currently_selected((unsigned)i); size_t selection = menu_navigation_get_selection(); @@ -1692,19 +1693,34 @@ static void rgui_render(void *data, bool is_idle) menu_entry_get(&entry, 0, (unsigned)i, NULL, true); /* Read entry parameters */ - entry_spacing = menu_entry_get_spacing(&entry); - menu_entry_get_value(&entry, entry_value, sizeof(entry_value)); entry_path = menu_entry_get_rich_label(&entry); + menu_entry_get_value(&entry, entry_value, sizeof(entry_value)); + + /* Get base width of entry title field */ + entry_title_max_len = RGUI_TERM_WIDTH(fb_width) - (1 + 2); /* Determine whether entry has a value component */ - has_value = !string_is_empty(entry_value); + if (!string_is_empty(entry_value)) + { + if (settings->bools.menu_rgui_full_width_layout) + { + /* Resize fields according to actual length of value string */ + entry_value_len = strlen(entry_value); + entry_value_len = entry_value_len > RGUI_ENTRY_VALUE_MAXLEN ? RGUI_ENTRY_VALUE_MAXLEN : entry_value_len; + } + else + { + /* Use classic fixed width layout */ + entry_value_len = menu_entry_get_spacing(&entry); + } + + /* Update width of entry title field */ + entry_title_max_len -= entry_value_len + 2; + } menu_entry_free(&entry); /* Format entry title string */ - entry_title_max_len = RGUI_TERM_WIDTH(fb_width) - (1 + 2); - entry_title_max_len = has_value ? entry_title_max_len - entry_spacing : entry_title_max_len; - ticker.s = entry_title_buf; ticker.len = entry_title_max_len; ticker.str = entry_path; @@ -1715,22 +1731,22 @@ static void rgui_render(void *data, bool is_idle) entry_title_buf_utf8len = utf8len(entry_title_buf); entry_title_buf_len = strlen(entry_title_buf); - if (has_value) + if (entry_value_len > 0) { /* Format entry value string */ ticker.s = type_str_buf; - ticker.len = entry_spacing; + ticker.len = entry_value_len; ticker.str = entry_value; menu_animation_ticker(&ticker); /* Print entry title + value */ - snprintf(message, sizeof(message), "%c %-*.*s %-.*s", + snprintf(message, sizeof(message), "%c %-*.*s %-.*s", entry_selected ? '>' : ' ', (int)(entry_title_max_len - entry_title_buf_utf8len + entry_title_buf_len), (int)(entry_title_max_len - entry_title_buf_utf8len + entry_title_buf_len), entry_title_buf, - entry_spacing, + entry_value_len, type_str_buf); } else diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6d0ec26a25..bf0e23e054 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6094,6 +6094,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist MENU_ENUM_LABEL_MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE, PARSE_ONLY_BOOL, false) == 0) count++; + if (menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, + PARSE_ONLY_BOOL, false) == 0) + count++; if (menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_MENU_LINEAR_FILTER, PARSE_ONLY_BOOL, false) == 0) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4ada39b89f..2386ec0611 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -8125,6 +8125,21 @@ static bool setting_append_list( SD_FLAG_NONE ); + CONFIG_BOOL( + list, list_info, + &settings->bools.menu_rgui_full_width_layout, + MENU_ENUM_LABEL_MENU_RGUI_FULL_WIDTH_LAYOUT, + MENU_ENUM_LABEL_VALUE_MENU_RGUI_FULL_WIDTH_LAYOUT, + rgui_full_width_layout, + 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); + if (video_driver_get_all_flags(&flags, GFX_CTX_FLAGS_MENU_FRAME_FILTERING)) { CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index 6bdf894e81..444be356c0 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -860,6 +860,7 @@ enum msg_hash_enums MENU_LABEL(MENU_RGUI_BORDER_FILLER_THICKNESS_ENABLE), MENU_LABEL(MENU_RGUI_LOCK_ASPECT), MENU_LABEL(MENU_RGUI_INTERNAL_UPSCALE_LEVEL), + MENU_LABEL(MENU_RGUI_FULL_WIDTH_LAYOUT), MENU_LABEL(MENU_LINEAR_FILTER), MENU_LABEL(MENU_HORIZONTAL_ANIMATION), MENU_LABEL(NAVIGATION_WRAPAROUND),