Merge from stable: implement gravity in scale behaviour
Implement every ClutterGravity value inside the scale behaviour and make the actors anchor to a gravity when scaling up and down.
This commit is contained in:
parent
e89f08560d
commit
fdb1a82569
@ -79,42 +79,51 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
ClutterBehaviourScalePrivate *priv;
|
ClutterBehaviourScalePrivate *priv;
|
||||||
gint sw, sh, w, h;
|
guint sw, sh, w, h;
|
||||||
|
gint x, y;
|
||||||
guint scale = GPOINTER_TO_UINT (data);
|
guint scale = GPOINTER_TO_UINT (data);
|
||||||
|
|
||||||
priv = CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
|
priv = CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
|
||||||
|
|
||||||
|
clutter_actor_get_abs_size (actor, &w, &h);
|
||||||
clutter_actor_set_scalex (actor, scale, scale);
|
clutter_actor_set_scalex (actor, scale, scale);
|
||||||
|
|
||||||
if (priv->gravity == CLUTTER_GRAVITY_NONE ||
|
if (priv->gravity == CLUTTER_GRAVITY_NONE ||
|
||||||
priv->gravity == CLUTTER_GRAVITY_NORTH_WEST)
|
priv->gravity == CLUTTER_GRAVITY_NORTH_WEST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
clutter_actor_get_abs_size (actor, (guint*) &sw, (guint*) &sh);
|
clutter_actor_get_abs_size (actor, &sw, &sh);
|
||||||
clutter_actor_get_size (actor, (guint*) &w, (guint*) &h);
|
|
||||||
|
x = clutter_actor_get_x (actor);
|
||||||
|
y = clutter_actor_get_y (actor);
|
||||||
|
|
||||||
switch (priv->gravity)
|
switch (priv->gravity)
|
||||||
{
|
{
|
||||||
case CLUTTER_GRAVITY_NORTH:
|
case CLUTTER_GRAVITY_NORTH:
|
||||||
|
clutter_actor_set_position (actor, x - ((sw - w) / 2), y);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_NORTH_EAST:
|
case CLUTTER_GRAVITY_NORTH_EAST:
|
||||||
|
clutter_actor_set_position (actor, x + w - sw, y);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_EAST:
|
case CLUTTER_GRAVITY_EAST:
|
||||||
|
clutter_actor_set_position (actor, x + w - sw, y - (sh - h) / 2);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_SOUTH_EAST:
|
case CLUTTER_GRAVITY_SOUTH_EAST:
|
||||||
|
clutter_actor_set_position (actor, x + w - sw, y + h - sh);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_SOUTH:
|
case CLUTTER_GRAVITY_SOUTH:
|
||||||
|
clutter_actor_set_position (actor, x - ((sw - w) / 2), y + h - sh);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_SOUTH_WEST:
|
case CLUTTER_GRAVITY_SOUTH_WEST:
|
||||||
|
clutter_actor_set_position (actor, x, y + h - sh);
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_WEST:
|
case CLUTTER_GRAVITY_WEST:
|
||||||
|
clutter_actor_set_position (actor, x, y - ((sh - h) / 2));
|
||||||
break;
|
break;
|
||||||
case CLUTTER_GRAVITY_CENTER:
|
case CLUTTER_GRAVITY_CENTER:
|
||||||
CLUTTER_NOTE (MISC, "gravity %i vs %i\n", sw, w);
|
clutter_actor_set_position (actor,
|
||||||
/*
|
x - ((sw - w) / 2),
|
||||||
* FIXME: This is actually broken for anything other than 0,0
|
y - ((sh - h) / 2));
|
||||||
*/
|
|
||||||
clutter_actor_set_position (actor, (w - sw) / 2, (h - sh) / 2);
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user