From d6d208da7de44b1a266957ad69acff6ee0f2fd4d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 6 May 2009 16:44:47 +0100 Subject: [PATCH] Remove Units from the public API With the recent change to internal floating point values, ClutterUnit has become a redundant type, defined to be a float. All integer entry points are being internally converted to floating point values to be passed to the GL pipeline with the least amount of conversion. ClutterUnit is thus exposed as just a "pixel with fractionary bits", and not -- as users might think -- as generic, resolution and device independent units. not that it was the case, but a definitive amount of people was convinced it did provide this "feature", and was flummoxed about the mere existence of this type. So, having ClutterUnit exposed in the public API doubles the entry points and has the following disadvantages: - we have to maintain twice the amount of entry points in ClutterActor - we still do an integer-to-float implicit conversion - we introduce a weird impedance between pixels and "pixels with fractionary bits" - language bindings will have to choose what to bind, and resort to manually overriding the API + *except* for language bindings based on GObject-Introspection, as they cannot do manual overrides, thus will replicate the entire set of entry points For these reason, we should coalesces every Actor entry point for pixels and for ClutterUnit into a single entry point taking a float, like: void clutter_actor_set_x (ClutterActor *self, gfloat x); void clutter_actor_get_size (ClutterActor *self, gfloat *width, gfloat *height); gfloat clutter_actor_get_height (ClutterActor *self); etc. The issues I have identified are: - we'll have a two cases of compiler warnings: - printf() format of the return values from %d to %f - clutter_actor_get_size() taking floats instead of unsigned ints - we'll have a problem with varargs when passing an integer instead of a floating point value, except on 64bit platforms where the size of a float is the same as the size of an int To be clear: the *intent* of the API should not change -- we still use pixels everywhere -- but: - we remove ambiguity in the API with regard to pixels and units - we remove entry points we get to maintain for the whole 1.0 version of the API - we make things simpler to bind for both manual language bindings and automatic (gobject-introspection based) ones - we have the simplest API possible while still exposing the capabilities of the underlying GL implementation --- clutter/clutter-actor.c | 2591 ++++++----------- clutter/clutter-actor.h | 223 +- clutter/clutter-animation.c | 3 + clutter/clutter-backend.c | 11 +- clutter/clutter-behaviour.c | 5 +- clutter/clutter-cairo-texture.c | 16 +- clutter/clutter-clone.c | 16 +- clutter/clutter-deprecated.h | 20 + clutter/clutter-event.c | 9 +- clutter/clutter-event.h | 24 +- clutter/clutter-group.c | 40 +- clutter/clutter-main.c | 22 +- clutter/clutter-private.h | 10 +- clutter/clutter-stage.c | 34 +- clutter/clutter-text.c | 50 +- clutter/clutter-texture.c | 63 +- clutter/clutter-types.h | 8 +- clutter/eglnative/clutter-stage-egl.c | 12 +- clutter/fruity/clutter-stage-fruity.c | 12 +- clutter/osx/clutter-stage-osx.c | 12 +- clutter/sdl/clutter-stage-sdl.c | 12 +- clutter/win32/clutter-stage-win32.c | 12 +- clutter/x11/clutter-stage-x11.c | 14 +- tests/conform/test-anchors.c | 15 +- tests/conform/test-timeline-dup-frames.c | 1 - tests/conform/test-timeline-interpolate.c | 1 - tests/conform/test-timeline-rewind.c | 1 - tests/conform/test-timeline-smoothness.c | 1 - tests/interactive/test-actor-clone.c | 4 +- tests/interactive/test-actors.c | 4 +- tests/interactive/test-animation.c | 12 +- .../interactive/test-clutter-cairo-flowers.c | 10 +- tests/interactive/test-depth.c | 24 +- tests/interactive/test-easing.c | 12 +- tests/interactive/test-fullscreen.c | 6 +- tests/interactive/test-layout.c | 16 +- tests/interactive/test-paint-wrapper.c | 6 +- tests/interactive/test-project.c | 46 +- tests/interactive/test-stage-read-pixels.c | 12 +- tests/interactive/test-unproject.c | 21 +- 40 files changed, 1346 insertions(+), 2065 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index b859433ed..6dca8ff3d 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -256,64 +256,65 @@ struct _ClutterActorPrivate /* fixed_x, fixed_y, and the allocation box are all in parent * coordinates. */ - ClutterUnit fixed_x; - ClutterUnit fixed_y; + gfloat fixed_x; + gfloat fixed_y; /* request mode */ ClutterRequestMode request_mode; /* our cached request width is for this height */ - ClutterUnit request_width_for_height; - ClutterUnit request_min_width; - ClutterUnit request_natural_width; + gfloat request_width_for_height; + gfloat request_min_width; + gfloat request_natural_width; + /* our cached request height is for this width */ - ClutterUnit request_height_for_width; - ClutterUnit request_min_height; - ClutterUnit request_natural_height; + gfloat request_height_for_width; + gfloat request_min_height; + gfloat request_natural_height; ClutterActorBox allocation; - guint position_set : 1; - guint min_width_set : 1; - guint min_height_set : 1; - guint natural_width_set : 1; - guint natural_height_set : 1; + guint position_set : 1; + guint min_width_set : 1; + guint min_height_set : 1; + guint natural_width_set : 1; + guint natural_height_set : 1; /* cached request is invalid (implies allocation is too) */ - guint needs_width_request : 1; + guint needs_width_request : 1; /* cached request is invalid (implies allocation is too) */ - guint needs_height_request : 1; + guint needs_height_request : 1; /* cached allocation is invalid (request has changed, probably) */ - guint needs_allocation : 1; + guint needs_allocation : 1; + guint queued_redraw : 1; + guint show_on_set_parent : 1; + guint has_clip : 1; + guint clip_to_allocation : 1; + guint enable_model_view_transform : 1; + guint enable_paint_unmapped : 1; - guint queued_redraw : 1; - - guint show_on_set_parent : 1; - guint has_clip : 1; - guint clip_to_allocation : 1; - - ClutterUnit clip[4]; + gfloat clip[4]; /* Rotation angles */ - gdouble rxang; - gdouble ryang; - gdouble rzang; + gdouble rxang; + gdouble ryang; + gdouble rzang; /* Rotation center: X axis */ - AnchorCoord rx_center; + AnchorCoord rx_center; /* Rotation center: Y axis */ - AnchorCoord ry_center; + AnchorCoord ry_center; /* Rotation center: Z axis */ - AnchorCoord rz_center; + AnchorCoord rz_center; /* Anchor point coordinates */ - AnchorCoord anchor; + AnchorCoord anchor; /* depth */ - ClutterUnit z; + gfloat z; - guint8 opacity; + guint8 opacity; ClutterActor *parent_actor; @@ -330,8 +331,6 @@ struct _ClutterActorPrivate PangoContext *pango_context; ClutterActor *opacity_parent; - guint enable_model_view_transform : 1; - guint enable_paint_unmapped : 1; }; enum @@ -343,8 +342,7 @@ enum /* X, Y, WIDTH, HEIGHT are "do what I mean" properties; * when set they force a size request, when gotten they * get the allocation if the allocation is valid, and the - * request otherwise. Also, they are in pixels, while - * all the underlying properties are in ClutterUnit. + * request otherwise */ PROP_X, PROP_Y, @@ -352,8 +350,7 @@ enum PROP_HEIGHT, /* Then the rest of these size-related properties are the "actual" - * underlying properties set or gotten by X, Y, WIDTH, HEIGHT. All - * of these are in ClutterUnit not in pixels. + * underlying properties set or gotten by X, Y, WIDTH, HEIGHT */ PROP_FIXED_X, PROP_FIXED_Y, @@ -458,13 +455,13 @@ static void destroy_shader_data (ClutterActor *self); * properties */ static void clutter_actor_set_min_width (ClutterActor *self, - ClutterUnit min_width); + gfloat min_width); static void clutter_actor_set_min_height (ClutterActor *self, - ClutterUnit min_height); + gfloat min_height); static void clutter_actor_set_natural_width (ClutterActor *self, - ClutterUnit natural_width); + gfloat natural_width); static void clutter_actor_set_natural_height (ClutterActor *self, - ClutterUnit natural_height); + gfloat natural_height); static void clutter_actor_set_min_width_set (ClutterActor *self, gboolean use_min_width); static void clutter_actor_set_min_height_set (ClutterActor *self, @@ -480,37 +477,30 @@ static void clutter_actor_update_map_state (ClutterActor *self, static void clutter_actor_unrealize_not_hiding (ClutterActor *self); /* Helper routines for managing anchor coords */ -static void clutter_anchor_coord_get_units (ClutterActor *self, +static void clutter_anchor_coord_get_units (ClutterActor *self, const AnchorCoord *coord, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z); -static void clutter_anchor_coord_set_units (AnchorCoord *coord, - ClutterUnit x, - ClutterUnit y, - ClutterUnit z); -static ClutterGravity clutter_anchor_coord_get_gravity (AnchorCoord *coord); -static void clutter_anchor_coord_set_gravity (AnchorCoord *coord, - ClutterGravity gravity); + gfloat *x, + gfloat *y, + gfloat *z); +static void clutter_anchor_coord_set_units (AnchorCoord *coord, + gfloat x, + gfloat y, + gfloat z); + +static ClutterGravity clutter_anchor_coord_get_gravity (AnchorCoord *coord); +static void clutter_anchor_coord_set_gravity (AnchorCoord *coord, + ClutterGravity gravity); + static gboolean clutter_anchor_coord_is_zero (const AnchorCoord *coord); /* Helper macro which translates by the anchor coord, applies the given transformation and then translates back */ -#define TRANSFORM_ABOUT_ANCHOR_COORD(actor, coord, transform) \ - G_STMT_START \ - { \ - ClutterUnit __tx, __ty, __tz; \ - clutter_anchor_coord_get_units ((actor), (coord), \ - &__tx, &__ty, &__tz); \ - cogl_translate (CLUTTER_UNITS_TO_FLOAT (__tx), \ - CLUTTER_UNITS_TO_FLOAT (__ty), \ - CLUTTER_UNITS_TO_FLOAT (__tz)); \ - (transform); \ - cogl_translate (-CLUTTER_UNITS_TO_FLOAT (__tx), \ - -CLUTTER_UNITS_TO_FLOAT (__ty), \ - -CLUTTER_UNITS_TO_FLOAT (__tz)); \ - } \ - G_STMT_END +#define TRANSFORM_ABOUT_ANCHOR_COORD(actor,coord,transform) G_STMT_START { \ + gfloat _tx, _ty, _tz; \ + clutter_anchor_coord_get_units ((actor), (coord), &_tx, &_ty, &_tz); \ + cogl_translate (_tx, _ty, _tz); \ + { transform; } \ + cogl_translate (-_tx, -_ty, -_tz); } G_STMT_END G_DEFINE_ABSTRACT_TYPE_WITH_CODE (ClutterActor, clutter_actor, @@ -678,14 +668,17 @@ clutter_actor_update_map_state (ClutterActor *self, { case MAP_STATE_CHECK: break; + case MAP_STATE_MAKE_MAPPED: g_assert (!was_mapped); clutter_actor_set_mapped (self, TRUE); break; + case MAP_STATE_MAKE_UNMAPPED: g_assert (was_mapped); clutter_actor_set_mapped (self, FALSE); break; + case MAP_STATE_MAKE_UNREALIZED: /* we only use MAKE_UNREALIZED in unparent, * and unparenting a stage isn't possible. @@ -697,28 +690,26 @@ clutter_actor_update_map_state (ClutterActor *self, break; } - if (CLUTTER_ACTOR_IS_MAPPED (self) && - !CLUTTER_ACTOR_IS_VISIBLE (self)) - g_warning ("Clutter toplevel is not visible, but is somehow still mapped"); + if (CLUTTER_ACTOR_IS_MAPPED (self) && !CLUTTER_ACTOR_IS_VISIBLE (self)) + { + g_warning ("Clutter toplevel is not visible, but is " + "somehow still mapped"); + } } else { - ClutterActorPrivate *priv; + ClutterActorPrivate *priv = self->priv; + ClutterActor *parent = priv->parent_actor; gboolean should_be_mapped; gboolean may_be_realized; gboolean must_be_realized; - ClutterActor *parent; - priv = self->priv; should_be_mapped = FALSE; may_be_realized = TRUE; must_be_realized = FALSE; - parent = priv->parent_actor; - - if (parent == NULL || - change == MAP_STATE_MAKE_UNREALIZED) + if (parent == NULL || change == MAP_STATE_MAKE_UNREALIZED) { may_be_realized = FALSE; } @@ -992,7 +983,6 @@ clutter_actor_show (ClutterActor *self) g_return_if_fail (CLUTTER_IS_ACTOR (self)); #ifdef CLUTTER_ENABLE_DEBUG - /* FIXME leave this for debugging only */ clutter_actor_verify_map_state (self); #endif @@ -1073,7 +1063,6 @@ clutter_actor_hide (ClutterActor *self) g_return_if_fail (CLUTTER_IS_ACTOR (self)); #ifdef CLUTTER_ENABLE_DEBUG - /* FIXME leave this for debugging only */ clutter_actor_verify_map_state (self); #endif @@ -1141,7 +1130,6 @@ clutter_actor_realize (ClutterActor *self) g_return_if_fail (CLUTTER_IS_ACTOR (self)); #ifdef CLUTTER_ENABLE_DEBUG - /* FIXME leave this for debugging only */ clutter_actor_verify_map_state (self); #endif @@ -1236,7 +1224,6 @@ clutter_actor_unrealize (ClutterActor *self) g_return_if_fail (!CLUTTER_ACTOR_IS_MAPPED (self)); #ifdef CLUTTER_ENABLE_DEBUG - /* FIXME leave this for debugging only */ clutter_actor_verify_map_state (self); #endif @@ -1323,7 +1310,6 @@ _clutter_actor_rerealize (ClutterActor *self, g_return_if_fail (CLUTTER_IS_ACTOR (self)); #ifdef CLUTTER_ENABLE_DEBUG - /* FIXME leave this for debugging only */ clutter_actor_verify_map_state (self); #endif @@ -1369,8 +1355,8 @@ clutter_actor_real_pick (ClutterActor *self, clutter_actor_get_allocation_box (self, &box); - width = CLUTTER_UNITS_TO_FLOAT (box.x2 - box.x1); - height = CLUTTER_UNITS_TO_FLOAT (box.y2 - box.y1); + width = box.x2 - box.x1; + height = box.y2 - box.y1; cogl_set_source_color4ub (color->red, color->green, @@ -1442,9 +1428,9 @@ clutter_actor_should_pick_paint (ClutterActor *self) static void clutter_actor_real_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { /* Default implementation is always 0x0, usually an actor * using this default is relying on someone to set the @@ -1461,9 +1447,9 @@ clutter_actor_real_get_preferred_width (ClutterActor *self, static void clutter_actor_real_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { /* Default implementation is always 0x0, usually an actor * using this default is relying on someone to set the @@ -1490,8 +1476,9 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, const ClutterActorBox *old) { ClutterActorPrivate *priv = self->priv; + GObject *obj = G_OBJECT (self); - g_object_freeze_notify (G_OBJECT (self)); + g_object_freeze_notify (obj); /* to avoid excessive requisition or allocation cycles we * use the cached values. @@ -1506,20 +1493,20 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, */ if (priv->needs_allocation) { - g_object_notify (G_OBJECT (self), "x"); - g_object_notify (G_OBJECT (self), "y"); - g_object_notify (G_OBJECT (self), "width"); - g_object_notify (G_OBJECT (self), "height"); + g_object_notify (obj, "x"); + g_object_notify (obj, "y"); + g_object_notify (obj, "width"); + g_object_notify (obj, "height"); } else if (priv->needs_width_request || priv->needs_height_request) { - g_object_notify (G_OBJECT (self), "width"); - g_object_notify (G_OBJECT (self), "height"); + g_object_notify (obj, "width"); + g_object_notify (obj, "height"); } else { - ClutterUnit xu, yu; - ClutterUnit widthu, heightu; + gfloat xu, yu; + gfloat widthu, heightu; xu = priv->allocation.x1; yu = priv->allocation.y1; @@ -1527,19 +1514,19 @@ clutter_actor_notify_if_geometry_changed (ClutterActor *self, heightu = priv->allocation.y2 - priv->allocation.y1; if (xu != old->x1) - g_object_notify (G_OBJECT (self), "x"); + g_object_notify (obj, "x"); if (yu != old->y1) - g_object_notify (G_OBJECT (self), "y"); + g_object_notify (obj, "y"); if (widthu != (old->x2 - old->x1)) - g_object_notify (G_OBJECT (self), "width"); + g_object_notify (obj, "width"); if (heightu != (old->y2 - old->y1)) - g_object_notify (G_OBJECT (self), "height"); + g_object_notify (obj, "height"); } - g_object_thaw_notify (G_OBJECT (self)); + g_object_thaw_notify (obj); } static void @@ -1627,9 +1614,9 @@ static inline void full_vertex_to_units (const full_vertex_t *f, ClutterVertex *u) { - u->x = CLUTTER_UNITS_FROM_FLOAT (f->x); - u->y = CLUTTER_UNITS_FROM_FLOAT (f->y); - u->z = CLUTTER_UNITS_FROM_FLOAT (f->z); + u->x = f->x; + u->y = f->y; + u->z = f->z; } /* Transforms a vertex using the passed matrix; vertex is @@ -1677,7 +1664,7 @@ full_vertex_transform (const CoglMatrix *matrix, } /* scales a fixed @vertex using @matrix and @viewport, and - * transforms the result into ClutterUnits, filling @vertex_p + * transforms the result into a ClutterVertex, filling @vertex_p */ static inline void full_vertex_scale (const CoglMatrix *matrix, @@ -1697,9 +1684,9 @@ full_vertex_scale (const CoglMatrix *matrix, v_width = viewport[2]; v_height = viewport[3]; - tmp.x = MTX_GL_SCALE_X (tmp.x, tmp.w, v_width, v_x); + tmp.x = MTX_GL_SCALE_X (tmp.x, tmp.w, v_width, v_x); tmp.y = MTX_GL_SCALE_Y (tmp.y, tmp.w, v_height, v_y); - tmp.z = MTX_GL_SCALE_Z (tmp.z, tmp.w, v_width, v_x); + tmp.z = MTX_GL_SCALE_Z (tmp.z, tmp.w, v_width, v_x); tmp.w = 0; full_vertex_to_units (&tmp, vertex_p); @@ -1714,18 +1701,18 @@ full_vertex_scale (const CoglMatrix *matrix, static void clutter_actor_transform_point_relative (ClutterActor *actor, ClutterActor *ancestor, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z, - ClutterUnit *w) + gfloat *x, + gfloat *y, + gfloat *z, + gfloat *w) { full_vertex_t vertex = { 0, }; CoglMatrix matrix; - vertex.x = (x != NULL) ? CLUTTER_UNITS_TO_FLOAT (*x) : 0; - vertex.y = (y != NULL) ? CLUTTER_UNITS_TO_FLOAT (*y) : 0; - vertex.z = (z != NULL) ? CLUTTER_UNITS_TO_FLOAT (*z) : 0; - vertex.w = (w != NULL) ? CLUTTER_UNITS_TO_FLOAT (*w) : 0; + vertex.x = (x != NULL) ? *x : 0; + vertex.y = (y != NULL) ? *y : 0; + vertex.z = (z != NULL) ? *z : 0; + vertex.w = (w != NULL) ? *w : 0; cogl_push_matrix(); @@ -1737,16 +1724,16 @@ clutter_actor_transform_point_relative (ClutterActor *actor, cogl_pop_matrix(); if (x) - *x = CLUTTER_UNITS_FROM_FLOAT (vertex.x); + *x = vertex.x; if (y) - *y = CLUTTER_UNITS_FROM_FLOAT (vertex.y); + *y = vertex.y; if (z) - *z = CLUTTER_UNITS_FROM_FLOAT (vertex.z); + *z = vertex.z; if (w) - *w = CLUTTER_UNITS_FROM_FLOAT (vertex.w); + *w = vertex.w; } /* Applies the transforms associated with this actor and its ancestors, @@ -1755,18 +1742,18 @@ clutter_actor_transform_point_relative (ClutterActor *actor, */ static void clutter_actor_transform_point (ClutterActor *actor, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z, - ClutterUnit *w) + gfloat *x, + gfloat *y, + gfloat *z, + gfloat *w) { full_vertex_t vertex = { 0, }; CoglMatrix matrix; - vertex.x = (x != NULL) ? CLUTTER_UNITS_TO_FLOAT (*x) : 0; - vertex.y = (y != NULL) ? CLUTTER_UNITS_TO_FLOAT (*y) : 0; - vertex.z = (z != NULL) ? CLUTTER_UNITS_TO_FLOAT (*z) : 0; - vertex.w = (w != NULL) ? CLUTTER_UNITS_TO_FLOAT (*w) : 0; + vertex.x = (x != NULL) ? *x : 0; + vertex.y = (y != NULL) ? *y : 0; + vertex.z = (z != NULL) ? *z : 0; + vertex.w = (w != NULL) ? *w : 0; cogl_push_matrix(); @@ -1778,16 +1765,16 @@ clutter_actor_transform_point (ClutterActor *actor, cogl_pop_matrix(); if (x) - *x = CLUTTER_UNITS_FROM_FLOAT (vertex.x); + *x = vertex.x; if (y) - *y = CLUTTER_UNITS_FROM_FLOAT (vertex.y); + *y = vertex.y; if (z) - *z = CLUTTER_UNITS_FROM_FLOAT (vertex.z); + *z = vertex.z; if (w) - *w = CLUTTER_UNITS_FROM_FLOAT (vertex.w); + *w = vertex.w; } /** @@ -1815,7 +1802,7 @@ clutter_actor_apply_relative_transform_to_point (ClutterActor *self, const ClutterVertex *point, ClutterVertex *vertex) { - ClutterUnit x, y, z, w; + gfloat x, y, z, w; full_vertex_t tmp; gfloat v[4]; @@ -1863,7 +1850,7 @@ clutter_actor_apply_transform_to_point (ClutterActor *self, ClutterVertex *vertex) { full_vertex_t tmp = { 0, }; - ClutterUnit x, y, z, w; + gfloat x, y, z, w; CoglMatrix matrix_p; gfloat v[4]; @@ -1909,8 +1896,8 @@ clutter_actor_transform_vertices_relative (ClutterActor *self, gfloat width, height; CoglMatrix mtx; - width = CLUTTER_UNITS_TO_FLOAT (priv->allocation.x2 - priv->allocation.x1); - height = CLUTTER_UNITS_TO_FLOAT (priv->allocation.y2 - priv->allocation.y1); + width = priv->allocation.x2 - priv->allocation.x1; + height = priv->allocation.y2 - priv->allocation.y1; cogl_push_matrix(); @@ -1943,8 +1930,8 @@ clutter_actor_transform_and_project_box (ClutterActor *self, gfloat width, height; full_vertex_t vertices[4]; - width = CLUTTER_UNITS_TO_FLOAT (box->x2 - box->x1); - height = CLUTTER_UNITS_TO_FLOAT (box->y2 - box->y1); + width = box->x2 - box->x1; + height = box->y2 - box->y1; /* We essentially have to dupe some code from clutter_redraw() here * to make sure GL Matrices etc are initialised if we're called and we @@ -1956,7 +1943,7 @@ clutter_actor_transform_and_project_box (ClutterActor *self, stage = clutter_actor_get_stage (self); /* FIXME: if were not yet added to a stage, its probably unsafe to - * return default - idealy the func should fail. + * return default - ideally the func should fail */ if (stage == NULL) stage = clutter_stage_get_default (); @@ -2037,7 +2024,7 @@ clutter_actor_get_allocation_vertices (ClutterActor *self, stage = clutter_actor_get_stage (self); /* FIXME: if were not yet added to a stage, its probably unsafe to - * return default - idealy the func should fail. + * return default - idealy the func should fail */ if (stage == NULL) stage = clutter_stage_get_default (); @@ -2117,7 +2104,7 @@ clutter_actor_get_abs_allocation_vertices (ClutterActor *self, ClutterActor *stage = clutter_actor_get_stage (self); /* FIXME: if were not yet added to a stage, its probably unsafe to - * return default - idealy the func should fail. + * return default - idealy the func should fail */ if (stage == NULL) stage = clutter_stage_get_default (); @@ -2143,9 +2130,9 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) gboolean is_stage = CLUTTER_IS_STAGE (self); if (!is_stage) - cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->allocation.x1), - CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1), - 0); + cogl_translate (priv->allocation.x1, + priv->allocation.y1, + 0); if (priv->z) cogl_translate (0, 0, priv->z); @@ -2157,29 +2144,33 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self) * entire object will move on the screen as a result of rotating it). */ if (priv->scale_x != 1.0 || priv->scale_y != 1.0) - TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->scale_center, - cogl_scale (priv->scale_x, - priv->scale_y, - 1.0)); + { + TRANSFORM_ABOUT_ANCHOR_COORD (self, + &priv->scale_center, + cogl_scale (priv->scale_x, + priv->scale_y, + 1.0)); + } if (priv->rzang) - TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->rz_center, - cogl_rotate (priv->rzang, - 0, 0, 1.0)); + TRANSFORM_ABOUT_ANCHOR_COORD (self, + &priv->rz_center, + cogl_rotate (priv->rzang, 0, 0, 1.0)); if (priv->ryang) - TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->ry_center, - cogl_rotate (priv->ryang, - 0, 1.0, 0)); + TRANSFORM_ABOUT_ANCHOR_COORD (self, + &priv->ry_center, + cogl_rotate (priv->ryang, 0, 1.0, 0)); if (priv->rxang) - TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->rx_center, - cogl_rotate (priv->rxang, - 1.0, 0, 0)); + TRANSFORM_ABOUT_ANCHOR_COORD (self, + &priv->rx_center, + cogl_rotate (priv->rxang, 1.0, 0, 0)); if (!is_stage && !clutter_anchor_coord_is_zero (&priv->anchor)) { - ClutterUnit x, y, z; + gfloat x, y, z; + clutter_anchor_coord_get_units (self, &priv->anchor, &x, &y, &z); cogl_translate (-x, -y, -z); } @@ -2211,7 +2202,7 @@ _clutter_actor_apply_modelview_transform_recursive (ClutterActor *self, stage = clutter_actor_get_stage (self); /* FIXME: if were not yet added to a stage, its probably unsafe to - * return default - idealy the func should fail. + * return default - idealy the func should fail */ if (stage == NULL) stage = clutter_stage_get_default (); @@ -2262,22 +2253,20 @@ clutter_actor_paint (ClutterActor *self) if (priv->has_clip) { - cogl_clip_push (CLUTTER_UNITS_TO_FLOAT (priv->clip[0]), - CLUTTER_UNITS_TO_FLOAT (priv->clip[1]), - CLUTTER_UNITS_TO_FLOAT (priv->clip[2]), - CLUTTER_UNITS_TO_FLOAT (priv->clip[3])); + cogl_clip_push (priv->clip[0], + priv->clip[1], + priv->clip[2], + priv->clip[3]); clip_set = TRUE; } else if (priv->clip_to_allocation) { - ClutterUnit width, height; + gfloat width, height; width = priv->allocation.x2 - priv->allocation.x1; height = priv->allocation.y2 - priv->allocation.y1; - cogl_clip_push (0, 0, - CLUTTER_UNITS_TO_FLOAT (width), - CLUTTER_UNITS_TO_FLOAT (height)); + cogl_clip_push (0, 0, width, height); clip_set = TRUE; } @@ -2379,10 +2368,10 @@ clutter_actor_set_property (GObject *object, clutter_actor_set_height (actor, g_value_get_int (value)); break; case PROP_FIXED_X: - clutter_actor_set_xu (actor, clutter_value_get_unit (value)); + clutter_actor_set_x (actor, clutter_value_get_unit (value)); break; case PROP_FIXED_Y: - clutter_actor_set_yu (actor, clutter_value_get_unit (value)); + clutter_actor_set_y (actor, clutter_value_get_unit (value)); break; case PROP_FIXED_POSITION_SET: clutter_actor_set_fixed_position_set (actor, g_value_get_boolean (value)); @@ -2441,30 +2430,34 @@ clutter_actor_set_property (GObject *object, break; case PROP_SCALE_CENTER_X: { - int center_x = g_value_get_int (value); - ClutterUnit center_y; + gint center_x = g_value_get_int (value); + gfloat center_y; clutter_anchor_coord_get_units (actor, &priv->scale_center, - NULL, ¢er_y, NULL); - clutter_actor_set_scale_fullu (actor, - priv->scale_x, - priv->scale_y, - CLUTTER_UNITS_FROM_DEVICE (center_x), - center_y); + NULL, + ¢er_y, + NULL); + clutter_actor_set_scale_full (actor, + priv->scale_x, + priv->scale_y, + center_x, + center_y); } break; case PROP_SCALE_CENTER_Y: { - ClutterUnit center_x; gint center_y = g_value_get_int (value); + gfloat center_x; clutter_anchor_coord_get_units (actor, &priv->scale_center, - ¢er_x, NULL, NULL); - clutter_actor_set_scale_fullu (actor, - priv->scale_x, - priv->scale_y, - center_x, - CLUTTER_UNITS_FROM_DEVICE (center_y)); + ¢er_x, + NULL, + NULL); + clutter_actor_set_scale_full (actor, + priv->scale_x, + priv->scale_y, + center_x, + center_y); } break; case PROP_SCALE_GRAVITY: @@ -2552,26 +2545,26 @@ clutter_actor_set_property (GObject *object, break; case PROP_ANCHOR_X: { - int anchor_x = g_value_get_int (value); - ClutterUnit anchor_y; + gint anchor_x = g_value_get_int (value); + gfloat anchor_y; clutter_anchor_coord_get_units (actor, &priv->anchor, - NULL, &anchor_y, NULL); - clutter_actor_set_anchor_pointu (actor, - CLUTTER_UNITS_FROM_DEVICE (anchor_x), - anchor_y); + NULL, + &anchor_y, + NULL); + clutter_actor_set_anchor_point (actor, anchor_x, anchor_y); } break; case PROP_ANCHOR_Y: { - ClutterUnit anchor_x; - int anchor_y = g_value_get_int (value); + gint anchor_y = g_value_get_int (value); + gfloat anchor_x; clutter_anchor_coord_get_units (actor, &priv->anchor, - &anchor_x, NULL, NULL); - clutter_actor_set_anchor_pointu (actor, - anchor_x, - CLUTTER_UNITS_FROM_DEVICE (anchor_y)); + &anchor_x, + NULL, + NULL); + clutter_actor_set_anchor_point (actor, anchor_x, anchor_y); } break; case PROP_ANCHOR_GRAVITY: @@ -2677,10 +2670,10 @@ clutter_actor_get_property (GObject *object, { ClutterGeometry clip = { 0, }; - clip.x = CLUTTER_UNITS_TO_DEVICE (priv->clip[0]); - clip.y = CLUTTER_UNITS_TO_DEVICE (priv->clip[1]); - clip.width = CLUTTER_UNITS_TO_DEVICE (priv->clip[2]); - clip.height = CLUTTER_UNITS_TO_DEVICE (priv->clip[3]); + clip.x = priv->clip[0]; + clip.y = priv->clip[1]; + clip.width = priv->clip[2]; + clip.height = priv->clip[3]; g_value_set_boxed (value, &clip); } @@ -2696,15 +2689,19 @@ clutter_actor_get_property (GObject *object, break; case PROP_SCALE_CENTER_X: { - gint center; + gfloat center; + clutter_actor_get_scale_center (actor, ¢er, NULL); + g_value_set_int (value, center); } break; case PROP_SCALE_CENTER_Y: { - gint center; + gfloat center; + clutter_actor_get_scale_center (actor, NULL, ¢er); + g_value_set_int (value, center); } break; @@ -2727,8 +2724,10 @@ clutter_actor_get_property (GObject *object, { ClutterVertex center; - clutter_actor_get_rotationu (actor, CLUTTER_X_AXIS, - ¢er.x, ¢er.y, ¢er.z); + clutter_actor_get_rotation (actor, CLUTTER_X_AXIS, + ¢er.x, + ¢er.y, + ¢er.z); g_value_set_boxed (value, ¢er); } @@ -2737,8 +2736,10 @@ clutter_actor_get_property (GObject *object, { ClutterVertex center; - clutter_actor_get_rotationu (actor, CLUTTER_Y_AXIS, - ¢er.x, ¢er.y, ¢er.z); + clutter_actor_get_rotation (actor, CLUTTER_Y_AXIS, + ¢er.x, + ¢er.y, + ¢er.z); g_value_set_boxed (value, ¢er); } @@ -2747,8 +2748,10 @@ clutter_actor_get_property (GObject *object, { ClutterVertex center; - clutter_actor_get_rotationu (actor, CLUTTER_Z_AXIS, - ¢er.x, ¢er.y, ¢er.z); + clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS, + ¢er.x, + ¢er.y, + ¢er.z); g_value_set_boxed (value, ¢er); } @@ -2758,18 +2761,24 @@ clutter_actor_get_property (GObject *object, break; case PROP_ANCHOR_X: { - ClutterUnit anchor_x; + gfloat anchor_x; + clutter_anchor_coord_get_units (actor, &priv->anchor, - &anchor_x, NULL, NULL); - g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (anchor_x)); + &anchor_x, + NULL, + NULL); + g_value_set_int (value, anchor_x); } break; case PROP_ANCHOR_Y: { - ClutterUnit anchor_y; + gfloat anchor_y; + clutter_anchor_coord_get_units (actor, &priv->anchor, - NULL, &anchor_y, NULL); - g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (anchor_y)); + NULL, + &anchor_y, + NULL); + g_value_set_int (value, anchor_y); } break; case PROP_ANCHOR_GRAVITY: @@ -2860,14 +2869,14 @@ clutter_actor_class_init (ClutterActorClass *klass) * position for the actor. If read, returns the fixed position if any, * otherwise the allocation if available, otherwise 0. */ - g_object_class_install_property (object_class, - PROP_X, - g_param_spec_int ("x", - "X coordinate", - "X coordinate of the actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("x", + "X coordinate", + "X coordinate of the actor", + -G_MAXINT, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_X, pspec); + /** * ClutterActor:y: * @@ -2875,14 +2884,14 @@ clutter_actor_class_init (ClutterActorClass *klass) * position for the actor. If read, returns the fixed position if * any, otherwise the allocation if available, otherwise 0. */ - g_object_class_install_property (object_class, - PROP_Y, - g_param_spec_int ("y", - "Y coordinate", - "Y coordinate of the actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("y", + "Y coordinate", + "Y coordinate of the actor", + -G_MAXINT, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_Y, pspec); + /** * ClutterActor:width: * @@ -2890,14 +2899,13 @@ clutter_actor_class_init (ClutterActorClass *klass) * natural size request of the actor to the given width. If read, returns * the allocated width if available, otherwise the width request. */ - g_object_class_install_property (object_class, - PROP_WIDTH, - g_param_spec_int ("width", - "Width", - "Width of the actor", - 0, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("width", + "Width", + "Width of the actor", + 0, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_WIDTH, pspec); /** * ClutterActor:height: * @@ -2905,217 +2913,230 @@ clutter_actor_class_init (ClutterActorClass *klass) * natural size request of the actor to the given height. If read, returns * the allocated height if available, otherwise the height request. */ + pspec = g_param_spec_int ("height", + "Height", + "Height of the actor", + 0, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_HEIGHT, pspec); + + /** + * ClutterActor:fixed-x: + * + * The fixed X position of the actor in pixels. + * + * Writing this property sets #ClutterActor:fixed-position-set + * property as well, as a side effect + * + * Since: 0.8 + */ + pspec = clutter_param_spec_unit ("fixed-x", + "Fixed X", + "Forced X position of the actor", + CLUTTER_MINUNIT, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_FIXED_X, pspec); + + /** + * ClutterActor:fixed-y: + * + * The fixed Y position of the actor in pixels. + * + * Writing this property sets the #ClutterActor:fixed-position-set + * property as well, as a side effect + * + * Since: 0.8 + */ + pspec = clutter_param_spec_unit ("fixed-y", + "Fixed Y", + "Forced Y position of the actor", + CLUTTER_MINUNIT, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_FIXED_Y, pspec); + + /** + * ClutterActor:fixed-position-set: + * + * This flag controls whether the #ClutterActor:fixed-x and + * #ClutterActor:fixed-y properties are used + * + * Since: 0.8 + */ + pspec = g_param_spec_boolean ("fixed-position-set", + "Fixed position set", + "Whether to use fixed positioning " + "for the actor", + FALSE, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, - PROP_HEIGHT, - g_param_spec_int ("height", - "Height", - "Height of the actor", - 0, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + PROP_FIXED_POSITION_SET, + pspec); /** - * ClutterActor:fixed-x + * ClutterActor:min-width: * - * The fixed X position of the actor in ClutterUnits. Writing this - * property sets the fixed-position-set property as well, as a side effect. + * A forced minimum width request for the actor, in pixels + * + * Writing this property sets the #ClutterActor:min-width-set property + * as well, as a side effect. + * + *This property overrides the usual width request of the actor. * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_FIXED_X, - clutter_param_spec_unit ("fixed-x", - "Fixed X", - "Forced X position of the actor", - CLUTTER_MINUNIT, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = clutter_param_spec_unit ("min-width", + "Min Width", + "Forced minimum width request " + "for the actor", + 0, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_MIN_WIDTH, pspec); /** - * ClutterActor:fixed-y + * ClutterActor:min-height: * - * The fixed Y position of the actor in ClutterUnits. Writing - * this property sets the fixed-position-set property as well, as a side - * effect. + * A forced minimum height request for the actor, in pixels + * + * Writing this property sets the #ClutterActor:min-height-set property + * as well, as a side effect. This property overrides the usual height + * request of the actor. * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_FIXED_Y, - clutter_param_spec_unit ("fixed-y", - "Fixed Y", - "Forced Y position of the actor", - CLUTTER_MINUNIT, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = clutter_param_spec_unit ("min-height", + "Min Height", + "Forced minimum height request " + "for the actor", + 0, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_MIN_HEIGHT, pspec); + /** - * ClutterActor:fixed-position-set + * ClutterActor:natural-width: * - * This flag controls whether the fixed-x and fixed-y properties are used. + * A forced natural width request for the actor, in pixels + * + * Writing this property sets the #ClutterActor:natural-width-set + * property as well, as a side effect. This property overrides the + * usual width request of the actor * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_FIXED_POSITION_SET, - g_param_spec_boolean ("fixed-position-set", - "Fixed position set", - "Whether to use fixed positioning for the actor", - FALSE, - CLUTTER_PARAM_READWRITE)); + pspec = clutter_param_spec_unit ("natural-width", + "Natural Width", + "Forced natural width request " + "for the actor", + 0, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_NATURAL_WIDTH, pspec); + /** - * ClutterActor:min-width + * ClutterActor:natural-height: * - * A forced minimum width request for the actor, in ClutterUnits. - * Writing this property sets the min-width-set property as well, as a side - * effect. This property overrides the usual width request of the actor. + * A forced natural height request for the actor, in pixels + * + * Writing this property sets the #ClutterActor:natural-height-set + * property as well, as a side effect. This property overrides the + * usual height request of the actor * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_MIN_WIDTH, - clutter_param_spec_unit ("min-width", - "Min Width", - "Forced minimum width request for the actor", - 0, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = clutter_param_spec_unit ("natural-height", + "Natural Height", + "Forced natural height request " + "for the actor", + 0, CLUTTER_MAXUNIT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_NATURAL_HEIGHT, pspec); + /** - * ClutterActor:min-height + * ClutterActor:min-width-set: * - * A forced minimum height request for the actor, in - * ClutterUnits. Writing this property sets the min-height-set - * property as well, as a side effect. This property overrides the usual - * height request of the actor. + * This flag controls whether the #ClutterActor:min-width property + * is used * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_MIN_HEIGHT, - clutter_param_spec_unit ("min-height", - "Min Height", - "Forced minimum height request for the actor", - 0, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("min-width-set", + "Minimum width set", + "Whether to use the min-width property", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_MIN_WIDTH_SET, pspec); + /** - * ClutterActor:natural-width + * ClutterActor:min-height-set: * - * A forced natural width request for the actor, in ClutterUnits. - * Writing this property sets the natural-width-set property as - * well, as a side effect. This property overrides the usual width request - * of the actor. + * This flag controls whether the #ClutterActor:min-height property + * is used * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_NATURAL_WIDTH, - clutter_param_spec_unit ("natural-width", - "Natural Width", - "Forced natural width request for the actor", - 0, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("min-height-set", + "Minimum height set", + "Whether to use the min-height property", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_MIN_HEIGHT_SET, pspec); + /** - * ClutterActor:natural-height + * ClutterActor:natural-width-set: * - * A forced natural height request for the actor, in ClutterUnits. - * Writing this property sets the natural-height-set property as well, as - * a side effect. This property overrides the usual height request - * of the actor. + * This flag controls whether the #ClutterActor:natural-width property + * is used * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_NATURAL_HEIGHT, - clutter_param_spec_unit ("natural-height", - "Natural Height", - "Forced natural height request for the actor", - 0, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("natural-width-set", + "Natural width set", + "Whether to use the natural-width property", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_NATURAL_WIDTH_SET, + pspec); + /** - * ClutterActor:min-width-set + * ClutterActor:natural-height-set: * - * This flag controls whether the min-width property is used. + * This flag controls whether the #ClutterActor:natural-height property + * is used * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_MIN_WIDTH_SET, - g_param_spec_boolean ("min-width-set", - "Minimum width set", - "Whether to use the min-width property", - FALSE, - CLUTTER_PARAM_READWRITE)); - /** - * ClutterActor:min-height-set - * - * This flag controls whether the min-height property is used. - * - * Since: 0.8 - */ - g_object_class_install_property - (object_class, - PROP_MIN_HEIGHT_SET, - g_param_spec_boolean ("min-height-set", - "Minimum height set", - "Whether to use the min-height property", - FALSE, - CLUTTER_PARAM_READWRITE)); - /** - * ClutterActor:natural-width-set - * - * This flag controls whether the natural-width property is used. - * - * Since: 0.8 - */ - g_object_class_install_property - (object_class, - PROP_NATURAL_WIDTH_SET, - g_param_spec_boolean ("natural-width-set", - "Natural width set", - "Whether to use the natural-width property", - FALSE, - CLUTTER_PARAM_READWRITE)); - /** - * ClutterActor:natural-height-set - * - * This flag controls whether the natural-height property is used. - * - * Since: 0.8 - */ - g_object_class_install_property - (object_class, - PROP_NATURAL_HEIGHT_SET, - g_param_spec_boolean ("natural-height-set", - "Natural height set", - "Whether to use the natural-height property", - FALSE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("natural-height-set", + "Natural height set", + "Whether to use the natural-height property", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_NATURAL_HEIGHT_SET, + pspec); + /** * ClutterActor:allocation: * - * The allocation for the actor, in ClutterUnits. This is - * read-only, but you might monitor this property to know when an - * actor moves or resizes. + * The allocation for the actor, in pixels + * + * This is property is read-only, but you might monitor it to know when an + * actor moves or resizes * * Since: 0.8 */ - g_object_class_install_property (object_class, - PROP_ALLOCATION, - g_param_spec_boxed ("allocation", - "Allocation", - "The actor's allocation", - CLUTTER_TYPE_ACTOR_BOX, - CLUTTER_PARAM_READABLE)); + pspec = g_param_spec_boxed ("allocation", + "Allocation", + "The actor's allocation", + CLUTTER_TYPE_ACTOR_BOX, + CLUTTER_PARAM_READABLE); + g_object_class_install_property (object_class, PROP_ALLOCATION, pspec); + /** * ClutterActor:request-mode: * @@ -3133,8 +3154,8 @@ clutter_actor_class_init (ClutterActorClass *klass) * * |[ * ClutterRequestMode mode; - * ClutterUnit natural_width, min_width; - * ClutterUnit natural_height, min_height; + * gfloat natural_width, min_width; + * gfloat natural_height, min_height; * * g_object_get (G_OBJECT (child), "request-mode", &mode, NULL); * if (mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH) @@ -3165,14 +3186,13 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - g_object_class_install_property (object_class, - PROP_REQUEST_MODE, - g_param_spec_enum ("request-mode", - "Request Mode", - "The actor's request mode", - CLUTTER_TYPE_REQUEST_MODE, - CLUTTER_REQUEST_HEIGHT_FOR_WIDTH, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_enum ("request-mode", + "Request Mode", + "The actor's request mode", + CLUTTER_TYPE_REQUEST_MODE, + CLUTTER_REQUEST_HEIGHT_FOR_WIDTH, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_REQUEST_MODE, pspec); /** * ClutterActor:depth: @@ -3181,44 +3201,47 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property (object_class, - PROP_DEPTH, - g_param_spec_int ("depth", - "Depth", - "Depth of actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("depth", + "Depth", + "Depth of actor", + -G_MAXINT, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_DEPTH, pspec); + /** * ClutterActor:opacity: * - * Opacity of the actor. + * Opacity of the actor, between 0 (fully transparent) and + * 255 (fully opaque) */ - g_object_class_install_property (object_class, - PROP_OPACITY, - g_param_spec_uchar ("opacity", - "Opacity", - "Opacity of actor", - 0, 0xff, - 0xff, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_uchar ("opacity", + "Opacity", + "Opacity of actor", + 0, 0xff, + 0xff, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_OPACITY, pspec); + /** * ClutterActor:visible: * - * Whether the actor is visible or not. + * Whether the actor is set to be visible or not + * + * See also #ClutterActor:mapped */ - g_object_class_install_property (object_class, - PROP_VISIBLE, - g_param_spec_boolean ("visible", - "Visible", - "Whether the actor is visible or not", - FALSE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("visible", + "Visible", + "Whether the actor is visible or not", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_VISIBLE, pspec); /** * ClutterActor:mapped: * - * Whether the actor is mapped (will be painted when stage is mapped) + * Whether the actor is mapped (will be painted when the stage + * to which it belongs is mapped) * * Since: 1.0 */ @@ -3246,60 +3269,60 @@ clutter_actor_class_init (ClutterActorClass *klass) /** * ClutterActor:reactive: * - * Whether the actor is reactive to events or not. + * Whether the actor is reactive to events or not + * + * Only reactive actors will emit event-related signals * * Since: 0.6 */ - g_object_class_install_property (object_class, - PROP_REACTIVE, - g_param_spec_boolean ("reactive", - "Reactive", - "Whether the actor " - "is reactive to " - "events or not", - FALSE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("reactive", + "Reactive", + "Whether the actor is reactive to events", + FALSE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_REACTIVE, pspec); + /** * ClutterActor:has-clip: * - * Whether the actor has the clip property set or not. + * Whether the actor has the #ClutterActor:clip property set or not */ - g_object_class_install_property (object_class, - PROP_HAS_CLIP, - g_param_spec_boolean ("has-clip", - "Has Clip", - "Whether the actor " - "has a clip set or " - "not", - FALSE, - CLUTTER_PARAM_READABLE)); + pspec = g_param_spec_boolean ("has-clip", + "Has Clip", + "Whether the actor has a clip set", + FALSE, + CLUTTER_PARAM_READABLE); + g_object_class_install_property (object_class, PROP_HAS_CLIP, pspec); + /** * ClutterActor:clip: * - * The clip region for the actor. + * The clip region for the actor, in actor-relative coordinates + * + * Every part of the actor outside the clip region will not be + * painted */ - g_object_class_install_property (object_class, - PROP_CLIP, - g_param_spec_boxed ("clip", - "Clip", - "The clip region for " - "the actor", - CLUTTER_TYPE_GEOMETRY, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boxed ("clip", + "Clip", + "The clip region for the actor", + CLUTTER_TYPE_GEOMETRY, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_CLIP, pspec); + /** * ClutterActor:name: * - * The name of the actor. + * The name of the actor * * Since: 0.2 */ - g_object_class_install_property (object_class, - PROP_NAME, - g_param_spec_string ("name", - "Name", - "Name of the actor", - NULL, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_string ("name", + "Name", + "Name of the actor", + NULL, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_NAME, pspec); + /** * ClutterActor:scale-x: * @@ -3307,16 +3330,14 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_SCALE_X, - g_param_spec_double ("scale-x", - "Scale-X", - "Scale factor on the X axis", - 0.0, - G_MAXDOUBLE, - 1.0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_double ("scale-x", + "Scale X", + "Scale factor on the X axis", + 0.0, G_MAXDOUBLE, + 1.0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_SCALE_X, pspec); + /** * ClutterActor:scale-y: * @@ -3324,16 +3345,13 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_SCALE_Y, - g_param_spec_double ("scale-y", - "Scale-Y", - "Scale factor on the Y axis", - 0.0, - G_MAXDOUBLE, - 1.0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_double ("scale-y", + "Scale Y", + "Scale factor on the Y axis", + 0.0, G_MAXDOUBLE, + 1.0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_SCALE_Y, pspec); /** * ClutterActor:scale-center-x: @@ -3377,59 +3395,54 @@ clutter_actor_class_init (ClutterActorClass *klass) CLUTTER_GRAVITY_NONE, CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, - PROP_SCALE_GRAVITY, pspec); + PROP_SCALE_GRAVITY, + pspec); /** * ClutterActor:rotation-angle-x: * - * The rotation angle on the X axis. + * The rotation angle on the X axis * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_ANGLE_X, - g_param_spec_double ("rotation-angle-x", - "Rotation Angle X", - "The rotation angle on the X axis", - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_double ("rotation-angle-x", + "Rotation Angle X", + "The rotation angle on the X axis", + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ROTATION_ANGLE_X, pspec); + /** * ClutterActor:rotation-angle-y: * - * The rotation angle on the Y axis. + * The rotation angle on the Y axis * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_ANGLE_Y, - g_param_spec_double ("rotation-angle-y", - "Rotation Angle Y", - "The rotation angle on the Y axis", - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_double ("rotation-angle-y", + "Rotation Angle Y", + "The rotation angle on the Y axis", + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ROTATION_ANGLE_Y, pspec); + /** * ClutterActor:rotation-angle-z: * - * The rotation angle on the Z axis. + * The rotation angle on the Z axis * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_ANGLE_Z, - g_param_spec_double ("rotation-angle-z", - "Rotation Angle Z", - "The rotation angle on the Z axis", - -G_MAXDOUBLE, - G_MAXDOUBLE, - 0.0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_double ("rotation-angle-z", + "Rotation Angle Z", + "The rotation angle on the Z axis", + -G_MAXDOUBLE, G_MAXDOUBLE, + 0.0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ROTATION_ANGLE_Z, pspec); + /** * ClutterActor:rotation-center-x: * @@ -3437,14 +3450,15 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_CENTER_X, - g_param_spec_boxed ("rotation-center-x", - "Rotation Center X", - "The rotation center on the X axis", - CLUTTER_TYPE_VERTEX, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boxed ("rotation-center-x", + "Rotation Center X", + "The rotation center on the X axis", + CLUTTER_TYPE_VERTEX, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_ROTATION_CENTER_X, + pspec); + /** * ClutterActor:rotation-center-y: * @@ -3452,14 +3466,15 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_CENTER_Y, - g_param_spec_boxed ("rotation-center-y", - "Rotation Center Y", - "The rotation center on the Y axis", - CLUTTER_TYPE_VERTEX, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boxed ("rotation-center-y", + "Rotation Center Y", + "The rotation center on the Y axis", + CLUTTER_TYPE_VERTEX, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_ROTATION_CENTER_Y, + pspec); + /** * ClutterActor:rotation-center-z: * @@ -3467,14 +3482,14 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.6 */ - g_object_class_install_property - (object_class, - PROP_ROTATION_CENTER_Z, - g_param_spec_boxed ("rotation-center-z", - "Rotation Center Z", - "The rotation center on the Z axis", - CLUTTER_TYPE_VERTEX, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boxed ("rotation-center-z", + "Rotation Center Z", + "The rotation center on the Z axis", + CLUTTER_TYPE_VERTEX, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_ROTATION_CENTER_Z, + pspec); /** * ClutterActor:rotation-center-z-gravity: @@ -3497,41 +3512,38 @@ clutter_actor_class_init (ClutterActorClass *klass) * ClutterActor:anchor-x: * * The X coordinate of an actor's anchor point, relative to - * the actor coordinate space, in pixels. + * the actor coordinate space, in pixels * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_ANCHOR_X, - g_param_spec_int ("anchor-x", - "Anchor X", - "X coordinate of the anchor point", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("anchor-x", + "Anchor X", + "X coordinate of the anchor point", + -G_MAXINT, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ANCHOR_X, pspec); + /** * ClutterActor:anchor-y: * * The Y coordinate of an actor's anchor point, relative to - * the actor coordinate space, in pixels. + * the actor coordinate space, in pixels * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_ANCHOR_Y, - g_param_spec_int ("anchor-y", - "Anchor Y", - "Y coordinate of the anchor point", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_int ("anchor-y", + "Anchor Y", + "Y coordinate of the anchor point", + -G_MAXINT, G_MAXINT, + 0, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, PROP_ANCHOR_Y, pspec); /** * ClutterActor:anchor-gravity: * - * The anchor point expressed as a #ClutterGravity. + * The anchor point expressed as a #ClutterGravity * * Since: 1.0 */ @@ -3554,15 +3566,14 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - g_object_class_install_property - (object_class, - PROP_SHOW_ON_SET_PARENT, - g_param_spec_boolean ("show-on-set-parent", - "Show on set parent", - "Whether the actor is shown" - " when parented", - TRUE, - CLUTTER_PARAM_READWRITE)); + pspec = g_param_spec_boolean ("show-on-set-parent", + "Show on set parent", + "Whether the actor is shown when parented", + TRUE, + CLUTTER_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_SHOW_ON_SET_PARENT, + pspec); /** * ClutterActor:clip-to-allocation: @@ -3596,7 +3607,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.2 */ actor_signals[DESTROY] = - g_signal_new ("destroy", + g_signal_new (I_("destroy"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, G_STRUCT_OFFSET (ClutterActorClass, destroy), @@ -3613,7 +3624,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.2 */ actor_signals[SHOW] = - g_signal_new ("show", + g_signal_new (I_("show"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (ClutterActorClass, show), @@ -3630,7 +3641,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.2 */ actor_signals[HIDE] = - g_signal_new ("hide", + g_signal_new (I_("hide"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (ClutterActorClass, hide), @@ -3647,7 +3658,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.2 */ actor_signals[PARENT_SET] = - g_signal_new ("parent-set", + g_signal_new (I_("parent-set"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, parent_set), @@ -3732,7 +3743,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[EVENT] = - g_signal_new ("event", + g_signal_new (I_("event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, event), @@ -3754,7 +3765,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[BUTTON_PRESS_EVENT] = - g_signal_new ("button-press-event", + g_signal_new (I_("button-press-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, button_press_event), @@ -3776,7 +3787,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[BUTTON_RELEASE_EVENT] = - g_signal_new ("button-release-event", + g_signal_new (I_("button-release-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, button_release_event), @@ -3798,7 +3809,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[SCROLL_EVENT] = - g_signal_new ("scroll-event", + g_signal_new (I_("scroll-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, scroll_event), @@ -3820,7 +3831,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[KEY_PRESS_EVENT] = - g_signal_new ("key-press-event", + g_signal_new (I_("key-press-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, key_press_event), @@ -3843,7 +3854,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[KEY_RELEASE_EVENT] = - g_signal_new ("key-release-event", + g_signal_new (I_("key-release-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, key_release_event), @@ -3865,7 +3876,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[MOTION_EVENT] = - g_signal_new ("motion-event", + g_signal_new (I_("motion-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, motion_event), @@ -3883,7 +3894,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[FOCUS_IN] = - g_signal_new ("focus-in", + g_signal_new (I_("focus-in"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, focus_in), @@ -3900,7 +3911,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[FOCUS_OUT] = - g_signal_new ("focus-out", + g_signal_new (I_("focus-out"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, focus_out), @@ -3921,7 +3932,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[ENTER_EVENT] = - g_signal_new ("enter-event", + g_signal_new (I_("enter-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, enter_event), @@ -3943,7 +3954,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[LEAVE_EVENT] = - g_signal_new ("leave-event", + g_signal_new (I_("leave-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, leave_event), @@ -3971,7 +3982,7 @@ clutter_actor_class_init (ClutterActorClass *klass) * Since: 0.6 */ actor_signals[CAPTURED_EVENT] = - g_signal_new ("captured-event", + g_signal_new (I_("captured-event"), G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ClutterActorClass, captured_event), @@ -4126,7 +4137,7 @@ clutter_actor_init (ClutterActor *self) priv->opacity_parent = NULL; priv->enable_model_view_transform = TRUE; - memset (priv->clip, 0, sizeof (ClutterUnit) * 4); + memset (priv->clip, 0, sizeof (gfloat) * 4); } /** @@ -4248,15 +4259,15 @@ clutter_actor_queue_relayout (ClutterActor *self) */ void clutter_actor_get_preferred_size (ClutterActor *self, - ClutterUnit *min_width_p, - ClutterUnit *min_height_p, - ClutterUnit *natural_width_p, - ClutterUnit *natural_height_p) + gfloat *min_width_p, + gfloat *min_height_p, + gfloat *natural_width_p, + gfloat *natural_height_p) { ClutterActorPrivate *priv; - ClutterUnit for_width, for_height; - ClutterUnit min_width, min_height; - ClutterUnit natural_width, natural_height; + gfloat for_width, for_height; + gfloat min_width, min_height; + gfloat natural_width, natural_height; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -4324,9 +4335,9 @@ clutter_actor_get_preferred_size (ClutterActor *self, */ void clutter_actor_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterActorClass *klass; ClutterActorPrivate *priv; @@ -4339,14 +4350,11 @@ clutter_actor_get_preferred_width (ClutterActor *self, if (priv->needs_width_request || priv->request_width_for_height != for_height) { - ClutterUnit min_width, natural_width; + gfloat min_width, natural_width; min_width = natural_width = 0; - CLUTTER_NOTE (LAYOUT, - "Width request for %" CLUTTER_UNITS_FORMAT " (%d px)", - for_height, - CLUTTER_UNITS_TO_DEVICE (for_height)); + CLUTTER_NOTE (LAYOUT, "Width request for %.2f px", for_height); klass->get_preferred_width (self, for_height, &min_width, @@ -4355,11 +4363,10 @@ clutter_actor_get_preferred_width (ClutterActor *self, if (natural_width < min_width - FLOAT_EPSILON) { g_warning ("Actor of type %s reported a natural width " - "of %" CLUTTER_UNITS_FORMAT " (%d px) lower " - "than min width %" CLUTTER_UNITS_FORMAT " (%d px)", + "of %.2f px lower than min width %.2f px", G_OBJECT_TYPE_NAME (self), - natural_width, CLUTTER_UNITS_TO_DEVICE (natural_width), - min_width, CLUTTER_UNITS_TO_DEVICE (min_width)); + natural_width, + min_width); } if (!priv->min_width_set) @@ -4400,9 +4407,9 @@ clutter_actor_get_preferred_width (ClutterActor *self, */ void clutter_actor_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterActorClass *klass; ClutterActorPrivate *priv; @@ -4415,14 +4422,11 @@ clutter_actor_get_preferred_height (ClutterActor *self, if (priv->needs_height_request || priv->request_height_for_width != for_width) { - ClutterUnit min_height, natural_height; + gfloat min_height, natural_height; min_height = natural_height = 0; - CLUTTER_NOTE (LAYOUT, - "Width request for %" CLUTTER_UNITS_FORMAT " (%d px)", - for_width, - CLUTTER_UNITS_TO_DEVICE (for_width)); + CLUTTER_NOTE (LAYOUT, "Width request for %.2f px", for_width); klass->get_preferred_height (self, for_width, &min_height, @@ -4431,11 +4435,10 @@ clutter_actor_get_preferred_height (ClutterActor *self, if (natural_height < min_height - FLOAT_EPSILON) { g_warning ("Actor of type %s reported a natural height " - "of %" CLUTTER_UNITS_FORMAT " (%d px) lower than " - "min height %" CLUTTER_UNITS_FORMAT " (%d px)", + "of %.2f px lower than min height %.2f px", G_OBJECT_TYPE_NAME (self), - natural_height, CLUTTER_UNITS_TO_DEVICE (natural_height), - min_height, CLUTTER_UNITS_TO_DEVICE (min_height)); + natural_height, + min_height); } if (!priv->min_height_set) @@ -4488,16 +4491,16 @@ clutter_actor_get_allocation_coords (ClutterActor *self, clutter_actor_get_allocation_box (self, &allocation); if (x_1) - *x_1 = CLUTTER_UNITS_TO_DEVICE (allocation.x1); + *x_1 = allocation.x1; if (y_1) - *y_1 = CLUTTER_UNITS_TO_DEVICE (allocation.y1); + *y_1 = allocation.y1; if (x_2) - *x_2 = CLUTTER_UNITS_TO_DEVICE (allocation.x2); + *x_2 = allocation.x2; if (y_2) - *y_2 = CLUTTER_UNITS_TO_DEVICE (allocation.y2); + *y_2 = allocation.y2; } /** @@ -4686,10 +4689,18 @@ void clutter_actor_get_geometry (ClutterActor *self, ClutterGeometry *geometry) { - g_return_if_fail (CLUTTER_IS_ACTOR (self)); + gfloat x, y, width, height; - clutter_actor_get_position (self, &geometry->x, &geometry->y); - clutter_actor_get_size (self, &geometry->width, &geometry->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; } /** @@ -4706,8 +4717,8 @@ clutter_actor_get_geometry (ClutterActor *self, */ void clutter_actor_set_position (ClutterActor *self, - gint x, - gint y) + gfloat x, + gfloat y) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -4719,35 +4730,6 @@ clutter_actor_set_position (ClutterActor *self, g_object_thaw_notify (G_OBJECT (self)); } -/** - * clutter_actor_set_positionu - * @self: A #ClutterActor - * @x: New left position of actor in #ClutterUnits - * @y: New top position of actor in #ClutterUnits - * - * Sets the actor's position in #ClutterUnits relative to any - * parent actor. - * - * If a layout manager is in use, this position will override the - * layout manager and force a fixed position. - * - * Since: 0.6 - */ -void -clutter_actor_set_positionu (ClutterActor *self, - ClutterUnit x, - ClutterUnit y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - g_object_freeze_notify (G_OBJECT (self)); - - clutter_actor_set_xu (self, x); - clutter_actor_set_yu (self, y); - - g_object_thaw_notify (G_OBJECT (self)); -} - /** * clutter_actor_get_fixed_position_set: * @self: A #ClutterActor @@ -4788,6 +4770,7 @@ clutter_actor_set_fixed_position_set (ClutterActor *self, self->priv->position_set = is_set != FALSE; g_object_notify (G_OBJECT (self), "fixed-position-set"); + clutter_actor_queue_relayout (self); } @@ -4798,57 +4781,35 @@ clutter_actor_set_fixed_position_set (ClutterActor *self, * @dy: Distance to move Actor on Y axis. * * Moves an actor by the specified distance relative to its current - * position in pixels. This function modifies the fixed position of an - * actor and thus removes it from any layout management. Another way - * to move an actor is with an anchor point, see - * clutter_actor_set_anchor_point(). + * position in pixels. + * + * This function modifies the fixed position of an actor and thus removes + * it from any layout management. Another way to move an actor is with an + * anchor point, see clutter_actor_set_anchor_point(). * * Since: 0.2 */ void clutter_actor_move_by (ClutterActor *self, - gint dx, - gint dy) + gfloat dx, + gfloat dy) { - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_move_byu (self, - CLUTTER_UNITS_FROM_DEVICE (dx), - CLUTTER_UNITS_FROM_DEVICE (dy)); -} - -/** - * clutter_actor_move_byu: - * @self: A #ClutterActor - * @dx: Distance to move Actor on X axis, in #ClutterUnits. - * @dy: Distance to move Actor on Y axis, in #ClutterUnits. - * - * Moves an actor by the specified distance relative to its current - * position. - * - * The move is accomplished by setting a fixed position, overriding - * any layout manager, see clutter_actor_set_positionu(). - * - * Since: 0.6 - */ -void -clutter_actor_move_byu (ClutterActor *self, - ClutterUnit dx, - ClutterUnit dy) -{ - ClutterUnit x, y; + ClutterActorPrivate *priv; + gfloat x, y; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - x = self->priv->fixed_x; - y = self->priv->fixed_y; + priv = self->priv; - clutter_actor_set_positionu (self, x + dx, y + dy); + x = priv->fixed_x; + y = priv->fixed_y; + + clutter_actor_set_position (self, x + dx, y + dy); } static void clutter_actor_set_min_width (ClutterActor *self, - ClutterUnit min_width) + gfloat min_width) { ClutterActorPrivate *priv = self->priv; ClutterActorBox old = { 0, }; @@ -4882,7 +4843,7 @@ clutter_actor_set_min_width (ClutterActor *self, static void clutter_actor_set_min_height (ClutterActor *self, - ClutterUnit min_height) + gfloat min_height) { ClutterActorPrivate *priv = self->priv; @@ -4917,7 +4878,7 @@ clutter_actor_set_min_height (ClutterActor *self, static void clutter_actor_set_natural_width (ClutterActor *self, - ClutterUnit natural_width) + gfloat natural_width) { ClutterActorPrivate *priv = self->priv; ClutterActorBox old = { 0, }; @@ -4952,7 +4913,7 @@ clutter_actor_set_natural_width (ClutterActor *self, static void clutter_actor_set_natural_height (ClutterActor *self, - ClutterUnit natural_height) + gfloat natural_height) { ClutterActorPrivate *priv = self->priv; ClutterActorBox old = { 0, }; @@ -5103,34 +5064,8 @@ clutter_actor_set_request_mode (ClutterActor *self, */ void clutter_actor_set_size (ClutterActor *self, - gint width, - gint height) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_sizeu (self, - CLUTTER_UNITS_FROM_DEVICE (width), - CLUTTER_UNITS_FROM_DEVICE (height)); -} - -/** - * clutter_actor_set_sizeu - * @self: A #ClutterActor - * @width: New width of actor in #ClutterUnits, or -1 - * @height: New height of actor in #ClutterUnits, or -1 - * - * Overrides the actor's size request in #ClutterUnits. If @width - * and/or @height are -1 the actor will use its normal size request (the - * override is removed). - * - * This function sets or unsets both the minimum and natural size. - * - * Since: 0.6 - */ -void -clutter_actor_set_sizeu (ClutterActor *self, - ClutterUnit width, - ClutterUnit height) + gfloat width, + gfloat height) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -5181,8 +5116,8 @@ clutter_actor_set_sizeu (ClutterActor *self, */ void clutter_actor_get_size (ClutterActor *self, - guint *width, - guint *height) + gfloat *width, + gfloat *height) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -5193,38 +5128,6 @@ clutter_actor_get_size (ClutterActor *self, *height = clutter_actor_get_height (self); } -/** - * clutter_actor_get_sizeu: - * @self: A #ClutterActor - * @width: return location for the width, or %NULL - * @height: return location for the height, or %NULL - * - * This function tries to "do what you mean" and return - * the size an actor will have. If the actor has a valid - * allocation, the allocation will be returned; otherwise, - * the actors natural size request will be returned. - * - * If you care whether you get the request vs. the allocation, you - * should probably call a different function like - * clutter_actor_get_allocation_coords() or - * clutter_actor_get_preferred_width(). - * - * Since: 0.6 - */ -void -clutter_actor_get_sizeu (ClutterActor *self, - ClutterUnit *width, - ClutterUnit *height) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - if (width) - *width = clutter_actor_get_widthu (self); - - if (height) - *height = clutter_actor_get_heightu (self); -} - /** * clutter_actor_get_position: * @self: a #ClutterActor @@ -5243,8 +5146,8 @@ clutter_actor_get_sizeu (ClutterActor *self, */ void clutter_actor_get_position (ClutterActor *self, - gint *x, - gint *y) + gfloat *x, + gfloat *y) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -5256,99 +5159,41 @@ clutter_actor_get_position (ClutterActor *self, } /** - * clutter_actor_get_positionu: - * @self: a #ClutterActor - * @x: (out): return location for the X coordinate, or %NULL - * @y: (out): return location for the Y coordinate, or %NULL - * - * This function tries to "do what you mean" and tell you where the - * actor is, prior to any transformations. Retrieves the fixed - * position of an actor in pixels, if one has been set; otherwise, if - * the allocation is valid, returns the actor's allocated position; - * otherwise, returns 0,0. - * - * The returned position is in #ClutterUnits. - * - * Since: 0.6 - */ -void -clutter_actor_get_positionu (ClutterActor *self, - ClutterUnit *x, - ClutterUnit *y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - if (x) - *x = clutter_actor_get_xu (self); - - if (y) - *y = clutter_actor_get_yu (self); -} - -/** - * clutter_actor_get_transformed_positionu - * @self: A #ClutterActor - * @x: return location for the X coordinate, or %NULL - * @y: return location for the Y coordinate, or %NULL - * - * Gets the absolute position of an actor, in #ClutterUnits, - * relative to the stage. - * - * Since: 0.8 - */ -void -clutter_actor_get_transformed_positionu (ClutterActor *self, - ClutterUnit *x, - ClutterUnit *y) -{ - ClutterVertex v1 = { 0, }; - ClutterVertex v2 = { 0, }; - - clutter_actor_apply_transform_to_point (self, &v1, &v2); - - if (x) - *x = v2.x; - if (y) - *y = v2.y; -} - -/** - * clutter_actor_get_transformed_position + * clutter_actor_get_transformed_position: * @self: A #ClutterActor * @x: (out): return location for the X coordinate, or %NULL * @y: (out): return location for the Y coordinate, or %NULL * - * Gets the absolute position of an actor, in pixels, relative - * to the stage. + * Gets the absolute position of an actor, in pixels relative to the stage. * * Since: 0.8 */ void clutter_actor_get_transformed_position (ClutterActor *self, - gint *x, - gint *y) + gfloat *x, + gfloat *y) { - ClutterUnit xu, yu; + ClutterVertex v1; + ClutterVertex v2; - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - xu = yu = 0; - clutter_actor_get_transformed_positionu (self, &xu, &yu); + v1.x = v1.y = 0; + clutter_actor_apply_transform_to_point (self, &v1, &v2); if (x) - *x = CLUTTER_UNITS_TO_DEVICE (xu); + *x = v2.x; + if (y) - *y = CLUTTER_UNITS_TO_DEVICE (yu); + *y = v2.y; } /** - * clutter_actor_get_transformed_sizeu: + * clutter_actor_get_transformed_size: * @self: A #ClutterActor * @width: (out): return location for the width, or %NULL * @height: (out): return location for the height, or %NULL * - * Gets the absolute size of an actor in #ClutterUnitss, taking - * into account the scaling factors. + * Gets the absolute size of an actor in pixels, taking into account the + * scaling factors. * * If the actor has a valid allocation, the allocated size will be used. * If the actor has not a valid allocation then the preferred size will @@ -5370,9 +5215,9 @@ clutter_actor_get_transformed_position (ClutterActor *self, * Since: 0.8 */ void -clutter_actor_get_transformed_sizeu (ClutterActor *self, - ClutterUnit *width, - ClutterUnit *height) +clutter_actor_get_transformed_size (ClutterActor *self, + gfloat *width, + gfloat *height) { ClutterActorPrivate *priv; ClutterVertex v[4]; @@ -5388,11 +5233,11 @@ clutter_actor_get_transformed_sizeu (ClutterActor *self, */ if (priv->needs_allocation) { - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; ClutterActorBox box; /* make a fake allocation to transform */ - clutter_actor_get_positionu (self, &box.x1, &box.y1); + clutter_actor_get_position (self, &box.x1, &box.y1); natural_width = natural_height = 0; clutter_actor_get_preferred_size (self, NULL, NULL, @@ -5433,38 +5278,7 @@ clutter_actor_get_transformed_sizeu (ClutterActor *self, } /** - * clutter_actor_get_transformed_size: - * @self: A #ClutterActor - * @width: (out): return location for the width, or %NULL - * @height: (out): return location for the height, or %NULL - * - * Gets the absolute size of an actor taking into account - * any scaling factors - * - * Since: 0.8 - */ -void -clutter_actor_get_transformed_size (ClutterActor *self, - guint *width, - guint *height) -{ - ClutterUnit wu, hu; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - wu = hu = 0; - clutter_actor_get_transformed_sizeu (self, &wu, &hu); - - if (width) - *width = CLUTTER_UNITS_TO_DEVICE (wu); - - if (height) - *height = CLUTTER_UNITS_TO_DEVICE (hu); -} - - -/** - * clutter_actor_get_width + * clutter_actor_get_width: * @self: A #ClutterActor * * Retrieves the width of a #ClutterActor. @@ -5488,55 +5302,24 @@ clutter_actor_get_transformed_size (ClutterActor *self, * * Return value: the width of the actor, in pixels */ -guint +gfloat clutter_actor_get_width (ClutterActor *self) { + ClutterActorPrivate *priv; + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return CLUTTER_UNITS_TO_DEVICE (clutter_actor_get_widthu (self)); -} + priv = self->priv; -/** - * clutter_actor_get_widthu - * @self: A #ClutterActor - * - * Retrieves the width of a #ClutterActor, in #ClutterUnits. - * - * If the actor has a valid allocation, this function will return the - * width of the allocated area given to the actor. - * - * If the actor does not have a valid allocation, this function will - * return the actor's natural width, that is the preferred width of - * the actor. - * - * If you care whether you get the preferred width or the width that - * has been assigned to the actor, you should probably call a different - * function like clutter_actor_get_allocation_coords() to retrieve the - * allocated size or clutter_actor_get_preferred_width() to retrieve the - * preferred width. - * - * If an actor has a fixed width, for instance a width that has been - * assigned using clutter_actor_set_width(), the width returned will - * be the same value. - * - * Return value: the width of the actor, in #ClutterUnits - * - * since: 0.6 - */ -ClutterUnit -clutter_actor_get_widthu (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - - if (self->priv->needs_allocation) + if (priv->needs_allocation) { - ClutterUnit natural_width = 0; + gfloat natural_width = 0; if (self->priv->request_mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH) clutter_actor_get_preferred_width (self, -1, NULL, &natural_width); else { - ClutterUnit natural_height = 0; + gfloat natural_height = 0; clutter_actor_get_preferred_height (self, -1, NULL, &natural_height); clutter_actor_get_preferred_width (self, natural_height, @@ -5547,11 +5330,11 @@ clutter_actor_get_widthu (ClutterActor *self) return natural_width; } else - return self->priv->allocation.x2 - self->priv->allocation.x1; + return priv->allocation.x2 - priv->allocation.x1; } /** - * clutter_actor_get_height + * clutter_actor_get_height: * @self: A #ClutterActor * * Retrieves the height of a #ClutterActor. @@ -5575,53 +5358,22 @@ clutter_actor_get_widthu (ClutterActor *self) * * Return value: the height of the actor, in pixels */ -guint +gfloat clutter_actor_get_height (ClutterActor *self) { + ClutterActorPrivate *priv; + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return CLUTTER_UNITS_TO_DEVICE (clutter_actor_get_heightu (self)); -} + priv = self->priv; -/** - * clutter_actor_get_heightu - * @self: A #ClutterActor - * - * Retrieves the height of a #ClutterActor, in #ClutterUnits. - * - * If the actor has a valid allocation, this function will return the - * height of the allocated area given to the actor. - * - * If the actor does not have a valid allocation, this function will - * return the actor's natural height, that is the preferred height of - * the actor. - * - * If you care whether you get the preferred height or the height that - * has been assigned to the actor, you should probably call a different - * function like clutter_actor_get_allocation_coords() to retrieve the - * allocated size or clutter_actor_get_preferred_height() to retrieve the - * preferred height. - * - * If an actor has a fixed height, for instance a height that has been - * assigned using clutter_actor_set_height(), the height returned will - * be the same value. - * - * Return value: the height of the actor, in #ClutterUnits - * - * since: 0.6 - */ -ClutterUnit -clutter_actor_get_heightu (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - - if (self->priv->needs_allocation) + if (priv->needs_allocation) { - ClutterUnit natural_height = 0; + gfloat natural_height = 0; - if (self->priv->request_mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH) + if (priv->request_mode == CLUTTER_REQUEST_HEIGHT_FOR_WIDTH) { - ClutterUnit natural_width = 0; + gfloat natural_width = 0; clutter_actor_get_preferred_width (self, -1, NULL, &natural_width); clutter_actor_get_preferred_height (self, natural_width, @@ -5633,7 +5385,7 @@ clutter_actor_get_heightu (ClutterActor *self) return natural_height; } else - return self->priv->allocation.y2 - self->priv->allocation.y1; + return priv->allocation.y2 - priv->allocation.y1; } /** @@ -5650,28 +5402,7 @@ clutter_actor_get_heightu (ClutterActor *self) **/ void clutter_actor_set_width (ClutterActor *self, - guint width) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_widthu (self, CLUTTER_UNITS_FROM_DEVICE (width)); -} - -/** - * clutter_actor_set_widthu - * @self: A #ClutterActor - * @width: Requested new width for the actor, in #ClutterUnits - * - * Forces a width on an actor, causing the actor's preferred width - * and height (if any) to be ignored. - * - * This function sets both the minimum and natural size of the actor. - * - * since: 0.6 - **/ -void -clutter_actor_set_widthu (ClutterActor *self, - ClutterUnit width) + gfloat width) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -5697,28 +5428,7 @@ clutter_actor_set_widthu (ClutterActor *self, **/ void clutter_actor_set_height (ClutterActor *self, - guint height) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_heightu (self, CLUTTER_UNITS_FROM_DEVICE (height)); -} - -/** - * clutter_actor_set_heightu - * @self: A #ClutterActor - * @height: Requested new height for the actor, in #ClutterUnits - * - * Forces a height on an actor, causing the actor's preferred width - * and height (if any) to be ignored. - * - * This function sets both the minimum and natural size of the actor. - * - * since: 0.6 - **/ -void -clutter_actor_set_heightu (ClutterActor *self, - ClutterUnit height) + gfloat height) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -5744,40 +5454,21 @@ clutter_actor_set_heightu (ClutterActor *self, */ void clutter_actor_set_x (ClutterActor *self, - gint x) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_xu (self, CLUTTER_UNITS_FROM_DEVICE (x)); -} - -/** - * clutter_actor_set_xu: - * @self: a #ClutterActor - * @x: the actor's position on the X axis, in #ClutterUnits - * - * Sets the actor's X coordinate, relative to its parent. - * - * Overrides any layout manager and forces a fixed position for - * the actor. - * - * Since: 0.6 - */ -void -clutter_actor_set_xu (ClutterActor *self, - ClutterUnit x) + gfloat x) { ClutterActorBox old = { 0, }; + ClutterActorPrivate *priv; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - if (self->priv->position_set && - self->priv->fixed_x == x) + priv = self->priv; + + if (priv->position_set && priv->fixed_x == x) return; clutter_actor_store_old_geometry (self, &old); - self->priv->fixed_x = x; + priv->fixed_x = x; clutter_actor_set_fixed_position_set (self, TRUE); clutter_actor_notify_if_geometry_changed (self, &old); @@ -5799,40 +5490,21 @@ clutter_actor_set_xu (ClutterActor *self, */ void clutter_actor_set_y (ClutterActor *self, - gint y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_yu (self, CLUTTER_UNITS_FROM_DEVICE (y)); -} - -/** - * clutter_actor_set_yu: - * @self: a #ClutterActor - * @y: the actor's position on the Y axis, in #ClutterUnits - * - * Sets the actor's Y coordinate, relative to its parent. - * - * Overrides any layout manager and forces a fixed position for - * the actor. - * - * Since: 0.6 - */ -void -clutter_actor_set_yu (ClutterActor *self, - ClutterUnit y) + gfloat y) { ClutterActorBox old = { 0, }; + ClutterActorPrivate *priv; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - if (self->priv->position_set && - self->priv->fixed_y == y) + priv = self->priv; + + if (priv->position_set && priv->fixed_y == y) return; clutter_actor_store_old_geometry (self, &old); - self->priv->fixed_y = y; + priv->fixed_y = y; clutter_actor_set_fixed_position_set (self, TRUE); clutter_actor_notify_if_geometry_changed (self, &old); @@ -5862,52 +5534,24 @@ clutter_actor_set_yu (ClutterActor *self, * Return value: the X coordinate, in pixels, ignoring any * transformation (i.e. scaling, rotation) */ -gint +gfloat clutter_actor_get_x (ClutterActor *self) { + ClutterActorPrivate *priv; + g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return CLUTTER_UNITS_TO_DEVICE (clutter_actor_get_xu (self)); -} + priv = self->priv; -/** - * clutter_actor_get_xu - * @self: A #ClutterActor - * - * Retrieves the X coordinate of a #ClutterActor, in #ClutterUnits. - * - * This function tries to "do what you mean", by returning the - * correct value depending on the actor's state. - * - * If the actor has a valid allocation, this function will return - * the X coordinate of the origin of the allocation box. - * - * If the actor has any fixed coordinate set using clutter_actor_set_x(), - * clutter_actor_set_position() or clutter_actor_set_geometry(), this - * function will return that coordinate. - * - * If both the allocation and a fixed position are missing, this function - * will return 0. - * - * Return value: the X coordinate, in #ClutterUnits, ignoring - * any transformation (i.e. scaling, rotation) - * - * Since: 0.6 - */ -ClutterUnit -clutter_actor_get_xu (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - - if (self->priv->needs_allocation) + if (priv->needs_allocation) { - if (self->priv->position_set) - return self->priv->fixed_x; + if (priv->position_set) + return priv->fixed_x; else return 0; } else - return self->priv->allocation.x1; + return priv->allocation.x1; } /** @@ -5932,43 +5576,11 @@ clutter_actor_get_xu (ClutterActor *self) * Return value: the Y coordinate, in pixels, ignoring any * transformation (i.e. scaling, rotation) */ -gint +gfloat clutter_actor_get_y (ClutterActor *self) { g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - return CLUTTER_UNITS_TO_DEVICE (clutter_actor_get_yu (self)); -} - -/** - * clutter_actor_get_yu - * @self: A #ClutterActor - * - * Retrieves the Y coordinate of a #ClutterActor, in #ClutterUnits. - * - * This function tries to "do what you mean", by returning the - * correct value depending on the actor's state. - * - * If the actor has a valid allocation, this function will return - * the Y coordinate of the origin of the allocation box. - * - * If the actor has any fixed coordinate set using clutter_actor_set_y(), - * clutter_actor_set_position() or clutter_actor_set_geometry(), this - * function will return that coordinate. - * - * If both the allocation and a fixed position are missing, this function - * will return 0. - * - * Return value: the Y coordinate, in #ClutterUnits, ignoring - * any transformation (i.e. scaling, rotation) - * - * Since: 0.6 - */ -ClutterUnit -clutter_actor_get_yu (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0); - if (self->priv->needs_allocation) { if (self->priv->position_set) @@ -5997,23 +5609,24 @@ clutter_actor_set_scale (ClutterActor *self, gdouble scale_x, gdouble scale_y) { + ClutterActorPrivate *priv; + g_return_if_fail (CLUTTER_IS_ACTOR (self)); - g_object_ref (self); + priv = self->priv; + g_object_freeze_notify (G_OBJECT (self)); - self->priv->scale_x = scale_x; + priv->scale_x = scale_x; g_object_notify (G_OBJECT (self), "scale-x"); - self->priv->scale_y = scale_y; + priv->scale_y = scale_y; g_object_notify (G_OBJECT (self), "scale-y"); - g_object_thaw_notify (G_OBJECT (self)); - if (CLUTTER_ACTOR_IS_VISIBLE (self)) clutter_actor_queue_redraw (self); - g_object_unref (self); + g_object_thaw_notify (G_OBJECT (self)); } /** @@ -6034,39 +5647,8 @@ void clutter_actor_set_scale_full (ClutterActor *self, gdouble scale_x, gdouble scale_y, - int center_x, - int center_y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_scale_fullu (self, scale_x, scale_y, - CLUTTER_UNITS_FROM_DEVICE (center_x), - CLUTTER_UNITS_FROM_DEVICE (center_y)); -} - -/** - * clutter_actor_set_scale_fullu: - * @self: A #ClutterActor - * @scale_x: double factor to scale actor by horizontally. - * @scale_y: double factor to scale actor by vertically. - * @center_x: X coordinate of the center of the scale. - * @center_y: Y coordinate of the center of the scale - * - * %ClutterUnit version of clutter_actor_set_scale_full(). - * - * Scales an actor with the given factors around the given center - * point. The center point is specified in - * %ClutterUnits relative to the anchor point (usually - * the top left corner of the actor). - * - * Since: 1.0 - */ -void -clutter_actor_set_scale_fullu (ClutterActor *self, - gdouble scale_x, - gdouble scale_y, - ClutterUnit center_x, - ClutterUnit center_y) + gfloat center_x, + gfloat center_y) { ClutterActorPrivate *priv; @@ -6174,45 +5756,15 @@ clutter_actor_get_scale (ClutterActor *self, */ void clutter_actor_get_scale_center (ClutterActor *self, - gint *center_x, - gint *center_y) -{ - ClutterUnit xu, yu; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_get_scale_centeru (self, &xu, &yu); - - if (center_x) - *center_x = CLUTTER_UNITS_TO_DEVICE (xu); - if (center_y) - *center_y = CLUTTER_UNITS_TO_DEVICE (yu); -} - -/** - * clutter_actor_get_scale_centeru: - * @self: A #ClutterActor - * @center_x: (out): Location to store the X position of the scale center, or %NULL. - * @center_y: (out): Location to store the Y position of the scale center, or %NULL. - * - * ClutterUnits version of clutter_actor_get_scale_center(). - * - * Retrieves the scale center coordinate in units relative to the top - * left corner of the actor. If the scale center was specified using a - * #ClutterGravity this will calculate the unit offset using the - * current size of the actor. - * - * Since: 1.0 - */ -void -clutter_actor_get_scale_centeru (ClutterActor *self, - ClutterUnit *center_x, - ClutterUnit *center_y) + gfloat *center_x, + gfloat *center_y) { g_return_if_fail (CLUTTER_IS_ACTOR (self)); clutter_anchor_coord_get_units (self, &self->priv->scale_center, - center_x, center_y, NULL); + center_x, + center_y, + NULL); } /** @@ -6247,12 +5799,20 @@ void clutter_actor_set_opacity (ClutterActor *self, guint8 opacity) { + ClutterActorPrivate *priv; + g_return_if_fail (CLUTTER_IS_ACTOR (self)); - self->priv->opacity = opacity; + priv = self->priv; - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); + if (priv->opacity != opacity) + { + priv->opacity = opacity; + + clutter_actor_queue_redraw (self); + + g_object_notify (G_OBJECT (self), "opacity"); + } } /** @@ -6378,27 +5938,14 @@ clutter_actor_get_gid (ClutterActor *self) * @self: a #ClutterActor * @depth: Z co-ord * - * Sets the Z co-ordinate of @self to @depth. The Units of which are dependant - * on the perspective setup. + * Sets the Z coordinate of @self to @depth. + * + * The unit used by @depth is dependant on the perspective setup. See + * also clutter_stage_set_perspective(). */ void clutter_actor_set_depth (ClutterActor *self, - gint depth) -{ - clutter_actor_set_depthu (self, CLUTTER_UNITS_FROM_DEVICE (depth)); -} - -/** - * clutter_actor_set_depthu: - * @self: a #ClutterActor - * @depth: Z co-ordinate, in #ClutterUnits - * - * Sets the Z co-ordinate of @self to @depth in #ClutterUnits, the - * units of which are dependant on the perspective setup. - */ -void -clutter_actor_set_depthu (ClutterActor *self, - ClutterUnit depth) + gfloat depth) { ClutterActorPrivate *priv; @@ -6408,7 +5955,7 @@ clutter_actor_set_depthu (ClutterActor *self, if (priv->z != depth) { - /* Sets Z value. - FIXME: should invert ?*/ + /* Sets Z value - XXX 2.0: should we invert? */ priv->z = depth; if (priv->parent_actor && CLUTTER_IS_CONTAINER (priv->parent_actor)) @@ -6418,15 +5965,14 @@ clutter_actor_set_depthu (ClutterActor *self, /* We need to resort the container stacking order as to * correctly render alpha values. * - * FIXME: This is sub optimal. maybe queue the the sort + * FIXME: This is sub-optimal. maybe queue the the sort * before stacking */ parent = CLUTTER_CONTAINER (priv->parent_actor); clutter_container_sort_depth_order (parent); } - if (CLUTTER_ACTOR_IS_VISIBLE (self)) - clutter_actor_queue_redraw (self); + clutter_actor_queue_redraw (self); g_object_notify (G_OBJECT (self), "depth"); } @@ -6440,86 +5986,14 @@ clutter_actor_set_depthu (ClutterActor *self, * * Return value: the depth of the actor */ -gint +gfloat clutter_actor_get_depth (ClutterActor *self) { g_return_val_if_fail (CLUTTER_IS_ACTOR (self), -1); - return CLUTTER_UNITS_TO_DEVICE (self->priv->z); -} - -/** - * clutter_actor_get_depthu: - * @self: a #ClutterActor - * - * Retrieves the depth of @self. - * - * Return value: the depth of the actor, in #ClutterUnits - * - * Since: 0.6 - */ -ClutterUnit -clutter_actor_get_depthu (ClutterActor *self) -{ - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), -1); - return self->priv->z; } -/** - * clutter_actor_set_rotationu: - * @self: a #ClutterActor - * @axis: the axis of rotation - * @angle: the angle of rotation - * @x: X coordinate of the rotation center, in #ClutterUnits - * @y: Y coordinate of the rotation center, in #ClutterUnits - * @z: Z coordinate of the rotation center, in #ClutterUnits - * - * Sets the rotation angle of @self around the given axis. - * - * This function is the units based variant of clutter_actor_set_rotation(). - * - * Since: 0.8 - */ -void -clutter_actor_set_rotationu (ClutterActor *self, - ClutterRotateAxis axis, - gdouble angle, - ClutterUnit x, - ClutterUnit y, - ClutterUnit z) -{ - ClutterActorPrivate *priv; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - priv = self->priv; - - g_object_freeze_notify (G_OBJECT (self)); - - clutter_actor_set_rotation_internal (self, axis, angle); - - switch (axis) - { - case CLUTTER_X_AXIS: - clutter_anchor_coord_set_units (&priv->rx_center, x, y, z); - g_object_notify (G_OBJECT (self), "rotation-center-x"); - break; - case CLUTTER_Y_AXIS: - clutter_anchor_coord_set_units (&priv->ry_center, x, y, z); - g_object_notify (G_OBJECT (self), "rotation-center-y"); - break; - case CLUTTER_Z_AXIS: - if (priv->rz_center.is_fractional) - g_object_notify (G_OBJECT (self), "rotation-center-z-gravity"); - clutter_anchor_coord_set_units (&priv->rz_center, x, y, z); - g_object_notify (G_OBJECT (self), "rotation-center-z"); - break; - } - - g_object_thaw_notify (G_OBJECT (self)); -} - /** * clutter_actor_set_rotation: * @self: a #ClutterActor @@ -6542,22 +6016,47 @@ clutter_actor_set_rotationu (ClutterActor *self, * actor, set using clutter_actor_set_anchor_point(). If no anchor * point is set, the upper left corner is assumed as the origin. * - * Since: 0.6 + * Since: 0.8 */ void clutter_actor_set_rotation (ClutterActor *self, ClutterRotateAxis axis, gdouble angle, - gint x, - gint y, - gint z) + gfloat x, + gfloat y, + gfloat z) { + ClutterActorPrivate *priv; + g_return_if_fail (CLUTTER_IS_ACTOR (self)); - clutter_actor_set_rotationu (self, axis, angle, - CLUTTER_UNITS_FROM_DEVICE (x), - CLUTTER_UNITS_FROM_DEVICE (y), - CLUTTER_UNITS_FROM_DEVICE (z)); + priv = self->priv; + + g_object_freeze_notify (G_OBJECT (self)); + + clutter_actor_set_rotation_internal (self, axis, angle); + + switch (axis) + { + case CLUTTER_X_AXIS: + clutter_anchor_coord_set_units (&priv->rx_center, x, y, z); + g_object_notify (G_OBJECT (self), "rotation-center-x"); + break; + + case CLUTTER_Y_AXIS: + clutter_anchor_coord_set_units (&priv->ry_center, x, y, z); + g_object_notify (G_OBJECT (self), "rotation-center-y"); + break; + + case CLUTTER_Z_AXIS: + if (priv->rz_center.is_fractional) + g_object_notify (G_OBJECT (self), "rotation-center-z-gravity"); + clutter_anchor_coord_set_units (&priv->rz_center, x, y, z); + g_object_notify (G_OBJECT (self), "rotation-center-z"); + break; + } + + g_object_thaw_notify (G_OBJECT (self)); } /** @@ -6575,9 +6074,9 @@ clutter_actor_set_rotation (ClutterActor *self, * Since: 1.0 */ void -clutter_actor_set_z_rotation_from_gravity (ClutterActor *self, - gdouble angle, - ClutterGravity gravity) +clutter_actor_set_z_rotation_from_gravity (ClutterActor *self, + gdouble angle, + ClutterGravity gravity) { ClutterActorPrivate *priv; @@ -6602,31 +6101,26 @@ clutter_actor_set_z_rotation_from_gravity (ClutterActor *self, } /** - * clutter_actor_get_rotationu: + * clutter_actor_get_rotation: * @self: a #ClutterActor * @axis: the axis of rotation - * @x: (out): return value for the X coordinate of the center of rotation, - * in #ClutterUnits - * @y: (out): return value for the Y coordinate of the center of rotation, - * in #ClutterUnits - * @z: (out): return value for the Z coordinate of the center of rotation, - * in #ClutterUnits + * @x: (out): return value for the X coordinate of the center of rotation + * @y: (out): return value for the Y coordinate of the center of rotation + * @z: (out): return value for the Z coordinate of the center of rotation * * Retrieves the angle and center of rotation on the given axis, * set using clutter_actor_set_rotation(). * - * This function is the units based variant of clutter_actor_get_rotation(). - * * Return value: the angle of rotation * * Since: 0.8 */ gdouble -clutter_actor_get_rotationu (ClutterActor *self, - ClutterRotateAxis axis, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z) +clutter_actor_get_rotation (ClutterActor *self, + ClutterRotateAxis axis, + gfloat *x, + gfloat *y, + gfloat *z) { ClutterActorPrivate *priv; gdouble retval = 0; @@ -6659,50 +6153,6 @@ clutter_actor_get_rotationu (ClutterActor *self, return retval; } -/** - * clutter_actor_get_rotation: - * @self: a #ClutterActor - * @axis: the axis of rotation - * @x: (out): return value for the X coordinate of the center of rotation - * @y: (out): return value for the Y coordinate of the center of rotation - * @z: (out): return value for the Z coordinate of the center of rotation - * - * Retrieves the angle and center of rotation on the given axis, - * set using clutter_actor_set_angle(). - * - * The coordinates of the center returned by this function depend on - * the axis passed. - * - * Return value: the angle of rotation. - * - * Since: 0.6 - */ -gdouble -clutter_actor_get_rotation (ClutterActor *self, - ClutterRotateAxis axis, - gint *x, - gint *y, - gint *z) -{ - ClutterUnit xu, yu, zu; - gdouble angle; - - g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0); - - angle = clutter_actor_get_rotationu (self, axis, &xu, &yu, &zu); - - if (x) - *x = CLUTTER_UNITS_TO_DEVICE (xu); - - if (y) - *y = CLUTTER_UNITS_TO_DEVICE (yu); - - if (z) - *z = CLUTTER_UNITS_TO_DEVICE (zu); - - return angle; -} - /** * clutter_actor_get_z_rotation_gravity: * @self: A #ClutterActor @@ -6724,14 +6174,12 @@ clutter_actor_get_z_rotation_gravity (ClutterActor *self) } /** - * clutter_actor_set_clipu: + * clutter_actor_set_clip: * @self: A #ClutterActor - * @xoff: X offset of the clip rectangle, in #ClutterUnits - * @yoff: Y offset of the clip rectangle, in #ClutterUnits - * @width: Width of the clip rectangle, in #ClutterUnits - * @height: Height of the clip rectangle, in #ClutterUnits - * - * Unit-based variant of clutter_actor_set_clip() + * @xoff: X offset of the clip rectangle + * @yoff: Y offset of the clip rectangle + * @width: Width of the clip rectangle + * @height: Height of the clip rectangle * * Sets clip area for @self. The clip area is always computed from the * upper left corner of the actor, even if the anchor point is set @@ -6740,11 +6188,11 @@ clutter_actor_get_z_rotation_gravity (ClutterActor *self) * Since: 0.6 */ void -clutter_actor_set_clipu (ClutterActor *self, - ClutterUnit xoff, - ClutterUnit yoff, - ClutterUnit width, - ClutterUnit height) +clutter_actor_set_clip (ClutterActor *self, + gfloat xoff, + gfloat yoff, + gfloat width, + gfloat height) { ClutterActorPrivate *priv; @@ -6772,34 +6220,6 @@ clutter_actor_set_clipu (ClutterActor *self, g_object_notify (G_OBJECT (self), "clip"); } -/** - * clutter_actor_set_clip: - * @self: A #ClutterActor - * @xoff: X offset of the clip rectangle, in pixels - * @yoff: Y offset of the clip rectangle, in pixels - * @width: Width of the clip rectangle, in pixels - * @height: Height of the clip rectangle, in pixels - * - * Sets clip area in pixels for @self. The clip area is always computed - * from the upper left corner of the actor, even if the anchor point is - * set otherwise. - */ -void -clutter_actor_set_clip (ClutterActor *self, - gint xoff, - gint yoff, - gint width, - gint height) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_clipu (self, - CLUTTER_UNITS_FROM_DEVICE (xoff), - CLUTTER_UNITS_FROM_DEVICE (yoff), - CLUTTER_UNITS_FROM_DEVICE (width), - CLUTTER_UNITS_FROM_DEVICE (height)); -} - /** * clutter_actor_remove_clip * @self: A #ClutterActor @@ -6840,25 +6260,23 @@ clutter_actor_has_clip (ClutterActor *self) } /** - * clutter_actor_get_clipu: + * clutter_actor_get_clip: * @self: a #ClutterActor * @xoff: (out): return location for the X offset of the clip rectangle, or %NULL * @yoff: (out): return location for the Y offset of the clip rectangle, or %NULL * @width: (out): return location for the width of the clip rectangle, or %NULL * @height: (out): return location for the height of the clip rectangle, or %NULL * - * Unit-based variant of clutter_actor_get_clip(). - * - * Gets the clip area for @self, in #ClutterUnits. + * Gets the clip area for @self, if any is set * * Since: 0.6 */ void -clutter_actor_get_clipu (ClutterActor *self, - ClutterUnit *xoff, - ClutterUnit *yoff, - ClutterUnit *width, - ClutterUnit *height) +clutter_actor_get_clip (ClutterActor *self, + gfloat *xoff, + gfloat *yoff, + gfloat *width, + gfloat *height) { ClutterActorPrivate *priv; @@ -6882,44 +6300,6 @@ clutter_actor_get_clipu (ClutterActor *self, *height = priv->clip[3]; } -/** - * clutter_actor_get_clip: - * @self: a #ClutterActor - * @xoff: (out): return location for the X offset of the clip rectangle, or %NULL - * @yoff: (out): return location for the Y offset of the clip rectangle, or %NULL - * @width: (out): return location for the width of the clip rectangle, or %NULL - * @height: (out): return location for the height of the clip rectangle, or %NULL - * - * Gets the clip area for @self, in pixels. - * - * Since: 0.6 - */ -void -clutter_actor_get_clip (ClutterActor *self, - gint *xoff, - gint *yoff, - gint *width, - gint *height) -{ - struct clipu { ClutterUnit x, y, width, height; } c = { 0, }; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_get_clipu (self, &c.x, &c.y, &c.width, &c.height); - - if (xoff) - *xoff = CLUTTER_UNITS_TO_DEVICE (c.x); - - if (yoff) - *yoff = CLUTTER_UNITS_TO_DEVICE (c.y); - - if (width) - *width = CLUTTER_UNITS_TO_DEVICE (c.width); - - if (height) - *height = CLUTTER_UNITS_TO_DEVICE (c.height); -} - /** * clutter_actor_set_parent: * @self: A #ClutterActor @@ -7405,55 +6785,6 @@ clutter_actor_get_reactive (ClutterActor *actor) return CLUTTER_ACTOR_IS_REACTIVE (actor) ? TRUE : FALSE; } -/** - * clutter_actor_set_anchor_point: - * @self: a #ClutterActor - * @anchor_x: X coordinate of the anchor point - * @anchor_y: Y coordinate of the anchor point - * - * Sets an anchor point for the @actor. The anchor point is a point in the - * coordinate space of an actor to which the actor position within its - * parent is relative; the default is (0, 0), i.e. the top-left corner of - * the actor. - * - * Since: 0.6 - */ -void -clutter_actor_set_anchor_point (ClutterActor *self, - gint anchor_x, - gint anchor_y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_set_anchor_pointu (self, - CLUTTER_UNITS_FROM_DEVICE (anchor_x), - CLUTTER_UNITS_FROM_DEVICE (anchor_y)); -} - -/** - * clutter_actor_move_anchor_point: - * @self: a #ClutterActor - * @anchor_x: X coordinate of the anchor point - * @anchor_y: Y coordinate of the anchor point - * - * Sets an anchor point for the @actor, and adjusts the actor postion so - * that the relative position of the actor toward its parent remains the - * same. - * - * Since: 0.6 - */ -void -clutter_actor_move_anchor_point (ClutterActor *self, - gint anchor_x, - gint anchor_y) -{ - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - clutter_actor_move_anchor_pointu (self, - CLUTTER_UNITS_FROM_DEVICE (anchor_x), - CLUTTER_UNITS_FROM_DEVICE (anchor_y)); -} - /** * clutter_actor_get_anchor_point: * @self: a #ClutterActor @@ -7466,30 +6797,26 @@ clutter_actor_move_anchor_point (ClutterActor *self, */ void clutter_actor_get_anchor_point (ClutterActor *self, - gint *anchor_x, - gint *anchor_y) + gfloat *anchor_x, + gfloat *anchor_y) { ClutterActorPrivate *priv; - ClutterUnit xu, yu; g_return_if_fail (CLUTTER_IS_ACTOR (self)); priv = self->priv; - clutter_anchor_coord_get_units (self, &priv->anchor, &xu, &yu, NULL); - - if (anchor_x) - *anchor_x = CLUTTER_UNITS_TO_DEVICE (xu); - - if (anchor_y) - *anchor_y = CLUTTER_UNITS_TO_DEVICE (yu); + clutter_anchor_coord_get_units (self, &priv->anchor, + anchor_x, + anchor_y, + NULL); } /** - * clutter_actor_set_anchor_pointu: + * clutter_actor_set_anchor_point: * @self: a #ClutterActor - * @anchor_x: X coordinate of the anchor point, in #ClutterUnits - * @anchor_y: Y coordinate of the anchor point, in #ClutterUnits + * @anchor_x: X coordinate of the anchor point + * @anchor_y: Y coordinate of the anchor point * * Sets an anchor point for @self. The anchor point is a point in the * coordinate space of an actor to which the actor position within its @@ -7499,13 +6826,13 @@ clutter_actor_get_anchor_point (ClutterActor *self, * Since: 0.6 */ void -clutter_actor_set_anchor_pointu (ClutterActor *self, - ClutterUnit anchor_x, - ClutterUnit anchor_y) +clutter_actor_set_anchor_point (ClutterActor *self, + gfloat anchor_x, + gfloat anchor_y) { ClutterActorPrivate *priv; gboolean changed = FALSE; - ClutterUnit old_anchor_x, old_anchor_y; + gfloat old_anchor_x, old_anchor_y; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -7514,7 +6841,9 @@ clutter_actor_set_anchor_pointu (ClutterActor *self, g_object_freeze_notify (G_OBJECT (self)); clutter_anchor_coord_get_units (self, &priv->anchor, - &old_anchor_x, &old_anchor_y, NULL); + &old_anchor_x, + &old_anchor_y, + NULL); if (priv->anchor.is_fractional) g_object_notify (G_OBJECT (self), "anchor-gravity"); @@ -7533,10 +6862,10 @@ clutter_actor_set_anchor_pointu (ClutterActor *self, clutter_anchor_coord_set_units (&priv->anchor, anchor_x, anchor_y, 0); - g_object_thaw_notify (G_OBJECT (self)); - if (changed && CLUTTER_ACTOR_IS_VISIBLE (self)) clutter_actor_queue_redraw (self); + + g_object_thaw_notify (G_OBJECT (self)); } /** @@ -7564,7 +6893,7 @@ clutter_actor_get_anchor_point_gravity (ClutterActor *self) } /** - * clutter_actor_move_anchor_pointu: + * clutter_actor_move_anchor_point: * @self: a #ClutterActor * @anchor_x: X coordinate of the anchor point * @anchor_y: Y coordinate of the anchor point @@ -7575,57 +6904,34 @@ clutter_actor_get_anchor_point_gravity (ClutterActor *self) * Since: 0.6 */ void -clutter_actor_move_anchor_pointu (ClutterActor *self, - ClutterUnit anchor_x, - ClutterUnit anchor_y) +clutter_actor_move_anchor_point (ClutterActor *self, + gfloat anchor_x, + gfloat anchor_y) { ClutterActorPrivate *priv; - ClutterUnit old_anchor_x, old_anchor_y; + gfloat old_anchor_x, old_anchor_y; g_return_if_fail (CLUTTER_IS_ACTOR (self)); priv = self->priv; clutter_anchor_coord_get_units (self, &priv->anchor, - &old_anchor_x, &old_anchor_y, NULL); + &old_anchor_x, + &old_anchor_y, + NULL); g_object_freeze_notify (G_OBJECT (self)); clutter_actor_set_anchor_point (self, anchor_x, anchor_y); if (priv->position_set) - clutter_actor_move_byu (self, - anchor_x - old_anchor_x, - anchor_y - old_anchor_y); + clutter_actor_move_by (self, + anchor_x - old_anchor_x, + anchor_y - old_anchor_y); g_object_thaw_notify (G_OBJECT (self)); } -/** - * clutter_actor_get_anchor_pointu: - * @self: a #ClutterActor - * @anchor_x: (out): return location for the X coordinate of the anchor point - * @anchor_y: (out): return location for the Y coordinate of the anchor point - * - * Gets the current anchor point of the @actor in #ClutterUnits. - * - * Since: 0.6 - */ -void -clutter_actor_get_anchor_pointu (ClutterActor *self, - ClutterUnit *anchor_x, - ClutterUnit *anchor_y) -{ - ClutterActorPrivate *priv; - - g_return_if_fail (CLUTTER_IS_ACTOR (self)); - - priv = self->priv; - - clutter_anchor_coord_get_units (self, &priv->anchor, - anchor_x, anchor_y, NULL); -} - /** * clutter_actor_move_anchor_point_from_gravity: * @self: a #ClutterActor @@ -7647,7 +6953,7 @@ void clutter_actor_move_anchor_point_from_gravity (ClutterActor *self, ClutterGravity gravity) { - ClutterUnit old_anchor_x, old_anchor_y, new_anchor_x, new_anchor_y; + gfloat old_anchor_x, old_anchor_y, new_anchor_x, new_anchor_y; ClutterActorPrivate *priv; g_return_if_fail (CLUTTER_IS_ACTOR (self)); @@ -7657,15 +6963,19 @@ clutter_actor_move_anchor_point_from_gravity (ClutterActor *self, g_object_freeze_notify (G_OBJECT (self)); clutter_anchor_coord_get_units (self, &priv->anchor, - &old_anchor_x, &old_anchor_y, NULL); + &old_anchor_x, + &old_anchor_y, + NULL); clutter_actor_set_anchor_point_from_gravity (self, gravity); clutter_anchor_coord_get_units (self, &priv->anchor, - &new_anchor_x, &new_anchor_y, NULL); + &new_anchor_x, + &new_anchor_y, + NULL); if (priv->position_set) - clutter_actor_move_byu (self, - new_anchor_x - old_anchor_x, - new_anchor_y - old_anchor_y); + clutter_actor_move_by (self, + new_anchor_x - old_anchor_x, + new_anchor_y - old_anchor_y); g_object_thaw_notify (G_OBJECT (self)); } @@ -7714,13 +7024,13 @@ typedef enum PARSE_ANCHOR_Y } ParseDimension; -static ClutterUnit +static gfloat parse_units (ClutterActor *self, ParseDimension dimension, JsonNode *node) { GValue value = { 0, }; - ClutterUnit retval = 0; + gfloat retval = 0; if (JSON_NODE_TYPE (node) != JSON_NODE_VALUE) return 0; @@ -7729,9 +7039,7 @@ parse_units (ClutterActor *self, if (G_VALUE_HOLDS (&value, G_TYPE_INT)) { - gint pixels = g_value_get_int (&value); - - retval = CLUTTER_UNITS_FROM_DEVICE (pixels); + retval = g_value_get_int (&value); } else if (G_VALUE_HOLDS (&value, G_TYPE_STRING)) { @@ -7747,13 +7055,13 @@ parse_units (ClutterActor *self, /* assume pixels */ if (*end == '\0') { - retval = CLUTTER_UNITS_FROM_DEVICE (val); + retval = val; goto out; } if (strcmp (end, "px") == 0) { - retval = CLUTTER_UNITS_FROM_DEVICE (val); + retval = val; goto out; } @@ -7793,11 +7101,11 @@ parse_units (ClutterActor *self, dimension == PARSE_WIDTH || dimension == PARSE_ANCHOR_X) { - retval = clutter_actor_get_widthu (stage) * val; + retval = clutter_actor_get_width (stage) * val; } else { - retval = clutter_actor_get_heightu (stage) * val; + retval = clutter_actor_get_height (stage) * val; } goto out; @@ -7837,11 +7145,11 @@ parse_units (ClutterActor *self, dimension == PARSE_WIDTH || dimension == PARSE_ANCHOR_X) { - retval = clutter_actor_get_widthu (stage) * val; + retval = clutter_actor_get_width (stage) * val; } else { - retval = clutter_actor_get_heightu (stage) * val; + retval = clutter_actor_get_height (stage) * val; } } else @@ -7863,9 +7171,9 @@ typedef struct { gdouble angle; - ClutterUnit center_x; - ClutterUnit center_y; - ClutterUnit center_z; + gfloat center_x; + gfloat center_y; + gfloat center_z; } RotationInfo; static inline gboolean @@ -8032,8 +7340,8 @@ clutter_actor_parse_custom_node (ClutterScriptable *scriptable, (strcmp (name, "anchor_x") == 0) || (strcmp (name, "anchor_y") == 0)) { - ClutterUnit units; ParseDimension dimension; + gfloat units; if (name[0] == 'x') dimension = PARSE_X; @@ -8054,7 +7362,7 @@ clutter_actor_parse_custom_node (ClutterScriptable *scriptable, /* convert back to pixels: all properties are pixel-based */ g_value_init (value, G_TYPE_INT); - g_value_set_int (value, CLUTTER_UNITS_TO_DEVICE (units)); + g_value_set_int (value, units); retval = TRUE; } @@ -8094,11 +7402,11 @@ clutter_actor_set_custom_property (ClutterScriptable *scriptable, info = g_value_get_pointer (value); - clutter_actor_set_rotationu (CLUTTER_ACTOR (scriptable), - info->axis, info->angle, - info->center_x, - info->center_y, - info->center_z); + clutter_actor_set_rotation (CLUTTER_ACTOR (scriptable), + info->axis, info->angle, + info->center_x, + info->center_y, + info->center_z); g_slice_free (RotationInfo, info); } @@ -8116,12 +7424,10 @@ clutter_scriptable_iface_init (ClutterScriptableIface *iface) /** * clutter_actor_transform_stage_point * @self: A #ClutterActor - * @x: (in): x screen coordinate of the point to unproject, in #ClutterUnits - * @y: (in): y screen coordinate of the point to unproject, in #ClutterUnits - * @x_out: (out): return location for the unprojected x coordinance, in - * #ClutterUnits - * @y_out: (out): return location for the unprojected y coordinance, in - * #ClutterUnits + * @x: (in): x screen coordinate of the point to unproject + * @y: (in): y screen coordinate of the point to unproject + * @x_out: (out): return location for the unprojected x coordinance + * @y_out: (out): return location for the unprojected y coordinance * * This function translates screen coordinates (@x, @y) to * coordinates relative to the actor. For example, it can be used to translate @@ -8136,7 +7442,8 @@ clutter_scriptable_iface_init (ClutterScriptableIface *iface) * * Note: This function is fairly computationally intensive. * - * Note: This function only works when the allocation is up-to-date, i.e. inside of paint() + * Note: This function only works when the allocation is up-to-date, + * i.e. inside of paint() * * Return value: %TRUE if conversion was successful. * @@ -8144,16 +7451,16 @@ clutter_scriptable_iface_init (ClutterScriptableIface *iface) */ gboolean clutter_actor_transform_stage_point (ClutterActor *self, - ClutterUnit x, - ClutterUnit y, - ClutterUnit *x_out, - ClutterUnit *y_out) + gfloat x, + gfloat y, + gfloat *x_out, + gfloat *y_out) { ClutterVertex v[4]; float ST[3][3]; float RQ[3][3]; int du, dv, xi, yi; - ClutterUnit px, py; + float px, py; float xf, yf, wf, det; ClutterActorPrivate *priv; @@ -8181,13 +7488,13 @@ clutter_actor_transform_stage_point (ClutterActor *self, /* Keeping these as ints simplifies the multiplication (no significant * loss of precision here). */ - du = CLUTTER_UNITS_TO_DEVICE (priv->allocation.x2 - priv->allocation.x1); - dv = CLUTTER_UNITS_TO_DEVICE (priv->allocation.y2 - priv->allocation.y1); + du = (int) (priv->allocation.x2 - priv->allocation.x1); + dv = (int) (priv->allocation.y2 - priv->allocation.y1); if (!du || !dv) return FALSE; -#define UX2FP CLUTTER_UNITS_TO_FLOAT +#define UX2FP(x) (x) #define DET2FP(a,b,c,d) (((a) * (d)) - ((b) * (c))) /* First, find mapping from unit uv square to xy quadrilateral; this @@ -8279,18 +7586,18 @@ clutter_actor_transform_stage_point (ClutterActor *self, * Now transform our point with the ST matrix; the notional w * coordinate is 1, hence the last part is simply added. */ - xi = CLUTTER_UNITS_TO_DEVICE (x); - yi = CLUTTER_UNITS_TO_DEVICE (y); + xi = (int) x; + yi = (int) y; xf = xi * ST[0][0] + yi * ST[1][0] + ST[2][0]; yf = xi * ST[0][1] + yi * ST[1][1] + ST[2][1]; wf = xi * ST[0][2] + yi * ST[1][2] + ST[2][2]; if (x_out) - *x_out = CLUTTER_UNITS_FROM_FLOAT (xf / wf); + *x_out = xf / wf; if (y_out) - *y_out = CLUTTER_UNITS_FROM_FLOAT (yf / wf); + *y_out = yf / wf; #undef UX2FP #undef DET2FP @@ -8311,7 +7618,7 @@ clutter_geometry_copy (const ClutterGeometry *geometry) static void clutter_geometry_free (ClutterGeometry *geometry) { - if (G_LIKELY (geometry)) + if (G_LIKELY (geometry != NULL)) g_slice_free (ClutterGeometry, geometry); } @@ -8342,7 +7649,7 @@ clutter_vertex_copy (const ClutterVertex *vertex) static void clutter_vertex_free (ClutterVertex *vertex) { - if (G_UNLIKELY (vertex)) + if (G_UNLIKELY (vertex != NULL)) g_slice_free (ClutterVertex, vertex); } @@ -8372,7 +7679,7 @@ clutter_actor_box_copy (const ClutterActorBox *box) static void clutter_actor_box_free (ClutterActorBox *box) { - if (G_LIKELY (box)) + if (G_LIKELY (box != NULL)) g_slice_free (ClutterActorBox, box); } @@ -8394,9 +7701,11 @@ clutter_actor_box_get_type (void) struct _ShaderData { ClutterShader *shader; - GHashTable *value_hash; /*< list of GValue's that should be set - * on the shader before each paint cycle - */ + + /* list of values that should be set on the shader + * before each paint cycle + */ + GHashTable *value_hash; }; static void @@ -8411,9 +7720,9 @@ static void destroy_shader_data (ClutterActor *self) { ClutterActorPrivate *actor_priv = self->priv; - ShaderData *shader_data = actor_priv->shader_data; + ShaderData *shader_data = actor_priv->shader_data; - if (!shader_data) + if (shader_data == NULL) return; if (shader_data->shader) @@ -8487,13 +7796,15 @@ clutter_actor_set_shader (ClutterActor *self, if (shader) g_object_ref (shader); else - /* if shader passed in is NULL we destroy the shader */ - destroy_shader_data (self); + { + /* if shader passed in is NULL we destroy the shader */ + destroy_shader_data (self); + } actor_priv = self->priv; shader_data = actor_priv->shader_data; - if (!shader_data) + if (shader_data != NULL) { actor_priv->shader_data = shader_data = g_new0 (ShaderData, 1); shader_data->value_hash = @@ -8501,7 +7812,7 @@ clutter_actor_set_shader (ClutterActor *self, g_free, shader_value_free); } - if (shader_data->shader) + if (shader_data->shader != NULL) g_object_unref (shader_data->shader); shader_data->shader = shader; @@ -8745,36 +8056,48 @@ void clutter_actor_get_box_from_vertices (ClutterVertex vtx[4], ClutterActorBox *box) { - ClutterUnit x_1, x_2, y_1, y_2; + gfloat x_1, x_2, y_1, y_2; /* 4-way min/max */ x_1 = vtx[0].x; y_1 = vtx[0].y; + if (vtx[1].x < x_1) x_1 = vtx[1].x; + if (vtx[2].x < x_1) x_1 = vtx[2].x; + if (vtx[3].x < x_1) x_1 = vtx[3].x; + if (vtx[1].y < y_1) y_1 = vtx[1].y; + if (vtx[2].y < y_1) y_1 = vtx[2].y; + if (vtx[3].y < y_1) y_1 = vtx[3].y; x_2 = vtx[0].x; y_2 = vtx[0].y; + if (vtx[1].x > x_2) x_2 = vtx[1].x; + if (vtx[2].x > x_2) x_2 = vtx[2].x; + if (vtx[3].x > x_2) x_2 = vtx[3].x; + if (vtx[1].y > y_2) y_2 = vtx[1].y; + if (vtx[2].y > y_2) y_2 = vtx[2].y; + if (vtx[3].y > y_2) y_2 = vtx[3].y; @@ -8830,14 +8153,14 @@ void clutter_actor_allocate_preferred_size (ClutterActor *self, gboolean absolute_origin_changed) { - ClutterUnit actor_x, actor_y; - ClutterUnit natural_width, natural_height; + gfloat actor_x, actor_y; + gfloat natural_width, natural_height; ClutterActorBox actor_box; g_return_if_fail (CLUTTER_IS_ACTOR (self)); - actor_x = clutter_actor_get_xu (self); - actor_y = clutter_actor_get_yu (self); + actor_x = clutter_actor_get_x (self); + actor_y = clutter_actor_get_y (self); clutter_actor_get_preferred_size (self, NULL, NULL, @@ -9029,20 +8352,22 @@ _clutter_actor_set_enable_paint_unmapped (ClutterActor *self, static void clutter_anchor_coord_get_units (ClutterActor *self, const AnchorCoord *coord, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z) + gfloat *x, + gfloat *y, + gfloat *z) { - if (G_UNLIKELY (coord->is_fractional)) + if (coord->is_fractional) { - ClutterUnit actor_width, actor_height; + gfloat actor_width, actor_height; - clutter_actor_get_sizeu (self, &actor_width, &actor_height); + clutter_actor_get_size (self, &actor_width, &actor_height); if (x) *x = actor_width * coord->v.fraction.x; + if (y) *y = actor_height * coord->v.fraction.y; + if (z) *z = 0; } @@ -9050,18 +8375,20 @@ clutter_anchor_coord_get_units (ClutterActor *self, { if (x) *x = coord->v.units.x; + if (y) *y = coord->v.units.y; + if (z) *z = coord->v.units.z; } } static void -clutter_anchor_coord_set_units (AnchorCoord *coord, - ClutterUnit x, - ClutterUnit y, - ClutterUnit z) +clutter_anchor_coord_set_units (AnchorCoord *coord, + gfloat x, + gfloat y, + gfloat z) { coord->is_fractional = FALSE; coord->v.units.x = x; @@ -9115,8 +8442,8 @@ clutter_anchor_coord_get_gravity (AnchorCoord *coord) } static void -clutter_anchor_coord_set_gravity (AnchorCoord *coord, - ClutterGravity gravity) +clutter_anchor_coord_set_gravity (AnchorCoord *coord, + ClutterGravity gravity) { switch (gravity) { diff --git a/clutter/clutter-actor.h b/clutter/clutter-actor.h index 83d78247d..098023c70 100644 --- a/clutter/clutter-actor.h +++ b/clutter/clutter-actor.h @@ -129,15 +129,15 @@ typedef enum * * Bounding box of an actor. The coordinates of the top left and right bottom * corners of an actor. The coordinates of the two points are expressed in - * #ClutterUnits, that is are device-independent. If you want to obtain - * the box dimensions in pixels, use clutter_actor_get_geometry(). + * pixels with sub-pixel precision */ struct _ClutterActorBox { - ClutterUnit x1; - ClutterUnit y1; - ClutterUnit x2; - ClutterUnit y2; + gfloat x1; + gfloat y1; + + gfloat x2; + gfloat y2; }; GType clutter_actor_box_get_type (void) G_GNUC_CONST; @@ -238,13 +238,13 @@ struct _ClutterActorClass /* size negotiation */ void (* get_preferred_width) (ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p); + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p); void (* get_preferred_height) (ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p); + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p); void (* allocate) (ClutterActor *actor, const ClutterActorBox *box, gboolean absolute_origin_changed); @@ -302,18 +302,18 @@ void clutter_actor_destroy (ClutterActor /* size negotiation */ void clutter_actor_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p); + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p); void clutter_actor_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p); + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p); void clutter_actor_get_preferred_size (ClutterActor *self, - ClutterUnit *min_width_p, - ClutterUnit *min_height_p, - ClutterUnit *natural_width_p, - ClutterUnit *natural_height_p); + gfloat *min_width_p, + gfloat *min_height_p, + gfloat *natural_width_p, + gfloat *natural_height_p); void clutter_actor_allocate (ClutterActor *self, const ClutterActorBox *box, gboolean absolute_origin_changed); @@ -337,100 +337,60 @@ void clutter_actor_set_geometry (ClutterActor void clutter_actor_get_geometry (ClutterActor *self, ClutterGeometry *geometry); void clutter_actor_set_size (ClutterActor *self, - gint width, - gint height); -void clutter_actor_set_sizeu (ClutterActor *self, - ClutterUnit width, - ClutterUnit height); + gfloat width, + gfloat height); void clutter_actor_get_size (ClutterActor *self, - guint *width, - guint *height); -void clutter_actor_get_sizeu (ClutterActor *self, - ClutterUnit *width, - ClutterUnit *height); + gfloat *width, + gfloat *height); void clutter_actor_get_transformed_size (ClutterActor *self, - guint *width, - guint *height); -void clutter_actor_get_transformed_sizeu (ClutterActor *self, - ClutterUnit *width, - ClutterUnit *height); + gfloat *width, + gfloat *height); void clutter_actor_set_position (ClutterActor *self, - gint x, - gint y); -void clutter_actor_set_positionu (ClutterActor *self, - ClutterUnit x, - ClutterUnit y); + gfloat x, + gfloat y); void clutter_actor_get_position (ClutterActor *self, - gint *x, - gint *y); -void clutter_actor_get_positionu (ClutterActor *self, - ClutterUnit *x, - ClutterUnit *y); + gfloat *x, + gfloat *y); void clutter_actor_get_transformed_position (ClutterActor *self, - gint *x, - gint *y); -void clutter_actor_get_transformed_positionu (ClutterActor *self, - ClutterUnit *x, - ClutterUnit *y); + gfloat *x, + gfloat *y); gboolean clutter_actor_get_fixed_position_set (ClutterActor *self); void clutter_actor_set_fixed_position_set (ClutterActor *self, gboolean is_set); -guint clutter_actor_get_width (ClutterActor *self); -ClutterUnit clutter_actor_get_widthu (ClutterActor *self); -guint clutter_actor_get_height (ClutterActor *self); -ClutterUnit clutter_actor_get_heightu (ClutterActor *self); +gfloat clutter_actor_get_width (ClutterActor *self); +gfloat clutter_actor_get_height (ClutterActor *self); void clutter_actor_set_width (ClutterActor *self, - guint width); -void clutter_actor_set_widthu (ClutterActor *self, - ClutterUnit width); + gfloat width); void clutter_actor_set_height (ClutterActor *self, - guint height); -void clutter_actor_set_heightu (ClutterActor *self, - ClutterUnit height); -gint clutter_actor_get_x (ClutterActor *self); -ClutterUnit clutter_actor_get_xu (ClutterActor *self); -gint clutter_actor_get_y (ClutterActor *self); -ClutterUnit clutter_actor_get_yu (ClutterActor *self); + gfloat height); +gfloat clutter_actor_get_x (ClutterActor *self); +gfloat clutter_actor_get_y (ClutterActor *self); void clutter_actor_set_x (ClutterActor *self, - gint x); -void clutter_actor_set_xu (ClutterActor *self, - ClutterUnit x); + gfloat x); void clutter_actor_set_y (ClutterActor *self, - gint y); -void clutter_actor_set_yu (ClutterActor *self, - ClutterUnit y); + gfloat y); void clutter_actor_set_rotation (ClutterActor *self, ClutterRotateAxis axis, gdouble angle, - gint x, - gint y, - gint z); -void clutter_actor_set_rotationu (ClutterActor *self, - ClutterRotateAxis axis, - gdouble angle, - ClutterUnit x, - ClutterUnit y, - ClutterUnit z); + gfloat x, + gfloat y, + gfloat z); void clutter_actor_set_z_rotation_from_gravity (ClutterActor *self, gdouble angle, ClutterGravity gravity); gdouble clutter_actor_get_rotation (ClutterActor *self, ClutterRotateAxis axis, - gint *x, - gint *y, - gint *z); -gdouble clutter_actor_get_rotationu (ClutterActor *self, - ClutterRotateAxis axis, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *z); + gfloat *x, + gfloat *y, + gfloat *z); ClutterGravity clutter_actor_get_z_rotation_gravity (ClutterActor *self); void clutter_actor_set_opacity (ClutterActor *self, guint8 opacity); guint8 clutter_actor_get_opacity (ClutterActor *self); + guint8 clutter_actor_get_paint_opacity (ClutterActor *self); gboolean clutter_actor_get_paint_visibility (ClutterActor *self); @@ -441,27 +401,17 @@ G_CONST_RETURN gchar *clutter_actor_get_name (ClutterActor guint32 clutter_actor_get_gid (ClutterActor *self); void clutter_actor_set_clip (ClutterActor *self, - gint xoff, - gint yoff, - gint width, - gint height); -void clutter_actor_set_clipu (ClutterActor *self, - ClutterUnit xoff, - ClutterUnit yoff, - ClutterUnit width, - ClutterUnit height); + gfloat xoff, + gfloat yoff, + gfloat width, + gfloat height); void clutter_actor_remove_clip (ClutterActor *self); gboolean clutter_actor_has_clip (ClutterActor *self); void clutter_actor_get_clip (ClutterActor *self, - gint *xoff, - gint *yoff, - gint *width, - gint *height); -void clutter_actor_get_clipu (ClutterActor *self, - ClutterUnit *xoff, - ClutterUnit *yoff, - ClutterUnit *width, - ClutterUnit *height); + gfloat *xoff, + gfloat *yoff, + gfloat *width, + gfloat *height); void clutter_actor_set_parent (ClutterActor *self, ClutterActor *parent); @@ -478,11 +428,8 @@ void clutter_actor_lower (ClutterActor void clutter_actor_raise_top (ClutterActor *self); void clutter_actor_lower_bottom (ClutterActor *self); void clutter_actor_set_depth (ClutterActor *self, - gint depth); -gint clutter_actor_get_depth (ClutterActor *self); -void clutter_actor_set_depthu (ClutterActor *self, - ClutterUnit depth); -ClutterUnit clutter_actor_get_depthu (ClutterActor *self); + gfloat depth); +gfloat clutter_actor_get_depth (ClutterActor *self); void clutter_actor_set_scale (ClutterActor *self, gdouble scale_x, @@ -490,13 +437,8 @@ void clutter_actor_set_scale (ClutterActor void clutter_actor_set_scale_full (ClutterActor *self, gdouble scale_x, gdouble scale_y, - int center_x, - int center_y); -void clutter_actor_set_scale_fullu (ClutterActor *self, - gdouble scale_x, - gdouble scale_y, - ClutterUnit center_x, - ClutterUnit center_y); + gfloat center_x, + gfloat center_y); void clutter_actor_set_scale_with_gravity (ClutterActor *self, gdouble scale_x, gdouble scale_y, @@ -505,19 +447,13 @@ void clutter_actor_get_scale (ClutterActor gdouble *scale_x, gdouble *scale_y); void clutter_actor_get_scale_center (ClutterActor *self, - gint *center_x, - gint *center_y); -void clutter_actor_get_scale_centeru (ClutterActor *self, - ClutterUnit *center_x, - ClutterUnit *center_y); + gfloat *center_x, + gfloat *center_y); ClutterGravity clutter_actor_get_scale_gravity (ClutterActor *self); void clutter_actor_move_by (ClutterActor *self, - gint dx, - gint dy); -void clutter_actor_move_byu (ClutterActor *self, - ClutterUnit dx, - ClutterUnit dy); + gfloat dx, + gfloat dy); void clutter_actor_set_reactive (ClutterActor *actor, gboolean reactive); @@ -543,34 +479,25 @@ void clutter_actor_set_shader_param_float (ClutterActor gfloat value); void clutter_actor_set_anchor_point (ClutterActor *self, - gint anchor_x, - gint anchor_y); + gfloat anchor_x, + gfloat anchor_y); void clutter_actor_move_anchor_point (ClutterActor *self, - gint anchor_x, - gint anchor_y); + gfloat anchor_x, + gfloat anchor_y); void clutter_actor_get_anchor_point (ClutterActor *self, - gint *anchor_x, - gint *anchor_y); + gfloat *anchor_x, + gfloat *anchor_y); ClutterGravity clutter_actor_get_anchor_point_gravity (ClutterActor *self); -void clutter_actor_set_anchor_pointu (ClutterActor *self, - ClutterUnit anchor_x, - ClutterUnit anchor_y); -void clutter_actor_move_anchor_pointu (ClutterActor *self, - ClutterUnit anchor_x, - ClutterUnit anchor_y); -void clutter_actor_get_anchor_pointu (ClutterActor *self, - ClutterUnit *anchor_x, - ClutterUnit *anchor_y); void clutter_actor_set_anchor_point_from_gravity (ClutterActor *self, ClutterGravity gravity); void clutter_actor_move_anchor_point_from_gravity (ClutterActor *self, ClutterGravity gravity); gboolean clutter_actor_transform_stage_point (ClutterActor *self, - ClutterUnit x, - ClutterUnit y, - ClutterUnit *x_out, - ClutterUnit *y_out); + gfloat x, + gfloat y, + gfloat *x_out, + gfloat *y_out); gboolean clutter_actor_is_rotated (ClutterActor *self); gboolean clutter_actor_is_scaled (ClutterActor *self); gboolean clutter_actor_should_pick_paint (ClutterActor *self); diff --git a/clutter/clutter-animation.c b/clutter/clutter-animation.c index 24b9c3f08..59076e847 100644 --- a/clutter/clutter-animation.c +++ b/clutter/clutter-animation.c @@ -1196,6 +1196,9 @@ clutter_animation_get_timeline (ClutterAnimation *animation) * the current values of the #ClutterAnimation:mode and * #ClutterAnimation:timeline properties. * + * If @alpha is not %NULL, the #ClutterAnimation will take ownership + * of the #ClutterAlpha instance. + * * Since: 1.0 */ void diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index becf9972f..3a02e7794 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -61,7 +61,8 @@ struct _ClutterBackendPrivate guint double_click_distance; gdouble resolution; - gdouble units_per_em; + + gfloat units_per_em; cairo_font_options_t *font_options; @@ -133,12 +134,12 @@ update_units_per_em (ClutterBackend *backend) } /* 10 points at 96 DPI is 12 pixels */ - priv->units_per_em = 1.2 * font_size + priv->units_per_em = 1.2f * font_size * dpi - / 96.0; + / 96.0f; } else - priv->units_per_em = -1.0; + priv->units_per_em = -1.0f; } static void @@ -359,7 +360,7 @@ _clutter_backend_init_events (ClutterBackend *backend) klass->init_events (backend); } -ClutterUnit +gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend) { ClutterBackendPrivate *priv; diff --git a/clutter/clutter-behaviour.c b/clutter/clutter-behaviour.c index c3ef6b2af..99156a7f6 100644 --- a/clutter/clutter-behaviour.c +++ b/clutter/clutter-behaviour.c @@ -552,13 +552,16 @@ notify_cb (GObject *object, * @behave: a #ClutterBehaviour * @alpha: a #ClutterAlpha or %NULL to unset a previously set alpha * - * Binds @alpha to a #ClutterBehaviour. The #ClutterAlpha object + * Binds @alpha to a #ClutterBehaviour. The #ClutterAlpha object * is what makes a behaviour work: for each tick of the timeline * used by #ClutterAlpha a new value of the alpha parameter is * computed by the alpha function; the value should be used by * the #ClutterBehaviour to update one or more properties of the * actors to which the behaviour applies. * + * If @alpha is not %NULL, the #ClutterBehaviour will take ownership + * of the #ClutterAlpha instance. + * * Since: 0.2 */ void diff --git a/clutter/clutter-cairo-texture.c b/clutter/clutter-cairo-texture.c index f638ff9c9..ab3f46445 100644 --- a/clutter/clutter-cairo-texture.c +++ b/clutter/clutter-cairo-texture.c @@ -319,9 +319,9 @@ clutter_cairo_texture_notify (GObject *object, static void clutter_cairo_texture_get_preferred_width (ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width, - ClutterUnit *natural_width) + gfloat for_height, + gfloat *min_width, + gfloat *natural_width) { ClutterCairoTexturePrivate *priv = CLUTTER_CAIRO_TEXTURE (actor)->priv; @@ -329,14 +329,14 @@ clutter_cairo_texture_get_preferred_width (ClutterActor *actor, *min_width = 0; if (natural_width) - *natural_width = CLUTTER_UNITS_FROM_DEVICE (priv->width); + *natural_width = (gfloat) priv->width; } static void clutter_cairo_texture_get_preferred_height (ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height, - ClutterUnit *natural_height) + gfloat for_width, + gfloat *min_height, + gfloat *natural_height) { ClutterCairoTexturePrivate *priv = CLUTTER_CAIRO_TEXTURE (actor)->priv; @@ -344,7 +344,7 @@ clutter_cairo_texture_get_preferred_height (ClutterActor *actor, *min_height = 0; if (natural_height) - *natural_height = CLUTTER_UNITS_FROM_DEVICE (priv->height); + *natural_height = (gfloat) priv->height; } static void diff --git a/clutter/clutter-clone.c b/clutter/clutter-clone.c index 16bd60be1..a8ba17cd4 100644 --- a/clutter/clutter-clone.c +++ b/clutter/clutter-clone.c @@ -69,14 +69,14 @@ static void clutter_clone_set_source_internal (ClutterClone *clone, ClutterActor *source); static void clutter_clone_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; ClutterActor *clone_source = priv->clone_source; - if (G_UNLIKELY (clone_source == NULL)) + if (clone_source == NULL) { if (min_width_p) *min_width_p = 0; @@ -93,14 +93,14 @@ clutter_clone_get_preferred_width (ClutterActor *self, static void clutter_clone_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterClonePrivate *priv = CLUTTER_CLONE (self)->priv; ClutterActor *clone_source = priv->clone_source; - if (G_UNLIKELY (clone_source == NULL)) + if (clone_source == NULL) { if (min_height_p) *min_height_p = 0; diff --git a/clutter/clutter-deprecated.h b/clutter/clutter-deprecated.h index 8e99ab951..8d0c99787 100644 --- a/clutter/clutter-deprecated.h +++ b/clutter/clutter-deprecated.h @@ -148,4 +148,24 @@ #define clutter_shader_set_uniform_1f clutter_shader_set_uniform_1f_REPLACED_BY_clutter_shader_set_uniform +#define clutter_actor_set_xu clutter_actor_set_xu_DEPRECATED_BY_clutter_actor_set_x +#define clutter_actor_set_yu clutter_actor_set_yu_DEPRECATED_BY_clutter_actor_set_y +#define clutter_actor_set_widthu clutter_actor_set_widthu_DEPRECATED_BY_clutter_actor_set_width +#define clutter_actor_set_heightu clutter_actor_set_heightu_DEPRECATED_BY_clutter_actor_set_height +#define clutter_actor_set_depthu clutter_actor_set_depthu_DEPRECATED_BY_clutter_actor_set_depth +#define clutter_actor_set_positionu clutter_actor_set_positionu_DEPRECATED_BY_clutter_actor_set_position +#define clutter_actor_set_sizeu clutter_actor_set_sizeu_DEPRECATED_BY_clutter_actor_set_size + +#define clutter_actor_set_anchor_pointu clutter_actor_set_anchor_pointu_DEPRECATED_BY_clutter_actor_set_anchor_point +#define clutter_actor_get_anchor_pointu clutter_actor_get_anchor_pointu_DEPRECATED_BY_clutter_actor_get_anchor_point +#define clutter_actor_move_byu clutter_actor_move_byu_DEPRECATED_BY_clutter_actor_move_by + +#define clutter_actor_get_xu clutter_actor_get_xu_DEPRECATED_BY_clutter_actor_get_x +#define clutter_actor_get_yu clutter_actor_get_yu_DEPRECATED_BY_clutter_actor_get_y +#define clutter_actor_get_widthu clutter_actor_get_widthu_DEPRECATED_BY_clutter_actor_get_width +#define clutter_actor_get_heightu clutter_actor_get_heightu_DEPRECATED_BY_clutter_actor_get_height +#define clutter_actor_get_depthu clutter_actor_get_depthu_DEPRECATED_BY_clutter_actor_get_depth +#define clutter_actor_get_positionu clutter_actor_get_positionu_DEPRECATED_BY_clutter_actor_get_position +#define clutter_actor_get_sizeu clutter_actor_get_sizeu_DEPRECATED_BY_clutter_actor_get_size + #endif /* CLUTTER_DEPRECATED_H */ diff --git a/clutter/clutter-event.c b/clutter/clutter-event.c index a275c4da9..84db43b39 100644 --- a/clutter/clutter-event.c +++ b/clutter/clutter-event.c @@ -119,10 +119,10 @@ clutter_event_get_state (ClutterEvent *event) */ void clutter_event_get_coords (ClutterEvent *event, - gint *x, - gint *y) + gfloat *x, + gfloat *y) { - gint event_x, event_y; + gfloat event_x, event_y; g_return_if_fail (event != NULL); @@ -140,15 +140,18 @@ clutter_event_get_coords (ClutterEvent *event, case CLUTTER_ENTER: case CLUTTER_LEAVE: break; + case CLUTTER_BUTTON_PRESS: case CLUTTER_BUTTON_RELEASE: event_x = event->button.x; event_y = event->button.y; break; + case CLUTTER_MOTION: event_x = event->motion.x; event_y = event->motion.y; break; + case CLUTTER_SCROLL: event_x = event->scroll.x; event_y = event->scroll.y; diff --git a/clutter/clutter-event.h b/clutter/clutter-event.h index 34583e7ee..984bdb194 100644 --- a/clutter/clutter-event.h +++ b/clutter/clutter-event.h @@ -221,8 +221,8 @@ typedef struct _ClutterInputDevice ClutterInputDevice; */ struct _ClutterAnyEvent { - ClutterEventType type; - guint32 time; + ClutterEventType type; + guint32 time; ClutterEventFlags flags; ClutterStage *stage; ClutterActor *source; @@ -290,8 +290,8 @@ struct _ClutterButtonEvent ClutterEventFlags flags; ClutterStage *stage; ClutterActor *source; - gint x; - gint y; + gfloat x; + gfloat y; ClutterModifierType modifier_state; guint32 button; guint click_count; @@ -322,8 +322,8 @@ struct _ClutterCrossingEvent ClutterEventFlags flags; ClutterStage *stage; ClutterActor *source; - gint x; - gint y; + gfloat x; + gfloat y; ClutterInputDevice *device; /* future use */ ClutterActor *related; }; @@ -352,8 +352,8 @@ struct _ClutterMotionEvent ClutterEventFlags flags; ClutterStage *stage; ClutterActor *source; - gint x; - gint y; + gfloat x; + gfloat y; ClutterModifierType modifier_state; gdouble *axes; /* Future use */ ClutterInputDevice *device; /* Future use */ @@ -384,8 +384,8 @@ struct _ClutterScrollEvent ClutterEventFlags flags; ClutterStage *stage; ClutterActor *source; - gint x; - gint y; + gfloat x; + gfloat y; ClutterScrollDirection direction; ClutterModifierType modifier_state; gdouble *axes; /* future use */ @@ -451,8 +451,8 @@ ClutterEventType clutter_event_type (ClutterEvent *event); guint32 clutter_event_get_time (ClutterEvent *event); ClutterModifierType clutter_event_get_state (ClutterEvent *event); void clutter_event_get_coords (ClutterEvent *event, - gint *x, - gint *y); + gfloat *x, + gfloat *y); gint clutter_event_get_device_id (ClutterEvent *event); ClutterActor* clutter_event_get_source (ClutterEvent *event); diff --git a/clutter/clutter-group.c b/clutter/clutter-group.c index a6a15d4ee..8e528501c 100644 --- a/clutter/clutter-group.c +++ b/clutter/clutter-group.c @@ -120,13 +120,13 @@ clutter_group_pick (ClutterActor *actor, } static void -clutter_fixed_layout_get_preferred_width (GList *children, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) +clutter_fixed_layout_get_preferred_width (GList *children, + gfloat *min_width_p, + gfloat *natural_width_p) { GList *l; - ClutterUnit min_left, min_right; - ClutterUnit natural_left, natural_right; + gfloat min_left, min_right; + gfloat natural_left, natural_right; min_left = 0; min_right = 0; @@ -136,9 +136,9 @@ clutter_fixed_layout_get_preferred_width (GList *children, for (l = children; l != NULL; l = l->next) { ClutterActor *child = l->data; - ClutterUnit child_x, child_min, child_natural; + gfloat child_x, child_min, child_natural; - child_x = clutter_actor_get_xu (child); + child_x = clutter_actor_get_x (child); clutter_actor_get_preferred_size (child, &child_min, NULL, @@ -196,13 +196,13 @@ clutter_fixed_layout_get_preferred_width (GList *children, } static void -clutter_fixed_layout_get_preferred_height (GList *children, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) +clutter_fixed_layout_get_preferred_height (GList *children, + gfloat *min_height_p, + gfloat *natural_height_p) { GList *l; - ClutterUnit min_top, min_bottom; - ClutterUnit natural_top, natural_bottom; + gfloat min_top, min_bottom; + gfloat natural_top, natural_bottom; min_top = 0; min_bottom = 0; @@ -212,9 +212,9 @@ clutter_fixed_layout_get_preferred_height (GList *children, for (l = children; l != NULL; l = l->next) { ClutterActor *child = l->data; - ClutterUnit child_y, child_min, child_natural; + gfloat child_y, child_min, child_natural; - child_y = clutter_actor_get_yu (child); + child_y = clutter_actor_get_y (child); clutter_actor_get_preferred_size (child, NULL, &child_min, @@ -286,9 +286,9 @@ clutter_fixed_layout_allocate (GList *children, static void clutter_group_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterGroupPrivate *priv = CLUTTER_GROUP (self)->priv; @@ -300,9 +300,9 @@ clutter_group_get_preferred_width (ClutterActor *self, static void clutter_group_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterGroupPrivate *priv = CLUTTER_GROUP (self)->priv; diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 9e0163a51..9c693e59e 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -119,7 +119,7 @@ clutter_get_show_fps (void) void _clutter_stage_maybe_relayout (ClutterActor *stage) { - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; ClutterActorBox box = { 0, }; /* avoid reentrancy */ @@ -140,8 +140,8 @@ _clutter_stage_maybe_relayout (ClutterActor *stage) box.y2 = natural_height; CLUTTER_NOTE (ACTOR, "Allocating (0, 0 - %d, %d) for the stage", - CLUTTER_UNITS_TO_DEVICE (natural_width), - CLUTTER_UNITS_TO_DEVICE (natural_height)); + (int) natural_width, + (int) natural_height); clutter_actor_allocate (stage, &box, FALSE); @@ -155,7 +155,7 @@ _clutter_stage_maybe_setup_viewport (ClutterStage *stage) if (CLUTTER_PRIVATE_FLAGS (stage) & CLUTTER_ACTOR_SYNC_MATRICES) { ClutterPerspective perspective; - guint width, height; + gfloat width, height; clutter_actor_get_size (CLUTTER_ACTOR (stage), &width, &height); clutter_stage_get_perspective (stage, &perspective); @@ -1931,8 +1931,8 @@ generate_enter_leave_events (ClutterEvent *event) { if (motion_current_actor) { - gint x, y; ClutterEvent cev; + gfloat x, y; cev.crossing.device = device; clutter_event_get_coords (event, &x, &y); @@ -2153,7 +2153,7 @@ clutter_do_event (ClutterEvent *event) case CLUTTER_SCROLL: { ClutterActor *actor; - gint x,y; + gfloat x, y; clutter_event_get_coords (event, &x, &y); @@ -2170,7 +2170,7 @@ clutter_do_event (ClutterEvent *event) if (event->type == CLUTTER_BUTTON_RELEASE) { CLUTTER_NOTE (EVENT, - "Release off stage received at %i, %i", + "Release off stage received at %.2f, %.2f", x, y); event->button.source = stage; @@ -2196,12 +2196,14 @@ clutter_do_event (ClutterEvent *event) /* FIXME: for an optimisation should check if there are - * actually any reactive actors and avoid the pick all togeather + * actually any reactive actors and avoid the pick all together * (signalling just the stage). Should be big help for gles. */ - CLUTTER_NOTE (EVENT, "Reactive event received at %i, %i - actor: %p", - x, y, actor); + CLUTTER_NOTE (EVENT, + "Reactive event received at %.2f, %.2f - actor: %p", + x, y, + actor); /* Create, enter/leave events if needed */ generate_enter_leave_events (event); diff --git a/clutter/clutter-private.h b/clutter/clutter-private.h index e669a640b..95b39e3b7 100644 --- a/clutter/clutter-private.h +++ b/clutter/clutter-private.h @@ -193,15 +193,15 @@ void _clutter_backend_init_events (ClutterBackend *backend); ClutterFeatureFlags _clutter_backend_get_features (ClutterBackend *backend); -ClutterUnit _clutter_backend_get_units_per_em (ClutterBackend *backend); +gfloat _clutter_backend_get_units_per_em (ClutterBackend *backend); void _clutter_feature_init (void); /* Picking code */ -ClutterActor *_clutter_do_pick (ClutterStage *stage, - gint x, - gint y, - ClutterPickMode mode); +ClutterActor *_clutter_do_pick (ClutterStage *stage, + gint x, + gint y, + ClutterPickMode mode); guint _clutter_pixel_to_id (guchar pixel[4]); diff --git a/clutter/clutter-stage.c b/clutter/clutter-stage.c index 2f9320d9d..5908241f4 100644 --- a/clutter/clutter-stage.c +++ b/clutter/clutter-stage.c @@ -127,9 +127,9 @@ static const ClutterColor default_stage_color = { 255, 255, 255, 255 }; static void clutter_stage_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; @@ -143,9 +143,9 @@ clutter_stage_get_preferred_width (ClutterActor *self, static void clutter_stage_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStagePrivate *priv = CLUTTER_STAGE (self)->priv; @@ -169,13 +169,14 @@ clutter_stage_allocate (ClutterActor *self, * then we simply ignore any allocation request and override the * allocation chain. */ - if (G_LIKELY (!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))) + if ((!clutter_feature_available (CLUTTER_FEATURE_STAGE_STATIC))) { ClutterActorClass *klass; - CLUTTER_NOTE (ACTOR, "Following allocation to %dx%d (origin %s)", - CLUTTER_UNITS_TO_DEVICE (box->x2 - box->x1), - CLUTTER_UNITS_TO_DEVICE (box->y2 - box->y1), + CLUTTER_NOTE (LAYOUT, + "Following allocation to %dx%d (origin %s)", + (int) (box->x2 - box->x1), + (int) (box->y2 - box->y1), origin_changed ? "changed" : "not changed"); klass = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class); @@ -188,7 +189,7 @@ clutter_stage_allocate (ClutterActor *self, { ClutterActorBox override = { 0, }; ClutterActorClass *klass; - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; /* propagate the allocation */ klass = CLUTTER_ACTOR_GET_CLASS (priv->impl); @@ -204,6 +205,15 @@ clutter_stage_allocate (ClutterActor *self, override.x2 = natural_width; override.y2 = natural_height; + CLUTTER_NOTE (LAYOUT, + "Overrigin original allocation of %dx%d " + "with %dx%d (origin %s)", + (int) (box->x2 - box->x1), + (int) (box->y2 - box->y1), + (int) (override.x2), + (int) (override.y2), + origin_changed ? "changed" : "not changed"); + /* and store the overridden allocation */ klass = CLUTTER_ACTOR_CLASS (clutter_stage_parent_class); klass->allocate (self, &override, origin_changed); @@ -320,7 +330,7 @@ static void clutter_stage_real_fullscreen (ClutterStage *stage) { ClutterStagePrivate *priv = stage->priv; - ClutterUnit natural_width, natural_height; + gfloat natural_width, natural_height; ClutterActorBox box; /* we need to force an allocation here because the size diff --git a/clutter/clutter-text.c b/clutter/clutter-text.c index 9ece4b8d7..4e9ded547 100644 --- a/clutter/clutter-text.c +++ b/clutter/clutter-text.c @@ -87,10 +87,10 @@ struct _LayoutCache PangoLayout *layout; /* The width that was used to generate this layout */ - ClutterUnit width; + gfloat width; /* The height that was used to generate this layout */ - ClutterUnit height; + gfloat height; /* A number representing the age of this cache (so that when a * new layout is needed the last used cache is replaced) @@ -240,8 +240,8 @@ clutter_text_clear_selection (ClutterText *self) static PangoLayout * clutter_text_create_layout_no_cache (ClutterText *text, - ClutterUnit allocation_width, - ClutterUnit allocation_height) + gfloat allocation_width, + gfloat allocation_height) { ClutterTextPrivate *priv = text->priv; PangoLayout *layout; @@ -386,8 +386,8 @@ clutter_text_font_changed_cb (ClutterText *text) */ static PangoLayout * clutter_text_create_layout (ClutterText *text, - ClutterUnit allocation_width, - ClutterUnit allocation_height) + gfloat allocation_width, + gfloat allocation_height) { ClutterTextPrivate *priv = text->priv; LayoutCache *oldest_cache = priv->cached_layouts; @@ -484,9 +484,9 @@ clutter_text_coords_to_position (ClutterText *text, static gboolean clutter_text_position_to_coords (ClutterText *self, gint position, - ClutterUnit *x, - ClutterUnit *y, - ClutterUnit *line_height) + gfloat *x, + gfloat *y, + gfloat *line_height) { ClutterTextPrivate *priv = self->priv; PangoRectangle rect; @@ -535,7 +535,7 @@ static inline void clutter_text_ensure_cursor_position (ClutterText *self) { ClutterTextPrivate *priv = self->priv; - ClutterUnit x, y, cursor_height; + gfloat x, y, cursor_height; ClutterGeometry cursor_pos = { 0, }; gboolean x_changed, y_changed; gboolean width_changed, height_changed; @@ -922,7 +922,7 @@ cursor_paint (ClutterText *self) gint i; gint index_; gint maxindex; - ClutterUnit y, height; + gfloat y, height; line = pango_layout_get_line_readonly (layout, line_no); pango_layout_line_x_to_index (line, G_MAXINT, &maxindex, NULL); @@ -1119,7 +1119,7 @@ clutter_text_button_press (ClutterActor *actor, ClutterText *self = CLUTTER_TEXT (actor); ClutterTextPrivate *priv = self->priv; gboolean res = FALSE; - ClutterUnit x, y; + gfloat x, y; gint index_; /* we'll steal keyfocus if we do not have it */ @@ -1186,9 +1186,9 @@ clutter_text_motion (ClutterActor *actor, { ClutterText *ttext = CLUTTER_TEXT (actor); ClutterTextPrivate *priv = ttext->priv; - ClutterUnit x, y; - gint index_; - const gchar *text; + gfloat x, y; + gint index_; + const gchar *text; if (!priv->in_select_drag) return FALSE; @@ -1401,16 +1401,16 @@ clutter_text_paint (ClutterActor *self) static void clutter_text_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterText *text = CLUTTER_TEXT (self); ClutterTextPrivate *priv = text->priv; PangoRectangle logical_rect = { 0, }; PangoLayout *layout; gint logical_width; - ClutterUnit layout_width; + gfloat layout_width; layout = clutter_text_create_layout (text, -1, -1); @@ -1440,9 +1440,9 @@ clutter_text_get_preferred_width (ClutterActor *self, static void clutter_text_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterText *text = CLUTTER_TEXT (self); @@ -1459,7 +1459,7 @@ clutter_text_get_preferred_height (ClutterActor *self, PangoLayout *layout; PangoRectangle logical_rect = { 0, }; gint logical_height; - ClutterUnit layout_height; + gfloat layout_height; layout = clutter_text_create_layout (text, for_width, -1); @@ -3284,11 +3284,11 @@ clutter_text_set_markup (ClutterText *self, PangoLayout * clutter_text_get_layout (ClutterText *self) { - ClutterUnit width, height; + gfloat width, height; g_return_val_if_fail (CLUTTER_IS_TEXT (self), NULL); - clutter_actor_get_sizeu (CLUTTER_ACTOR (self), &width, &height); + clutter_actor_get_size (CLUTTER_ACTOR (self), &width, &height); return clutter_text_create_layout (self, width, height); } diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index 50c2e5de0..147261dc0 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -77,8 +77,8 @@ typedef struct _ClutterTextureAsyncData ClutterTextureAsyncData; struct _ClutterTexturePrivate { - gint width; - gint height; + gfloat width; + gfloat height; gint max_tile_waste; ClutterTextureQuality filter_quality; CoglHandle material; @@ -351,9 +351,9 @@ clutter_texture_realize (ClutterActor *actor) static void clutter_texture_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterTexture *texture = CLUTTER_TEXTURE (self); ClutterTexturePrivate *priv = texture->priv; @@ -370,19 +370,14 @@ clutter_texture_get_preferred_width (ClutterActor *self, for_height < 0 || priv->height <= 0) { - *natural_width_p = CLUTTER_UNITS_FROM_DEVICE (priv->width); + *natural_width_p = priv->width; } else { /* Set the natural width so as to preserve the aspect ratio */ - gfloat ratio, height; + gfloat ratio = priv->width / priv->height; - ratio = (float)(priv->width) / (float)(priv->height); - - height = CLUTTER_UNITS_TO_FLOAT (for_height); - - *natural_width_p = - CLUTTER_UNITS_FROM_FLOAT (ratio * height); + *natural_width_p = ratio * for_height; } } } @@ -395,9 +390,9 @@ clutter_texture_get_preferred_width (ClutterActor *self, static void clutter_texture_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterTexture *texture = CLUTTER_TEXTURE (self); ClutterTexturePrivate *priv = texture->priv; @@ -414,19 +409,14 @@ clutter_texture_get_preferred_height (ClutterActor *self, for_width < 0 || priv->width <= 0) { - *natural_height_p = CLUTTER_UNITS_FROM_DEVICE (priv->height); + *natural_height_p = priv->height; } else { /* Set the natural height so as to preserve the aspect ratio */ - gfloat ratio, width; + gfloat ratio = priv->height / priv->width; - ratio = (float)(priv->height) / (float)(priv->width); - - width = CLUTTER_UNITS_TO_FLOAT (for_width); - - *natural_height_p = - CLUTTER_UNITS_FROM_FLOAT (ratio * width); + *natural_height_p = ratio * for_width; } } } @@ -460,7 +450,7 @@ clutter_texture_set_fbo_projection (ClutterActor *self) ClutterTexturePrivate *priv = CLUTTER_TEXTURE (self)->priv; ClutterVertex verts[4]; gfloat viewport[4]; - ClutterUnit x_min, x_max, y_min, y_max; + gfloat x_min, x_max, y_min, y_max; gfloat tx_min, tx_max, ty_min, ty_max; gfloat tan_angle, near_size; ClutterPerspective perspective; @@ -495,13 +485,13 @@ clutter_texture_set_fbo_projection (ClutterActor *self) /* Convert the coordinates back to [-1,1] range */ cogl_get_viewport (viewport); - tx_min = (CLUTTER_UNITS_TO_FLOAT (x_min) / viewport[2]) + tx_min = (x_min / viewport[2]) * 2 - 1.0; - tx_max = (CLUTTER_UNITS_TO_FLOAT (x_max) / viewport[2]) + tx_max = (x_max / viewport[2]) * 2 - 1.0; - ty_min = (CLUTTER_UNITS_TO_FLOAT (y_min) / viewport[3]) + ty_min = (y_min / viewport[3]) * 2 - 1.0; - ty_max = (CLUTTER_UNITS_TO_FLOAT (y_max) / viewport[3]) + ty_max = (y_max / viewport[3]) * 2 - 1.0; /* Set up a projection matrix so that the actor will be projected as @@ -558,8 +548,8 @@ clutter_texture_paint (ClutterActor *self) if ((stage = clutter_actor_get_stage (self))) { - guint stage_width, stage_height; - ClutterActor *source_parent; + gfloat stage_width, stage_height; + ClutterActor *source_parent; clutter_stage_get_perspective (CLUTTER_STAGE (stage), &perspective); clutter_actor_get_size (stage, &stage_width, &stage_height); @@ -571,6 +561,7 @@ clutter_texture_paint (ClutterActor *self) perspective.aspect, perspective.z_near, perspective.z_far); + /* Use a projection matrix that makes the actor appear as it would if it was rendered at its normal screen location */ clutter_texture_set_fbo_projection (self); @@ -1445,7 +1436,7 @@ clutter_texture_set_cogl_texture (ClutterTexture *texture, priv->width = width; priv->height = height; - CLUTTER_NOTE (TEXTURE, "set size %ix%i\n", + CLUTTER_NOTE (TEXTURE, "set size %.2fx%.2f\n", priv->width, priv->height); @@ -2310,7 +2301,7 @@ on_fbo_source_size_change (GObject *object, ClutterTexture *texture) { ClutterTexturePrivate *priv = texture->priv; - guint w, h; + gfloat w, h; clutter_actor_get_transformed_size (priv->fbo_source, &w, &h); @@ -2453,7 +2444,7 @@ clutter_texture_new_from_actor (ClutterActor *actor) { ClutterTexture *texture; ClutterTexturePrivate *priv; - guint w, h; + gfloat w, h; g_return_val_if_fail (CLUTTER_IS_ACTOR (actor), NULL); @@ -2523,8 +2514,8 @@ clutter_texture_new_from_actor (ClutterActor *actor) G_CALLBACK(on_fbo_parent_change), texture); - priv->width = w; - priv->height = h; + priv->width = w; + priv->height = h; clutter_actor_set_size (CLUTTER_ACTOR (texture), priv->width, priv->height); diff --git a/clutter/clutter-types.h b/clutter/clutter-types.h index 1d9ba450b..88921ad95 100644 --- a/clutter/clutter-types.h +++ b/clutter/clutter-types.h @@ -106,15 +106,15 @@ GType clutter_geometry_get_type (void) G_GNUC_CONST; * @y: Y coordinate of the vertex * @z: Z coordinate of the vertex * - * Vertex of an actor in 3D space, expressed in device independent units. + * Vertex of an actor in 3D space, expressed in pixels * * Since: 0.4 */ struct _ClutterVertex { - ClutterUnit x; - ClutterUnit y; - ClutterUnit z; + gfloat x; + gfloat y; + gfloat z; }; GType clutter_vertex_get_type (void) G_GNUC_CONST; diff --git a/clutter/eglnative/clutter-stage-egl.c b/clutter/eglnative/clutter-stage-egl.c index 7e766ed71..3d134b27d 100644 --- a/clutter/eglnative/clutter-stage-egl.c +++ b/clutter/eglnative/clutter-stage-egl.c @@ -221,9 +221,9 @@ clutter_stage_egl_realize (ClutterActor *actor) static void clutter_stage_egl_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self); @@ -236,9 +236,9 @@ clutter_stage_egl_get_preferred_width (ClutterActor *self, static void clutter_stage_egl_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self); diff --git a/clutter/fruity/clutter-stage-fruity.c b/clutter/fruity/clutter-stage-fruity.c index ea1603a58..76dc1351f 100644 --- a/clutter/fruity/clutter-stage-fruity.c +++ b/clutter/fruity/clutter-stage-fruity.c @@ -190,9 +190,9 @@ clutter_stage_egl_realize (ClutterActor *actor) static void clutter_stage_egl_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self); @@ -205,9 +205,9 @@ clutter_stage_egl_get_preferred_width (ClutterActor *self, static void clutter_stage_egl_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageEGL *stage_egl = CLUTTER_STAGE_EGL (self); diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index cb60b3676..b29070c5b 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -367,9 +367,9 @@ clutter_stage_osx_hide (ClutterActor *actor) static void clutter_stage_osx_get_preferred_width (ClutterActor *actor, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); gboolean is_resizable; @@ -394,9 +394,9 @@ clutter_stage_osx_get_preferred_width (ClutterActor *actor, static void clutter_stage_osx_get_preferred_height (ClutterActor *actor, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageOSX *self = CLUTTER_STAGE_OSX (actor); gboolean is_resizable; diff --git a/clutter/sdl/clutter-stage-sdl.c b/clutter/sdl/clutter-stage-sdl.c index 215c28307..43259b369 100644 --- a/clutter/sdl/clutter-stage-sdl.c +++ b/clutter/sdl/clutter-stage-sdl.c @@ -103,9 +103,9 @@ clutter_stage_sdl_realize (ClutterActor *actor) static void clutter_stage_sdl_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self); @@ -118,9 +118,9 @@ clutter_stage_sdl_get_preferred_width (ClutterActor *self, static void clutter_stage_sdl_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageSDL *stage_sdl = CLUTTER_STAGE_SDL (self); diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c index 7d233c6c2..f49549416 100644 --- a/clutter/win32/clutter-stage-win32.c +++ b/clutter/win32/clutter-stage-win32.c @@ -81,9 +81,9 @@ clutter_stage_win32_hide (ClutterActor *actor) static void clutter_stage_win32_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self); int width; @@ -105,9 +105,9 @@ clutter_stage_win32_get_preferred_width (ClutterActor *self, static void clutter_stage_win32_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageWin32 *stage_win32 = CLUTTER_STAGE_WIN32 (self); int height; diff --git a/clutter/x11/clutter-stage-x11.c b/clutter/x11/clutter-stage-x11.c index 56a33d9cf..9aff476a6 100644 --- a/clutter/x11/clutter-stage-x11.c +++ b/clutter/x11/clutter-stage-x11.c @@ -94,7 +94,7 @@ clutter_stage_x11_fix_window_size (ClutterStageX11 *stage_x11) if (stage_x11->xwin != None && stage_x11->is_foreign_xwin == FALSE) { XSizeHints *size_hints; - ClutterUnit min_width, min_height; + gfloat min_width, min_height; size_hints = XAllocSizeHints(); @@ -172,9 +172,9 @@ clutter_stage_x11_set_wm_protocols (ClutterStageX11 *stage_x11) static void clutter_stage_x11_get_preferred_width (ClutterActor *self, - ClutterUnit for_height, - ClutterUnit *min_width_p, - ClutterUnit *natural_width_p) + gfloat for_height, + gfloat *min_width_p, + gfloat *natural_width_p) { ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (self); gboolean resize; @@ -211,9 +211,9 @@ clutter_stage_x11_get_preferred_width (ClutterActor *self, static void clutter_stage_x11_get_preferred_height (ClutterActor *self, - ClutterUnit for_width, - ClutterUnit *min_height_p, - ClutterUnit *natural_height_p) + gfloat for_width, + gfloat *min_height_p, + gfloat *natural_height_p) { ClutterStageX11 *stage_x11 = CLUTTER_STAGE_X11 (self); gboolean resize; diff --git a/tests/conform/test-anchors.c b/tests/conform/test-anchors.c index f0211241f..f3118b4fd 100644 --- a/tests/conform/test-anchors.c +++ b/tests/conform/test-anchors.c @@ -417,8 +417,8 @@ test_rotate_center (TestState *state) gdouble angle_x, angle_y, angle_z; ClutterVertex *center_x, *center_y, *center_z; ClutterGravity z_center_gravity; - guint stage_width, stage_height; - gint rect_x, rect_y; + gfloat stage_width, stage_height; + gfloat rect_x, rect_y; int i; /* Position the rectangle at the center of the stage so that @@ -426,16 +426,17 @@ test_rotate_center (TestState *state) appear as a flat line. This makes verifying the transformations easier */ clutter_actor_get_size (clutter_actor_get_stage (rect), - &stage_width, &stage_height); + &stage_width, + &stage_height); rect_x = stage_width / 2; rect_y = stage_height / 2; clutter_actor_set_position (rect, rect_x, rect_y); /* Assert the default settings */ - g_assert (clutter_actor_get_x (rect) == rect_x); - g_assert (clutter_actor_get_y (rect) == rect_y); - g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); - g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); + g_assert_cmpfloat (clutter_actor_get_x (rect), ==, rect_x); + g_assert_cmpfloat (clutter_actor_get_y (rect), ==, rect_y); + g_assert_cmpfloat (clutter_actor_get_width (rect), ==, RECT_WIDTH); + g_assert_cmpfloat (clutter_actor_get_height (rect), ==, RECT_HEIGHT); g_object_get (rect, "rotation-angle-x", &angle_x, "rotation-angle-y", &angle_y, diff --git a/tests/conform/test-timeline-dup-frames.c b/tests/conform/test-timeline-dup-frames.c index 0d8c3ff3e..de41f1f0e 100644 --- a/tests/conform/test-timeline-dup-frames.c +++ b/tests/conform/test-timeline-dup-frames.c @@ -76,7 +76,6 @@ frame_tick (gpointer data) { TestState *state = data; GTimeVal cur_tick = { 0, }; - GSList *l; gulong msecs; g_get_current_time (&cur_tick); diff --git a/tests/conform/test-timeline-interpolate.c b/tests/conform/test-timeline-interpolate.c index 1e9ca1578..5779b0902 100644 --- a/tests/conform/test-timeline-interpolate.c +++ b/tests/conform/test-timeline-interpolate.c @@ -139,7 +139,6 @@ frame_tick (gpointer data) { TestState *state = data; GTimeVal cur_tick = { 0, }; - GSList *l; gulong msecs; g_get_current_time (&cur_tick); diff --git a/tests/conform/test-timeline-rewind.c b/tests/conform/test-timeline-rewind.c index b13aaa419..c46e7a5ff 100644 --- a/tests/conform/test-timeline-rewind.c +++ b/tests/conform/test-timeline-rewind.c @@ -75,7 +75,6 @@ frame_tick (gpointer data) { TestState *state = data; GTimeVal cur_tick = { 0, }; - GSList *l; gulong msecs; g_get_current_time (&cur_tick); diff --git a/tests/conform/test-timeline-smoothness.c b/tests/conform/test-timeline-smoothness.c index 9824c639d..ab34d7e4e 100644 --- a/tests/conform/test-timeline-smoothness.c +++ b/tests/conform/test-timeline-smoothness.c @@ -89,7 +89,6 @@ frame_tick (gpointer data) { TestState *state = data; GTimeVal cur_tick = { 0, }; - GSList *l; gulong msecs; g_get_current_time (&cur_tick); diff --git a/tests/interactive/test-actor-clone.c b/tests/interactive/test-actor-clone.c index 82fb8142e..92c7f79f8 100644 --- a/tests/interactive/test-actor-clone.c +++ b/tests/interactive/test-actor-clone.c @@ -48,12 +48,12 @@ input_cb (ClutterActor *stage, { ClutterButtonEvent *button_event; ClutterActor *e; - gint x, y; + gfloat x, y; clutter_event_get_coords (event, &x, &y); button_event = (ClutterButtonEvent *) event; - g_print ("*** button press event (button:%d) at %d, %d ***\n", + g_print ("*** button press event (button:%d) at %.2f, %.2f ***\n", button_event->button, x, y); diff --git a/tests/interactive/test-actors.c b/tests/interactive/test-actors.c index fcaa49275..eb2c49df3 100644 --- a/tests/interactive/test-actors.c +++ b/tests/interactive/test-actors.c @@ -48,12 +48,12 @@ input_cb (ClutterActor *stage, { ClutterButtonEvent *button_event; ClutterActor *e; - gint x, y; + gfloat x, y; clutter_event_get_coords (event, &x, &y); button_event = (ClutterButtonEvent *) event; - g_print ("*** button press event (button:%d) at %d, %d ***\n", + g_print ("*** button press event (button:%d) at %.2f, %.2f ***\n", button_event->button, x, y); diff --git a/tests/interactive/test-animation.c b/tests/interactive/test-animation.c index 54cf0fe89..032400f63 100644 --- a/tests/interactive/test-animation.c +++ b/tests/interactive/test-animation.c @@ -21,8 +21,8 @@ on_button_press (ClutterActor *actor, gpointer dummy) { ClutterAnimation *animation; - gint old_x, old_y, new_x, new_y; - guint old_width, old_height, new_width, new_height; + gfloat old_x, old_y, new_x, new_y; + gfloat old_width, old_height, new_width, new_height; gdouble new_angle; ClutterVertex vertex = { 0, }; ClutterColor new_color = { 0, }; @@ -65,10 +65,10 @@ on_button_press (ClutterActor *actor, animation = clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000, - "x", new_x, - "y", new_y, - "width", new_width, - "height", new_height, + "x", (int) new_x, + "y", (int) new_y, + "width", (int) new_width, + "height", (int) new_height, "color", &new_color, "rotation-angle-z", new_angle, "fixed::rotation-center-z", &vertex, diff --git a/tests/interactive/test-clutter-cairo-flowers.c b/tests/interactive/test-clutter-cairo-flowers.c index c66531672..746d62313 100644 --- a/tests/interactive/test-clutter-cairo-flowers.c +++ b/tests/interactive/test-clutter-cairo-flowers.c @@ -186,11 +186,11 @@ test_clutter_cairo_flowers_main (int argc, char **argv) { flowers[i] = g_new0(Flower, 1); flowers[i]->ctex = make_flower_actor(); - flowers[i]->x = rand() % clutter_actor_get_width(stage) - - (PETAL_MIN+PETAL_VAR)*2; - flowers[i]->y = rand() % clutter_actor_get_height(stage); - flowers[i]->rv = rand() % 5 + 1; - flowers[i]->v = rand() % 10 + 2; + flowers[i]->x = rand() % (int) clutter_actor_get_width (stage) + - (PETAL_MIN + PETAL_VAR) * 2; + flowers[i]->y = rand() % (int) clutter_actor_get_height (stage); + flowers[i]->rv = rand() % 5 + 1; + flowers[i]->v = rand() % 10 + 2; clutter_group_add (CLUTTER_GROUP(stage), flowers[i]->ctex); clutter_actor_set_position (flowers[i]->ctex, diff --git a/tests/interactive/test-depth.c b/tests/interactive/test-depth.c index 39799c4bd..2f8491077 100644 --- a/tests/interactive/test-depth.c +++ b/tests/interactive/test-depth.c @@ -26,7 +26,7 @@ raise_top (gpointer ignored) static ClutterActor * clone_box (ClutterActor *original) { - guint width, height; + gfloat width, height; ClutterActor *group; ClutterActor *clone; @@ -35,38 +35,39 @@ clone_box (ClutterActor *original) group = clutter_group_new (); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); - clutter_actor_set_depth (clone, width/2); + clutter_actor_set_depth (clone, width / 2); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); - clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 180, width/2, 0, 0); - clutter_actor_set_depth (clone, -(gint)width/2); + clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 180, width / 2, 0, 0); + clutter_actor_set_depth (clone, -width / 2); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0); - clutter_actor_set_depth (clone, width/2); + clutter_actor_set_depth (clone, width / 2); clutter_actor_set_position (clone, 0, 0); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_Y_AXIS, 90, 0, 0, 0); - clutter_actor_set_depth (clone, width/2); + clutter_actor_set_depth (clone, width / 2); clutter_actor_set_position (clone, width, 0); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0); - clutter_actor_set_depth (clone, -(gint)width/2); + clutter_actor_set_depth (clone, -width / 2); clutter_actor_set_position (clone, 0, height); clone = clutter_clone_new (original); clutter_container_add_actor (CLUTTER_CONTAINER (group), clone); clutter_actor_set_rotation (clone, CLUTTER_X_AXIS, 90, 0, 0, 0); - clutter_actor_set_depth (clone, -(gint)width/2); + clutter_actor_set_depth (clone, -width / 2); clutter_actor_set_position (clone, 0, 0); clutter_actor_show_all (group); + return group; } @@ -78,8 +79,8 @@ janus_group (const gchar *front_text, ClutterColor red = {0xff, 0x00, 0x00, 0xff}; ClutterColor green = {0x00, 0xff, 0x00, 0xff}; ClutterActor *group, *rectangle, *front, *back; - guint width, height; - guint width2, height2; + gfloat width, height; + gfloat width2, height2; group = clutter_group_new (); rectangle = clutter_rectangle_new_with_color (&slide_color); @@ -93,11 +94,12 @@ janus_group (const gchar *front_text, if (width2 > width) width = width2; + if (height2 > height) height = height2; clutter_actor_set_size (rectangle, width, height); - clutter_actor_set_rotation (back, CLUTTER_Y_AXIS, 180, width/2, 0, 0); + clutter_actor_set_rotation (back, CLUTTER_Y_AXIS, 180, width / 2, 0, 0); clutter_container_add (CLUTTER_CONTAINER (group), back, rectangle, front, NULL); diff --git a/tests/interactive/test-easing.c b/tests/interactive/test-easing.c index a8ff176f7..296812da3 100644 --- a/tests/interactive/test-easing.c +++ b/tests/interactive/test-easing.c @@ -53,8 +53,8 @@ on_button_press (ClutterActor *actor, if (event->button == 3) { gchar *text; - guint stage_width, stage_height; - guint label_width, label_height; + gfloat stage_width, stage_height; + gfloat label_width, label_height; current_mode = (current_mode + 1 < n_easing_modes) ? current_mode + 1 : 0; @@ -94,8 +94,8 @@ on_button_press (ClutterActor *actor, animation = clutter_actor_animate (rectangle, cur_mode, 2000, - "x", event->x, - "y", event->y, + "x", (int) event->x, + "y", (int) event->y, "color", &color, NULL); } @@ -110,8 +110,8 @@ test_easing_main (int argc, char *argv[]) ClutterColor stage_color = { 0x66, 0x66, 0xdd, 0xff }; ClutterColor rect_color = { 0x44, 0xdd, 0x44, 0xff }; gchar *text; - guint stage_width, stage_height; - guint label_width, label_height; + gfloat stage_width, stage_height; + gfloat label_width, label_height; clutter_init (&argc, &argv); diff --git a/tests/interactive/test-fullscreen.c b/tests/interactive/test-fullscreen.c index 36948cf74..2952a8eb4 100644 --- a/tests/interactive/test-fullscreen.c +++ b/tests/interactive/test-fullscreen.c @@ -15,7 +15,7 @@ static int state = START; static void on_fullscreen (ClutterStage *stage) { - g_debug ("fullscreen set, size: %dx%d, mapped: %s", + g_debug ("fullscreen set, size: %.2fx%.2f, mapped: %s", clutter_actor_get_width (CLUTTER_ACTOR (stage)), clutter_actor_get_height (CLUTTER_ACTOR (stage)), CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false"); @@ -24,7 +24,7 @@ on_fullscreen (ClutterStage *stage) static void on_unfullscreen (ClutterStage *stage) { - g_debug ("fullscreen unset, size: %dx%d, mapped: %s", + g_debug ("fullscreen unset, size: %.2fx%.2f, mapped: %s", clutter_actor_get_width (CLUTTER_ACTOR (stage)), clutter_actor_get_height (CLUTTER_ACTOR (stage)), CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false"); @@ -85,7 +85,7 @@ test_fullscreen_main (int argc, char *argv[]) clutter_stage_fullscreen (CLUTTER_STAGE (stage)); clutter_actor_show (stage); - g_debug ("stage size: %dx%d, mapped: %s", + g_debug ("stage size: %.2fx%.2f, mapped: %s", clutter_actor_get_width (stage), clutter_actor_get_height (stage), CLUTTER_ACTOR_IS_MAPPED (stage) ? "true" : "false"); diff --git a/tests/interactive/test-layout.c b/tests/interactive/test-layout.c index 25da8ef6a..ecd5ce8e4 100644 --- a/tests/interactive/test-layout.c +++ b/tests/interactive/test-layout.c @@ -237,7 +237,7 @@ my_thing_get_preferred_width (ClutterActor *self, child = l->data; - child_x = clutter_actor_get_xu (child); + child_x = clutter_actor_get_x (child); clutter_actor_get_preferred_size (child, &child_min, NULL, @@ -315,7 +315,7 @@ my_thing_get_preferred_height (ClutterActor *self, child = l->data; - child_y = clutter_actor_get_yu (child); + child_y = clutter_actor_get_y (child); clutter_actor_get_preferred_size (child, NULL, &child_min, @@ -490,8 +490,7 @@ my_thing_paint (ClutterActor *actor) g_assert (child != NULL); - if (CLUTTER_ACTOR_IS_VISIBLE (child)) - clutter_actor_paint (child); + clutter_actor_paint (child); } cogl_pop_matrix(); @@ -748,7 +747,7 @@ test_layout_main (int argc, char *argv[]) { ClutterActor *stage, *instructions; ClutterAlpha *alpha; - gint i; + gint i, size; GError *error = NULL; clutter_init (&argc, &argv); @@ -776,7 +775,12 @@ test_layout_main (int argc, char *argv[]) if (error) g_error ("Unable to load 'redhand.png': %s", error->message); - for (i = 0; i < 33; i++) + size = g_random_int_range (MIN_SIZE, MAX_SIZE); + clutter_actor_set_size (icon, size, size); + clutter_behaviour_apply (behaviour, icon); + clutter_container_add_actor (CLUTTER_CONTAINER (box), icon); + + for (i = 1; i < 33; i++) { ClutterActor *clone = create_item (); diff --git a/tests/interactive/test-paint-wrapper.c b/tests/interactive/test-paint-wrapper.c index ac650d6c8..ac346f5da 100644 --- a/tests/interactive/test-paint-wrapper.c +++ b/tests/interactive/test-paint-wrapper.c @@ -51,7 +51,7 @@ input_cb (ClutterStage *stage, { ClutterButtonEvent *button_event; ClutterActor *e; - gint x, y; + gfloat x, y; clutter_event_get_coords (event, &x, &y); @@ -125,7 +125,7 @@ hand_pre_paint (ClutterActor *actor, gpointer user_data) { SuperOH *oh = (SuperOH *) user_data; - guint w, h; + gfloat w, h; int actor_num; for (actor_num = 0; oh->hand[actor_num] != actor; actor_num++); @@ -145,7 +145,7 @@ hand_post_paint (ClutterActor *actor, gpointer user_data) { SuperOH *oh = (SuperOH *) user_data; - guint w, h; + gfloat w, h; int actor_num; for (actor_num = 0; oh->hand[actor_num] != actor; actor_num++); diff --git a/tests/interactive/test-project.c b/tests/interactive/test-project.c index f62fd9c1c..25481f3f7 100644 --- a/tests/interactive/test-project.c +++ b/tests/interactive/test-project.c @@ -21,19 +21,17 @@ init_handles () clutter_actor_set_position (p[i], 0, 0); clutter_group_add (CLUTTER_GROUP (main_stage), p[i]); - clutter_actor_set_positionu (p[i], - v[i].x - - clutter_actor_get_widthu (p[i])/2, - v[i].y - - clutter_actor_get_heightu (p[i])/2); + clutter_actor_set_position (p[i], + v[i].x - clutter_actor_get_width (p[i]) / 2, + v[i].y - clutter_actor_get_height (p[i]) / 2); clutter_actor_raise_top (p[i]); clutter_actor_show (p[i]); } - v1.x = clutter_actor_get_widthu (rect) / 2; - v1.y = clutter_actor_get_heightu (rect) / 2; + v1.x = clutter_actor_get_width (rect) / 2; + v1.y = clutter_actor_get_height (rect) / 2; v1.z = 0; clutter_actor_apply_transform_to_point (rect, &v1, &v2); @@ -41,11 +39,9 @@ init_handles () clutter_actor_set_size (p[4], 5, 5); clutter_actor_set_position (p[4], 0, 0); clutter_group_add (CLUTTER_GROUP (main_stage), p[4]); - clutter_actor_set_positionu (p[4], - v2.x - - clutter_actor_get_widthu (p[4])/2, - v2.y - - clutter_actor_get_heightu (p[4])/2); + clutter_actor_set_position (p[4], + v2.x - clutter_actor_get_width (p[4]) / 2, + v2.y - clutter_actor_get_height (p[4]) / 2); clutter_actor_raise_top (p[4]); @@ -62,21 +58,19 @@ place_handles () clutter_actor_get_abs_allocation_vertices (rect, v); for (i = 0; i < 4; ++i) { - clutter_actor_set_positionu (p[i], - v[i].x - - clutter_actor_get_widthu (p[i])/2, - v[i].y - - clutter_actor_get_heightu (p[i])/2); + clutter_actor_set_position (p[i], + v[i].x - clutter_actor_get_width (p[i])/2, + v[i].y - clutter_actor_get_height (p[i])/2); } - v1.x = clutter_actor_get_widthu (rect)/2; - v1.y = clutter_actor_get_heightu (rect)/2; + v1.x = clutter_actor_get_width (rect) / 2; + v1.y = clutter_actor_get_height (rect) / 2; v1.z = 0; clutter_actor_apply_transform_to_point (rect, &v1, &v2); - clutter_actor_set_positionu (p[4], - v2.x - clutter_actor_get_widthu (p[4])/2, - v2.y - clutter_actor_get_heightu (p[4])/2); + clutter_actor_set_position (p[4], + v2.x - clutter_actor_get_width (p[4])/2, + v2.y - clutter_actor_get_height (p[4])/2); } #define M(m,row,col) (m)[col*4+row] @@ -103,8 +97,8 @@ on_event (ClutterStage *stage, { case CLUTTER_BUTTON_PRESS: { - gint x, y; - ClutterActor * actor; + ClutterActor *actor; + gfloat x, y; clutter_event_get_coords (event, &x, &y); @@ -124,7 +118,7 @@ on_event (ClutterStage *stage, { if (dragging) { - gint x, y; + gfloat x, y; gint i; ClutterActorBox box1, box2; ClutterUnit xp, yp; @@ -148,7 +142,7 @@ on_event (ClutterStage *stage, CLUTTER_UNITS_TO_FLOAT (xp), CLUTTER_UNITS_TO_FLOAT (yp)); - clutter_actor_move_byu (rect, xp, yp); + clutter_actor_move_by (rect, xp, yp); } else { diff --git a/tests/interactive/test-stage-read-pixels.c b/tests/interactive/test-stage-read-pixels.c index b0d813970..2b5ec78ee 100644 --- a/tests/interactive/test-stage-read-pixels.c +++ b/tests/interactive/test-stage-read-pixels.c @@ -65,17 +65,18 @@ on_motion_idle (gpointer user_data) { CallbackData *data = (CallbackData *) user_data; guchar *pixels, *p; - guint stage_width, stage_height; + gfloat stage_width, stage_height; gint x, y; data->idle_source = 0; clutter_actor_get_size (data->stage, &stage_width, &stage_height); - x = CLAMP (data->event.x - TEX_SIZE / 2, 0, (int) stage_width - TEX_SIZE); - y = CLAMP (data->event.y - TEX_SIZE / 2, 0, (int) stage_height - TEX_SIZE); + x = CLAMP (data->event.x - TEX_SIZE / 2, 0, stage_width - TEX_SIZE); + y = CLAMP (data->event.y - TEX_SIZE / 2, 0, stage_height - TEX_SIZE); - clutter_actor_set_position (data->box, x + TEX_SIZE / 2 - 1, + clutter_actor_set_position (data->box, + x + TEX_SIZE / 2 - 1, y + TEX_SIZE / 2 - 1); clutter_actor_show (data->box); /* Redraw so that the layouting will be done and the box will be @@ -83,7 +84,8 @@ on_motion_idle (gpointer user_data) clutter_redraw (CLUTTER_STAGE (data->stage)); pixels = clutter_stage_read_pixels (CLUTTER_STAGE (data->stage), - x, y, TEX_SIZE, TEX_SIZE); + x, y, + TEX_SIZE, TEX_SIZE); /* Make a red dot in the center */ p = pixels + (TEX_SIZE / 2 - DOT_SIZE / 2) * TEX_SIZE * 4 diff --git a/tests/interactive/test-unproject.c b/tests/interactive/test-unproject.c index 188757b72..6c1e857e2 100644 --- a/tests/interactive/test-unproject.c +++ b/tests/interactive/test-unproject.c @@ -23,9 +23,9 @@ on_event (ClutterStage *stage, { case CLUTTER_BUTTON_PRESS: { - gint x, y; - ClutterActor * actor; - ClutterUnit xu2, yu2; + ClutterActor *actor; + gfloat xu2, yu2; + gfloat x, y; clutter_event_get_coords (event, &x, &y); @@ -33,10 +33,7 @@ on_event (ClutterStage *stage, CLUTTER_PICK_ALL, x, y); - if (clutter_actor_transform_stage_point (actor, - CLUTTER_UNITS_FROM_DEVICE (x), - CLUTTER_UNITS_FROM_DEVICE (y), - &xu2, &yu2)) + if (clutter_actor_transform_stage_point (actor, x, y, &xu2, &yu2)) { gchar *txt; @@ -44,16 +41,14 @@ on_event (ClutterStage *stage, txt = g_strdup_printf ("Click on rectangle\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", - x, y, - CLUTTER_UNITS_TO_DEVICE (xu2), - CLUTTER_UNITS_TO_DEVICE (yu2)); + (int) x, (int) y, + (int) xu2, (int) yu2); else txt = g_strdup_printf ("Click on stage\n" "Screen coords: [%d, %d]\n" "Local coords : [%d, %d]", - x, y, - CLUTTER_UNITS_TO_DEVICE (xu2), - CLUTTER_UNITS_TO_DEVICE (yu2)); + (int) x, (int) y, + (int) xu2, (int) yu2); clutter_text_set_text (CLUTTER_TEXT (label), txt); g_free (txt);