From 588c4504a1cbdef74198e02813e1539f0468e411 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 9 Jul 2007 21:39:03 +0000 Subject: [PATCH] Handle opacity inversion in ClutterBehaviourOpacity Always make sure that the opacity is a positive integer, even if the start and end opacities are inverted. Also, use the correct integer-to-pointer casts, as the opacity is an unsigned integer. --- clutter/clutter-behaviour-opacity.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/clutter/clutter-behaviour-opacity.c b/clutter/clutter-behaviour-opacity.c index e01475415..97beae4ec 100644 --- a/clutter/clutter-behaviour-opacity.c +++ b/clutter/clutter-behaviour-opacity.c @@ -83,31 +83,32 @@ alpha_notify_foreach (ClutterBehaviour *behaviour, ClutterActor *actor, gpointer data) { - clutter_actor_set_opacity (actor, GPOINTER_TO_INT(data)); + clutter_actor_set_opacity (actor, GPOINTER_TO_UINT(data)); } static void clutter_behaviour_alpha_notify (ClutterBehaviour *behave, guint32 alpha_value) { - guint8 opacity; ClutterBehaviourOpacityPrivate *priv; + guint8 delta, opacity; priv = CLUTTER_BEHAVIOUR_OPACITY (behave)->priv; - opacity = alpha_value - * (priv->opacity_end - priv->opacity_start) - / CLUTTER_ALPHA_MAX_ALPHA; + if (priv->opacity_end > priv->opacity_start) + delta = priv->opacity_end - priv->opacity_start; + else + delta = priv->opacity_start - priv->opacity_end; - opacity += priv->opacity_start; + opacity = alpha_value * delta / CLUTTER_ALPHA_MAX_ALPHA; + opacity += ((priv->opacity_end > priv->opacity_start) ? priv->opacity_start + : priv->opacity_end); - CLUTTER_NOTE (BEHAVIOUR, "alpha: %i, opacity: %i", - alpha_value, - opacity); + CLUTTER_NOTE (BEHAVIOUR, "alpha: %i, opacity: %i", alpha_value, opacity); clutter_behaviour_actors_foreach (behave, alpha_notify_foreach, - GINT_TO_POINTER((gint)opacity)); + GUINT_TO_POINTER ((guint) opacity)); } static void