diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/animate.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/src/animate.c b/src/animate.c index 9928daa..7eca040 100644 --- a/src/animate.c +++ b/src/animate.c @@ -102,10 +102,36 @@ Animation *animation_shine_create(gint64 duration) return (gpointer)shine; } +static bool pulse_layout(Animation *pulse, Layout *layout) +{ + gint64 end = pulse->start + pulse->duration; + gint64 now = g_get_monotonic_time(); + if (now > end) return false; + + // After half the duration we invert direction + gint64 mid = pulse->start + pulse->duration / 2; + double t = now <= mid + ? (double)(now - pulse->start) / (mid - pulse->start) + : 1.0 - (double)(now - mid) / (end - mid); + + double pos = cubic_bezier(t, 0.19, 1.0, 0.22, 1.0); + int max = 0.15 * layout->height; + + layout->x_pad = layout->btn->x_pad + max * pos; + layout->y_pad = layout->btn->y_pad + max * pos; + + return true; +} + Animation *animation_pulse_create(gint64 duration) { - // TODO - return NULL; + // Note the 0 initialization + Animation *pulse = g_malloc0(sizeof(Animation)); + pulse->type = ANIM_PULSE; + pulse->layout_func = (LayoutFunc)pulse_layout; + pulse->duration = duration; + + return (gpointer)pulse; } void animation_destroy(Animation *anim) |
