mirror of
https://github.com/libretro/RetroArch
synced 2025-03-02 19:13:34 +00:00
Merge pull request #10114 from jdgleaver/widget-scaling
(Menu Widgets) Add scaling
This commit is contained in:
commit
136163ba4f
@ -970,6 +970,12 @@ static const unsigned playlist_entry_remove_enable = PLAYLIST_ENTRY_REMOVE_ENABL
|
||||
/* Default scale factor for non-frambuffer-based menu
|
||||
* drivers and menu widgets */
|
||||
#define DEFAULT_MENU_SCALE_FACTOR 1.0f
|
||||
/* Specifies whether menu widgets should be scaled
|
||||
* 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 */
|
||||
#define DEFAULT_MENU_WIDGET_SCALE_FACTOR 1.0f
|
||||
|
||||
/* Log level for the frontend */
|
||||
#define DEFAULT_FRONTEND_LOG_LEVEL 1
|
||||
|
@ -1423,7 +1423,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
|
||||
SETTING_BOOL("keyboard_gamepad_enable", &settings->bools.input_keyboard_gamepad_enable, true, true, false);
|
||||
SETTING_BOOL("core_set_supports_no_game_enable", &settings->bools.set_supports_no_game_enable, true, true, false);
|
||||
SETTING_BOOL("audio_enable", &settings->bools.audio_enable, true, DEFAULT_AUDIO_ENABLE, false);
|
||||
SETTING_BOOL("menu_enable_widgets", &settings->bools.menu_enable_widgets, true, DEFAULT_MENU_ENABLE_WIDGETS, false);
|
||||
SETTING_BOOL("menu_enable_widgets", &settings->bools.menu_enable_widgets, true, DEFAULT_MENU_ENABLE_WIDGETS, false);
|
||||
SETTING_BOOL("menu_widget_scale_auto", &settings->bools.menu_widget_scale_auto, true, DEFAULT_MENU_WIDGET_SCALE_AUTO, false);
|
||||
SETTING_BOOL("audio_enable_menu", &settings->bools.audio_enable_menu, true, audio_enable_menu, false);
|
||||
SETTING_BOOL("audio_enable_menu_ok", &settings->bools.audio_enable_menu_ok, true, audio_enable_menu_ok, false);
|
||||
SETTING_BOOL("audio_enable_menu_cancel", &settings->bools.audio_enable_menu_cancel, true, audio_enable_menu_cancel, false);
|
||||
@ -1699,6 +1700,7 @@ static struct config_float_setting *populate_settings_float(settings_t *settings
|
||||
#endif
|
||||
#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_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);
|
||||
|
@ -151,6 +151,7 @@ typedef struct settings
|
||||
/* Menu */
|
||||
bool filter_by_current_core;
|
||||
bool menu_enable_widgets;
|
||||
bool menu_widget_scale_auto;
|
||||
bool menu_show_start_screen;
|
||||
bool menu_pause_libretro;
|
||||
bool menu_savestate_resume;
|
||||
@ -405,6 +406,7 @@ typedef struct settings
|
||||
float video_msg_bgcolor_opacity;
|
||||
|
||||
float menu_scale_factor;
|
||||
float menu_widget_scale_factor;
|
||||
float menu_wallpaper_opacity;
|
||||
float menu_framebuffer_opacity;
|
||||
float menu_footer_opacity;
|
||||
|
@ -502,6 +502,10 @@ MSG_HASH(MENU_ENUM_LABEL_CONTENT_DIR,
|
||||
"content_directory")
|
||||
MSG_HASH(MENU_ENUM_LABEL_MENU_SCALE_FACTOR,
|
||||
"menu_scale_factor")
|
||||
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_DRIVER_SETTINGS,
|
||||
"driver_settings")
|
||||
MSG_HASH(MENU_ENUM_LABEL_CHECK_FOR_MISSING_FIRMWARE,
|
||||
|
@ -916,6 +916,22 @@ MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_MENU_SCALE_FACTOR,
|
||||
"Applies a global scaling factor when drawing the menu. Can be used to increase or decrease the size of the user interface."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_AUTO,
|
||||
"Auto Scale Menu Widgets"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_AUTO,
|
||||
"Automatically resize decorated notifications, indicators and controls based on current menu scale."
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR,
|
||||
"Menu Widget Scale Override"
|
||||
)
|
||||
MSG_HASH(
|
||||
MENU_ENUM_SUBLABEL_MENU_WIDGET_SCALE_FACTOR,
|
||||
"Applies a manual scaling factor override when drawing menu widgets. Only applies when 'Auto Scale Menu 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,
|
||||
"Drivers"
|
||||
|
@ -529,6 +529,8 @@ default_sublabel_macro(action_bind_sublabel_ozone_truncate_playlist_name,
|
||||
default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata, MENU_ENUM_SUBLABEL_OZONE_SCROLL_CONTENT_METADATA)
|
||||
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_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_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)
|
||||
@ -1758,6 +1760,12 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
|
||||
case MENU_ENUM_LABEL_MENU_SCALE_FACTOR:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_scale_factor);
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_widget_scale_auto);
|
||||
break;
|
||||
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_WALLPAPER_OPACITY:
|
||||
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_menu_wallpaper_opacity);
|
||||
break;
|
||||
|
@ -460,16 +460,7 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded)
|
||||
if (!ozone)
|
||||
return;
|
||||
|
||||
/* Due to the 'multi-column' menu layout
|
||||
* (i.e. sidebars + entries), actual scale factor
|
||||
* must be capped to a sensible upper limit
|
||||
* > Normal left hand sidebar width must be no
|
||||
* more than 1/3 of the total screen width,
|
||||
* otherwise menu becomes unusable */
|
||||
ozone->capped_scale_factor =
|
||||
(SIDEBAR_WIDTH * ozone->last_scale_factor) > (ozone->last_width * 0.3333333f) ?
|
||||
((float)ozone->last_width * 0.3333333f / (float)SIDEBAR_WIDTH) : ozone->last_scale_factor;
|
||||
scale_factor = ozone->capped_scale_factor;
|
||||
scale_factor = ozone->last_scale_factor;
|
||||
|
||||
/* Calculate dimensions */
|
||||
ozone->dimensions.header_height = HEADER_HEIGHT * scale_factor;
|
||||
@ -1146,7 +1137,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned timedate_offset = 0;
|
||||
bool use_smooth_ticker = settings->bools.menu_ticker_smooth;
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
unsigned logo_icon_size = 60 * scale_factor;
|
||||
unsigned status_icon_size = 92 * scale_factor;
|
||||
unsigned seperator_margin = 30 * scale_factor;
|
||||
@ -1290,7 +1281,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, video_frame_info_t *video_i
|
||||
|
||||
static void ozone_draw_footer(ozone_handle_t *ozone, video_frame_info_t *video_info, settings_t *settings)
|
||||
{
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
unsigned seperator_margin = 30 * scale_factor;
|
||||
|
||||
/* Separator */
|
||||
@ -2196,7 +2187,7 @@ static void ozone_list_cache(void *data,
|
||||
if (!ozone)
|
||||
return;
|
||||
|
||||
scale_factor = ozone->capped_scale_factor;
|
||||
scale_factor = ozone->last_scale_factor;
|
||||
ozone->need_compute = true;
|
||||
ozone->selection_old_list = ozone->selection;
|
||||
ozone->scroll_old = ozone->animations.scroll_y;
|
||||
|
@ -52,6 +52,8 @@ typedef struct ozone_handle ozone_handle_t;
|
||||
#define ENTRY_ICON_SIZE 46
|
||||
#define ENTRY_ICON_PADDING 15
|
||||
|
||||
/* > 'SIDEBAR_WIDTH' must be kept in sync with
|
||||
* menu driver metrics */
|
||||
#define SIDEBAR_WIDTH 408
|
||||
#define SIDEBAR_X_PADDING 40
|
||||
#define SIDEBAR_Y_PADDING 20
|
||||
@ -179,7 +181,6 @@ struct ozone_handle
|
||||
unsigned last_width;
|
||||
unsigned last_height;
|
||||
float last_scale_factor;
|
||||
float capped_scale_factor;
|
||||
|
||||
bool need_compute;
|
||||
|
||||
|
@ -118,7 +118,7 @@ static void ozone_draw_cursor_slice(ozone_handle_t *ozone,
|
||||
unsigned width, unsigned height,
|
||||
size_t y, float alpha)
|
||||
{
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
int slice_x = x_offset - 14 * scale_factor;
|
||||
int slice_y = (int)y + 8 * scale_factor;
|
||||
unsigned slice_new_w = width + (3 + 28 - 4) * scale_factor;
|
||||
@ -261,7 +261,7 @@ void ozone_draw_osk(ozone_handle_t *ozone,
|
||||
unsigned text_color;
|
||||
struct string_list *list;
|
||||
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
unsigned margin = 75 * scale_factor;
|
||||
unsigned padding = 10 * scale_factor;
|
||||
unsigned bottom_end = video_info->height/2;
|
||||
@ -353,7 +353,7 @@ void ozone_draw_messagebox(ozone_handle_t *ozone,
|
||||
unsigned height = video_info->height;
|
||||
struct string_list *list = !string_is_empty(message)
|
||||
? string_split(message, "\n") : NULL;
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
|
||||
if (!list || !ozone || !ozone->fonts.footer)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone,
|
||||
{
|
||||
bool switch_is_on = true;
|
||||
bool do_draw_text = false;
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
|
||||
if (!entry->checked && string_is_empty(value))
|
||||
return;
|
||||
@ -200,7 +200,7 @@ void ozone_compute_entries_position(ozone_handle_t *ozone)
|
||||
|
||||
file_list_t *selection_buf = NULL;
|
||||
int entry_padding = ozone_get_entries_padding(ozone, false);
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
|
||||
|
||||
@ -364,7 +364,7 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
|
||||
int16_t cursor_x = 0;
|
||||
int16_t cursor_y = 0;
|
||||
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
|
||||
menu_input_get_pointer_state(&pointer);
|
||||
|
||||
|
@ -116,7 +116,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
|
||||
settings_t *settings = config_get_ptr();
|
||||
uint32_t text_alpha = ozone->animations.sidebar_text_alpha * 255.0f;
|
||||
bool use_smooth_ticker = settings->bools.menu_ticker_smooth;
|
||||
float scale_factor = ozone->capped_scale_factor;
|
||||
float scale_factor = ozone->last_scale_factor;
|
||||
|
||||
/* Initial ticker configuration */
|
||||
if (use_smooth_ticker)
|
||||
|
@ -1186,7 +1186,6 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry)
|
||||
}
|
||||
|
||||
static void menu_animation_update_time(
|
||||
const char *menu_driver,
|
||||
bool timedate_enable,
|
||||
unsigned video_width, unsigned video_height,
|
||||
float menu_ticker_speed)
|
||||
@ -1255,27 +1254,32 @@ static void menu_animation_update_time(
|
||||
* every 2 frames is optimal, but may be too fast
|
||||
* for some users - so play it safe. Users can always
|
||||
* set ticker speed to 2x if they prefer)
|
||||
* Note 2: It turns out that resolution adjustment
|
||||
* also fails for Ozone, because it doesn't implement
|
||||
* any kind of DPI scaling - i.e. text gets smaller
|
||||
* as resolution increases. This is annoying. It
|
||||
* means we have to use a fixed multiplier for
|
||||
* Ozone as well...
|
||||
* Note 3: GLUI uses the new DPI scaling system,
|
||||
* Note 2: GLUI uses the new DPI scaling system,
|
||||
* so scaling multiplier is menu_display_get_dpi_scale()
|
||||
* multiplied by a small correction factor (since the
|
||||
* default 1.0x speed is just a little faster than the
|
||||
* non-smooth ticker) */
|
||||
if (string_is_equal(menu_driver, "rgui"))
|
||||
ticker_pixel_increment *= 0.25f;
|
||||
/* TODO/FIXME: Remove this Ozone special case if/when
|
||||
* Ozone gets proper DPI scaling */
|
||||
else if (string_is_equal(menu_driver, "ozone"))
|
||||
ticker_pixel_increment *= 0.5f;
|
||||
else if (string_is_equal(menu_driver, "glui"))
|
||||
ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.8f);
|
||||
else if (video_width > 0)
|
||||
ticker_pixel_increment *= ((float)video_width / 1920.0f);
|
||||
* non-smooth ticker)
|
||||
* Note 3: Ozone now also uses the new DPI scaling
|
||||
* system. We therefore take the same approach as GLUI,
|
||||
* but with a different correction factor (expected
|
||||
* scroll speed is somewhat lower for Ozone) */
|
||||
switch (menu_driver_ident_id())
|
||||
{
|
||||
case MENU_DRIVER_ID_RGUI:
|
||||
ticker_pixel_increment *= 0.25f;
|
||||
break;
|
||||
case MENU_DRIVER_ID_OZONE:
|
||||
ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.5f);
|
||||
break;
|
||||
case MENU_DRIVER_ID_GLUI:
|
||||
ticker_pixel_increment *= (menu_display_get_dpi_scale(video_width, video_height) * 0.8f);
|
||||
break;
|
||||
case MENU_DRIVER_ID_XMB:
|
||||
default:
|
||||
if (video_width > 0)
|
||||
ticker_pixel_increment *= ((float)video_width / 1920.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
/* > Update accumulator */
|
||||
ticker_pixel_accumulator += ticker_pixel_increment;
|
||||
@ -1291,7 +1295,6 @@ static void menu_animation_update_time(
|
||||
}
|
||||
|
||||
bool menu_animation_update(
|
||||
const char *menu_driver,
|
||||
bool menu_timedate_enable,
|
||||
float menu_ticker_speed,
|
||||
unsigned video_width,
|
||||
@ -1300,7 +1303,6 @@ bool menu_animation_update(
|
||||
unsigned i;
|
||||
|
||||
menu_animation_update_time(
|
||||
menu_driver,
|
||||
menu_timedate_enable,
|
||||
video_width, video_height,
|
||||
menu_ticker_speed);
|
||||
|
@ -199,7 +199,6 @@ void menu_timer_start(menu_timer_t *timer, menu_timer_ctx_entry_t *timer_entry);
|
||||
void menu_timer_kill(menu_timer_t *timer);
|
||||
|
||||
bool menu_animation_update(
|
||||
const char *menu_driver,
|
||||
bool menu_timedate_enable,
|
||||
float menu_ticker_speed,
|
||||
unsigned video_width,
|
||||
|
@ -6491,6 +6491,8 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
menu_displaylist_build_info_selective_t build_list[] = {
|
||||
{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_VIDEO_FONT_ENABLE, PARSE_ONLY_BOOL, true },
|
||||
{MENU_ENUM_LABEL_FPS_SHOW, PARSE_ONLY_BOOL, false },
|
||||
{MENU_ENUM_LABEL_FPS_UPDATE_INTERVAL, PARSE_ONLY_UINT, false },
|
||||
@ -6528,6 +6530,15 @@ unsigned menu_displaylist_build_list(file_list_t *list, enum menu_displaylist_ct
|
||||
if (settings->bools.video_msg_bgcolor_enable)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO:
|
||||
if (menu_widgets_ready())
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
case MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR:
|
||||
if (menu_widgets_ready())
|
||||
if (!settings->bools.menu_widget_scale_auto)
|
||||
build_list[i].checked = true;
|
||||
break;
|
||||
default:
|
||||
if (settings->bools.video_font_enable)
|
||||
build_list[i].checked = true;
|
||||
|
@ -88,6 +88,10 @@
|
||||
* DPI-aware menu scaling factors */
|
||||
#define REFERENCE_DPI 96.0f
|
||||
|
||||
/* 'OZONE_SIDEBAR_WIDTH' must be kept in sync
|
||||
* with ozone menu driver metrics */
|
||||
#define OZONE_SIDEBAR_WIDTH 408
|
||||
|
||||
typedef struct menu_ctx_load_image
|
||||
{
|
||||
void *data;
|
||||
@ -323,6 +327,8 @@ static menu_handle_t *menu_driver_data = NULL;
|
||||
static const menu_ctx_driver_t *menu_driver_ctx = NULL;
|
||||
static void *menu_userdata = NULL;
|
||||
|
||||
static enum menu_driver_id_type menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
|
||||
/* Quick jumping indices with L/R.
|
||||
* Rebuilt when parsing directory. */
|
||||
static size_t scroll_index_list[SCROLL_INDEX_SIZE];
|
||||
@ -2048,17 +2054,292 @@ void menu_display_unset_framebuffer_dirty_flag(void)
|
||||
menu_display_framebuf_dirty = false;
|
||||
}
|
||||
|
||||
float menu_display_get_dpi_scale(unsigned width, unsigned height)
|
||||
static float menu_display_get_adjusted_scale_internal(float base_scale, float scale_factor, unsigned width)
|
||||
{
|
||||
/* Apply user-set scaling factor */
|
||||
float adjusted_scale = base_scale * scale_factor;
|
||||
|
||||
/* Ozone has a capped scale factor */
|
||||
adjusted_scale = (menu_driver_id == MENU_DRIVER_ID_OZONE) ?
|
||||
(((float)OZONE_SIDEBAR_WIDTH * adjusted_scale) > ((float)width * 0.3333333f) ?
|
||||
((float)width * 0.3333333f / (float)OZONE_SIDEBAR_WIDTH) : adjusted_scale) :
|
||||
adjusted_scale;
|
||||
|
||||
/* Ensure final scale is 'sane' */
|
||||
return (adjusted_scale > 0.0001f) ? adjusted_scale : 1.0f;
|
||||
}
|
||||
|
||||
/* Ugh... Since we must now have independent scale
|
||||
* factors for menus and widgets, and most of the internal
|
||||
* scaling variables are cached/static, a huge amount of
|
||||
* code duplication is required for the pixel_scale and
|
||||
* dpi_scale functions. A necessary evil, I suppose... */
|
||||
|
||||
float menu_display_get_pixel_scale(unsigned width, unsigned height)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
static unsigned last_height = 0;
|
||||
static float scale = 0.0f;
|
||||
static bool scale_cached = false;
|
||||
bool scale_updated = false;
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
float menu_scale_factor = 1.0f;
|
||||
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();
|
||||
|
||||
if (settings)
|
||||
menu_scale_factor = settings->floats.menu_scale_factor;
|
||||
|
||||
/* We need to perform a square root here, which
|
||||
* can be slow on some platforms (not *slow*, but
|
||||
* it involves enough work that it's worth trying
|
||||
* to optimise). We therefore cache the pixel scale,
|
||||
* and only update on first run or when the video
|
||||
* size changes */
|
||||
if (!scale_cached ||
|
||||
(width != last_width) ||
|
||||
(height != last_height))
|
||||
{
|
||||
/* Baseline reference is a 1080p display */
|
||||
scale = (float)(
|
||||
sqrt((double)((width * width) + (height * height))) /
|
||||
DIAGONAL_PIXELS_1080P);
|
||||
|
||||
scale_cached = true;
|
||||
scale_updated = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
}
|
||||
|
||||
/* Adjusted scale calculation may also be slow, so
|
||||
* only update if something changes */
|
||||
if (scale_updated ||
|
||||
(menu_scale_factor != last_menu_scale_factor) ||
|
||||
(menu_driver_id != last_menu_driver_id))
|
||||
{
|
||||
adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width);
|
||||
last_menu_scale_factor = menu_scale_factor;
|
||||
last_menu_driver_id = menu_driver_id;
|
||||
}
|
||||
|
||||
return adjusted_scale;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
float menu_display_get_widget_pixel_scale(unsigned width, unsigned height)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
static unsigned last_height = 0;
|
||||
static float scale = 0.0f;
|
||||
static bool scale_cached = false;
|
||||
bool scale_updated = false;
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
float menu_scale_factor = 1.0f;
|
||||
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();
|
||||
|
||||
/* When using RGUI, settings->floats.menu_scale_factor
|
||||
* is ignored
|
||||
* > If we are not using a widget scale factor override,
|
||||
* just set menu_scale_factor to 1.0 */
|
||||
if (settings)
|
||||
menu_scale_factor = settings->bools.menu_widget_scale_auto ?
|
||||
((menu_driver_id == MENU_DRIVER_ID_RGUI) ?
|
||||
1.0f : settings->floats.menu_scale_factor) :
|
||||
settings->floats.menu_widget_scale_factor;
|
||||
|
||||
/* We need to perform a square root here, which
|
||||
* can be slow on some platforms (not *slow*, but
|
||||
* it involves enough work that it's worth trying
|
||||
* to optimise). We therefore cache the pixel scale,
|
||||
* and only update on first run or when the video
|
||||
* size changes */
|
||||
if (!scale_cached ||
|
||||
(width != last_width) ||
|
||||
(height != last_height))
|
||||
{
|
||||
/* Baseline reference is a 1080p display */
|
||||
scale = (float)(
|
||||
sqrt((double)((width * width) + (height * height))) /
|
||||
DIAGONAL_PIXELS_1080P);
|
||||
|
||||
scale_cached = true;
|
||||
scale_updated = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
}
|
||||
|
||||
/* Adjusted scale calculation may also be slow, so
|
||||
* only update if something changes */
|
||||
if (scale_updated ||
|
||||
(menu_scale_factor != last_menu_scale_factor) ||
|
||||
(menu_driver_id != last_menu_driver_id))
|
||||
{
|
||||
adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width);
|
||||
last_menu_scale_factor = menu_scale_factor;
|
||||
last_menu_driver_id = menu_driver_id;
|
||||
}
|
||||
|
||||
return adjusted_scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
float menu_display_get_dpi_scale_internal(unsigned width, unsigned height)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
static unsigned last_height = 0;
|
||||
static float scale = 0.0f;
|
||||
static bool scale_cached = false;
|
||||
float menu_scale_factor = 0.0f;
|
||||
settings_t *settings = config_get_ptr();
|
||||
float diagonal_pixels;
|
||||
float pixel_scale;
|
||||
float dpi;
|
||||
gfx_ctx_metrics_t metrics;
|
||||
|
||||
if (scale_cached &&
|
||||
(width == last_width) &&
|
||||
(height == last_height))
|
||||
return scale;
|
||||
|
||||
/* Determine the diagonal 'size' of the display
|
||||
* (or window) in terms of pixels */
|
||||
diagonal_pixels = (float)sqrt(
|
||||
(double)((width * width) + (height * height)));
|
||||
|
||||
/* TODO/FIXME: On Mac, calling video_context_driver_get_metrics()
|
||||
* here causes RetroArch to crash (EXC_BAD_ACCESS). This is
|
||||
* unfortunate, and needs to be fixed at the gfx context driver
|
||||
* level. Until this is done, all we can do is fallback to using
|
||||
* the old legacy 'magic number' scaling on Mac platforms. */
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
|
||||
if (true)
|
||||
{
|
||||
scale = (diagonal_pixels / 6.5f) / 212.0f;
|
||||
scale_cached = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
return scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get pixel scale relative to baseline 1080p display */
|
||||
pixel_scale = diagonal_pixels / DIAGONAL_PIXELS_1080P;
|
||||
|
||||
/* Attempt to get display DPI */
|
||||
metrics.type = DISPLAY_METRIC_DPI;
|
||||
metrics.value = &dpi;
|
||||
|
||||
if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f))
|
||||
{
|
||||
float display_size;
|
||||
float dpi_scale;
|
||||
|
||||
#if defined(ANDROID) || defined(HAVE_COCOATOUCH)
|
||||
/* Android/iOS devices tell complete lies when
|
||||
* reporting DPI values. From the Android devices
|
||||
* I've had access to, the DPI is generally
|
||||
* overestimated by 17%. All we can do is apply
|
||||
* a blind correction factor... */
|
||||
dpi = dpi * 0.83f;
|
||||
#endif
|
||||
|
||||
/* Note: If we are running in windowed mode, this
|
||||
* 'display size' is actually the window size - which
|
||||
* kinda makes a mess of everything. Since we cannot
|
||||
* get fullscreen resolution when running in windowed
|
||||
* mode, there is nothing we can do about this. So just
|
||||
* treat the window as a display, and hope for the best... */
|
||||
display_size = diagonal_pixels / dpi;
|
||||
dpi_scale = dpi / REFERENCE_DPI;
|
||||
|
||||
/* Note: We have tried leveraging every possible metric
|
||||
* (and numerous studies on TV/monitor/mobile device
|
||||
* usage habits) to determine an appropriate auto scaling
|
||||
* factor. *None of these 'smart'/technical methods work
|
||||
* consistently in the real world* - there is simply too
|
||||
* much variance.
|
||||
* So instead we have implemented a very fuzzy/loose
|
||||
* method which is crude as can be, but actually has
|
||||
* some semblance of usability... */
|
||||
|
||||
if (display_size > 24.0f)
|
||||
{
|
||||
/* DPI scaling fails miserably when using large
|
||||
* displays. Having a UI element that's 1 inch high
|
||||
* on all screens might seem like a good idea - until
|
||||
* you realise that a HTPC user is probably sitting
|
||||
* several metres from their TV, which makes something
|
||||
* 1 inch high virtually invisible.
|
||||
* So we make some assumptions:
|
||||
* - Normal size displays <= 24 inches are probably
|
||||
* PC monitors, with an eye-to-screen distance of
|
||||
* 1 arm length. Under these conditions, fixed size
|
||||
* (DPI scaled) UI elements should be visible for most
|
||||
* users
|
||||
* - Large displays > 24 inches start to encroach on
|
||||
* TV territory. Once we start working with TVs, we
|
||||
* have to consider users sitting on a couch - and
|
||||
* in this situation, we fall back to the age-old
|
||||
* standard of UI elements occupying a fixed fraction
|
||||
* of the display size (i.e. just look at the menu of
|
||||
* any console system for the past decade)
|
||||
* - 24 -> 32 inches is a grey area, where the display
|
||||
* might be a monitor or a TV. Above 32 inches, a TV
|
||||
* is almost a certainty. So we simply lerp between
|
||||
* dpi scaling and pixel scaling as the display size
|
||||
* increases from 24 to 32 */
|
||||
float fraction = (display_size > 32.0f) ? 32.0f : display_size;
|
||||
fraction = fraction - 24.0f;
|
||||
fraction = fraction / (32.0f - 24.0f);
|
||||
|
||||
scale = ((1.0f - fraction) * dpi_scale) + (fraction * pixel_scale);
|
||||
}
|
||||
else if (display_size < 12.0f)
|
||||
{
|
||||
/* DPI scaling also fails when using very small
|
||||
* displays - i.e. mobile devices (tablets/phones).
|
||||
* That 1 inch UI element is going to look pretty
|
||||
* dumb on a 5 inch screen in landscape orientation...
|
||||
* We're essentially in the opposite situation to the
|
||||
* TV case above, and it turns out that a similar
|
||||
* solution provides relief: as screen size reduces
|
||||
* from 12 inches to zero, we lerp from dpi scaling
|
||||
* to pixel scaling */
|
||||
float fraction = display_size / 12.0f;
|
||||
|
||||
scale = ((1.0f - fraction) * pixel_scale) + (fraction * dpi_scale);
|
||||
}
|
||||
else
|
||||
scale = dpi_scale;
|
||||
}
|
||||
/* If DPI retrieval is unsupported, all we can do
|
||||
* is use the raw pixel scale */
|
||||
else
|
||||
scale = pixel_scale;
|
||||
|
||||
scale_cached = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
float menu_display_get_dpi_scale(unsigned width, unsigned height)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
static unsigned last_height = 0;
|
||||
static float scale = 0.0f;
|
||||
static bool scale_cached = false;
|
||||
bool scale_updated = false;
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
float menu_scale_factor = 1.0f;
|
||||
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();
|
||||
|
||||
if (settings)
|
||||
menu_scale_factor = settings->floats.menu_scale_factor;
|
||||
menu_scale_factor = settings->floats.menu_scale_factor;
|
||||
|
||||
/* Scale is based on display metrics - these are a fixed
|
||||
* hardware property. To minimise performance overheads
|
||||
@ -2068,148 +2349,81 @@ float menu_display_get_dpi_scale(unsigned width, unsigned height)
|
||||
(width != last_width) ||
|
||||
(height != last_height))
|
||||
{
|
||||
float diagonal_pixels;
|
||||
float pixel_scale;
|
||||
float dpi;
|
||||
gfx_ctx_metrics_t metrics;
|
||||
|
||||
/* Determine the diagonal 'size' of the display
|
||||
* (or window) in terms of pixels */
|
||||
diagonal_pixels = (float)sqrt(
|
||||
(double)((width * width) + (height * height)));
|
||||
|
||||
/* TODO/FIXME: On Mac, calling video_context_driver_get_metrics()
|
||||
* here causes RetroArch to crash (EXC_BAD_ACCESS). This is
|
||||
* unfortunate, and needs to be fixed at the gfx context driver
|
||||
* level. Until this is done, all we can do is fallback to using
|
||||
* the old legacy 'magic number' scaling on Mac platforms.
|
||||
* Note: We use a rather ugly construct here so the 'Mac hack'
|
||||
* can be added in one place, without polluting the rest of
|
||||
* the code. */
|
||||
#if defined(HAVE_COCOA) || defined(HAVE_COCOA_METAL)
|
||||
if (true)
|
||||
{
|
||||
scale = (diagonal_pixels / 6.5f) / 212.0f;
|
||||
scale_cached = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
|
||||
if (settings)
|
||||
return scale * ((menu_scale_factor > 0.0001f) ?
|
||||
menu_scale_factor : 1.0f);
|
||||
|
||||
return scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get pixel scale relative to baseline 1080p display */
|
||||
pixel_scale = diagonal_pixels / DIAGONAL_PIXELS_1080P;
|
||||
|
||||
/* Attempt to get display DPI */
|
||||
metrics.type = DISPLAY_METRIC_DPI;
|
||||
metrics.value = &dpi;
|
||||
|
||||
if (video_context_driver_get_metrics(&metrics) && (dpi > 0.0f))
|
||||
{
|
||||
float display_size;
|
||||
float dpi_scale;
|
||||
|
||||
#if defined(ANDROID) || defined(HAVE_COCOATOUCH)
|
||||
/* Android/iOS devices tell complete lies when
|
||||
* reporting DPI values. From the Android devices
|
||||
* I've had access to, the DPI is generally
|
||||
* overestimated by 17%. All we can do is apply
|
||||
* a blind correction factor... */
|
||||
dpi = dpi * 0.83f;
|
||||
#endif
|
||||
|
||||
/* Note: If we are running in windowed mode, this
|
||||
* 'display size' is actually the window size - which
|
||||
* kinda makes a mess of everything. Since we cannot
|
||||
* get fullscreen resolution when running in windowed
|
||||
* mode, there is nothing we can do about this. So just
|
||||
* treat the window as a display, and hope for the best... */
|
||||
display_size = diagonal_pixels / dpi;
|
||||
dpi_scale = dpi / REFERENCE_DPI;
|
||||
|
||||
/* Note: We have tried leveraging every possible metric
|
||||
* (and numerous studies on TV/monitor/mobile device
|
||||
* usage habits) to determine an appropriate auto scaling
|
||||
* factor. *None of these 'smart'/technical methods work
|
||||
* consistently in the real world* - there is simply too
|
||||
* much variance.
|
||||
* So instead we have implemented a very fuzzy/loose
|
||||
* method which is crude as can be, but actually has
|
||||
* some semblance of usability... */
|
||||
|
||||
if (display_size > 24.0f)
|
||||
{
|
||||
/* DPI scaling fails miserably when using large
|
||||
* displays. Having a UI element that's 1 inch high
|
||||
* on all screens might seem like a good idea - until
|
||||
* you realise that a HTPC user is probably sitting
|
||||
* several metres from their TV, which makes something
|
||||
* 1 inch high virtually invisible.
|
||||
* So we make some assumptions:
|
||||
* - Normal size displays <= 24 inches are probably
|
||||
* PC monitors, with an eye-to-screen distance of
|
||||
* 1 arm length. Under these conditions, fixed size
|
||||
* (DPI scaled) UI elements should be visible for most
|
||||
* users
|
||||
* - Large displays > 24 inches start to encroach on
|
||||
* TV territory. Once we start working with TVs, we
|
||||
* have to consider users sitting on a couch - and
|
||||
* in this situation, we fall back to the age-old
|
||||
* standard of UI elements occupying a fixed fraction
|
||||
* of the display size (i.e. just look at the menu of
|
||||
* any console system for the past decade)
|
||||
* - 24 -> 32 inches is a grey area, where the display
|
||||
* might be a monitor or a TV. Above 32 inches, a TV
|
||||
* is almost a certainty. So we simply lerp between
|
||||
* dpi scaling and pixel scaling as the display size
|
||||
* increases from 24 to 32 */
|
||||
float fraction = (display_size > 32.0f) ? 32.0f : display_size;
|
||||
fraction = fraction - 24.0f;
|
||||
fraction = fraction / (32.0f - 24.0f);
|
||||
|
||||
scale = ((1.0f - fraction) * dpi_scale) + (fraction * pixel_scale);
|
||||
}
|
||||
else if (display_size < 12.0f)
|
||||
{
|
||||
/* DPI scaling also fails when using very small
|
||||
* displays - i.e. mobile devices (tablets/phones).
|
||||
* That 1 inch UI element is going to look pretty
|
||||
* dumb on a 5 inch screen in landscape orientation...
|
||||
* We're essentially in the opposite situation to the
|
||||
* TV case above, and it turns out that a similar
|
||||
* solution provides relief: as screen size reduces
|
||||
* from 12 inches to zero, we lerp from dpi scaling
|
||||
* to pixel scaling */
|
||||
float fraction = display_size / 12.0f;
|
||||
|
||||
scale = ((1.0f - fraction) * pixel_scale) + (fraction * dpi_scale);
|
||||
}
|
||||
else
|
||||
scale = dpi_scale;
|
||||
}
|
||||
/* If DPI retrieval is unsupported, all we can do
|
||||
* is use the raw pixel scale */
|
||||
else
|
||||
scale = pixel_scale;
|
||||
|
||||
scale_cached = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
scale = menu_display_get_dpi_scale_internal(width, height);
|
||||
scale_cached = true;
|
||||
scale_updated = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
}
|
||||
|
||||
/* Apply user scaling factor */
|
||||
if (settings)
|
||||
return scale * ((menu_scale_factor > 0.0001f) ?
|
||||
menu_scale_factor : 1.0f);
|
||||
/* Adjusted scale calculation may also be slow, so
|
||||
* only update if something changes */
|
||||
if (scale_updated ||
|
||||
(menu_scale_factor != last_menu_scale_factor) ||
|
||||
(menu_driver_id != last_menu_driver_id))
|
||||
{
|
||||
adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width);
|
||||
last_menu_scale_factor = menu_scale_factor;
|
||||
last_menu_driver_id = menu_driver_id;
|
||||
}
|
||||
|
||||
return scale;
|
||||
return adjusted_scale;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
float menu_display_get_widget_dpi_scale(unsigned width, unsigned height)
|
||||
{
|
||||
static unsigned last_width = 0;
|
||||
static unsigned last_height = 0;
|
||||
static float scale = 0.0f;
|
||||
static bool scale_cached = false;
|
||||
bool scale_updated = false;
|
||||
static float last_menu_scale_factor = 0.0f;
|
||||
float menu_scale_factor = 1.0f;
|
||||
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();
|
||||
|
||||
/* When using RGUI, settings->floats.menu_scale_factor
|
||||
* is ignored
|
||||
* > If we are not using a widget scale factor override,
|
||||
* just set menu_scale_factor to 1.0 */
|
||||
if (settings)
|
||||
menu_scale_factor = settings->bools.menu_widget_scale_auto ?
|
||||
((menu_driver_id == MENU_DRIVER_ID_RGUI) ?
|
||||
1.0f : settings->floats.menu_scale_factor) :
|
||||
settings->floats.menu_widget_scale_factor;
|
||||
|
||||
/* Scale is based on display metrics - these are a fixed
|
||||
* hardware property. To minimise performance overheads
|
||||
* we therefore only call video_context_driver_get_metrics()
|
||||
* on first run, or when the current video resolution changes */
|
||||
if (!scale_cached ||
|
||||
(width != last_width) ||
|
||||
(height != last_height))
|
||||
{
|
||||
scale = menu_display_get_dpi_scale_internal(width, height);
|
||||
scale_cached = true;
|
||||
scale_updated = true;
|
||||
last_width = width;
|
||||
last_height = height;
|
||||
}
|
||||
|
||||
/* Adjusted scale calculation may also be slow, so
|
||||
* only update if something changes */
|
||||
if (scale_updated ||
|
||||
(menu_scale_factor != last_menu_scale_factor) ||
|
||||
(menu_driver_id != last_menu_driver_id))
|
||||
{
|
||||
adjusted_scale = menu_display_get_adjusted_scale_internal(scale, menu_scale_factor, width);
|
||||
last_menu_scale_factor = menu_scale_factor;
|
||||
last_menu_driver_id = menu_driver_id;
|
||||
}
|
||||
|
||||
return adjusted_scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool menu_display_driver_exists(const char *s)
|
||||
{
|
||||
unsigned i;
|
||||
@ -3365,6 +3579,11 @@ const char *menu_driver_ident(void)
|
||||
return menu_driver_ctx->ident;
|
||||
}
|
||||
|
||||
enum menu_driver_id_type menu_driver_ident_id(void)
|
||||
{
|
||||
return menu_driver_id;
|
||||
}
|
||||
|
||||
void menu_driver_frame(video_frame_info_t *video_info)
|
||||
{
|
||||
if (video_info->menu_is_alive && menu_driver_ctx->frame)
|
||||
@ -3455,8 +3674,38 @@ bool menu_driver_list_set_selection(file_list_t *list)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void menu_driver_set_id(void)
|
||||
{
|
||||
const char *driver_name = NULL;
|
||||
|
||||
menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
|
||||
if (!menu_driver_ctx || !menu_driver_ctx->ident)
|
||||
return;
|
||||
|
||||
driver_name = menu_driver_ctx->ident;
|
||||
|
||||
if (string_is_empty(driver_name))
|
||||
return;
|
||||
|
||||
if (string_is_equal(driver_name, "rgui"))
|
||||
menu_driver_id = MENU_DRIVER_ID_RGUI;
|
||||
else if (string_is_equal(driver_name, "ozone"))
|
||||
menu_driver_id = MENU_DRIVER_ID_OZONE;
|
||||
else if (string_is_equal(driver_name, "glui"))
|
||||
menu_driver_id = MENU_DRIVER_ID_GLUI;
|
||||
else if (string_is_equal(driver_name, "xmb"))
|
||||
menu_driver_id = MENU_DRIVER_ID_XMB;
|
||||
else if (string_is_equal(driver_name, "xui"))
|
||||
menu_driver_id = MENU_DRIVER_ID_XUI;
|
||||
else if (string_is_equal(driver_name, "stripes"))
|
||||
menu_driver_id = MENU_DRIVER_ID_STRIPES;
|
||||
}
|
||||
|
||||
static bool menu_driver_init_internal(bool video_is_threaded)
|
||||
{
|
||||
menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
|
||||
if (menu_driver_ctx->init)
|
||||
{
|
||||
menu_driver_data = (menu_handle_t*)
|
||||
@ -3478,6 +3727,8 @@ static bool menu_driver_init_internal(bool video_is_threaded)
|
||||
if (!menu_driver_ctx->lists_init(menu_driver_data))
|
||||
return false;
|
||||
|
||||
menu_driver_set_id();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -3684,6 +3935,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
free(menu_userdata);
|
||||
menu_userdata = NULL;
|
||||
|
||||
menu_driver_id = MENU_DRIVER_ID_UNKNOWN;
|
||||
|
||||
#ifndef HAVE_DYNAMIC
|
||||
if (frontend_driver_has_fork())
|
||||
#endif
|
||||
|
@ -224,6 +224,17 @@ enum menu_settings_type
|
||||
MENU_SETTINGS_LAST
|
||||
};
|
||||
|
||||
enum menu_driver_id_type
|
||||
{
|
||||
MENU_DRIVER_ID_UNKNOWN = 0,
|
||||
MENU_DRIVER_ID_RGUI,
|
||||
MENU_DRIVER_ID_OZONE,
|
||||
MENU_DRIVER_ID_GLUI,
|
||||
MENU_DRIVER_ID_XMB,
|
||||
MENU_DRIVER_ID_XUI,
|
||||
MENU_DRIVER_ID_STRIPES
|
||||
};
|
||||
|
||||
typedef struct menu_display_ctx_driver
|
||||
{
|
||||
/* Draw graphics to the screen. */
|
||||
@ -526,6 +537,8 @@ const char* config_get_menu_driver_options(void);
|
||||
|
||||
const char *menu_driver_ident(void);
|
||||
|
||||
enum menu_driver_id_type menu_driver_ident_id(void);
|
||||
|
||||
bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data);
|
||||
|
||||
void menu_driver_frame(video_frame_info_t *video_info);
|
||||
@ -594,7 +607,12 @@ void menu_display_unset_viewport(unsigned width, unsigned height);
|
||||
bool menu_display_get_framebuffer_dirty_flag(void);
|
||||
void menu_display_set_framebuffer_dirty_flag(void);
|
||||
void menu_display_unset_framebuffer_dirty_flag(void);
|
||||
float menu_display_get_pixel_scale(unsigned width, unsigned height);
|
||||
float menu_display_get_dpi_scale(unsigned width, unsigned height);
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
float menu_display_get_widget_pixel_scale(unsigned width, unsigned height);
|
||||
float menu_display_get_widget_dpi_scale(unsigned width, unsigned height);
|
||||
#endif
|
||||
bool menu_display_init_first_driver(bool video_is_threaded);
|
||||
bool menu_display_restore_clear_color(void);
|
||||
void menu_display_clear_color(menu_display_ctx_clearcolor_t *color,
|
||||
|
@ -11761,6 +11761,48 @@ static bool setting_append_list(
|
||||
&subgroup_info,
|
||||
parent_group);
|
||||
|
||||
/* This is the SETTINGS_LIST_FONT category, but the
|
||||
* parent group is ONSCREEN_DISPLAY_SETTINGS.
|
||||
* Menu widget settings don't belong in the SETTINGS_LIST_FONT
|
||||
* category, but they *do* belong in the ONSCREEN_DISPLAY_SETTINGS
|
||||
* group. I don't want to refactor these names, so we'll assume
|
||||
* group trumps category, and just place the widget settings here */
|
||||
#ifdef HAVE_MENU_WIDGETS
|
||||
CONFIG_BOOL(
|
||||
list, list_info,
|
||||
&settings->bools.menu_widget_scale_auto,
|
||||
MENU_ENUM_LABEL_MENU_WIDGET_SCALE_AUTO,
|
||||
MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_AUTO,
|
||||
DEFAULT_MENU_WIDGET_SCALE_AUTO,
|
||||
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
|
||||
);
|
||||
(*list)[list_info->index - 1].action_ok = &setting_bool_action_left_with_refresh;
|
||||
(*list)[list_info->index - 1].action_left = &setting_bool_action_left_with_refresh;
|
||||
(*list)[list_info->index - 1].action_right = &setting_bool_action_right_with_refresh;
|
||||
|
||||
CONFIG_FLOAT(
|
||||
list, list_info,
|
||||
&settings->floats.menu_widget_scale_factor,
|
||||
MENU_ENUM_LABEL_MENU_WIDGET_SCALE_FACTOR,
|
||||
MENU_ENUM_LABEL_VALUE_MENU_WIDGET_SCALE_FACTOR,
|
||||
DEFAULT_MENU_WIDGET_SCALE_FACTOR,
|
||||
"%.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(
|
||||
list, list_info,
|
||||
&settings->bools.video_font_enable,
|
||||
@ -12844,10 +12886,11 @@ static bool setting_append_list(
|
||||
|
||||
START_SUB_GROUP(list, list_info, "Display", &group_info, &subgroup_info, parent_group);
|
||||
|
||||
/* Only implemented for GLUI, XMB and Ozone at present */
|
||||
/* > MaterialUI, XMB and Ozone all support menu scaling */
|
||||
if (string_is_equal(settings->arrays.menu_driver, "glui") ||
|
||||
string_is_equal(settings->arrays.menu_driver, "xmb") ||
|
||||
string_is_equal(settings->arrays.menu_driver, "ozone"))
|
||||
{
|
||||
CONFIG_FLOAT(
|
||||
list, list_info,
|
||||
&settings->floats.menu_scale_factor,
|
||||
@ -12862,6 +12905,7 @@ 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);
|
||||
}
|
||||
|
||||
#ifdef HAVE_XMB
|
||||
if (string_is_equal(settings->arrays.menu_driver, "xmb"))
|
||||
|
@ -289,10 +289,12 @@ static unsigned libretro_message_width = 0;
|
||||
static char libretro_message[LIBRETRO_MESSAGE_SIZE] = {'\0'};
|
||||
|
||||
/* Metrics */
|
||||
#define BASE_FONT_SIZE 32.0f
|
||||
|
||||
static float widget_font_size;
|
||||
static unsigned simple_widget_padding = 0;
|
||||
static unsigned simple_widget_height;
|
||||
static unsigned glyph_width;
|
||||
static unsigned line_height;
|
||||
|
||||
static unsigned msg_queue_height;
|
||||
static unsigned msg_queue_icon_size_x;
|
||||
@ -316,6 +318,15 @@ static unsigned msg_queue_task_hourglass_x;
|
||||
|
||||
static unsigned generic_message_height; /* used for both generic and libretro messages */
|
||||
|
||||
static unsigned load_content_animation_icon_size_initial;
|
||||
static unsigned load_content_animation_icon_size_target;
|
||||
|
||||
static unsigned divider_width_1px;
|
||||
|
||||
static unsigned last_video_width;
|
||||
static unsigned last_video_height;
|
||||
static float last_scale_factor;
|
||||
|
||||
static void msg_widget_msg_transition_animation_done(void *userdata)
|
||||
{
|
||||
menu_widget_msg_t *msg = (menu_widget_msg_t*) userdata;
|
||||
@ -423,9 +434,8 @@ void menu_widgets_msg_queue_push(
|
||||
unsigned width = menu_driver_is_alive() ?
|
||||
msg_queue_default_rect_width_menu_alive : msg_queue_default_rect_width;
|
||||
unsigned text_width = font_driver_get_message_width(font_regular, title, title_length, msg_queue_text_scale_factor);
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
msg_widget->text_height = msg_queue_text_scale_factor * settings->floats.video_font_size;
|
||||
msg_widget->text_height = msg_queue_text_scale_factor * widget_font_size;
|
||||
|
||||
/* Text is too wide, split it into two lines */
|
||||
if (text_width > width)
|
||||
@ -863,10 +873,38 @@ static void menu_widgets_hourglass_tick(void *userdata)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
|
||||
void menu_widgets_iterate(unsigned width, unsigned height)
|
||||
/* Forward declaration */
|
||||
static void menu_widgets_layout(
|
||||
bool is_threaded, const char *dir_assets, char *font_path);
|
||||
|
||||
void menu_widgets_iterate(
|
||||
unsigned width, unsigned height,
|
||||
const char *dir_assets, char *font_path)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
/* Check whether screen dimensions or menu scale
|
||||
* factor have changed */
|
||||
float scale_factor = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ?
|
||||
menu_display_get_widget_pixel_scale(width, height) :
|
||||
menu_display_get_widget_dpi_scale(width, height);
|
||||
|
||||
if ((scale_factor != last_scale_factor) ||
|
||||
(width != last_video_width) ||
|
||||
(height != last_video_height))
|
||||
{
|
||||
last_scale_factor = scale_factor;
|
||||
last_video_width = width;
|
||||
last_video_height = height;
|
||||
|
||||
/* Note: We don't need a full context reset here
|
||||
* > Just rescale layout, and reset frame time counter */
|
||||
menu_widgets_layout(
|
||||
video_driver_is_threaded(),
|
||||
dir_assets, font_path);
|
||||
video_driver_monitor_reset();
|
||||
}
|
||||
|
||||
/* Messages queue */
|
||||
|
||||
/* Consume one message if available */
|
||||
@ -944,8 +982,6 @@ void menu_widgets_iterate(unsigned width, unsigned height)
|
||||
if (screenshot_filename[0] != '\0')
|
||||
{
|
||||
menu_timer_ctx_entry_t timer;
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_font_size = settings->floats.video_font_size;
|
||||
|
||||
video_driver_texture_unload(&screenshot_texture);
|
||||
|
||||
@ -953,7 +989,7 @@ void menu_widgets_iterate(unsigned width, unsigned height)
|
||||
"", &screenshot_texture, TEXTURE_FILTER_MIPMAP_LINEAR,
|
||||
&screenshot_texture_width, &screenshot_texture_height);
|
||||
|
||||
screenshot_height = video_font_size * 4;
|
||||
screenshot_height = widget_font_size * 4;
|
||||
screenshot_width = width;
|
||||
|
||||
screenshot_scale_factor = menu_widgets_get_thumbnail_scale_factor(
|
||||
@ -1013,8 +1049,6 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info,
|
||||
{
|
||||
unsigned height = simple_widget_height;
|
||||
const char *txt = msg_hash_to_str(msg);
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_font_size = settings->floats.video_font_size;
|
||||
|
||||
width = font_driver_get_message_width(font_regular, txt, (unsigned)strlen(txt), 1) + simple_widget_padding*2;
|
||||
|
||||
@ -1027,7 +1061,7 @@ static int menu_widgets_draw_indicator(video_frame_info_t *video_info,
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
txt,
|
||||
top_right_x_advance - width + simple_widget_padding, video_font_size + simple_widget_padding/4,
|
||||
top_right_x_advance - width + simple_widget_padding, widget_font_size + simple_widget_padding/4,
|
||||
video_info->width, video_info->height,
|
||||
0xFFFFFFFF, TEXT_ALIGN_LEFT,
|
||||
1.0f,
|
||||
@ -1054,8 +1088,6 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
|
||||
bool draw_msg_new = false;
|
||||
unsigned task_percentage_offset = 0;
|
||||
char task_percentage[256] = {0};
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_font_size = settings->floats.video_font_size;
|
||||
|
||||
if (msg->msg_new)
|
||||
draw_msg_new = !string_is_equal(msg->msg_new, msg->msg);
|
||||
@ -1143,7 +1175,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
|
||||
menu_display_draw_text(font_regular,
|
||||
msg->msg_new,
|
||||
msg_queue_task_text_start_x,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f - msg_queue_height/2 + msg->msg_transition_animation,
|
||||
video_info->width, video_info->height,
|
||||
text_color,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1157,7 +1189,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
|
||||
menu_display_draw_text(font_regular,
|
||||
msg->msg,
|
||||
msg_queue_task_text_start_x,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f + msg->msg_transition_animation,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f + msg->msg_transition_animation,
|
||||
video_info->width, video_info->height,
|
||||
text_color,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1180,7 +1212,7 @@ static void menu_widgets_draw_task_msg(menu_widget_msg_t *msg, video_frame_info_
|
||||
menu_display_draw_text(font_regular,
|
||||
task_percentage,
|
||||
msg_queue_rect_start_x - msg_queue_icon_size_x + rect_width - msg_queue_glyph_width,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * video_font_size + msg_queue_height/4 - video_font_size/2.25f,
|
||||
video_info->height - msg->offset_y + msg_queue_text_scale_factor * widget_font_size + msg_queue_height/4 - widget_font_size/2.25f,
|
||||
video_info->width, video_info->height,
|
||||
text_color,
|
||||
TEXT_ALIGN_RIGHT,
|
||||
@ -1300,12 +1332,11 @@ static void menu_widgets_draw_backdrop(video_frame_info_t *video_info, float alp
|
||||
|
||||
static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_info)
|
||||
{
|
||||
/* TODO: scale this right ? (change metrics) */
|
||||
|
||||
/* TODO: change metrics? */
|
||||
int icon_size = (int) load_content_animation_icon_size;
|
||||
uint32_t text_alpha = load_content_animation_fade_alpha * 255.0f;
|
||||
uint32_t text_color = COLOR_TEXT_ALPHA(0xB8B8B800, text_alpha);
|
||||
unsigned text_offset = -25 * load_content_animation_fade_alpha;
|
||||
unsigned text_offset = -25 * last_scale_factor * load_content_animation_fade_alpha;
|
||||
float *icon_color = load_content_animation_icon_color;
|
||||
|
||||
/* Fade out */
|
||||
@ -1328,7 +1359,7 @@ static void menu_widgets_draw_load_content_animation(video_frame_info_t *video_i
|
||||
menu_display_draw_text(font_bold,
|
||||
load_content_animation_content_name,
|
||||
video_info->width/2,
|
||||
video_info->height/2 + 175 + 25 + text_offset,
|
||||
video_info->height/2 + (175 + 25) * last_scale_factor + text_offset,
|
||||
video_info->width,
|
||||
video_info->height,
|
||||
text_color,
|
||||
@ -1356,8 +1387,6 @@ void menu_widgets_frame(void *data)
|
||||
video_frame_info_t *video_info = (video_frame_info_t*)data;
|
||||
int top_right_x_advance = video_info->width;
|
||||
int scissor_me_timbers = 0;
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_font_size = settings->floats.video_font_size;
|
||||
|
||||
menu_widgets_frame_count++;
|
||||
|
||||
@ -1391,28 +1420,28 @@ void menu_widgets_frame(void *data)
|
||||
/* top line */
|
||||
menu_display_draw_quad(video_info,
|
||||
0, 0,
|
||||
video_info->width, 1,
|
||||
video_info->width, divider_width_1px,
|
||||
video_info->width, video_info->height,
|
||||
outline_color
|
||||
);
|
||||
/* bottom line */
|
||||
menu_display_draw_quad(video_info,
|
||||
0, video_info->height-1,
|
||||
video_info->width, 1,
|
||||
0, video_info->height-divider_width_1px,
|
||||
video_info->width, divider_width_1px,
|
||||
video_info->width, video_info->height,
|
||||
outline_color
|
||||
);
|
||||
/* left line */
|
||||
menu_display_draw_quad(video_info,
|
||||
0, 0,
|
||||
1, video_info->height,
|
||||
divider_width_1px, video_info->height,
|
||||
video_info->width, video_info->height,
|
||||
outline_color
|
||||
);
|
||||
/* right line */
|
||||
menu_display_draw_quad(video_info,
|
||||
video_info->width-1, 0,
|
||||
1, video_info->height,
|
||||
video_info->width-divider_width_1px, 0,
|
||||
divider_width_1px, video_info->height,
|
||||
video_info->width, video_info->height,
|
||||
outline_color
|
||||
);
|
||||
@ -1436,7 +1465,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular, libretro_message,
|
||||
simple_widget_padding,
|
||||
video_info->height - generic_message_height/2 + line_height/4,
|
||||
video_info->height - generic_message_height/2 + widget_font_size/4,
|
||||
video_info->width, video_info->height,
|
||||
text_color, TEXT_ALIGN_LEFT,
|
||||
1, false, 0, false);
|
||||
@ -1456,7 +1485,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular, generic_message,
|
||||
video_info->width/2,
|
||||
video_info->height - generic_message_height/2 + line_height/4,
|
||||
video_info->height - generic_message_height/2 + widget_font_size/4,
|
||||
video_info->width, video_info->height,
|
||||
text_color, TEXT_ALIGN_CENTER,
|
||||
1, false, 0, false);
|
||||
@ -1488,7 +1517,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
msg_hash_to_str(MSG_SCREENSHOT_SAVED),
|
||||
screenshot_thumbnail_width + simple_widget_padding, video_font_size * 1.9f + screenshot_y,
|
||||
screenshot_thumbnail_width + simple_widget_padding, widget_font_size * 1.9f + screenshot_y,
|
||||
video_info->width, video_info->height,
|
||||
text_color_faint,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1505,7 +1534,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
shotname,
|
||||
screenshot_thumbnail_width + simple_widget_padding, video_font_size * 2.9f + screenshot_y,
|
||||
screenshot_thumbnail_width + simple_widget_padding, widget_font_size * 2.9f + screenshot_y,
|
||||
video_info->width, video_info->height,
|
||||
text_color_info,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1569,7 +1598,7 @@ void menu_widgets_frame(void *data)
|
||||
/* Title */
|
||||
menu_display_draw_text(font_regular,
|
||||
msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED),
|
||||
cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 1.9f + cheevo_y,
|
||||
cheevo_height + simple_widget_padding - unfold_offet, widget_font_size * 1.9f + cheevo_y,
|
||||
video_info->width, video_info->height,
|
||||
text_color_faint,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1582,7 +1611,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
cheevo_title,
|
||||
cheevo_height + simple_widget_padding - unfold_offet, video_font_size * 2.9f + cheevo_y,
|
||||
cheevo_height + simple_widget_padding - unfold_offet, widget_font_size * 2.9f + cheevo_y,
|
||||
video_info->width, video_info->height,
|
||||
text_color_info,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1606,13 +1635,13 @@ void menu_widgets_frame(void *data)
|
||||
menu_texture_item volume_icon = 0;
|
||||
|
||||
unsigned volume_width = video_info->width / 3;
|
||||
unsigned volume_height = video_font_size * 4;
|
||||
unsigned volume_height = widget_font_size * 4;
|
||||
unsigned icon_size = menu_widgets_icons_textures[MENU_WIDGETS_ICON_VOLUME_MED] ? volume_height : simple_widget_padding;
|
||||
unsigned text_color = COLOR_TEXT_ALPHA(0xffffffff, (unsigned)(volume_text_alpha*255.0f));
|
||||
unsigned text_color_db = COLOR_TEXT_ALPHA(text_color_faint, (unsigned)(volume_text_alpha*255.0f));
|
||||
|
||||
unsigned bar_x = icon_size;
|
||||
unsigned bar_height = video_font_size / 2;
|
||||
unsigned bar_height = widget_font_size / 2;
|
||||
unsigned bar_width = volume_width - bar_x - simple_widget_padding;
|
||||
unsigned bar_y = volume_height / 2 + bar_height/2;
|
||||
|
||||
@ -1688,7 +1717,7 @@ void menu_widgets_frame(void *data)
|
||||
const char *text = msg_hash_to_str(MSG_AUDIO_MUTED);
|
||||
menu_display_draw_text(font_regular,
|
||||
text,
|
||||
volume_width/2, volume_height/2 + video_font_size / 3,
|
||||
volume_width/2, volume_height/2 + widget_font_size / 3,
|
||||
video_info->width, video_info->height,
|
||||
text_color, TEXT_ALIGN_CENTER,
|
||||
1, false, 0, false
|
||||
@ -1724,7 +1753,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
msg,
|
||||
volume_width - simple_widget_padding, video_font_size * 2,
|
||||
volume_width - simple_widget_padding, widget_font_size * 2,
|
||||
video_info->width, video_info->height,
|
||||
text_color_db,
|
||||
TEXT_ALIGN_RIGHT,
|
||||
@ -1733,7 +1762,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
percentage_msg,
|
||||
icon_size, video_font_size * 2,
|
||||
icon_size, widget_font_size * 2,
|
||||
video_info->width, video_info->height,
|
||||
text_color,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1768,6 +1797,11 @@ void menu_widgets_frame(void *data)
|
||||
int text_width = font_driver_get_message_width(font_regular, text, (unsigned)strlen(text), 1.0f);
|
||||
int total_width = text_width + simple_widget_padding * 2;
|
||||
|
||||
int fps_text_x = top_right_x_advance - simple_widget_padding - text_width;
|
||||
/* Ensure that left hand side of text does
|
||||
* not bleed off the edge of the screen */
|
||||
fps_text_x = (fps_text_x < 0) ? 0 : fps_text_x;
|
||||
|
||||
menu_display_set_alpha(menu_widgets_backdrop_orig, DEFAULT_BACKDROP);
|
||||
|
||||
menu_display_draw_quad(video_info,
|
||||
@ -1779,7 +1813,7 @@ void menu_widgets_frame(void *data)
|
||||
|
||||
menu_display_draw_text(font_regular,
|
||||
text,
|
||||
top_right_x_advance - simple_widget_padding - text_width, video_font_size + simple_widget_padding/4,
|
||||
fps_text_x, widget_font_size + simple_widget_padding/4,
|
||||
video_info->width, video_info->height,
|
||||
0xFFFFFFFF,
|
||||
TEXT_ALIGN_LEFT,
|
||||
@ -1855,6 +1889,16 @@ bool menu_widgets_init(bool video_is_threaded)
|
||||
if (!file_list_reserve(current_msgs, MSG_QUEUE_ONSCREEN_MAX))
|
||||
goto error;
|
||||
|
||||
/* Initialise scaling parameters
|
||||
* NOTE - special cases:
|
||||
* > Ozone has a capped scale factor
|
||||
* > 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 = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ?
|
||||
menu_display_get_widget_pixel_scale(last_video_width, last_video_height) :
|
||||
menu_display_get_widget_dpi_scale(last_video_width, last_video_height);
|
||||
|
||||
return true;
|
||||
|
||||
error:
|
||||
@ -1863,93 +1907,66 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
void menu_widgets_context_reset(bool is_threaded,
|
||||
unsigned width, unsigned height)
|
||||
static void menu_widgets_layout(
|
||||
bool is_threaded, const char *dir_assets, char *font_path)
|
||||
{
|
||||
int i;
|
||||
char xmb_path[PATH_MAX_LENGTH];
|
||||
char monochrome_png_path[PATH_MAX_LENGTH];
|
||||
char menu_widgets_path[PATH_MAX_LENGTH];
|
||||
char theme_path[PATH_MAX_LENGTH];
|
||||
char ozone_path[PATH_MAX_LENGTH];
|
||||
char font_path[PATH_MAX_LENGTH];
|
||||
settings_t *settings = config_get_ptr();
|
||||
float video_font_size = settings->floats.video_font_size;
|
||||
int font_height = 0;
|
||||
|
||||
/* Textures paths */
|
||||
fill_pathname_join(
|
||||
menu_widgets_path,
|
||||
settings->paths.directory_assets,
|
||||
"menu_widgets",
|
||||
sizeof(menu_widgets_path)
|
||||
);
|
||||
/* Base font size must be determined first */
|
||||
widget_font_size = BASE_FONT_SIZE * last_scale_factor;
|
||||
|
||||
fill_pathname_join(
|
||||
xmb_path,
|
||||
settings->paths.directory_assets,
|
||||
"xmb",
|
||||
sizeof(xmb_path)
|
||||
);
|
||||
/* Initialise fonts */
|
||||
|
||||
/* Monochrome */
|
||||
fill_pathname_join(
|
||||
theme_path,
|
||||
xmb_path,
|
||||
"monochrome",
|
||||
sizeof(theme_path)
|
||||
);
|
||||
|
||||
fill_pathname_join(
|
||||
monochrome_png_path,
|
||||
theme_path,
|
||||
"png",
|
||||
sizeof(monochrome_png_path)
|
||||
);
|
||||
|
||||
/* Load textures */
|
||||
/* Icons */
|
||||
for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++)
|
||||
/* > Free existing */
|
||||
if (font_regular)
|
||||
{
|
||||
menu_display_reset_textures_list(menu_widgets_icons_names[i], monochrome_png_path, &menu_widgets_icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL);
|
||||
menu_display_font_free(font_regular);
|
||||
font_regular = NULL;
|
||||
}
|
||||
if (font_bold)
|
||||
{
|
||||
menu_display_font_free(font_bold);
|
||||
font_bold = NULL;
|
||||
}
|
||||
|
||||
/* Message queue */
|
||||
menu_display_reset_textures_list("msg_queue_icon.png", menu_widgets_path, &msg_queue_icon, TEXTURE_FILTER_LINEAR, NULL, NULL);
|
||||
menu_display_reset_textures_list("msg_queue_icon_outline.png", menu_widgets_path, &msg_queue_icon_outline, TEXTURE_FILTER_LINEAR, NULL, NULL);
|
||||
menu_display_reset_textures_list("msg_queue_icon_rect.png", menu_widgets_path, &msg_queue_icon_rect, TEXTURE_FILTER_NEAREST, NULL, NULL);
|
||||
|
||||
msg_queue_has_icons = msg_queue_icon && msg_queue_icon_outline && msg_queue_icon_rect;
|
||||
|
||||
/* Fonts paths */
|
||||
fill_pathname_join(
|
||||
ozone_path,
|
||||
settings->paths.directory_assets,
|
||||
"ozone",
|
||||
sizeof(ozone_path)
|
||||
);
|
||||
|
||||
/* Fonts */
|
||||
if (settings->paths.path_font[0] == '\0')
|
||||
/* > Create new */
|
||||
if (string_is_empty(font_path))
|
||||
{
|
||||
fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path));
|
||||
font_regular = menu_display_font_file(font_path, video_font_size, is_threaded);
|
||||
char ozone_path[PATH_MAX_LENGTH];
|
||||
char font_path[PATH_MAX_LENGTH];
|
||||
|
||||
ozone_path[0] = '\0';
|
||||
font_path[0] = '\0';
|
||||
|
||||
/* Base path */
|
||||
fill_pathname_join(ozone_path, dir_assets, "ozone", sizeof(ozone_path));
|
||||
|
||||
/* Create regular font */
|
||||
fill_pathname_join(font_path, ozone_path, "regular.ttf", sizeof(font_path));
|
||||
font_regular = menu_display_font_file(font_path, widget_font_size, is_threaded);
|
||||
|
||||
/* Create bold font */
|
||||
fill_pathname_join(font_path, ozone_path, "bold.ttf", sizeof(font_path));
|
||||
font_bold = menu_display_font_file(font_path, video_font_size, is_threaded);
|
||||
font_bold = menu_display_font_file(font_path, widget_font_size, is_threaded);
|
||||
}
|
||||
else
|
||||
{
|
||||
font_regular = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded);
|
||||
font_bold = menu_display_font_file(settings->paths.path_font, video_font_size, is_threaded);
|
||||
/* Load fonts from user-supplied path */
|
||||
font_regular = menu_display_font_file(font_path, widget_font_size, is_threaded);
|
||||
font_bold = menu_display_font_file(font_path, widget_font_size, is_threaded);
|
||||
}
|
||||
|
||||
/* Metrics */
|
||||
simple_widget_padding = video_font_size * 2/3;
|
||||
simple_widget_height = video_font_size + simple_widget_padding;
|
||||
glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1);
|
||||
line_height = font_driver_get_line_height(font_regular, 1);
|
||||
/* > Get actual font size */
|
||||
font_height = font_driver_get_line_height(font_regular, 1.0f);
|
||||
if (font_height > 0)
|
||||
widget_font_size = (float)font_height;
|
||||
|
||||
msg_queue_height = video_font_size * 2.5f;
|
||||
/* Calculate dimensions */
|
||||
simple_widget_padding = widget_font_size * 2.0f/3.0f;
|
||||
simple_widget_height = widget_font_size + simple_widget_padding;
|
||||
glyph_width = font_driver_get_message_width(font_regular, "a", 1, 1);
|
||||
|
||||
msg_queue_height = widget_font_size * 2.5f;
|
||||
|
||||
if (msg_queue_has_icons)
|
||||
{
|
||||
@ -1984,14 +2001,89 @@ void menu_widgets_context_reset(bool is_threaded,
|
||||
msg_queue_task_text_start_x -= msg_queue_glyph_width*2;
|
||||
|
||||
msg_queue_regular_text_start = msg_queue_rect_start_x + msg_queue_regular_padding_x;
|
||||
msg_queue_regular_text_base_y = video_font_size * msg_queue_text_scale_factor + msg_queue_height/2;
|
||||
msg_queue_regular_text_base_y = widget_font_size * msg_queue_text_scale_factor + msg_queue_height/2;
|
||||
|
||||
msg_queue_task_hourglass_x = msg_queue_rect_start_x - msg_queue_icon_size_x;
|
||||
|
||||
generic_message_height = video_font_size * 2;
|
||||
generic_message_height = widget_font_size * 2;
|
||||
|
||||
msg_queue_default_rect_width_menu_alive = msg_queue_glyph_width * 40;
|
||||
msg_queue_default_rect_width = width - msg_queue_regular_text_start - (2 * simple_widget_padding);
|
||||
msg_queue_default_rect_width = last_video_width - msg_queue_regular_text_start - (2 * simple_widget_padding);
|
||||
|
||||
load_content_animation_icon_size_initial = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE * last_scale_factor;
|
||||
load_content_animation_icon_size_target = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE * last_scale_factor;
|
||||
|
||||
divider_width_1px = (last_scale_factor > 1.0f) ? (unsigned)(last_scale_factor + 0.5f) : 1;
|
||||
}
|
||||
|
||||
void menu_widgets_context_reset(bool is_threaded,
|
||||
unsigned width, unsigned height,
|
||||
const char *dir_assets, char *font_path)
|
||||
{
|
||||
int i;
|
||||
char xmb_path[PATH_MAX_LENGTH];
|
||||
char monochrome_png_path[PATH_MAX_LENGTH];
|
||||
char menu_widgets_path[PATH_MAX_LENGTH];
|
||||
char theme_path[PATH_MAX_LENGTH];
|
||||
|
||||
xmb_path[0] = '\0';
|
||||
monochrome_png_path[0] = '\0';
|
||||
menu_widgets_path[0] = '\0';
|
||||
theme_path[0] = '\0';
|
||||
|
||||
/* Textures paths */
|
||||
fill_pathname_join(
|
||||
menu_widgets_path,
|
||||
dir_assets,
|
||||
"menu_widgets",
|
||||
sizeof(menu_widgets_path)
|
||||
);
|
||||
|
||||
fill_pathname_join(
|
||||
xmb_path,
|
||||
dir_assets,
|
||||
"xmb",
|
||||
sizeof(xmb_path)
|
||||
);
|
||||
|
||||
/* Monochrome */
|
||||
fill_pathname_join(
|
||||
theme_path,
|
||||
xmb_path,
|
||||
"monochrome",
|
||||
sizeof(theme_path)
|
||||
);
|
||||
|
||||
fill_pathname_join(
|
||||
monochrome_png_path,
|
||||
theme_path,
|
||||
"png",
|
||||
sizeof(monochrome_png_path)
|
||||
);
|
||||
|
||||
/* Load textures */
|
||||
/* Icons */
|
||||
for (i = 0; i < MENU_WIDGETS_ICON_LAST; i++)
|
||||
{
|
||||
menu_display_reset_textures_list(menu_widgets_icons_names[i], monochrome_png_path, &menu_widgets_icons_textures[i], TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL);
|
||||
}
|
||||
|
||||
/* Message queue */
|
||||
menu_display_reset_textures_list("msg_queue_icon.png", menu_widgets_path, &msg_queue_icon, TEXTURE_FILTER_LINEAR, NULL, NULL);
|
||||
menu_display_reset_textures_list("msg_queue_icon_outline.png", menu_widgets_path, &msg_queue_icon_outline, TEXTURE_FILTER_LINEAR, NULL, NULL);
|
||||
menu_display_reset_textures_list("msg_queue_icon_rect.png", menu_widgets_path, &msg_queue_icon_rect, TEXTURE_FILTER_NEAREST, NULL, NULL);
|
||||
|
||||
msg_queue_has_icons = msg_queue_icon && msg_queue_icon_outline && msg_queue_icon_rect;
|
||||
|
||||
/* Update scaling/dimensions */
|
||||
last_video_width = width;
|
||||
last_video_height = height;
|
||||
last_scale_factor = (menu_driver_ident_id() == MENU_DRIVER_ID_XMB) ?
|
||||
menu_display_get_widget_pixel_scale(last_video_width, last_video_height) :
|
||||
menu_display_get_widget_dpi_scale(last_video_width, last_video_height);
|
||||
menu_widgets_layout(is_threaded, dir_assets, font_path);
|
||||
|
||||
video_driver_monitor_reset();
|
||||
}
|
||||
|
||||
void menu_widgets_context_destroy(void)
|
||||
@ -2009,8 +2101,10 @@ void menu_widgets_context_destroy(void)
|
||||
video_driver_texture_unload(&msg_queue_icon_rect);
|
||||
|
||||
/* Fonts */
|
||||
menu_display_font_free(font_regular);
|
||||
menu_display_font_free(font_bold);
|
||||
if (font_regular)
|
||||
menu_display_font_free(font_regular);
|
||||
if (font_bold)
|
||||
menu_display_font_free(font_bold);
|
||||
|
||||
font_regular = NULL;
|
||||
font_bold = NULL;
|
||||
@ -2122,12 +2216,10 @@ static void menu_widgets_volume_timer_end(void *userdata)
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
|
||||
void menu_widgets_volume_update_and_show(void)
|
||||
void menu_widgets_volume_update_and_show(float new_volume)
|
||||
{
|
||||
menu_timer_ctx_entry_t entry;
|
||||
settings_t *settings = config_get_ptr();
|
||||
bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE));
|
||||
float new_volume = settings->floats.audio_volume;
|
||||
bool mute = *(audio_get_bool_ptr(AUDIO_ACTION_MUTE_ENABLE));
|
||||
|
||||
menu_animation_kill_by_tag(&volume_tag);
|
||||
|
||||
@ -2245,7 +2337,6 @@ void menu_widgets_cleanup_load_content_animation(void)
|
||||
void menu_widgets_start_load_content_animation(const char *content_name, bool remove_extension)
|
||||
{
|
||||
/* TODO: finish the animation based on design, correct all timings */
|
||||
/* TODO: scale the icon correctly */
|
||||
menu_animation_ctx_entry_t entry;
|
||||
menu_timer_ctx_entry_t timer_entry;
|
||||
int i;
|
||||
@ -2270,7 +2361,7 @@ void menu_widgets_start_load_content_animation(const char *content_name, bool re
|
||||
path_remove_extension(load_content_animation_content_name);
|
||||
|
||||
/* Reset animation state */
|
||||
load_content_animation_icon_size = LOAD_CONTENT_ANIMATION_INITIAL_ICON_SIZE;
|
||||
load_content_animation_icon_size = load_content_animation_icon_size_initial;
|
||||
load_content_animation_icon_alpha = 0.0f;
|
||||
load_content_animation_fade_alpha = 0.0f;
|
||||
load_content_animation_final_fade_alpha = 0.0f;
|
||||
@ -2287,7 +2378,7 @@ void menu_widgets_start_load_content_animation(const char *content_name, bool re
|
||||
/* Position */
|
||||
entry.duration = ANIMATION_LOAD_CONTENT_DURATION;
|
||||
entry.subject = &load_content_animation_icon_size;
|
||||
entry.target_value = LOAD_CONTENT_ANIMATION_TARGET_ICON_SIZE;
|
||||
entry.target_value = load_content_animation_icon_size_target;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
|
||||
@ -2404,8 +2495,7 @@ static void menu_widgets_achievement_unfold(void *userdata)
|
||||
static void menu_widgets_start_achievement_notification(void)
|
||||
{
|
||||
menu_animation_ctx_entry_t entry;
|
||||
settings_t *settings = config_get_ptr();
|
||||
cheevo_height = settings->floats.video_font_size * 4;
|
||||
cheevo_height = widget_font_size * 4;
|
||||
cheevo_width = MAX(
|
||||
font_driver_get_message_width(font_regular, msg_hash_to_str(MSG_ACHIEVEMENT_UNLOCKED), 0, 1),
|
||||
font_driver_get_message_width(font_regular, cheevo_title, 0, 1)
|
||||
|
@ -48,9 +48,11 @@ void menu_widgets_msg_queue_push(
|
||||
enum message_queue_category category,
|
||||
unsigned prio, bool flush);
|
||||
|
||||
void menu_widgets_volume_update_and_show(void);
|
||||
void menu_widgets_volume_update_and_show(float new_volume);
|
||||
|
||||
void menu_widgets_iterate(unsigned width, unsigned height);
|
||||
void menu_widgets_iterate(
|
||||
unsigned width, unsigned height,
|
||||
const char *dir_assets, char *font_path);
|
||||
|
||||
void menu_widgets_screenshot_taken(const char *shotname, const char *filename);
|
||||
|
||||
@ -70,7 +72,8 @@ void menu_widgets_start_load_content_animation(
|
||||
void menu_widgets_cleanup_load_content_animation(void);
|
||||
|
||||
void menu_widgets_context_reset(bool is_threaded,
|
||||
unsigned width, unsigned height);
|
||||
unsigned width, unsigned height,
|
||||
const char *dir_assets, char *font_path);
|
||||
|
||||
void menu_widgets_context_destroy(void);
|
||||
|
||||
|
@ -517,6 +517,8 @@ enum msg_hash_enums
|
||||
MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END = MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN + RARCH_BIND_LIST_END,
|
||||
|
||||
MENU_LABEL(MENU_SCALE_FACTOR),
|
||||
MENU_LABEL(MENU_WIDGET_SCALE_AUTO),
|
||||
MENU_LABEL(MENU_WIDGET_SCALE_FACTOR),
|
||||
MENU_LABEL(MENU_WALLPAPER_OPACITY),
|
||||
MENU_LABEL(MENU_FRAMEBUFFER_OPACITY),
|
||||
MENU_LABEL(MENU_USE_PREFERRED_SYSTEM_COLOR_THEME),
|
||||
|
14
retroarch.c
14
retroarch.c
@ -5415,7 +5415,7 @@ static void command_event_set_volume(float gain)
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (menu_widgets_inited)
|
||||
menu_widgets_volume_update_and_show();
|
||||
menu_widgets_volume_update_and_show(settings->floats.audio_volume);
|
||||
else
|
||||
#endif
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -6895,7 +6895,7 @@ TODO: Add a setting for these tweaks */
|
||||
|
||||
#if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS)
|
||||
if (menu_widgets_inited)
|
||||
menu_widgets_volume_update_and_show();
|
||||
menu_widgets_volume_update_and_show(configuration_settings->floats.audio_volume);
|
||||
else
|
||||
#endif
|
||||
runloop_msg_queue_push(msg, 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
|
||||
@ -23451,7 +23451,9 @@ static void drivers_init(int flags)
|
||||
|
||||
if (menu_widgets_inited)
|
||||
menu_widgets_context_reset(video_is_threaded,
|
||||
video_driver_width, video_driver_height);
|
||||
video_driver_width, video_driver_height,
|
||||
settings->paths.directory_assets,
|
||||
settings->paths.path_font);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -27277,7 +27279,6 @@ static enum runloop_state runloop_check_state(void)
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
menu_animation_update(
|
||||
settings->arrays.menu_driver,
|
||||
settings->bools.menu_timedate_enable,
|
||||
settings->floats.menu_ticker_speed,
|
||||
video_driver_width, video_driver_height);
|
||||
@ -27286,7 +27287,10 @@ static enum runloop_state runloop_check_state(void)
|
||||
if (menu_widgets_inited)
|
||||
{
|
||||
runloop_msg_queue_lock();
|
||||
menu_widgets_iterate(video_driver_width, video_driver_height);
|
||||
menu_widgets_iterate(
|
||||
video_driver_width, video_driver_height,
|
||||
settings->paths.directory_assets,
|
||||
settings->paths.path_font);
|
||||
runloop_msg_queue_unlock();
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user