diff options
author | James Magahern <james@magahern.com> | 2019-01-20 16:32:34 -0800 |
---|---|---|
committer | James Magahern <james@magahern.com> | 2019-01-20 16:33:42 -0800 |
commit | 2f4561cb78c1f53ace26f56f28050d7b75c6414d (patch) | |
tree | da4b6a15b0eeb6e518652dd3fb5c23ec80a1e911 /src/animation.h | |
parent | Also don't allow input in xsecurelock path (TODO: unify these) (diff) |
Animation support. Logo animates in and out now
Diffstat (limited to 'src/animation.h')
-rw-r--r-- | src/animation.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/animation.h b/src/animation.h new file mode 100644 index 0000000..3064d1b --- /dev/null +++ b/src/animation.h @@ -0,0 +1,59 @@ +/* + * animation.h + * + * Created by buzzert <buzzert@buzzert.net> 2019-01-20 + */ + +#pragma once +#include <stdbool.h> +#include <time.h> + +typedef double anim_time_interval_t; + +struct animation_t; +typedef void(*AnimationCompletion)(struct animation_t *anim, void *context); + +typedef enum { + _EmptyAnimationType, + ACursorAnimation, + ALogoAnimation, +} AnimationType; + +typedef struct { + AnimationType type; + + bool cursor_animating; + double cursor_fade_direction; +} CursorAnimation; + +typedef struct { + AnimationType type; + + bool direction; // false: in, true: out +} LogoAnimation; + +typedef union { + AnimationType type; + + CursorAnimation cursor_anim; + LogoAnimation logo_anim; +} Animation; + +typedef struct { + bool completed; + anim_time_interval_t start_time; + + AnimationCompletion completion_func; + void *completion_func_context; + + Animation anim; +} animation_t; + +// Convenience: returns current time as anim_time_interval_t +anim_time_interval_t anim_now(); + +// Easing functions +double anim_qubic_ease_out(double p); +double anim_quad_ease_out(double p); + + |