From 7495848f149bcaa19b8f9d089484582f6a451941 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 18 Nov 2007 15:36:04 +0000 Subject: [PATCH] 2007-11-18 Emmanuele Bassi * clutter.symbols: Update exported symbols. * clutter/clutter-actor.[ch]: Remove clutter_actor_rotate_* and clutter_actor_get_rx* and provide a simpler rotation API: clutter_actor_set_rotation() and clutter_actor_get_rotation(). * clutter/clutter-deprecated.h: Deprecate the old rotation API. * clutter/clutter-behaviour-bspline.c: * clutter/clutter-behaviour-rotate.c: * clutter/clutter-effect.c: Update internal usage of the rotation API. * tests/test-project.c: Ditto as above. --- ChangeLog | 17 ++ clutter.symbols | 17 +- clutter/clutter-actor.c | 351 +++++++++++----------------- clutter/clutter-actor.h | 21 ++ clutter/clutter-behaviour-bspline.c | 6 +- clutter/clutter-behaviour-rotate.c | 29 +-- clutter/clutter-deprecated.h | 16 +- clutter/clutter-effect.c | 12 +- tests/test-project.c | 2 +- 9 files changed, 214 insertions(+), 257 deletions(-) diff --git a/ChangeLog b/ChangeLog index ddf76ca86..04b6e993a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2007-11-18 Emmanuele Bassi + + * clutter.symbols: Update exported symbols. + + * clutter/clutter-actor.[ch]: Remove clutter_actor_rotate_* + and clutter_actor_get_rx* and provide a simpler rotation API: + clutter_actor_set_rotation() and clutter_actor_get_rotation(). + + * clutter/clutter-deprecated.h: Deprecate the old rotation API. + + * clutter/clutter-behaviour-bspline.c: + * clutter/clutter-behaviour-rotate.c: + * clutter/clutter-effect.c: Update internal usage of the + rotation API. + + * tests/test-project.c: Ditto as above. + 2007-11-17 Emmanuele Bassi Optimise Atoms usage in the X11 and X11-based backends. diff --git a/clutter.symbols b/clutter.symbols index 330295895..b832ebbb1 100644 --- a/clutter.symbols +++ b/clutter.symbols @@ -26,18 +26,10 @@ clutter_actor_get_x clutter_actor_set_x clutter_actor_get_y clutter_actor_set_y -clutter_actor_rotate_x -clutter_actor_rotate_y -clutter_actor_rotate_z -clutter_actor_rotate_xx -clutter_actor_rotate_yx -clutter_actor_rotate_zx -clutter_actor_get_rxang -clutter_actor_get_ryang -clutter_actor_get_rzang -clutter_actor_get_rxangx -clutter_actor_get_ryangx -clutter_actor_get_rzangx +clutter_actor_set_rotation +clutter_actor_set_rotationx +clutter_actor_get_rotation +clutter_actor_get_rotationx clutter_actor_set_opacity clutter_actor_get_opacity clutter_actor_set_name @@ -221,7 +213,6 @@ clutter_container_remove_actor clutter_container_remove_valist clutter_container_get_children clutter_container_foreach -clutter_container_find_child_by_id clutter_container_find_child_by_name clutter_container_raise_child clutter_container_lower_child diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index ed14911d8..d4be7871f 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -2534,261 +2534,184 @@ clutter_actor_get_depth (ClutterActor *self) } /** - * clutter_actor_rotate_z: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @x: X co-ord to rotate actor around ( relative to actor position ) - * @y: Y co-ord to rotate actor around ( relative to actor position ) + * clutter_actor_set_rotationx: + * @self: a #ClutterActor + * @angle: the angle of rotation + * @axis: the axis of rotation + * @x: X coordinate of the rotation center + * @y: Y coordinate of the rotation center + * @z: Z coordinate of the rotation center * - * Rotates actor around the Z axis. + * Sets the rotation angle of @self around the given axis. + * + * This function is the fixed point variant of clutter_actor_set_rotation(). + * + * Since: 0.6 */ void -clutter_actor_rotate_z (ClutterActor *self, - gfloat angle, - gint x, - gint y) +clutter_actor_set_rotationx (ClutterActor *self, + ClutterFixed angle, + ClutterRotateAxis axis, + gint x, + gint y, + gint z) { + ClutterActorPrivate *priv; + g_return_if_fail (CLUTTER_IS_ACTOR (self)); - self->priv->rzang = CLUTTER_FLOAT_TO_FIXED (angle); - self->priv->rzx = x; - self->priv->rzy = y; + priv = self->priv; + + switch (axis) + { + case CLUTTER_X_AXIS: + priv->rxang = angle; + priv->rxy = y; + priv->rxz = z; + break; + + case CLUTTER_Y_AXIS: + priv->ryang = angle; + priv->ryx = x; + priv->ryz = z; + break; + + case CLUTTER_Z_AXIS: + priv->rzang = angle; + priv->rzx = x; + priv->rzy = y; + break; + } if (CLUTTER_ACTOR_IS_VISIBLE (self)) clutter_actor_queue_redraw (self); } /** - * clutter_actor_rotate_x: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @y: Y co-ord to rotate actor around ( relative to actor position ) - * @z: Z co-ord to rotate actor around ( relative to actor position ) + * clutter_actor_set_rotation: + * @self: a #ClutterActor + * @angle: the angle of rotation + * @axis: the axis of rotation + * @x: X coordinate of the rotation center + * @y: Y coordinate of the rotation center + * @z: Z coordinate of the rotation center * - * Rotates actor around the X axis. + * Sets the rotation angle of @self around the given axis. + * + * The rotation center coordinates depend on the value of @axis: + * + * %CLUTTER_X_AXIS requires @y and @z + * %CLUTTER_Y_AXIS requires @x and @z + * %CLUTTER_Z_AXIS requires @x and @y + * + * + * Since: 0.6 */ void -clutter_actor_rotate_x (ClutterActor *self, - gfloat angle, - gint y, - gint z) +clutter_actor_set_rotation (ClutterActor *self, + gdouble angle, + ClutterRotateAxis axis, + gint x, + gint y, + gint z) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); - self->priv->rxang = CLUTTER_FLOAT_TO_FIXED(angle); - self->priv->rxy = y; - self->priv->rxz = z; - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); + clutter_actor_set_rotationx (self, CLUTTER_FLOAT_TO_FIXED (angle), + axis, + x, y, z); } /** - * clutter_actor_rotate_y: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @x: X co-ord to rotate actor around ( relative to actor position ) - * @z: Z co-ord to rotate actor around ( relative to actor position ) + * clutter_actor_get_rotationx: + * @self: a #ClutterActor + * @axis: the axis of rotation + * @x: return value for the X coordinate of the center of rotation + * @y: return value for the Y coordinate of the center of rotation + * @z: return value for the Z coordinate of the center of rotation * - * Rotates actor around the X axis. - */ -void -clutter_actor_rotate_y (ClutterActor *self, - gfloat angle, - gint x, - gint z) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - self->priv->ryang = CLUTTER_FLOAT_TO_FIXED(angle); - - self->priv->ryx = x; - self->priv->ryz = z; - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); -} - -/** - * clutter_actor_rotate_zx: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @x: X co-ord to rotate actor around ( relative to actor position ) - * @y: Y co-ord to rotate actor around ( relative to actor position ) + * Retrieves the angle and center of rotation on the given axis, + * set using clutter_actor_set_rotation(). * - * Rotates actor around the Z axis. - */ -void -clutter_actor_rotate_zx (ClutterActor *self, - ClutterFixed angle, - gint x, - gint y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - self->priv->rzang = angle; - self->priv->rzx = x; - self->priv->rzy = y; - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); -} - -/** - * clutter_actor_rotate_xx: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @y: Y co-ord to rotate actor around ( relative to actor position ) - * @z: Z co-ord to rotate actor around ( relative to actor position ) + * This function is the fixed point variant of clutter_actor_get_rotation(). * - * Rotates actor around the X axis. - */ -void -clutter_actor_rotate_xx (ClutterActor *self, - ClutterFixed angle, - gint y, - gint z) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - self->priv->rxang = angle; - self->priv->rxy = y; - self->priv->rxz = z; - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); -} - -/** - * clutter_actor_rotate_yx: - * @self: A #ClutterActor - * @angle: Angle of rotation - * @x: X co-ord to rotate actor around ( relative to actor position ) - * @z: Z co-ord to rotate actor around ( relative to actor position ) + * Return value: the angle of rotation as a fixed point value. * - * Rotates actor around the X axis. - */ -void -clutter_actor_rotate_yx (ClutterActor *self, - ClutterFixed angle, - gint x, - gint z) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - self->priv->ryang = angle; - self->priv->ryx = x; - self->priv->ryz = z; - - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); -} - -/** - * clutter_actor_get_rxangx: - * @self: A #ClutterActor - * - * Gets the angle of rotation around the X axis. - * - * Returns: the angle or rotation, as a fixed point value - * - * Since: 0.4 + * Since: 0.6 */ ClutterFixed -clutter_actor_get_rxangx (ClutterActor *self) +clutter_actor_get_rotationx (ClutterActor *self, + ClutterRotateAxis axis, + gint *x, + gint *y, + gint *z) { + ClutterActorPrivate *priv; + ClutterFixed retval = 0; + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return self->priv->rxang; + priv = self->priv; + + switch (axis) + { + case CLUTTER_X_AXIS: + retval = priv->rxang; + if (y) + *y = priv->rxy; + if (z) + *z = priv->rxz; + break; + + case CLUTTER_Y_AXIS: + retval = priv->ryang; + if (x) + *x = priv->ryx; + if (z) + *z = priv->ryz; + break; + + case CLUTTER_Z_AXIS: + retval = priv->rzang; + if (x) + *x = priv->rzx; + if (y) + *y = priv->rzy; + break; + } + + return retval; } /** - * clutter_actor_get_rxang: + * clutter_actor_get_rotation: * @self: a #ClutterActor + * @axis: the axis of rotation + * @x: return value for the X coordinate of the center of rotation + * @y: return value for the Y coordinate of the center of rotation + * @z: return value for the Z coordinate of the center of rotation * - * Gets the angle of rotation around the X axis. + * Retrieves the angle and center of rotation on the given axis, + * set using clutter_actor_set_angle(). * - * Return value: the angle of rotation + * The coordinates of the center depend on the axis used. * - * Since: 0.4 + * Return value: the angle of rotation. + * + * Since: 0.6 */ gdouble -clutter_actor_get_rxang (ClutterActor *self) +clutter_actor_get_rotation (ClutterActor *self, + ClutterRotateAxis axis, + gint *x, + gint *y, + gint *z) { - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.); + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0); - return CLUTTER_FIXED_TO_FLOAT (self->priv->rxang); -} - -/** - * clutter_actor_get_ryangx: - * @self: A #ClutterActor - * - * Gets the angle of rotation around the Y axis. - * - * Return value: the angle of rotation, as a fixed point value - * - * Since: 0.4 - */ -ClutterFixed -clutter_actor_get_ryangx (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - - return self->priv->ryang; -} - -/** - * clutter_actor_get_ryang: - * @self: a #ClutterActor - * - * Gets the angle of rotation around the Y axis. - * - * Return value: the angle of rotation - * - * Since: 0.4 - */ -gdouble -clutter_actor_get_ryang (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.); - - return CLUTTER_FIXED_TO_FLOAT (self->priv->ryang); -} - -/** - * clutter_actor_get_rzangx: - * @self: A #ClutterActor - * - * Gets the angle of rotation around x axis in degrees. - * - * Return value: the angle of rotation, as a fixed point value - * - * Since: 0.4 - */ -ClutterFixed -clutter_actor_get_rzangx (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return self->priv->rzang; -} - -/** - * clutter_actor_get_rzang: - * @self: a #ClutterActor - * - * Gets the angle of rotation around the Z axis. - * - * Return value: the angle of rotation - * - * Since: 0.4 - */ -gdouble -clutter_actor_get_rzang (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.); - - return CLUTTER_FIXED_TO_FLOAT (self->priv->rzang); + return CLUTTER_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self, + axis, + x, y, z)); } /** diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 9fd477da4..067f0824d 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -273,6 +273,27 @@ void clutter_actor_set_x (ClutterActor *sel void clutter_actor_set_y (ClutterActor *self, gint y); +void clutter_actor_set_rotation (ClutterActor *self, + gdouble angle, + ClutterRotateAxis axis, + gint x, + gint y, + gint z);void clutter_actor_set_rotationx (ClutterActor *self, + ClutterFixed fixed, + ClutterRotateAxis axis, + gint x, + gint y, + gint z); +gdouble clutter_actor_get_rotation (ClutterActor *self, + ClutterRotateAxis axis, + gint *x, + gint *y, + gint *z); +ClutterFixed clutter_actor_get_rotationx (ClutterActor *self, + ClutterRotateAxis axis, + gint *x, + gint *y, + gint *z); void clutter_actor_rotate_x (ClutterActor *self, gfloat angle, gint y, diff --git a/clutter/clutter-behaviour-bspline.c b/clutter/clutter-behaviour-bspline.c index 529905221..ebb4849ed 100644 --- a/clutter/clutter-behaviour-bspline.c +++ b/clutter/clutter-behaviour-bspline.c @@ -35,7 +35,7 @@ * control points given when creating a new #ClutterBehaviourBspline instance. * * Additional bezier curves can be added to the end of the bspline using - * clutter_behaviour_bspline_append() family of functions, control points can + * clutter_behaviour_bspline_append_* family of functions, control points can * be moved using clutter_behaviour_bspline_adjust(). The bspline can be split * into two with clutter_behaviour_bspline_split(), and bsplines can be * concatenated using clutter_behaviour_bspline_join(). @@ -725,7 +725,7 @@ clutter_scriptable_iface_init (ClutterScriptableIface *iface) * * Bspline is defined by 3n + 1 points, n >=1; any trailing points passed * into this function are stored internally and used during any subsequent - * clutter_behaviour_bspline_append() operations. + * clutter_behaviour_bspline_append_* operations. * * Return value: a #ClutterBehaviour * @@ -860,7 +860,7 @@ clutter_behaviour_bspline_append_knots_valist (ClutterBehaviourBspline *bs, } /** - * clutter_behaviour_bspline_append_knots + * clutter_behaviour_bspline_append_knots: * @bs: a #ClutterBehaviourBspline * @first_knot: first #ClutterKnot * @VarArgs: a NULL-terminated array of #ClutterKnot control points. diff --git a/clutter/clutter-behaviour-rotate.c b/clutter/clutter-behaviour-rotate.c index 816aa28f5..e460a2831 100644 --- a/clutter/clutter-behaviour-rotate.c +++ b/clutter/clutter-behaviour-rotate.c @@ -88,33 +88,18 @@ alpha_notify_foreach (ClutterBehaviour *behaviour, ClutterActor *actor, gpointer data) { - ClutterFixed angle; - ClutterBehaviourRotate *rotate_behaviour; + ClutterFixed angle = GPOINTER_TO_UINT (data); + ClutterBehaviourRotate *rotate_behaviour; ClutterBehaviourRotatePrivate *priv; rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour); priv = rotate_behaviour->priv; - angle = GPOINTER_TO_UINT(data); - - switch (priv->axis) - { - case CLUTTER_X_AXIS: - clutter_actor_rotate_xx (actor, - angle, - priv->center_y, priv->center_z); - break; - case CLUTTER_Y_AXIS: - clutter_actor_rotate_yx (actor, - angle, - priv->center_x, priv->center_z); - break; - case CLUTTER_Z_AXIS: - clutter_actor_rotate_zx (actor, - angle, - priv->center_x, priv->center_y); - break; - } + clutter_actor_set_rotationx (actor, angle, + priv->axis, + priv->center_x, + priv->center_y, + priv->center_z); } static void diff --git a/clutter/clutter-deprecated.h b/clutter/clutter-deprecated.h index f199b5f0c..9d339fffd 100644 --- a/clutter/clutter-deprecated.h +++ b/clutter/clutter-deprecated.h @@ -8,7 +8,7 @@ * * Functions that are simply renamed should give errors containing * _REPLACED_BY_ whilst functions that are deprecated by new functions with - * new * functionality should giver errors containing _DEPRECATED_BY_. + * new functionality should giver errors containing _DEPRECATED_BY_. */ #define clutter_behaviour_ellipse_set_angle_begin clutter_behaviour_ellipse_set_angle_begin_REPLACED_BY_clutter_behaviour_set_angle_start @@ -16,6 +16,20 @@ #define clutter_behaviour_ellipse_get_angle_begin clutter_behaviour_ellipse_get_angle_begin_REPLACED_BY_clutter_behaviour_get_angle_start #define clutter_behaviour_ellipse_get_angle_beginx clutter_behaviour_ellipse_get_angle_beginx_REPLACED_BY_clutter_behaviour_get_angle_startx #define clutter_behaviour_bspline_append clutter_behaviour_bspline_append_REPLACED_BY_clutter_behaviour_bspline_append_knots + #define clutter_actor_get_id clutter_actor_get_id_REPLACED_BY_clutter_actor_get_gid +#define clutter_actor_rotate_x clutter_actor_rotate_x_DEPRECATED_BY_clutter_actor_set_rotation +#define clutter_actor_rotate_y clutter_actor_rotate_y_DEPRECATED_BY_clutter_actor_set_rotation +#define clutter_actor_rotate_z clutter_actor_rotate_z_DEPRECATED_BY_clutter_actor_set_rotation +#define clutter_actor_rotate_xx clutter_actor_rotate_xx_DEPRECATED_BY_clutter_actor_set_rotationx +#define clutter_actor_rotate_yx clutter_actor_rotate_yx_DEPRECATED_BY_clutter_actor_set_rotationx +#define clutter_actor_rotate_zx clutter_actor_rotate_zx_DEPRECATED_BY_clutter_actor_set_rotationx +#define clutter_actor_get_rxang clutter_actor_get_rxang_DEPRECATED_BY_clutter_actor_get_rotation +#define clutter_actor_get_ryang clutter_actor_get_ryang_DEPRECATED_BY_clutter_actor_get_rotation +#define clutter_actor_get_rzang clutter_actor_get_rzang_DEPRECATED_BY_clutter_actor_get_rotation +#define clutter_actor_get_rxangx clutter_actor_get_rxangx_DEPRECATED_BY_clutter_actor_get_rotationx +#define clutter_actor_get_ryangx clutter_actor_get_ryangx_DEPRECATED_BY_clutter_actor_get_rotationx +#define clutter_actor_get_rzangx clutter_actor_get_rzangx_DEPRECATED_BY_clutter_actor_get_rotationx + #endif /* CLUTTER_DEPRECATED_H */ diff --git a/clutter/clutter-effect.c b/clutter/clutter-effect.c index 8a2d5b6f5..4d04863a5 100644 --- a/clutter/clutter-effect.c +++ b/clutter/clutter-effect.c @@ -743,7 +743,9 @@ clutter_effect_rotate_x (ClutterEffectTemplate *template_, c->completed_data = completed_data; - clutter_actor_rotate_x (actor, angle_start, center_y, center_y); + clutter_actor_set_rotation (actor, angle_start, + CLUTTER_X_AXIS, + 0, center_y, center_z); c->behave = clutter_behaviour_rotate_new (c->alpha, CLUTTER_X_AXIS, @@ -803,7 +805,9 @@ clutter_effect_rotate_y (ClutterEffectTemplate *template_, c->completed_data = completed_data; - clutter_actor_rotate_y (actor, angle_start, center_x, center_z); + clutter_actor_set_rotation (actor, angle_start, + CLUTTER_Y_AXIS, + center_x, 0, center_z); c->behave = clutter_behaviour_rotate_new (c->alpha, CLUTTER_Y_AXIS, @@ -863,7 +867,9 @@ clutter_effect_rotate_z (ClutterEffectTemplate *template_, c->completed_data = completed_data; - clutter_actor_rotate_z (actor, angle_start, center_x, center_y); + clutter_actor_set_rotation (actor, angle_start, + CLUTTER_Z_AXIS, + center_x, center_y, 0); c->behave = clutter_behaviour_rotate_new (c->alpha, CLUTTER_Z_AXIS, diff --git a/tests/test-project.c b/tests/test-project.c index 35d10b9ff..37e53c22e 100644 --- a/tests/test-project.c +++ b/tests/test-project.c @@ -216,7 +216,7 @@ main (int argc, char *argv[]) rect = clutter_rectangle_new_with_color (&white); clutter_actor_set_size (rect, 320, 240); clutter_actor_set_position (rect, 180, 120); - clutter_actor_rotate_y (rect, 60, 0, 0); + clutter_actor_set_rotation (rect, 60, CLUTTER_Y_AXIS, 0, 0, 0); clutter_group_add (CLUTTER_GROUP (main_stage), rect); label = clutter_label_new_with_text ("Mono 8pt", "Drag the blue rectangles");