From 85d979fe783447e83c83fca79ca983ac2a48b293 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 16 Apr 2007 16:50:34 +0000 Subject: [PATCH] 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. --- clutter/clutter-behaviour-scale.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/clutter/clutter-behaviour-scale.c b/clutter/clutter-behaviour-scale.c index 383a31480..bbac76c9d 100644 --- a/clutter/clutter-behaviour-scale.c +++ b/clutter/clutter-behaviour-scale.c @@ -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; }