Move progress callback to hexagram_anim_stop
This commit is contained in:
parent
9d8a5d303a
commit
0d6bcc7db2
2 changed files with 11 additions and 8 deletions
|
@ -13,6 +13,10 @@ typedef enum {
|
|||
HEXAGRAM_ANIM_RADIUS = 1 << 2
|
||||
} hexagram_anim_flags;
|
||||
|
||||
typedef struct _hexagram_anim_stop hexagram_anim_stop;
|
||||
|
||||
typedef double (hexagram_anim_progress_fn)(hexagram_anim_stop *, double);
|
||||
|
||||
typedef struct _hexagram_anim_action {
|
||||
int flags;
|
||||
|
||||
|
@ -31,11 +35,12 @@ typedef struct _hexagram_anim_action {
|
|||
} from, to;
|
||||
} hexagram_anim_action;
|
||||
|
||||
typedef struct _hexagram_anim_stop {
|
||||
struct _hexagram_anim_stop {
|
||||
hexagram_anim_action *actions;
|
||||
size_t count;
|
||||
double duration;
|
||||
} hexagram_anim_stop;
|
||||
hexagram_anim_progress_fn *fn;
|
||||
};
|
||||
|
||||
typedef struct _hexagram_anim {
|
||||
hexagram_anim_stop *stops;
|
||||
|
@ -43,11 +48,9 @@ typedef struct _hexagram_anim {
|
|||
struct timeval start, now;
|
||||
} hexagram_anim;
|
||||
|
||||
typedef double (hexagram_anim_progress_fn)(hexagram_anim_stop *, double);
|
||||
|
||||
void hexagram_anim_init(hexagram_anim *anim);
|
||||
|
||||
int hexagram_anim_step(hexagram_anim *anim, hexagram_anim_progress_fn *fn);
|
||||
int hexagram_anim_step(hexagram_anim *anim);
|
||||
|
||||
double hexagram_anim_duration(hexagram_anim *anim);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ static inline double stop_offset(hexagram_anim *anim, size_t index) {
|
|||
return offset;
|
||||
}
|
||||
|
||||
int hexagram_anim_step(hexagram_anim *anim, hexagram_anim_progress_fn *fn) {
|
||||
int hexagram_anim_step(hexagram_anim *anim) {
|
||||
struct timeval tv;
|
||||
double offset = 0.0, interval, progress;
|
||||
size_t i, a;
|
||||
|
@ -53,8 +53,8 @@ int hexagram_anim_step(hexagram_anim *anim, hexagram_anim_progress_fn *fn) {
|
|||
if (i == anim->count) {
|
||||
i--;
|
||||
progress = 1.0;
|
||||
} else if (fn) {
|
||||
progress = fn(&anim->stops[i],
|
||||
} else if (anim->stops[i].fn) {
|
||||
progress = anim->stops[i].fn(&anim->stops[i],
|
||||
(interval - offset) / anim->stops[i].duration);
|
||||
} else {
|
||||
progress = (interval - offset) / anim->stops[i].duration;
|
||||
|
|
Loading…
Add table
Reference in a new issue