From 29f8189d0eb2279ddbce4f1670cfb66d96b0f09c Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 4 Mar 2020 17:07:49 +0000 Subject: [PATCH] Add independent widget scale override settings for fullscreen/windowed modes --- config.def.h | 5 ++++- configuration.c | 1 + configuration.h | 1 + gfx/gfx_display.c | 16 +++++++++++----- gfx/gfx_display.h | 6 ++++-- gfx/gfx_widgets.c | 24 ++++++++++++------------ gfx/gfx_widgets.h | 6 +++--- intl/msg_hash_fr.h | 4 ++-- intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_pt_br.h | 4 ++-- intl/msg_hash_us.h | 12 ++++++++++-- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 8 ++++++++ menu/menu_setting.c | 15 +++++++++++++++ msg_hash.h | 1 + retroarch.c | 13 ++++++++++--- 16 files changed, 90 insertions(+), 32 deletions(-) diff --git a/config.def.h b/config.def.h index 80a218d63a..fd86393c2b 100644 --- a/config.def.h +++ b/config.def.h @@ -979,8 +979,11 @@ static const unsigned playlist_entry_remove_enable = PLAYLIST_ENTRY_REMOVE_ENABL * automatically using the default menu scale factor */ #define DEFAULT_MENU_WIDGET_SCALE_AUTO true /* Default scale factor for menu widgets when widget - * auto scaling is disabled */ + * auto scaling is disabled (fullscreen mode) */ #define DEFAULT_MENU_WIDGET_SCALE_FACTOR 1.0f +/* Default scale factor for menu widgets when widget + * auto scaling is disabled (windowed mode) */ +#define DEFAULT_MENU_WIDGET_SCALE_FACTOR_WINDOWED 1.0f /* Log level for the frontend */ #define DEFAULT_FRONTEND_LOG_LEVEL 1 diff --git a/configuration.c b/configuration.c index 545281ea74..bab610d52a 100644 --- a/configuration.c +++ b/configuration.c @@ -1698,6 +1698,7 @@ static struct config_float_setting *populate_settings_float(settings_t *settings #ifdef HAVE_MENU SETTING_FLOAT("menu_scale_factor", &settings->floats.menu_scale_factor, true, DEFAULT_MENU_SCALE_FACTOR, false); SETTING_FLOAT("menu_widget_scale_factor", &settings->floats.menu_widget_scale_factor, true, DEFAULT_MENU_WIDGET_SCALE_FACTOR, false); + SETTING_FLOAT("menu_widget_scale_factor_windowed", &settings->floats.menu_widget_scale_factor_windowed, true, DEFAULT_MENU_WIDGET_SCALE_FACTOR_WINDOWED, false); SETTING_FLOAT("menu_wallpaper_opacity", &settings->floats.menu_wallpaper_opacity, true, menu_wallpaper_opacity, false); SETTING_FLOAT("menu_framebuffer_opacity", &settings->floats.menu_framebuffer_opacity, true, menu_framebuffer_opacity, false); SETTING_FLOAT("menu_footer_opacity", &settings->floats.menu_footer_opacity, true, menu_footer_opacity, false); diff --git a/configuration.h b/configuration.h index c11ad65a80..1dd01f6dc0 100644 --- a/configuration.h +++ b/configuration.h @@ -409,6 +409,7 @@ typedef struct settings float menu_scale_factor; float menu_widget_scale_factor; + float menu_widget_scale_factor_windowed; float menu_wallpaper_opacity; float menu_framebuffer_opacity; float menu_footer_opacity; diff --git a/gfx/gfx_display.c b/gfx/gfx_display.c index 58208f0b7a..2b466814c0 100644 --- a/gfx/gfx_display.c +++ b/gfx/gfx_display.c @@ -391,7 +391,8 @@ float gfx_display_get_dpi_scale(unsigned width, unsigned height) return adjusted_scale; } -float gfx_display_get_widget_dpi_scale(unsigned width, unsigned height) +float gfx_display_get_widget_dpi_scale( + unsigned width, unsigned height, bool fullscreen) { static unsigned last_width = 0; static unsigned last_height = 0; @@ -404,7 +405,9 @@ float gfx_display_get_widget_dpi_scale(unsigned width, unsigned height) settings_t *settings = config_get_ptr(); bool gfx_widget_scale_auto = settings->bools.menu_widget_scale_auto; float _menu_scale_factor = settings->floats.menu_scale_factor; - float menu_widget_scale_factor = settings->floats.menu_widget_scale_factor; + float menu_widget_scale_factor = fullscreen ? + settings->floats.menu_widget_scale_factor : + settings->floats.menu_widget_scale_factor_windowed; /* When using RGUI, _menu_scale_factor * is ignored @@ -446,7 +449,8 @@ float gfx_display_get_widget_dpi_scale(unsigned width, unsigned height) return adjusted_scale; } -float gfx_display_get_widget_pixel_scale(unsigned width, unsigned height) +float gfx_display_get_widget_pixel_scale( + unsigned width, unsigned height, bool fullscreen) { static unsigned last_width = 0; static unsigned last_height = 0; @@ -457,9 +461,11 @@ float gfx_display_get_widget_pixel_scale(unsigned width, unsigned height) static enum menu_driver_id_type last_menu_driver_id = MENU_DRIVER_ID_UNKNOWN; static float adjusted_scale = 1.0f; settings_t *settings = config_get_ptr(); - float _menu_scale_factor = settings->floats.menu_scale_factor; - float menu_widget_scale_factor = settings->floats.menu_widget_scale_factor; bool gfx_widget_scale_auto = settings->bools.menu_widget_scale_auto; + float _menu_scale_factor = settings->floats.menu_scale_factor; + float menu_widget_scale_factor = fullscreen ? + settings->floats.menu_widget_scale_factor : + settings->floats.menu_widget_scale_factor_windowed; /* When using RGUI, _menu_scale_factor is ignored * > If we are not using a widget scale factor override, diff --git a/gfx/gfx_display.h b/gfx/gfx_display.h index e9ce317738..a87d159135 100644 --- a/gfx/gfx_display.h +++ b/gfx/gfx_display.h @@ -331,9 +331,11 @@ void gfx_display_set_driver_id(enum menu_driver_id_type type); float gfx_display_get_dpi_scale(unsigned width, unsigned height); -float gfx_display_get_widget_dpi_scale(unsigned width, unsigned height); +float gfx_display_get_widget_dpi_scale( + unsigned width, unsigned height, bool fullscreen); -float gfx_display_get_widget_pixel_scale(unsigned width, unsigned height); +float gfx_display_get_widget_pixel_scale( + unsigned width, unsigned height, bool fullscreen); void gfx_display_allocate_white_texture(void); diff --git a/gfx/gfx_widgets.c b/gfx/gfx_widgets.c index 81e9c926cb..942abce850 100644 --- a/gfx/gfx_widgets.c +++ b/gfx/gfx_widgets.c @@ -923,7 +923,7 @@ bool menu_driver_get_load_content_animation_data( #endif void gfx_widgets_iterate( - unsigned width, unsigned height, + unsigned width, unsigned height, bool fullscreen, const char *dir_assets, char *font_path, bool is_threaded) { @@ -931,9 +931,9 @@ void gfx_widgets_iterate( /* Check whether screen dimensions or menu scale * factor have changed */ - float scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) - ? gfx_display_get_widget_pixel_scale(width, height) - : gfx_display_get_widget_dpi_scale(width, height); + float scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) ? + gfx_display_get_widget_pixel_scale(width, height, fullscreen) : + gfx_display_get_widget_dpi_scale(width, height, fullscreen); if ((scale_factor != last_scale_factor) || (width != last_video_width) || @@ -1933,7 +1933,7 @@ void gfx_widgets_frame(void *data) gfx_display_unset_viewport(video_info->width, video_info->height); } -bool gfx_widgets_init(bool video_is_threaded) +bool gfx_widgets_init(bool video_is_threaded, bool fullscreen) { if (!gfx_display_init_first_driver(video_is_threaded)) goto error; @@ -1959,9 +1959,9 @@ bool gfx_widgets_init(bool video_is_threaded) * > XMB uses pixel based scaling - all other drivers * use DPI based scaling */ video_driver_get_size(&last_video_width, &last_video_height); - last_scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) - ? gfx_display_get_widget_pixel_scale(last_video_width, last_video_height) - : gfx_display_get_widget_dpi_scale(last_video_width, last_video_height); + last_scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) ? + gfx_display_get_widget_pixel_scale(last_video_width, last_video_height, fullscreen) : + gfx_display_get_widget_dpi_scale(last_video_width, last_video_height, fullscreen); return true; @@ -2097,7 +2097,7 @@ static void gfx_widgets_layout( } void gfx_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height, + unsigned width, unsigned height, bool fullscreen, const char *dir_assets, char *font_path) { int i; @@ -2158,9 +2158,9 @@ void gfx_widgets_context_reset(bool is_threaded, /* Update scaling/dimensions */ last_video_width = width; last_video_height = height; - last_scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) - ? gfx_display_get_widget_pixel_scale(last_video_width, last_video_height) - : gfx_display_get_widget_dpi_scale(last_video_width, last_video_height); + last_scale_factor = (gfx_display_get_driver_id() == MENU_DRIVER_ID_XMB) ? + gfx_display_get_widget_pixel_scale(last_video_width, last_video_height, fullscreen) : + gfx_display_get_widget_dpi_scale(last_video_width, last_video_height, fullscreen); gfx_widgets_layout(is_threaded, dir_assets, font_path); video_driver_monitor_reset(); diff --git a/gfx/gfx_widgets.h b/gfx/gfx_widgets.h index dbffd9eae6..6470c10cc2 100644 --- a/gfx/gfx_widgets.h +++ b/gfx/gfx_widgets.h @@ -40,7 +40,7 @@ #define HOURGLASS_DURATION 1000 #define GENERIC_MESSAGE_DURATION 3000 -bool gfx_widgets_init(bool video_is_threaded); +bool gfx_widgets_init(bool video_is_threaded, bool fullscreen); void gfx_widgets_free(void); @@ -57,7 +57,7 @@ void gfx_widgets_volume_update_and_show(float new_volume, bool mute); void gfx_widgets_iterate( - unsigned width, unsigned height, + unsigned width, unsigned height, bool fullscreen, const char *dir_assets, char *font_path, bool is_threaded); @@ -81,7 +81,7 @@ void gfx_widgets_start_load_content_animation( void gfx_widgets_cleanup_load_content_animation(void); void gfx_widgets_context_reset(bool is_threaded, - unsigned width, unsigned height, + unsigned width, unsigned height, bool fullscreen, const char *dir_assets, char *font_path); void gfx_widgets_push_achievement(const char *title, const char *badge); diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 197c8c5346..28420ea78b 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -934,11 +934,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, - "Remplacement de l'échelle des widgets graphiques" + "Remplacement de l'échelle des widgets graphiques (plein écran)" ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR, - "Applique une valeur manuelle de remplacement du facteur d'échelle pour l'affichage des widgets graphiques. Cette valeur est appliquée uniquement si l'option 'Mise à l'échelle automatique des widgets graphiques' est désactivée. Peut être utile pour augmenter ou réduire la taille des notifications améliorées, indicateurs et commandes indépendamment du menu lui-même." + "Applique une valeur manuelle de remplacement du facteur d'échelle pour l'affichage des widgets graphiques en mode plein écran. Cette valeur est appliquée uniquement si l'option 'Mise à l'échelle automatique des widgets graphiques' est désactivée. Peut être utile pour augmenter ou réduire la taille des notifications améliorées, indicateurs et commandes indépendamment du menu lui-même." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 55bdec12c8..b83471a93b 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -508,6 +508,8 @@ MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO, "menu_widget_scale_auto") MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, "menu_widget_scale_factor") +MSG_HASH(MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + "menu_widget_scale_factor_windowed") MSG_HASH(MENU_ENUM_LABEL_DRIVER_SETTINGS, "driver_settings") MSG_HASH(MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 2326dc92ea..3cf267ce02 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -934,11 +934,11 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, - "Substituição da escala dos widgets gráficos" + "Substituição da escala dos widgets gráficos (tela cheia)" ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR, - "Aplica uma substituição manual da escala ao desenhar os widgets do menu. Aplica-se apenas quando 'Escala automática nos widgets gráficos' está desativado. Pode ser usado para aumentar ou diminuir o tamanho das notificações, indicadores e controles decorados independentemente do próprio menu." + "Aplica uma substituição manual da escala ao desenhar os widgets do menu no modo de tela cheia. Aplica-se apenas quando 'Escala automática nos widgets gráficos' está desativado. Pode ser usado para aumentar ou diminuir o tamanho das notificações, indicadores e controles decorados independentemente do próprio menu." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 2b21ba6e8c..582ca6dd8f 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -938,11 +938,19 @@ MSG_HASH( ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR, - "Graphics Widgets Scale Override" + "Graphics Widgets Scale Override (Fullscreen)" ) MSG_HASH( MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR, - "Applies a manual scaling factor override when drawing menu widgets. Only applies when 'Auto Scale Graphics Widgets' is disabled. Can be used to increase or decrease the size of decorated notifications, indicators and controls independently from the menu itself." + "Applies a manual scaling factor override when drawing menu widgets in fullscreen mode. Only applies when 'Auto Scale Graphics Widgets' is disabled. Can be used to increase or decrease the size of decorated notifications, indicators and controls independently from the menu itself." + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + "Graphics Widgets Scale Override (Windowed)" + ) +MSG_HASH( + MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + "Applies a manual scaling factor override when drawing menu widgets in windowed mode. Only applies when 'Auto Scale Graphics Widgets' is disabled. Can be used to increase or decrease the size of decorated notifications, indicators and controls independently from the menu itself." ) MSG_HASH( MENU_ENUM_LABEL_VALUE_DRIVER_SETTINGS, diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index ce10ec14d7..03404dd579 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -547,6 +547,7 @@ default_sublabel_macro(action_bind_sublabel_menu_use_preferred_system_color_them default_sublabel_macro(action_bind_sublabel_menu_scale_factor, MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR) default_sublabel_macro(action_bind_sublabel_menu_widget_scale_auto, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_AUTO) default_sublabel_macro(action_bind_sublabel_menu_widget_scale_factor, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR) +default_sublabel_macro(action_bind_sublabel_menu_widget_scale_factor_windowed, MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED) 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) default_sublabel_macro(action_bind_sublabel_menu_horizontal_animation, MENU_ENUM_SUBLABEL_MENU_HORIZONTAL_ANIMATION) @@ -1797,6 +1798,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_factor); break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_factor_windowed); + break; case MENU_ENUM_LABEL_MENU_WALLPAPER_OPACITY: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_wallpaper_opacity); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index fd9cc0d24e..96662464a2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6595,6 +6595,7 @@ unsigned menu_displaylist_build_list( {MENU_ENUM_LABEL_MENU_WIDGETS_ENABLE, PARSE_ONLY_BOOL, true }, {MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO, PARSE_ONLY_BOOL, false }, {MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR, PARSE_ONLY_FLOAT, false }, + {MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED, PARSE_ONLY_FLOAT, false }, {MENU_ENUM_LABEL_FPS_SHOW, PARSE_ONLY_BOOL, false }, {MENU_ENUM_LABEL_FPS_UPDATE_INTERVAL, PARSE_ONLY_UINT, false }, {MENU_ENUM_LABEL_FRAMECOUNT_SHOW, PARSE_ONLY_BOOL, false }, @@ -6642,6 +6643,13 @@ unsigned menu_displaylist_build_list( if (menu_enable_widgets) if (!menu_widget_scale_auto) build_list[i].checked = true; +#endif + break; + case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED: +#ifdef HAVE_GFX_WIDGETS + if (menu_enable_widgets) + if (!menu_widget_scale_auto) + build_list[i].checked = true; #endif break; default: diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 3232723f70..0947cabbd4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -11906,6 +11906,21 @@ static bool setting_append_list( general_read_handler); (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; menu_settings_list_current_add_range(list, list_info, 0.2, 5.0, 0.01, true, true); + + CONFIG_FLOAT( + list, list_info, + &settings->floats.menu_widget_scale_factor_windowed, + MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + DEFAULT_MENU_WIDGET_SCALE_FACTOR_WINDOWED, + "%.2fx", + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; + menu_settings_list_current_add_range(list, list_info, 0.2, 5.0, 0.01, true, true); #endif CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index fe556d4715..e672c3ac90 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -519,6 +519,7 @@ enum msg_hash_enums MENU_LABEL(MENU_SCALE_FACTOR), MENU_LABEL(MENU_WIDGET_SCALE_AUTO), MENU_LABEL(MENU_WIDGET_SCALE_FACTOR), + MENU_LABEL(MENU_WIDGET_SCALE_FACTOR_WINDOWED), MENU_LABEL(MENU_WALLPAPER_OPACITY), MENU_LABEL(MENU_FRAMEBUFFER_OPACITY), MENU_LABEL(MENU_USE_PREFERRED_SYSTEM_COLOR_THEME), diff --git a/retroarch.c b/retroarch.c index 85e7aa9c7f..b17cb6e508 100644 --- a/retroarch.c +++ b/retroarch.c @@ -25100,12 +25100,16 @@ static void drivers_init(int flags) if (settings->bools.menu_enable_widgets && video_driver_has_widgets()) { + bool video_is_fullscreen = settings->bools.video_fullscreen || + rarch_force_fullscreen; + if (!gfx_widgets_inited) - gfx_widgets_inited = gfx_widgets_init(video_is_threaded); + gfx_widgets_inited = gfx_widgets_init( + video_is_threaded, video_is_fullscreen); if (gfx_widgets_inited) gfx_widgets_context_reset(video_is_threaded, - video_driver_width, video_driver_height, + video_driver_width, video_driver_height, video_is_fullscreen, settings->paths.directory_assets, settings->paths.path_font); else @@ -29044,9 +29048,12 @@ static enum runloop_state runloop_check_state(retro_time_t current_time) #if defined(HAVE_GFX_WIDGETS) if (gfx_widgets_inited) { + bool video_is_fullscreen = settings->bools.video_fullscreen || + rarch_force_fullscreen; + runloop_msg_queue_lock(); gfx_widgets_iterate( - video_driver_width, video_driver_height, + video_driver_width, video_driver_height, video_is_fullscreen, settings->paths.directory_assets, settings->paths.path_font, video_driver_is_threaded_internal());