diff --git a/ChangeLog b/ChangeLog index 9b9b071bb..e5a4f3fbe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-12-07 Emmanuele Bassi + + * clutter/clutter-actor.h: + * clutter/clutter-actor.c: + (clutter_actor_get_sizeu), + (clutter_actor_get_positionu): Add unit-based accessors to + the size and position. + 2007-12-07 Tomas Frydrych * clutter/clutter-behaviour-ellipse.c: diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 5488a5b58..5637c5d19 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -2109,6 +2109,35 @@ clutter_actor_get_size (ClutterActor *self, *height = CLUTTER_UNITS_TO_INT (box.y2 - box.y1); } +/** + * clutter_actor_get_sizeu: + * @self: A #ClutterActor + * @width: Location to store width if non NULL. + * @height: Location to store height if non NULL. + * + * Gets the size of an actor in #ClutterUnits ignoring any scaling + * factors. + * + * Since: 0.6 + */ +void +clutter_actor_get_sizeu (ClutterActor *self, + ClutterUnit *width, + ClutterUnit *height) +{ + ClutterActorBox box; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + + clutter_actor_query_coords (self, &box); + + if (width) + *width = box.x2 - box.x1; + + if (height) + *height = box.y2 - box.y1; +} + /** * clutter_actor_get_position: * @self: a #ClutterActor @@ -2137,6 +2166,34 @@ clutter_actor_get_position (ClutterActor *self, *y = CLUTTER_UNITS_TO_INT (box.y1); } +/** + * clutter_actor_get_positionu: + * @self: a #ClutterActor + * @x: return location for the X coordinate, or %NULL + * @y: return location for the Y coordinate, or %NULL + * + * Retrieves the position of an actor in #ClutterUnits. + * + * Since: 0.6 + */ +void +clutter_actor_get_positionu (ClutterActor *self, + ClutterUnit *x, + ClutterUnit *y) +{ + ClutterActorBox box = { 0, }; + + g_return_if_fail (CLUTTER_IS_ACTOR (self)); + + clutter_actor_query_coords (self, &box); + + if (x) + *x = box.x1; + + if (y) + *y = box.y1; +} + /* * clutter_actor_get_abs_position_units * @self: A #ClutterActor @@ -3949,27 +4006,27 @@ clutter_scriptable_iface_init (ClutterScriptableIface *iface) /** * clutter_actor_transform_stage_point * @self: A #ClutterActor - * @x: x screen coordiance of point to unproject, in #ClutterUnit - * @y: y screen coordiance of point to unproject, in #ClutterUnit - * @x: x_out location where to store the unprojected x coordinance, in - * #ClutterUnit. - * @y: y_out location where to store the unprojected y coordinance, in - * #ClutterUnit. + * @x: x screen coordinate of the point to unproject, in #ClutterUnits + * @y: y screen coordinate of the point to unproject, in #ClutterUnits + * @x_out: return location for the unprojected x coordinance, in + * #ClutterUnits + * @y_out: return location for the unprojected y coordinance, in + * #ClutterUnits * - * Return value: TRUE if conversion was successful. - * - * The function translates point with screen coordinates x,y to coordinates - * relative to the actor, i.e., it can be used, to translate screen events - * from global screen coordinates into local coordinates. + * The function translates point with screen coordinates (@x, @y) to + * coordinates relative to the actor, i.e. it can be used to translate + * screen events from global screen coordinates into local coordinates. * * The conversion can fail, notably if the transform stack results in the * actor being projected on the screen as a mere line. * - * The conversion should not be expected to be pixel-perfect due to the nature - * of the operation. In general the error grows when the skewing of the actor - * rectangle on screen increases. + * The conversion should not be expected to be pixel-perfect due to the + * nature of the operation. In general the error grows when the skewing + * of the actor rectangle on screen increases. * - * WARNING: This function is fairly computationally intensive. + * Note: This function is fairly computationally intensive. + * + * Return value: %TRUE if conversion was successful. * * Since: 0.6 */ diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index cee73b3a2..ec80e84f0 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -256,6 +256,15 @@ void clutter_actor_set_size (ClutterActor *sel void clutter_actor_set_sizeu (ClutterActor *self, ClutterUnit width, ClutterUnit height); +void clutter_actor_get_size (ClutterActor *self, + guint *width, + guint *height); +void clutter_actor_get_sizeu (ClutterActor *self, + ClutterUnit *width, + ClutterUnit *height); +void clutter_actor_get_abs_size (ClutterActor *self, + guint *width, + guint *height); void clutter_actor_set_position (ClutterActor *self, gint x, gint y); @@ -265,6 +274,9 @@ void clutter_actor_set_positionu (ClutterActor *sel void clutter_actor_get_position (ClutterActor *self, gint *x, gint *y); +void clutter_actor_get_positionu (ClutterActor *self, + ClutterUnit *x, + ClutterUnit *y); void clutter_actor_get_abs_position (ClutterActor *self, gint *x, gint *y); @@ -368,12 +380,6 @@ void clutter_actor_get_scale (ClutterActor *sel gdouble *scale_x, gdouble *scale_y); -void clutter_actor_get_abs_size (ClutterActor *self, - guint *width, - guint *height); -void clutter_actor_get_size (ClutterActor *self, - guint *width, - guint *height); void clutter_actor_move_by (ClutterActor *self, gint dx, gint dy);