mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 10:20:51 +00:00
Merge pull request #10134 from jdgleaver/ozone-bg-opacity
(Ozone) Enable configuration of background opacity when content is running
This commit is contained in:
commit
51b9854a19
@ -1665,10 +1665,11 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
gfx_animation_ctx_entry_t entry;
|
||||
ozone_handle_t* ozone = (ozone_handle_t*) data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
unsigned color_theme = video_info->ozone_color_theme;
|
||||
unsigned color_theme = settings->uints.menu_ozone_color_theme;
|
||||
gfx_animation_ctx_tag messagebox_tag = (uintptr_t)ozone->pending_message;
|
||||
bool draw_osk = menu_input_dialog_get_display_kb();
|
||||
static bool draw_osk_old = false;
|
||||
float *background_color = NULL;
|
||||
|
||||
#if 0
|
||||
static bool reset = false;
|
||||
@ -1708,16 +1709,18 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
}
|
||||
|
||||
/* Change theme on the fly */
|
||||
if (color_theme != last_color_theme || last_use_preferred_system_color_theme != settings->bools.menu_use_preferred_system_color_theme)
|
||||
if ((color_theme != last_color_theme) ||
|
||||
(last_use_preferred_system_color_theme != settings->bools.menu_use_preferred_system_color_theme))
|
||||
{
|
||||
if (!settings->bools.menu_use_preferred_system_color_theme)
|
||||
ozone_set_color_theme(ozone, color_theme);
|
||||
else
|
||||
if (settings->bools.menu_use_preferred_system_color_theme)
|
||||
{
|
||||
video_info->ozone_color_theme = ozone_get_system_theme();
|
||||
ozone_set_color_theme(ozone, video_info->ozone_color_theme);
|
||||
color_theme = ozone_get_system_theme();
|
||||
settings->uints.menu_ozone_color_theme = color_theme;
|
||||
}
|
||||
|
||||
ozone_set_color_theme(ozone, color_theme);
|
||||
ozone_set_background_running_opacity(ozone, video_info->menu_framebuffer_opacity);
|
||||
|
||||
last_use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme;
|
||||
}
|
||||
|
||||
@ -1739,10 +1742,21 @@ static void ozone_frame(void *data, video_frame_info_t *video_info)
|
||||
ozone->raster_blocks.sidebar.carr.coords.vertices = 0;
|
||||
|
||||
/* Background */
|
||||
if (video_info->libretro_running &&
|
||||
(video_info->menu_framebuffer_opacity < 1.0f))
|
||||
{
|
||||
if (video_info->menu_framebuffer_opacity != last_framebuffer_opacity)
|
||||
ozone_set_background_running_opacity(ozone, video_info->menu_framebuffer_opacity);
|
||||
|
||||
background_color = ozone->theme->background_libretro_running;
|
||||
}
|
||||
else
|
||||
background_color = ozone->theme->background;
|
||||
|
||||
gfx_display_draw_quad(video_info,
|
||||
0, 0, video_info->width, video_info->height,
|
||||
video_info->width, video_info->height,
|
||||
!video_info->libretro_running ? ozone->theme->background : ozone->theme->background_libretro_running
|
||||
background_color
|
||||
);
|
||||
|
||||
/* Header, footer */
|
||||
|
@ -747,7 +747,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i
|
||||
bool show_left_thumbnail;
|
||||
|
||||
/* Background */
|
||||
if (!video_info->libretro_running)
|
||||
if (!video_info->libretro_running || (video_info->menu_framebuffer_opacity >= 1.0f))
|
||||
{
|
||||
gfx_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + ozone->dimensions.spacer_1px, (unsigned) ozone->animations.thumbnail_bar_position, ozone->dimensions.sidebar_gradient_height, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient);
|
||||
gfx_display_draw_quad(video_info, x_position, ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_gradient_height, (unsigned) ozone->animations.thumbnail_bar_position, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background);
|
||||
|
@ -151,7 +151,7 @@ void ozone_draw_sidebar(ozone_handle_t *ozone, video_frame_info_t *video_info)
|
||||
/* Background */
|
||||
sidebar_height = video_info->height - ozone->dimensions.header_height - ozone->dimensions.sidebar_gradient_height * 2 - ozone->dimensions.footer_height;
|
||||
|
||||
if (!video_info->libretro_running)
|
||||
if (!video_info->libretro_running || (video_info->menu_framebuffer_opacity >= 1.0f))
|
||||
{
|
||||
gfx_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + ozone->dimensions.spacer_1px, (unsigned) ozone->dimensions.sidebar_width, ozone->dimensions.sidebar_gradient_height, video_info->width, video_info->height, ozone->theme->sidebar_top_gradient);
|
||||
gfx_display_draw_quad(video_info, ozone->sidebar_offset, ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_gradient_height, (unsigned) ozone->dimensions.sidebar_width, sidebar_height, video_info->width, video_info->height, ozone->theme->sidebar_background);
|
||||
|
@ -86,6 +86,12 @@ unsigned last_color_theme = 0;
|
||||
bool last_use_preferred_system_color_theme = false;
|
||||
ozone_theme_t *ozone_default_theme = &ozone_theme_dark; /* also used as a tag for cursor animation */
|
||||
|
||||
/* Enable runtime configuration of framebuffer
|
||||
* opacity */
|
||||
float last_framebuffer_opacity = -1.0f;
|
||||
static float background_running_alpha_top = 1.0f;
|
||||
static float background_running_alpha_bottom = 0.75f;
|
||||
|
||||
void ozone_set_color_theme(ozone_handle_t *ozone, unsigned color_theme)
|
||||
{
|
||||
ozone_theme_t *theme = ozone_default_theme;
|
||||
@ -136,3 +142,37 @@ unsigned ozone_get_system_theme(void)
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ozone_set_background_running_opacity(ozone_handle_t *ozone, float framebuffer_opacity)
|
||||
{
|
||||
float *background = NULL;
|
||||
|
||||
if (!ozone || !ozone->theme->background_libretro_running)
|
||||
return;
|
||||
|
||||
background = ozone->theme->background_libretro_running;
|
||||
|
||||
/* When content is running, background is a
|
||||
* gradient that from top to bottom transitions
|
||||
* from maximum to minimum opacity
|
||||
* > RetroArch default 'framebuffer_opacity'
|
||||
* is 0.900. At this setting:
|
||||
* - Background top has an alpha of 1.0
|
||||
* - Background bottom has an alpha of 0.75 */
|
||||
background_running_alpha_top = framebuffer_opacity / 0.9f;
|
||||
background_running_alpha_top = (background_running_alpha_top > 1.0f) ?
|
||||
1.0f : (background_running_alpha_top < 0.0f) ?
|
||||
0.0f : background_running_alpha_top;
|
||||
|
||||
background_running_alpha_bottom = (2.5f * framebuffer_opacity) - 1.5f;
|
||||
background_running_alpha_bottom = (background_running_alpha_bottom > 1.0f) ?
|
||||
1.0f : (background_running_alpha_bottom < 0.0f) ?
|
||||
0.0f : background_running_alpha_bottom;
|
||||
|
||||
background[11] = background_running_alpha_top;
|
||||
background[15] = background_running_alpha_top;
|
||||
background[3] = background_running_alpha_bottom;
|
||||
background[7] = background_running_alpha_bottom;
|
||||
|
||||
last_framebuffer_opacity = framebuffer_opacity;
|
||||
}
|
||||
|
@ -151,8 +151,10 @@ extern unsigned ozone_themes_count;
|
||||
extern unsigned last_color_theme;
|
||||
extern bool last_use_preferred_system_color_theme;
|
||||
extern ozone_theme_t *ozone_default_theme;
|
||||
extern float last_framebuffer_opacity;
|
||||
|
||||
void ozone_set_color_theme(ozone_handle_t *ozone, unsigned color_theme);
|
||||
unsigned ozone_get_system_theme(void);
|
||||
void ozone_set_background_running_opacity(ozone_handle_t *ozone, float framebuffer_opacity);
|
||||
|
||||
#endif
|
||||
|
@ -12294,7 +12294,8 @@ static bool setting_append_list(
|
||||
|
||||
START_SUB_GROUP(list, list_info, "State", &group_info, &subgroup_info, parent_group);
|
||||
|
||||
if (string_is_not_equal(settings->arrays.menu_driver, "rgui"))
|
||||
if (string_is_not_equal(settings->arrays.menu_driver, "rgui") &&
|
||||
string_is_not_equal(settings->arrays.menu_driver, "ozone"))
|
||||
{
|
||||
CONFIG_PATH(
|
||||
list, list_info,
|
||||
@ -12325,7 +12326,10 @@ static bool setting_append_list(
|
||||
(*list)[list_info->index - 1].action_ok = &setting_action_ok_uint;
|
||||
menu_settings_list_current_add_range(list, list_info, 0.0, 1.0, 0.010, true, true);
|
||||
SETTINGS_DATA_LIST_CURRENT_ADD_FLAGS(list, list_info, SD_FLAG_LAKKA_ADVANCED);
|
||||
}
|
||||
|
||||
if (string_is_not_equal(settings->arrays.menu_driver, "rgui"))
|
||||
{
|
||||
CONFIG_FLOAT(
|
||||
list, list_info,
|
||||
&settings->floats.menu_framebuffer_opacity,
|
||||
|
Loading…
x
Reference in New Issue
Block a user