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.
This commit is contained in:
Emmanuele Bassi 2007-07-09 21:39:03 +00:00
parent 8de3caa946
commit 588c4504a1

View File

@ -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