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:
parent
8de3caa946
commit
588c4504a1
1 changed files with 11 additions and 10 deletions
|
@ -83,31 +83,32 @@ alpha_notify_foreach (ClutterBehaviour *behaviour,
|
||||||
ClutterActor *actor,
|
ClutterActor *actor,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
clutter_actor_set_opacity (actor, GPOINTER_TO_INT(data));
|
clutter_actor_set_opacity (actor, GPOINTER_TO_UINT(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_behaviour_alpha_notify (ClutterBehaviour *behave,
|
clutter_behaviour_alpha_notify (ClutterBehaviour *behave,
|
||||||
guint32 alpha_value)
|
guint32 alpha_value)
|
||||||
{
|
{
|
||||||
guint8 opacity;
|
|
||||||
ClutterBehaviourOpacityPrivate *priv;
|
ClutterBehaviourOpacityPrivate *priv;
|
||||||
|
guint8 delta, opacity;
|
||||||
|
|
||||||
priv = CLUTTER_BEHAVIOUR_OPACITY (behave)->priv;
|
priv = CLUTTER_BEHAVIOUR_OPACITY (behave)->priv;
|
||||||
|
|
||||||
opacity = alpha_value
|
if (priv->opacity_end > priv->opacity_start)
|
||||||
* (priv->opacity_end - priv->opacity_start)
|
delta = priv->opacity_end - priv->opacity_start;
|
||||||
/ CLUTTER_ALPHA_MAX_ALPHA;
|
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",
|
CLUTTER_NOTE (BEHAVIOUR, "alpha: %i, opacity: %i", alpha_value, opacity);
|
||||||
alpha_value,
|
|
||||||
opacity);
|
|
||||||
|
|
||||||
clutter_behaviour_actors_foreach (behave,
|
clutter_behaviour_actors_foreach (behave,
|
||||||
alpha_notify_foreach,
|
alpha_notify_foreach,
|
||||||
GINT_TO_POINTER((gint)opacity));
|
GUINT_TO_POINTER ((guint) opacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Add table
Reference in a new issue