2014-09-19 11:36:18 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2017-01-22 12:40:32 +00:00
|
|
|
* Copyright (C) 2014-2017 - Jean-André Santoni
|
|
|
|
* Copyright (C) 2011-2017 - Daniel De Matteis
|
2014-10-10 17:53:13 +00:00
|
|
|
*
|
2014-09-19 11:36:18 +00:00
|
|
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
#ifndef _GFX_ANIMATION_H
|
|
|
|
#define _GFX_ANIMATION_H
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2014-10-10 17:53:13 +00:00
|
|
|
#include <stdint.h>
|
2014-09-19 11:36:18 +00:00
|
|
|
#include <stdlib.h>
|
2016-06-03 03:49:46 +00:00
|
|
|
|
2015-02-01 22:05:16 +00:00
|
|
|
#include <boolean.h>
|
2016-06-03 03:49:46 +00:00
|
|
|
#include <retro_common_api.h>
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2020-02-16 14:26:58 +00:00
|
|
|
#include "font_driver.h"
|
2019-08-21 15:32:39 +00:00
|
|
|
|
2016-06-03 03:49:46 +00:00
|
|
|
RETRO_BEGIN_DECLS
|
2014-10-12 18:22:33 +00:00
|
|
|
|
2019-02-24 12:08:30 +00:00
|
|
|
#define TICKER_SPACER_DEFAULT " | "
|
2019-02-21 10:03:02 +00:00
|
|
|
|
2020-08-14 04:29:13 +00:00
|
|
|
#define ANIM_IS_ACTIVE(_p) ((_p)->animation_is_active || (_p)->ticker_is_active)
|
|
|
|
|
2018-09-18 13:13:33 +00:00
|
|
|
typedef void (*tween_cb) (void*);
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2020-03-03 14:33:26 +00:00
|
|
|
typedef void (*update_time_cb) (float *ticker_pixel_increment,
|
2020-02-16 12:40:18 +00:00
|
|
|
unsigned width, unsigned height);
|
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
enum gfx_animation_ctl_state
|
2015-09-25 21:33:11 +00:00
|
|
|
{
|
2016-02-11 00:54:09 +00:00
|
|
|
MENU_ANIMATION_CTL_NONE = 0,
|
2015-12-11 11:00:49 +00:00
|
|
|
MENU_ANIMATION_CTL_DEINIT,
|
2015-09-25 21:39:02 +00:00
|
|
|
MENU_ANIMATION_CTL_CLEAR_ACTIVE,
|
2018-10-17 04:55:49 +00:00
|
|
|
MENU_ANIMATION_CTL_SET_ACTIVE
|
2015-09-25 21:33:11 +00:00
|
|
|
};
|
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
enum gfx_animation_easing_type
|
2015-02-11 00:15:16 +00:00
|
|
|
{
|
|
|
|
/* Linear */
|
|
|
|
EASING_LINEAR = 0,
|
|
|
|
/* Quad */
|
|
|
|
EASING_IN_QUAD,
|
|
|
|
EASING_OUT_QUAD,
|
|
|
|
EASING_IN_OUT_QUAD,
|
|
|
|
EASING_OUT_IN_QUAD,
|
|
|
|
/* Cubic */
|
|
|
|
EASING_IN_CUBIC,
|
|
|
|
EASING_OUT_CUBIC,
|
|
|
|
EASING_IN_OUT_CUBIC,
|
|
|
|
EASING_OUT_IN_CUBIC,
|
|
|
|
/* Quart */
|
|
|
|
EASING_IN_QUART,
|
|
|
|
EASING_OUT_QUART,
|
|
|
|
EASING_IN_OUT_QUART,
|
|
|
|
EASING_OUT_IN_QUART,
|
|
|
|
/* Quint */
|
|
|
|
EASING_IN_QUINT,
|
|
|
|
EASING_OUT_QUINT,
|
|
|
|
EASING_IN_OUT_QUINT,
|
|
|
|
EASING_OUT_IN_QUINT,
|
|
|
|
/* Sine */
|
|
|
|
EASING_IN_SINE,
|
|
|
|
EASING_OUT_SINE,
|
|
|
|
EASING_IN_OUT_SINE,
|
|
|
|
EASING_OUT_IN_SINE,
|
|
|
|
/* Expo */
|
|
|
|
EASING_IN_EXPO,
|
|
|
|
EASING_OUT_EXPO,
|
|
|
|
EASING_IN_OUT_EXPO,
|
|
|
|
EASING_OUT_IN_EXPO,
|
|
|
|
/* Circ */
|
|
|
|
EASING_IN_CIRC,
|
|
|
|
EASING_OUT_CIRC,
|
|
|
|
EASING_IN_OUT_CIRC,
|
|
|
|
EASING_OUT_IN_CIRC,
|
|
|
|
/* Bounce */
|
|
|
|
EASING_IN_BOUNCE,
|
|
|
|
EASING_OUT_BOUNCE,
|
|
|
|
EASING_IN_OUT_BOUNCE,
|
2017-08-14 05:13:50 +00:00
|
|
|
EASING_OUT_IN_BOUNCE,
|
|
|
|
|
|
|
|
EASING_LAST
|
2015-02-11 00:15:16 +00:00
|
|
|
};
|
|
|
|
|
2019-02-14 15:10:07 +00:00
|
|
|
/* TODO:
|
|
|
|
* Add a reverse loop ticker for languages
|
|
|
|
* that read right to left */
|
2020-02-16 13:01:34 +00:00
|
|
|
enum gfx_animation_ticker_type
|
2019-02-14 15:10:07 +00:00
|
|
|
{
|
|
|
|
TICKER_TYPE_BOUNCE = 0,
|
|
|
|
TICKER_TYPE_LOOP,
|
|
|
|
TICKER_TYPE_LAST
|
|
|
|
};
|
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
typedef struct gfx_animation_ctx_entry
|
2016-02-25 14:44:30 +00:00
|
|
|
{
|
2020-08-14 15:11:18 +00:00
|
|
|
float *subject;
|
|
|
|
void *userdata;
|
|
|
|
tween_cb cb;
|
2017-09-29 14:49:41 +00:00
|
|
|
uintptr_t tag;
|
2016-02-25 14:44:30 +00:00
|
|
|
float duration;
|
|
|
|
float target_value;
|
2020-08-14 15:11:18 +00:00
|
|
|
enum gfx_animation_easing_type easing_enum;
|
2020-02-16 13:01:34 +00:00
|
|
|
} gfx_animation_ctx_entry_t;
|
2016-02-25 14:44:30 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
typedef struct gfx_animation_ctx_ticker
|
2016-02-25 14:19:33 +00:00
|
|
|
{
|
|
|
|
uint64_t idx;
|
2017-09-29 14:49:41 +00:00
|
|
|
char *s;
|
2016-02-25 14:19:33 +00:00
|
|
|
const char *str;
|
2019-02-14 15:10:07 +00:00
|
|
|
const char *spacer;
|
2020-08-14 15:11:18 +00:00
|
|
|
size_t len;
|
|
|
|
enum gfx_animation_ticker_type type_enum;
|
|
|
|
bool selected;
|
2020-02-16 13:01:34 +00:00
|
|
|
} gfx_animation_ctx_ticker_t;
|
2016-02-25 14:19:33 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
typedef struct gfx_animation_ctx_ticker_smooth
|
2019-08-21 15:32:39 +00:00
|
|
|
{
|
|
|
|
uint64_t idx;
|
|
|
|
const char *src_str;
|
|
|
|
const char *spacer;
|
|
|
|
char *dst_str;
|
2020-08-14 15:11:18 +00:00
|
|
|
unsigned *dst_str_width; /* May be set to NULL
|
|
|
|
(RGUI + XMB do not require this info) */
|
2019-08-21 15:32:39 +00:00
|
|
|
unsigned *x_offset;
|
2020-08-14 15:11:18 +00:00
|
|
|
font_data_t *font;
|
|
|
|
size_t dst_str_len;
|
|
|
|
unsigned glyph_width; /* Fallback if font == NULL */
|
|
|
|
unsigned field_width;
|
|
|
|
float font_scale;
|
|
|
|
enum gfx_animation_ticker_type type_enum;
|
|
|
|
bool selected;
|
2020-02-16 13:01:34 +00:00
|
|
|
} gfx_animation_ctx_ticker_smooth_t;
|
2019-08-21 15:32:39 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
typedef struct gfx_animation_ctx_line_ticker
|
2019-07-18 15:43:21 +00:00
|
|
|
{
|
|
|
|
uint64_t idx;
|
2020-08-14 15:11:18 +00:00
|
|
|
const char *str;
|
2019-07-18 15:43:21 +00:00
|
|
|
char *s;
|
|
|
|
size_t len;
|
2020-08-14 15:11:18 +00:00
|
|
|
size_t line_len;
|
|
|
|
size_t max_lines;
|
|
|
|
enum gfx_animation_ticker_type type_enum;
|
2020-02-16 13:01:34 +00:00
|
|
|
} gfx_animation_ctx_line_ticker_t;
|
2019-07-18 15:43:21 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
typedef struct gfx_animation_ctx_line_ticker_smooth
|
2019-08-29 15:46:49 +00:00
|
|
|
{
|
|
|
|
uint64_t idx;
|
2020-08-14 15:11:18 +00:00
|
|
|
font_data_t *font;
|
2019-08-29 15:46:49 +00:00
|
|
|
const char *src_str;
|
2020-08-14 15:11:18 +00:00
|
|
|
float *y_offset;
|
2019-08-29 15:46:49 +00:00
|
|
|
char *dst_str;
|
|
|
|
size_t dst_str_len;
|
2019-08-30 13:28:07 +00:00
|
|
|
char *top_fade_str;
|
|
|
|
size_t top_fade_str_len;
|
|
|
|
float *top_fade_y_offset;
|
|
|
|
float *top_fade_alpha;
|
|
|
|
float *bottom_fade_y_offset;
|
|
|
|
float *bottom_fade_alpha;
|
2020-08-14 15:11:18 +00:00
|
|
|
char *bottom_fade_str;
|
|
|
|
size_t bottom_fade_str_len;
|
|
|
|
unsigned field_width;
|
|
|
|
unsigned field_height;
|
|
|
|
float font_scale;
|
|
|
|
enum gfx_animation_ticker_type type_enum;
|
|
|
|
bool fade_enabled;
|
2020-02-16 13:01:34 +00:00
|
|
|
} gfx_animation_ctx_line_ticker_smooth_t;
|
2019-08-29 15:46:49 +00:00
|
|
|
|
2020-02-16 17:24:45 +00:00
|
|
|
typedef float gfx_timer_t;
|
2018-11-13 13:33:32 +00:00
|
|
|
|
2020-02-16 17:24:45 +00:00
|
|
|
typedef struct gfx_timer_ctx_entry
|
2018-11-13 13:33:32 +00:00
|
|
|
{
|
|
|
|
tween_cb cb;
|
|
|
|
void *userdata;
|
2020-08-14 15:11:18 +00:00
|
|
|
float duration;
|
2020-02-16 17:24:45 +00:00
|
|
|
} gfx_timer_ctx_entry_t;
|
2018-11-13 13:33:32 +00:00
|
|
|
|
2020-02-16 17:24:45 +00:00
|
|
|
typedef struct gfx_delayed_animation
|
2019-01-23 11:05:53 +00:00
|
|
|
{
|
2020-08-14 15:11:18 +00:00
|
|
|
gfx_animation_ctx_entry_t entry; /* pointer alignment */
|
2020-02-16 17:24:45 +00:00
|
|
|
gfx_timer_t timer;
|
|
|
|
} gfx_delayed_animation_t;
|
2019-01-23 11:05:53 +00:00
|
|
|
|
2020-08-14 03:53:57 +00:00
|
|
|
typedef float (*easing_cb) (float, float, float, float);
|
|
|
|
|
|
|
|
struct tween
|
|
|
|
{
|
2020-08-14 15:11:18 +00:00
|
|
|
easing_cb easing;
|
|
|
|
tween_cb cb;
|
|
|
|
void *userdata;
|
|
|
|
uintptr_t tag;
|
2020-08-14 03:53:57 +00:00
|
|
|
float duration;
|
|
|
|
float running_since;
|
|
|
|
float initial_value;
|
|
|
|
float target_value;
|
|
|
|
float *subject;
|
|
|
|
bool deleted;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gfx_animation
|
|
|
|
{
|
|
|
|
uint64_t ticker_idx; /* updated every TICKER_SPEED us */
|
|
|
|
uint64_t ticker_slow_idx; /* updated every TICKER_SLOW_SPEED us */
|
|
|
|
uint64_t ticker_pixel_idx; /* updated every frame */
|
|
|
|
uint64_t ticker_pixel_line_idx; /* updated every frame */
|
|
|
|
retro_time_t cur_time;
|
|
|
|
retro_time_t old_time;
|
2020-08-14 15:11:18 +00:00
|
|
|
struct tween* list;
|
|
|
|
struct tween* pending;
|
2020-08-14 03:53:57 +00:00
|
|
|
|
|
|
|
float delta_time;
|
|
|
|
|
2020-08-14 15:11:18 +00:00
|
|
|
bool pending_deletes;
|
|
|
|
bool in_update;
|
|
|
|
bool animation_is_active;
|
|
|
|
bool ticker_is_active;
|
2020-08-14 03:53:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct gfx_animation gfx_animation_t;
|
|
|
|
|
2020-02-16 17:24:45 +00:00
|
|
|
void gfx_timer_start(gfx_timer_t *timer, gfx_timer_ctx_entry_t *timer_entry);
|
2018-11-13 13:33:32 +00:00
|
|
|
|
2020-02-16 17:24:45 +00:00
|
|
|
void gfx_timer_kill(gfx_timer_t *timer);
|
2018-11-13 13:33:32 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_update(
|
2020-08-14 04:29:13 +00:00
|
|
|
gfx_animation_t *p_anim,
|
2020-02-26 07:09:20 +00:00
|
|
|
retro_time_t current_time,
|
2020-02-16 17:24:45 +00:00
|
|
|
bool timedate_enable,
|
|
|
|
float ticker_speed,
|
2020-02-12 15:31:15 +00:00
|
|
|
unsigned video_width,
|
|
|
|
unsigned video_height);
|
2017-01-17 15:37:03 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_ticker(gfx_animation_ctx_ticker_t *ticker);
|
2017-01-17 15:29:23 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_ticker_smooth(gfx_animation_ctx_ticker_smooth_t *ticker);
|
2019-08-21 15:32:39 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_line_ticker(gfx_animation_ctx_line_ticker_t *line_ticker);
|
2019-07-18 15:43:21 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *line_ticker);
|
2019-08-29 15:46:49 +00:00
|
|
|
|
2020-06-08 02:09:12 +00:00
|
|
|
bool gfx_animation_kill_by_tag(uintptr_t *tag);
|
2018-10-17 04:49:24 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_push(gfx_animation_ctx_entry_t *entry);
|
2017-01-17 15:53:06 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
void gfx_animation_push_delayed(unsigned delay, gfx_animation_ctx_entry_t *entry);
|
2019-01-23 11:05:53 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
bool gfx_animation_ctl(enum gfx_animation_ctl_state state, void *data);
|
2015-09-06 00:41:36 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
uint64_t gfx_animation_get_ticker_idx(void);
|
2019-02-14 10:58:27 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
uint64_t gfx_animation_get_ticker_slow_idx(void);
|
2019-02-14 10:58:27 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
uint64_t gfx_animation_get_ticker_pixel_idx(void);
|
2019-08-21 15:32:39 +00:00
|
|
|
|
2020-03-03 14:33:26 +00:00
|
|
|
uint64_t gfx_animation_get_ticker_pixel_line_idx(void);
|
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
void gfx_animation_set_update_time_cb(update_time_cb cb);
|
2020-02-16 12:40:18 +00:00
|
|
|
|
2020-02-16 13:01:34 +00:00
|
|
|
void gfx_animation_unset_update_time_cb(void);
|
2020-02-16 12:40:18 +00:00
|
|
|
|
2020-08-14 04:29:13 +00:00
|
|
|
gfx_animation_t *anim_get_ptr(void);
|
|
|
|
|
2016-06-03 03:49:46 +00:00
|
|
|
RETRO_END_DECLS
|
2014-10-12 18:22:33 +00:00
|
|
|
|
2014-10-10 17:53:13 +00:00
|
|
|
#endif
|