2014-09-19 11:36:18 +00:00
|
|
|
/* RetroArch - A frontend for libretro.
|
2015-01-07 16:46:50 +00:00
|
|
|
* Copyright (C) 2014-2015 - Jean-André Santoni
|
|
|
|
* Copyright (C) 2011-2015 - 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/>.
|
|
|
|
*/
|
|
|
|
|
2014-10-10 17:54:15 +00:00
|
|
|
#ifndef _MENU_ANIMATION_H
|
|
|
|
#define _MENU_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>
|
2015-02-01 22:05:16 +00:00
|
|
|
#include <boolean.h>
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2014-10-12 18:22:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-09-19 11:36:18 +00:00
|
|
|
typedef float (*easingFunc)(float, float, float, float);
|
2015-02-01 23:46:00 +00:00
|
|
|
typedef void (*tween_cb) (void);
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2015-02-10 23:40:18 +00:00
|
|
|
struct tween
|
2014-09-19 11:36:18 +00:00
|
|
|
{
|
|
|
|
int alive;
|
|
|
|
float duration;
|
|
|
|
float running_since;
|
|
|
|
float initial_value;
|
|
|
|
float target_value;
|
|
|
|
float* subject;
|
|
|
|
easingFunc easing;
|
2015-02-01 23:46:00 +00:00
|
|
|
tween_cb cb;
|
2015-02-10 23:40:18 +00:00
|
|
|
};
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2015-02-10 23:40:18 +00:00
|
|
|
typedef struct animation
|
|
|
|
{
|
|
|
|
struct tween *list;
|
|
|
|
|
|
|
|
size_t capacity;
|
|
|
|
size_t size;
|
|
|
|
} animation_t;
|
|
|
|
|
2015-02-11 00:15:16 +00:00
|
|
|
enum animation_easing_type
|
|
|
|
{
|
|
|
|
/* 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,
|
|
|
|
EASING_OUT_IN_BOUNCE,
|
|
|
|
};
|
|
|
|
|
2015-02-10 23:40:18 +00:00
|
|
|
void menu_animation_free(animation_t *animation);
|
|
|
|
|
2015-02-11 00:15:16 +00:00
|
|
|
bool menu_animation_push(animation_t *animation, float duration,
|
|
|
|
float target_value, float* subject,
|
|
|
|
enum animation_easing_type easing_enum, tween_cb cb);
|
2014-10-09 22:01:45 +00:00
|
|
|
|
2015-03-12 18:29:43 +00:00
|
|
|
bool menu_animation_update(animation_t *animation, float dt);
|
2014-09-19 11:36:18 +00:00
|
|
|
|
2015-02-11 17:52:59 +00:00
|
|
|
/**
|
|
|
|
* menu_animation_ticker_line:
|
|
|
|
* @buf : buffer to write new message line to.
|
|
|
|
* @len : length of buffer @input.
|
|
|
|
* @idx : Index. Will be used for ticker logic.
|
|
|
|
* @str : Input string.
|
|
|
|
* @selected : Is the item currently selected in the menu?
|
|
|
|
*
|
|
|
|
* Take the contents of @str and apply a ticker effect to it,
|
|
|
|
* and write the results in @buf.
|
|
|
|
**/
|
|
|
|
void menu_animation_ticker_line(char *buf, size_t len, unsigned tick,
|
|
|
|
const char *str, bool selected);
|
|
|
|
|
2014-10-12 18:22:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-10 17:53:13 +00:00
|
|
|
#endif
|