From 5b7c61a026bc46a646fc28f147540669a9b555c2 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 10 Aug 2012 14:17:56 +0100 Subject: [PATCH] actor: Deprecate Geometry-related API We cannot fully deprecate Geometry, because ClutterActor and ClutterText are actually using the type in signals and properties; but we can deprecate the API that uses this type, so that 2.0 will be able to avoid it entirely. --- clutter/clutter-actor.c | 90 ------------------ clutter/clutter-actor.h | 2 - clutter/clutter-paint-volume.c | 2 +- clutter/deprecated/clutter-actor-deprecated.c | 93 +++++++++++++++++++ clutter/deprecated/clutter-actor.h | 4 + clutter/deprecated/clutter-rectangle.c | 3 +- 6 files changed, 100 insertions(+), 94 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index a75b20f3e..a8f8ba43e 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -9376,39 +9376,6 @@ clutter_actor_get_allocation_box (ClutterActor *self, *box = self->priv->allocation; } -/** - * clutter_actor_get_allocation_geometry: - * @self: A #ClutterActor - * @geom: (out): allocation geometry in pixels - * - * Gets the layout box an actor has been assigned. The allocation can - * only be assumed valid inside a paint() method; anywhere else, it - * may be out-of-date. - * - * An allocation does not incorporate the actor's scale or anchor point; - * those transformations do not affect layout, only rendering. - * - * The returned rectangle is in pixels. - * - * Since: 0.8 - */ -void -clutter_actor_get_allocation_geometry (ClutterActor *self, - ClutterGeometry *geom) -{ - ClutterActorBox box; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - g_return_if_fail (geom != NULL); - - clutter_actor_get_allocation_box (self, &box); - - geom->x = CLUTTER_NEARBYINT (clutter_actor_box_get_x (&box)); - geom->y = CLUTTER_NEARBYINT (clutter_actor_box_get_y (&box)); - geom->width = CLUTTER_NEARBYINT (clutter_actor_box_get_width (&box)); - geom->height = CLUTTER_NEARBYINT (clutter_actor_box_get_height (&box)); -} - static void clutter_actor_update_constraints (ClutterActor *self, ClutterActorBox *allocation) @@ -9810,63 +9777,6 @@ clutter_actor_set_allocation (ClutterActor *self, g_object_thaw_notify (G_OBJECT (self)); } -/** - * clutter_actor_set_geometry: - * @self: A #ClutterActor - * @geometry: A #ClutterGeometry - * - * Sets the actor's fixed position and forces its minimum and natural - * size, in pixels. This means the untransformed actor will have the - * given geometry. This is the same as calling clutter_actor_set_position() - * and clutter_actor_set_size(). - * - * Deprecated: 1.10: Use clutter_actor_set_position() and - * clutter_actor_set_size() instead. - */ -void -clutter_actor_set_geometry (ClutterActor *self, - const ClutterGeometry *geometry) -{ - g_object_freeze_notify (G_OBJECT (self)); - - clutter_actor_set_position (self, geometry->x, geometry->y); - clutter_actor_set_size (self, geometry->width, geometry->height); - - g_object_thaw_notify (G_OBJECT (self)); -} - -/** - * clutter_actor_get_geometry: - * @self: A #ClutterActor - * @geometry: (out caller-allocates): A location to store actors #ClutterGeometry - * - * Gets the size and position of an actor relative to its parent - * actor. This is the same as calling clutter_actor_get_position() and - * clutter_actor_get_size(). It tries to "do what you mean" and get the - * requested size and position if the actor's allocation is invalid. - * - * Deprecated: 1.10: Use clutter_actor_get_position() and - * clutter_actor_get_size(), or clutter_actor_get_allocation_geometry() - * instead. - */ -void -clutter_actor_get_geometry (ClutterActor *self, - ClutterGeometry *geometry) -{ - gfloat x, y, width, height; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - g_return_if_fail (geometry != NULL); - - clutter_actor_get_position (self, &x, &y); - clutter_actor_get_size (self, &width, &height); - - geometry->x = (int) x; - geometry->y = (int) y; - geometry->width = (int) width; - geometry->height = (int) height; -} - /** * clutter_actor_set_position: * @self: A #ClutterActor diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 1edb465b1..ee1324d5a 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -361,8 +361,6 @@ void clutter_actor_set_allocation ClutterAllocationFlags flags); void clutter_actor_get_allocation_box (ClutterActor *self, ClutterActorBox *box); -void clutter_actor_get_allocation_geometry (ClutterActor *self, - ClutterGeometry *geom); void clutter_actor_get_allocation_vertices (ClutterActor *self, ClutterActor *ancestor, ClutterVertex verts[]); diff --git a/clutter/clutter-paint-volume.c b/clutter/clutter-paint-volume.c index ba7abb84b..9eeee1e9b 100644 --- a/clutter/clutter-paint-volume.c +++ b/clutter/clutter-paint-volume.c @@ -734,7 +734,7 @@ _clutter_paint_volume_complete (ClutterPaintVolume *pv) /* * _clutter_paint_volume_get_box: * @pv: a #ClutterPaintVolume - * @box: a pixel aligned #ClutterGeometry + * @box: a pixel aligned #ClutterActorBox * * Transforms a 3D paint volume into a 2D bounding box in the * same coordinate space as the 3D paint volume. diff --git a/clutter/deprecated/clutter-actor-deprecated.c b/clutter/deprecated/clutter-actor-deprecated.c index 9a8c32ebf..ff3a37c06 100644 --- a/clutter/deprecated/clutter-actor-deprecated.c +++ b/clutter/deprecated/clutter-actor-deprecated.c @@ -5,6 +5,7 @@ #include #define CLUTTER_DISABLE_DEPRECATION_WARNINGS +#include "deprecated/clutter-actor.h" #include "clutter-actor-private.h" #include "clutter-private.h" @@ -316,3 +317,95 @@ clutter_actor_set_shader_param_int (ClutterActor *self, g_value_unset (&var); } + +/** + * clutter_actor_set_geometry: + * @self: A #ClutterActor + * @geometry: A #ClutterGeometry + * + * Sets the actor's fixed position and forces its minimum and natural + * size, in pixels. This means the untransformed actor will have the + * given geometry. This is the same as calling clutter_actor_set_position() + * and clutter_actor_set_size(). + * + * Deprecated: 1.10: Use clutter_actor_set_position() and + * clutter_actor_set_size() instead. + */ +void +clutter_actor_set_geometry (ClutterActor *self, + const ClutterGeometry *geometry) +{ + g_object_freeze_notify (G_OBJECT (self)); + + clutter_actor_set_position (self, geometry->x, geometry->y); + clutter_actor_set_size (self, geometry->width, geometry->height); + + g_object_thaw_notify (G_OBJECT (self)); +} + +/** + * clutter_actor_get_geometry: + * @self: A #ClutterActor + * @geometry: (out caller-allocates): A location to store actors #ClutterGeometry + * + * Gets the size and position of an actor relative to its parent + * actor. This is the same as calling clutter_actor_get_position() and + * clutter_actor_get_size(). It tries to "do what you mean" and get the + * requested size and position if the actor's allocation is invalid. + * + * Deprecated: 1.10: Use clutter_actor_get_position() and + * clutter_actor_get_size(), or clutter_actor_get_allocation_geometry() + * instead. + */ +void +clutter_actor_get_geometry (ClutterActor *self, + ClutterGeometry *geometry) +{ + gfloat x, y, width, height; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + g_return_if_fail (geometry != NULL); + + clutter_actor_get_position (self, &x, &y); + clutter_actor_get_size (self, &width, &height); + + geometry->x = (int) x; + geometry->y = (int) y; + geometry->width = (int) width; + geometry->height = (int) height; +} + +/** + * clutter_actor_get_allocation_geometry: + * @self: A #ClutterActor + * @geom: (out): allocation geometry in pixels + * + * Gets the layout box an actor has been assigned. The allocation can + * only be assumed valid inside a paint() method; anywhere else, it + * may be out-of-date. + * + * An allocation does not incorporate the actor's scale or anchor point; + * those transformations do not affect layout, only rendering. + * + * The returned rectangle is in pixels. + * + * Since: 0.8 + * + * Deprecated: 1.12: Use clutter_actor_get_allocation_box() instead. + */ +void +clutter_actor_get_allocation_geometry (ClutterActor *self, + ClutterGeometry *geom) +{ + ClutterActorBox box; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + g_return_if_fail (geom != NULL); + + clutter_actor_get_allocation_box (self, &box); + + geom->x = CLUTTER_NEARBYINT (clutter_actor_box_get_x (&box)); + geom->y = CLUTTER_NEARBYINT (clutter_actor_box_get_y (&box)); + geom->width = CLUTTER_NEARBYINT (clutter_actor_box_get_width (&box)); + geom->height = CLUTTER_NEARBYINT (clutter_actor_box_get_height (&box)); +} diff --git a/clutter/deprecated/clutter-actor.h b/clutter/deprecated/clutter-actor.h index eafb5eb3a..9302e9423 100644 --- a/clutter/deprecated/clutter-actor.h +++ b/clutter/deprecated/clutter-actor.h @@ -152,6 +152,10 @@ CLUTTER_DEPRECATED_IN_1_12 void clutter_actor_get_transformation_matrix (ClutterActor *self, ClutterMatrix *matrix); +CLUTTER_DEPRECATED_IN_1_12_FOR (clutter_actor_get_allocation_box) +void clutter_actor_get_allocation_geometry (ClutterActor *self, + ClutterGeometry *geom); + G_END_DECLS #endif /* __CLUTTER_ACTOR_DEPRECATED_H__ */ diff --git a/clutter/deprecated/clutter-rectangle.c b/clutter/deprecated/clutter-rectangle.c index 03e8ac811..b6236aff5 100644 --- a/clutter/deprecated/clutter-rectangle.c +++ b/clutter/deprecated/clutter-rectangle.c @@ -37,7 +37,8 @@ #endif #define CLUTTER_DISABLE_DEPRECATION_WARNINGS -#include "clutter-rectangle.h" +#include "deprecated/clutter-rectangle.h" +#include "deprecated/clutter-actor.h" #include "clutter-actor-private.h" #include "clutter-color.h"