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:
Emmanuele Bassi 2007-04-19 15:24:35 +00:00
parent e89f08560d
commit fdb1a82569

View File

@ -79,42 +79,51 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
gpointer data)
{
ClutterBehaviourScalePrivate *priv;
gint sw, sh, w, h;
guint sw, sh, w, h;
gint x, y;
guint scale = GPOINTER_TO_UINT (data);
priv = CLUTTER_BEHAVIOUR_SCALE (behaviour)->priv;
clutter_actor_get_abs_size (actor, &w, &h);
clutter_actor_set_scalex (actor, scale, scale);
if (priv->gravity == CLUTTER_GRAVITY_NONE ||
priv->gravity == CLUTTER_GRAVITY_NORTH_WEST)
return;
clutter_actor_get_abs_size (actor, (guint*) &sw, (guint*) &sh);
clutter_actor_get_size (actor, (guint*) &w, (guint*) &h);
clutter_actor_get_abs_size (actor, &sw, &sh);
x = clutter_actor_get_x (actor);
y = clutter_actor_get_y (actor);
switch (priv->gravity)
{
case CLUTTER_GRAVITY_NORTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y);
break;
case CLUTTER_GRAVITY_NORTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y);
break;
case CLUTTER_GRAVITY_EAST:
clutter_actor_set_position (actor, x + w - sw, y - (sh - h) / 2);
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
clutter_actor_set_position (actor, x + w - sw, y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH:
clutter_actor_set_position (actor, x - ((sw - w) / 2), y + h - sh);
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
clutter_actor_set_position (actor, x, y + h - sh);
break;
case CLUTTER_GRAVITY_WEST:
clutter_actor_set_position (actor, x, y - ((sh - h) / 2));
break;
case CLUTTER_GRAVITY_CENTER:
CLUTTER_NOTE (MISC, "gravity %i vs %i\n", sw, w);
/*
* FIXME: This is actually broken for anything other than 0,0
*/
clutter_actor_set_position (actor, (w - sw) / 2, (h - sh) / 2);
clutter_actor_set_position (actor,
x - ((sw - w) / 2),
y - ((sh - h) / 2));
default:
break;
}