From 2d19c5b79c562f421224a7733e08a42c3328bf0f Mon Sep 17 00:00:00 2001 From: Jonny Lamb Date: Wed, 15 Dec 2010 10:11:04 +0000 Subject: contact-view: make animations slightly more shiny Signed-off-by: Jonny Lamb --- liszt/contact-view.c | 87 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 29 deletions(-) diff --git a/liszt/contact-view.c b/liszt/contact-view.c index 86d57b35c..b7daf7fc3 100644 --- a/liszt/contact-view.c +++ b/liszt/contact-view.c @@ -516,52 +516,71 @@ lol_contact_view_new (void) } static gboolean -selected_timeout_add (gpointer data) +to_blue_timeout (gpointer data) { LolContactView *self = data; - LolContactViewPrivate *priv = self->priv; - gfloat to_add = 3.2; - gfloat height; + ClutterColor color; + gboolean out = TRUE; + + clutter_box_get_color (CLUTTER_BOX (self), &color); + + color.red -= 12; + color.green -= 8; + color.blue -= 2; + + if (color.red <= 83) + color.red = 83; - height = clutter_actor_get_height (priv->actions) + to_add; + if (color.green <= 136) + color.green = 136; - clutter_actor_set_height (priv->actions, height); + if (color.blue <= 224) + color.blue = 224; - if (height >= 32.0) - return FALSE; + if (color.red == 83 && color.green == 136 && color.blue == 224) + out = FALSE; - return TRUE; + clutter_box_set_color (CLUTTER_BOX (self), &color); + + return out; } static gboolean -selected_timeout_subtract (gpointer data) +to_white_timeout (gpointer data) { LolContactView *self = data; - LolContactViewPrivate *priv = self->priv; - gfloat to_sub = 3.2; - gfloat height; + ClutterColor color; + gboolean out = TRUE; + + clutter_box_get_color (CLUTTER_BOX (self), &color); + + if (color.red >= 243) + color.red = 255; + else + color.red += 12; - height = clutter_actor_get_height (priv->actions) - to_sub; + if (color.green >= 247) + color.green = 255; + else + color.green += 8; - if (height <= 0) - height = 0.0; + if (color.blue >= 253) + color.blue = 255; + else + color.blue += 2; - clutter_actor_set_height (priv->actions, height); + if (color.red == 255 && color.green == 255 && color.blue == 255) + out = FALSE; - if (height == 0.0) - { - clutter_actor_hide (priv->actions); - return FALSE; - } + clutter_box_set_color (CLUTTER_BOX (self), &color); - return TRUE; + return out; } void lol_contact_view_toggle_selected (LolContactView *self) { LolContactViewPrivate *priv = self->priv; - ClutterColor blue = { 83, 136, 224, 255 }; ClutterColor white = { 255, 255, 255, 255 }; ClutterColor black = { 0, 0, 0, 255 }; @@ -569,19 +588,29 @@ lol_contact_view_toggle_selected (LolContactView *self) if (priv->selected) { - 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); + clutter_actor_set_height (priv->actions, 0.0); + clutter_actor_set_opacity (priv->actions, 0.0); + + clutter_actor_animate (priv->actions, CLUTTER_LINEAR, 250, + "height", 32.0, + "opacity", 255, + NULL); + + g_timeout_add (1, to_blue_timeout, self); } else { - clutter_box_set_color (CLUTTER_BOX (self), &white); clutter_text_set_color (CLUTTER_TEXT (priv->name_text), &black); - g_timeout_add (10, selected_timeout_subtract, self); + clutter_actor_animate (priv->actions, CLUTTER_LINEAR, 250, + "height", 0.0, + "opacity", 0, + NULL); + + g_timeout_add (1, to_white_timeout, self); } g_signal_emit (self, signals[SELECTED], 0, priv->selected); -- cgit v1.2.3