aboutsummaryrefslogtreecommitdiff
path: root/src/animate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/animate.c')
-rw-r--r--src/animate.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/animate.c b/src/animate.c
index 313cfa7..387c9b8 100644
--- a/src/animate.c
+++ b/src/animate.c
@@ -179,6 +179,41 @@ Animation *animation_group_shrink_create(gint64 duration)
return shrink;
}
+static bool grow_func(Animation *grow, Layout *layout)
+{
+ g_assert_false(layout->btn->simple);
+ ButtonGroup *group = (gpointer)layout->btn;
+
+ gint64 end = grow->start + grow->duration;
+ gint64 now = g_get_monotonic_time();
+ if (now > end) return false;
+
+ double t = (double)(now - grow->start) / (end - grow->start);
+ double pos = smoothstep(t, 0, 1);
+
+ int start_w = CAST(layout->children->data, Layout)->width;
+ int width = start_w + pos * (layout->width - start_w);
+ layout->width = width;
+
+ for (GList *it = layout->children, *next = it->next; it; it = next, next = it ? it->next : NULL) {
+ Layout *child = it->data;
+ if (child->x + child->width > layout->x + width)
+ layout->children = g_list_delete_link(layout->children, it);
+ }
+
+ return true;
+}
+
+Animation *animation_group_grow_create(gint64 duration)
+{
+ // Note the 0 initialization
+ Animation *grow = g_malloc0(sizeof(Animation));
+ grow->type = ANIM_GROUP_GROW;
+ grow->layout_func = (LayoutFunc)grow_func;
+ grow->duration = duration;
+ return grow;
+}
+
void animation_destroy(Animation *anim)
{
if (anim == NULL) return;