mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 18:20:27 +00:00
Every menu driver can set its own callback
This commit is contained in:
parent
98227a886b
commit
084bad5aaa
@ -5588,6 +5588,13 @@ static void materialui_init_nav_bar(materialui_handle_t *mui)
|
||||
mui->nav_bar.location = MUI_NAV_BAR_LOCATION_BOTTOM;
|
||||
}
|
||||
|
||||
static void materialui_menu_animation_update_time(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height)
|
||||
{
|
||||
*(dst) *= menu_display_get_dpi_scale(video_width, video_height) * 0.8f;
|
||||
}
|
||||
|
||||
static void *materialui_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
unsigned width, height;
|
||||
@ -5670,10 +5677,13 @@ static void *materialui_init(void **userdata, bool video_is_threaded)
|
||||
mui->fullscreen_thumbnail_alpha = 0.0f;
|
||||
mui->fullscreen_thumbnail_label[0] = '\0';
|
||||
|
||||
menu_animation_set_update_time_cb(materialui_menu_animation_update_time);
|
||||
|
||||
return menu;
|
||||
error:
|
||||
if (menu)
|
||||
free(menu);
|
||||
menu_animation_unset_update_time_cb();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -5692,6 +5702,7 @@ static void materialui_free(void *data)
|
||||
|
||||
if (mui->thumbnail_path_data)
|
||||
free(mui->thumbnail_path_data);
|
||||
menu_animation_unset_update_time_cb();
|
||||
}
|
||||
|
||||
static void materialui_context_bg_destroy(materialui_handle_t *mui)
|
||||
|
@ -124,6 +124,14 @@ void ozone_free_list_nodes(file_list_t *list, bool actiondata)
|
||||
}
|
||||
}
|
||||
|
||||
static void ozone_menu_animation_update_time(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height)
|
||||
{
|
||||
*(dst) *= menu_display_get_dpi_scale(video_width, video_height) * 0.5f;
|
||||
}
|
||||
|
||||
|
||||
static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
bool fallback_color_theme = false;
|
||||
@ -303,6 +311,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
);
|
||||
|
||||
last_use_preferred_system_color_theme = settings->bools.menu_use_preferred_system_color_theme;
|
||||
menu_animation_set_update_time_cb(ozone_menu_animation_update_time);
|
||||
|
||||
return menu;
|
||||
|
||||
@ -327,6 +336,7 @@ error:
|
||||
|
||||
if (menu)
|
||||
free(menu);
|
||||
menu_animation_unset_update_time_cb();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@ -367,6 +377,7 @@ static void ozone_free(void *data)
|
||||
if (ozone->thumbnail_path_data)
|
||||
free(ozone->thumbnail_path_data);
|
||||
}
|
||||
menu_animation_unset_update_time_cb();
|
||||
}
|
||||
|
||||
unsigned ozone_count_lines(const char *str)
|
||||
|
@ -4240,6 +4240,13 @@ static bool rgui_set_aspect_ratio(rgui_t *rgui, bool delay_update)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void rgui_menu_animation_update_time(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned height)
|
||||
{
|
||||
*(dst) *= 0.25f;
|
||||
}
|
||||
|
||||
static void *rgui_init(void **userdata, bool video_is_threaded)
|
||||
{
|
||||
unsigned new_font_height;
|
||||
@ -4348,6 +4355,8 @@ static void *rgui_init(void **userdata, bool video_is_threaded)
|
||||
* values (shoult not be necessary, but some platforms may
|
||||
* not handle struct initialisation correctly...) */
|
||||
memset(&rgui->pointer, 0, sizeof(menu_input_pointer_t));
|
||||
|
||||
menu_animation_set_update_time_cb(rgui_menu_animation_update_time);
|
||||
|
||||
return menu;
|
||||
|
||||
@ -4359,6 +4368,7 @@ error:
|
||||
rgui_thumbnail_free(&mini_left_thumbnail);
|
||||
if (menu)
|
||||
free(menu);
|
||||
menu_animation_unset_update_time_cb();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -4383,6 +4393,8 @@ static void rgui_free(void *data)
|
||||
free(rgui_upscale_buf.data);
|
||||
rgui_upscale_buf.data = NULL;
|
||||
}
|
||||
|
||||
menu_animation_unset_update_time_cb();
|
||||
}
|
||||
|
||||
static void rgui_set_texture(void)
|
||||
|
@ -33,7 +33,6 @@
|
||||
#undef DG_DYNARR_IMPLEMENTATION
|
||||
|
||||
#include "menu_animation.h"
|
||||
#include "menu_driver.h"
|
||||
#include "../performance_counters.h"
|
||||
|
||||
typedef float (*easing_cb) (float, float, float, float);
|
||||
@ -85,6 +84,13 @@ static float delta_time = 0.0f;
|
||||
static bool animation_is_active = false;
|
||||
static bool ticker_is_active = false;
|
||||
|
||||
/* Forward declarations */
|
||||
static void menu_animation_update_time_default(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height);
|
||||
|
||||
static update_time_cb update_time_callback = menu_animation_update_time_default;
|
||||
|
||||
/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */
|
||||
|
||||
static float easing_linear(float t, float b, float c, float d)
|
||||
@ -1187,27 +1193,6 @@ bool menu_animation_push(menu_animation_ctx_entry_t *entry)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void menu_animation_update_time_rgui(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned height)
|
||||
{
|
||||
*(dst) *= 0.25f;
|
||||
}
|
||||
|
||||
static void menu_animation_update_time_ozone(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height)
|
||||
{
|
||||
*(dst) *= menu_display_get_dpi_scale(video_width, video_height) * 0.5f;
|
||||
}
|
||||
|
||||
static void menu_animation_update_time_materialui(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height)
|
||||
{
|
||||
*(dst) *= menu_display_get_dpi_scale(video_width, video_height) * 0.8f;
|
||||
}
|
||||
|
||||
static void menu_animation_update_time_default(
|
||||
float *dst,
|
||||
unsigned video_width, unsigned video_height)
|
||||
@ -1215,9 +1200,18 @@ static void menu_animation_update_time_default(
|
||||
if (video_width > 0)
|
||||
*(dst) *= ((float)video_width / 1920.0f);
|
||||
}
|
||||
|
||||
void menu_animation_set_update_time_cb(update_time_cb cb)
|
||||
{
|
||||
update_time_callback = cb;
|
||||
}
|
||||
|
||||
void menu_animation_unset_update_time_cb(void)
|
||||
{
|
||||
update_time_callback = menu_animation_update_time_default;
|
||||
}
|
||||
|
||||
static void menu_animation_update_time(
|
||||
unsigned type,
|
||||
bool timedate_enable,
|
||||
unsigned video_width, unsigned video_height,
|
||||
float menu_ticker_speed)
|
||||
@ -1293,24 +1287,8 @@ static void menu_animation_update_time(
|
||||
* system. We therefore take the same approach as GLUI,
|
||||
* but with a different correction factor (expected
|
||||
* scroll speed is somewhat lower for Ozone) */
|
||||
switch (type)
|
||||
{
|
||||
case MENU_DRIVER_ID_RGUI:
|
||||
menu_animation_update_time_rgui(&ticker_pixel_increment, video_width, video_height);
|
||||
break;
|
||||
case MENU_DRIVER_ID_OZONE:
|
||||
menu_animation_update_time_ozone(&ticker_pixel_increment, video_width, video_height);
|
||||
break;
|
||||
case MENU_DRIVER_ID_GLUI:
|
||||
menu_animation_update_time_materialui(
|
||||
&ticker_pixel_increment, video_width, video_height);
|
||||
break;
|
||||
case MENU_DRIVER_ID_XMB:
|
||||
default:
|
||||
menu_animation_update_time_default(
|
||||
&ticker_pixel_increment, video_width, video_height);
|
||||
break;
|
||||
}
|
||||
update_time_callback(&ticker_pixel_increment,
|
||||
video_width, video_height);
|
||||
|
||||
/* > Update accumulator */
|
||||
ticker_pixel_accumulator += ticker_pixel_increment;
|
||||
@ -1326,7 +1304,6 @@ static void menu_animation_update_time(
|
||||
}
|
||||
|
||||
bool menu_animation_update(
|
||||
unsigned type,
|
||||
bool menu_timedate_enable,
|
||||
float menu_ticker_speed,
|
||||
unsigned video_width,
|
||||
@ -1335,7 +1312,6 @@ bool menu_animation_update(
|
||||
unsigned i;
|
||||
|
||||
menu_animation_update_time(
|
||||
type,
|
||||
menu_timedate_enable,
|
||||
video_width, video_height,
|
||||
menu_ticker_speed);
|
||||
|
@ -31,6 +31,9 @@ RETRO_BEGIN_DECLS
|
||||
|
||||
typedef void (*tween_cb) (void*);
|
||||
|
||||
typedef void (*update_time_cb) (float *dst,
|
||||
unsigned width, unsigned height);
|
||||
|
||||
enum menu_animation_ctl_state
|
||||
{
|
||||
MENU_ANIMATION_CTL_NONE = 0,
|
||||
@ -198,7 +201,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(
|
||||
unsigned type,
|
||||
bool menu_timedate_enable,
|
||||
float menu_ticker_speed,
|
||||
unsigned video_width,
|
||||
@ -232,6 +234,10 @@ uint64_t menu_animation_get_ticker_slow_idx(void);
|
||||
|
||||
uint64_t menu_animation_get_ticker_pixel_idx(void);
|
||||
|
||||
void menu_animation_set_update_time_cb(update_time_cb cb);
|
||||
|
||||
void menu_animation_unset_update_time_cb(void);
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif
|
||||
|
@ -27280,7 +27280,6 @@ static enum runloop_state runloop_check_state(void)
|
||||
|
||||
#if defined(HAVE_MENU)
|
||||
menu_animation_update(
|
||||
menu_driver_ident_id(),
|
||||
settings->bools.menu_timedate_enable,
|
||||
settings->floats.menu_ticker_speed,
|
||||
video_driver_width, video_driver_height);
|
||||
|
Loading…
Reference in New Issue
Block a user