From 183f3ad98fbbe6439947b4569d934b5b8a54c9f7 Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Tue, 14 Dec 2010 13:24:01 +0000 Subject: contact-view: animate the showing and hiding of the actions Signed-off-by: Jonny Lamb --- liszt/contact-view.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/liszt/contact-view.c b/liszt/contact-view.c index 968027910..21ed0fd38 100644 --- a/liszt/contact-view.c +++ b/liszt/contact-view.c @@ -475,6 +475,48 @@ lol_contact_view_new (void) NULL); } +static gboolean +selected_timeout_add (gpointer data) +{ + LolContactView *self = data; + LolContactViewPrivate *priv = self->priv; + gfloat to_add = 3.2; + gfloat height; + + height = clutter_actor_get_height (priv->actions) + to_add; + + clutter_actor_set_height (priv->actions, height); + + if (height >= 32.0) + return FALSE; + + return TRUE; +} + +static gboolean +selected_timeout_subtract (gpointer data) +{ + LolContactView *self = data; + LolContactViewPrivate *priv = self->priv; + gfloat to_sub = 3.2; + gfloat height; + + height = clutter_actor_get_height (priv->actions) - to_sub; + + if (height <= 0) + height = 0.0; + + clutter_actor_set_height (priv->actions, height); + + if (height == 0.0) + { + clutter_actor_hide (priv->actions); + return FALSE; + } + + return TRUE; +} + void lol_contact_view_toggle_selected (LolContactView *self) { @@ -490,12 +532,16 @@ lol_contact_view_toggle_selected (LolContactView *self) clutter_box_set_color (CLUTTER_BOX (self), &blue); clutter_actor_show (priv->actions); clutter_text_set_color (CLUTTER_TEXT (priv->name_text), &white); + + clutter_actor_set_height (priv->actions, 0); + g_timeout_add (10, selected_timeout_add, self); } else { clutter_box_set_color (CLUTTER_BOX (self), &white); - clutter_actor_hide (priv->actions); clutter_text_set_color (CLUTTER_TEXT (priv->name_text), &black); + + g_timeout_add (10, selected_timeout_subtract, self); } g_signal_emit (self, signals[SELECTED], 0, priv->selected); -- cgit v1.2.3