From c759aeb6a720043b8b74242d5e18da405be3825d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Sun, 31 May 2009 15:15:46 +0100 Subject: [PATCH] Uniformly use floats in Actor properties All the underlying implementation and the public entry points have been switched to floats; the only missing bits are the Actor properties that deal with positioning and sizing. This usually means a major pain when dealing with GValues and varargs functions. While GValue will warn you when dealing with the wrong conversions, varags will simply die an horrible (and hard to debug) death via segfault. Nothing much to do here, except warn people in the release notes and hope for the best. --- clutter/clutter-actor.c | 353 +++++++++++------- clutter/clutter-interval.c | 12 +- tests/conform/Makefile.am | 3 + tests/conform/test-anchors.c | 145 +++---- tests/conform/test-binding-pool.c | 18 +- tests/interactive/test-animation.c | 8 +- .../interactive/test-clutter-cairo-flowers.c | 23 +- tests/interactive/test-cogl-multitexture.c | 2 +- tests/interactive/test-cogl-tex-polygon.c | 2 +- tests/interactive/test-cogl-tex-tile.c | 2 +- tests/interactive/test-easing.c | 4 +- tests/interactive/test-layout.c | 17 +- tests/interactive/test-multistage.c | 2 +- tests/interactive/test-paint-wrapper.c | 2 +- tests/interactive/test-rotate.c | 2 +- tests/interactive/test-shader.c | 3 +- 16 files changed, 346 insertions(+), 252 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 3d6cab872..ac3f42dad 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -2369,91 +2369,109 @@ clutter_actor_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - - ClutterActor *actor; - ClutterActorPrivate *priv; - - actor = CLUTTER_ACTOR(object); - priv = actor->priv; + ClutterActor *actor = CLUTTER_ACTOR (object); + ClutterActorPrivate *priv = actor->priv; switch (prop_id) { case PROP_X: - clutter_actor_set_x (actor, g_value_get_int (value)); + clutter_actor_set_x (actor, g_value_get_float (value)); break; + case PROP_Y: - clutter_actor_set_y (actor, g_value_get_int (value)); + clutter_actor_set_y (actor, g_value_get_float (value)); break; + case PROP_WIDTH: - clutter_actor_set_width (actor, g_value_get_int (value)); + clutter_actor_set_width (actor, g_value_get_float (value)); break; + case PROP_HEIGHT: - clutter_actor_set_height (actor, g_value_get_int (value)); + clutter_actor_set_height (actor, g_value_get_float (value)); break; + case PROP_FIXED_X: - clutter_actor_set_x (actor, clutter_value_get_unit (value)); + clutter_actor_set_x (actor, g_value_get_float (value)); break; + case PROP_FIXED_Y: - clutter_actor_set_y (actor, clutter_value_get_unit (value)); + clutter_actor_set_y (actor, g_value_get_float (value)); break; + case PROP_FIXED_POSITION_SET: clutter_actor_set_fixed_position_set (actor, g_value_get_boolean (value)); break; + case PROP_MIN_WIDTH: - clutter_actor_set_min_width (actor, clutter_value_get_unit (value)); + clutter_actor_set_min_width (actor, g_value_get_float (value)); break; + case PROP_MIN_HEIGHT: - clutter_actor_set_min_height (actor, clutter_value_get_unit (value)); + clutter_actor_set_min_height (actor, g_value_get_float (value)); break; + case PROP_NATURAL_WIDTH: - clutter_actor_set_natural_width (actor, clutter_value_get_unit (value)); + clutter_actor_set_natural_width (actor, g_value_get_float (value)); break; + case PROP_NATURAL_HEIGHT: - clutter_actor_set_natural_height (actor, clutter_value_get_unit (value)); + clutter_actor_set_natural_height (actor, g_value_get_float (value)); break; + case PROP_MIN_WIDTH_SET: clutter_actor_set_min_width_set (actor, g_value_get_boolean (value)); break; + case PROP_MIN_HEIGHT_SET: clutter_actor_set_min_height_set (actor, g_value_get_boolean (value)); break; + case PROP_NATURAL_WIDTH_SET: clutter_actor_set_natural_width_set (actor, g_value_get_boolean (value)); break; + case PROP_NATURAL_HEIGHT_SET: clutter_actor_set_natural_height_set (actor, g_value_get_boolean (value)); break; + case PROP_REQUEST_MODE: clutter_actor_set_request_mode (actor, g_value_get_enum (value)); break; + case PROP_DEPTH: - clutter_actor_set_depth (actor, g_value_get_int (value)); + clutter_actor_set_depth (actor, g_value_get_float (value)); break; + case PROP_OPACITY: clutter_actor_set_opacity (actor, g_value_get_uchar (value)); break; + case PROP_NAME: clutter_actor_set_name (actor, g_value_get_string (value)); break; + case PROP_VISIBLE: if (g_value_get_boolean (value) == TRUE) clutter_actor_show (actor); else clutter_actor_hide (actor); break; + case PROP_SCALE_X: clutter_actor_set_scale (actor, g_value_get_double (value), priv->scale_y); break; + case PROP_SCALE_Y: clutter_actor_set_scale (actor, priv->scale_x, g_value_get_double (value)); break; + case PROP_SCALE_CENTER_X: { - gint center_x = g_value_get_int (value); + gfloat center_x = g_value_get_float (value); gfloat center_y; clutter_anchor_coord_get_units (actor, &priv->scale_center, @@ -2467,9 +2485,10 @@ clutter_actor_set_property (GObject *object, center_y); } break; + case PROP_SCALE_CENTER_Y: { - gint center_y = g_value_get_int (value); + gfloat center_y = g_value_get_float (value); gfloat center_x; clutter_anchor_coord_get_units (actor, &priv->scale_center, @@ -2483,21 +2502,24 @@ clutter_actor_set_property (GObject *object, center_y); } break; + case PROP_SCALE_GRAVITY: clutter_actor_set_scale_with_gravity (actor, priv->scale_x, priv->scale_y, g_value_get_enum (value)); break; + case PROP_CLIP: { - ClutterGeometry *geom = g_value_get_boxed (value); + const ClutterGeometry *geom = g_value_get_boxed (value); clutter_actor_set_clip (actor, geom->x, geom->y, geom->width, geom->height); } break; + case PROP_CLIP_TO_ALLOCATION: if (priv->clip_to_allocation != g_value_get_boolean (value)) { @@ -2505,24 +2527,29 @@ clutter_actor_set_property (GObject *object, clutter_actor_queue_redraw (actor); } break; + case PROP_REACTIVE: clutter_actor_set_reactive (actor, g_value_get_boolean (value)); break; + case PROP_ROTATION_ANGLE_X: clutter_actor_set_rotation_internal (actor, CLUTTER_X_AXIS, g_value_get_double (value)); break; + case PROP_ROTATION_ANGLE_Y: clutter_actor_set_rotation_internal (actor, CLUTTER_Y_AXIS, g_value_get_double (value)); break; + case PROP_ROTATION_ANGLE_Z: clutter_actor_set_rotation_internal (actor, CLUTTER_Z_AXIS, g_value_get_double (value)); break; + case PROP_ROTATION_CENTER_X: { const ClutterVertex *center; @@ -2536,6 +2563,7 @@ clutter_actor_set_property (GObject *object, center->z); } break; + case PROP_ROTATION_CENTER_Y: { const ClutterVertex *center; @@ -2549,6 +2577,7 @@ clutter_actor_set_property (GObject *object, center->z); } break; + case PROP_ROTATION_CENTER_Z: { const ClutterVertex *center; @@ -2562,13 +2591,15 @@ clutter_actor_set_property (GObject *object, center->z); } break; + case PROP_ROTATION_CENTER_Z_GRAVITY: - clutter_actor_set_z_rotation_from_gravity - (actor, priv->rzang, g_value_get_enum (value)); + clutter_actor_set_z_rotation_from_gravity (actor, priv->rzang, + g_value_get_enum (value)); break; + case PROP_ANCHOR_X: { - gint anchor_x = g_value_get_int (value); + gfloat anchor_x = g_value_get_float (value); gfloat anchor_y; clutter_anchor_coord_get_units (actor, &priv->anchor, @@ -2578,10 +2609,11 @@ clutter_actor_set_property (GObject *object, clutter_actor_set_anchor_point (actor, anchor_x, anchor_y); } break; + case PROP_ANCHOR_Y: { - gint anchor_y = g_value_get_int (value); - gfloat anchor_x; + gfloat anchor_y = g_value_get_int (value); + gfloat anchor_x; clutter_anchor_coord_get_units (actor, &priv->anchor, &anchor_x, @@ -2590,13 +2622,16 @@ clutter_actor_set_property (GObject *object, clutter_actor_set_anchor_point (actor, anchor_x, anchor_y); } break; + case PROP_ANCHOR_GRAVITY: clutter_actor_set_anchor_point_from_gravity (actor, g_value_get_enum (value)); break; + case PROP_SHOW_ON_SET_PARENT: priv->show_on_set_parent = g_value_get_boolean (value); break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2609,86 +2644,107 @@ clutter_actor_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - ClutterActor *actor; - ClutterActorPrivate *priv; - - actor = CLUTTER_ACTOR(object); - priv = actor->priv; + ClutterActor *actor = CLUTTER_ACTOR (object); + ClutterActorPrivate *priv = actor->priv; switch (prop_id) { case PROP_X: - g_value_set_int (value, clutter_actor_get_x (actor)); + g_value_set_float (value, clutter_actor_get_x (actor)); break; + case PROP_Y: - g_value_set_int (value, clutter_actor_get_y (actor)); + g_value_set_float (value, clutter_actor_get_y (actor)); break; + case PROP_WIDTH: - g_value_set_int (value, clutter_actor_get_width (actor)); + g_value_set_float (value, clutter_actor_get_width (actor)); break; + case PROP_HEIGHT: - g_value_set_int (value, clutter_actor_get_height (actor)); + g_value_set_float (value, clutter_actor_get_height (actor)); break; + case PROP_FIXED_X: - clutter_value_set_unit (value, priv->fixed_x); + g_value_set_float (value, priv->fixed_x); break; + case PROP_FIXED_Y: - clutter_value_set_unit (value, priv->fixed_y); + g_value_set_float (value, priv->fixed_y); break; + case PROP_FIXED_POSITION_SET: g_value_set_boolean (value, priv->position_set); break; + case PROP_MIN_WIDTH: - clutter_value_set_unit (value, priv->request_min_width); + g_value_set_float (value, priv->request_min_width); break; + case PROP_MIN_HEIGHT: - clutter_value_set_unit (value, priv->request_min_height); + g_value_set_float (value, priv->request_min_height); break; + case PROP_NATURAL_WIDTH: - clutter_value_set_unit (value, priv->request_natural_width); + g_value_set_float (value, priv->request_natural_width); break; + case PROP_NATURAL_HEIGHT: - clutter_value_set_unit (value, priv->request_natural_height); + g_value_set_float (value, priv->request_natural_height); break; + case PROP_MIN_WIDTH_SET: g_value_set_boolean (value, priv->min_width_set); break; + case PROP_MIN_HEIGHT_SET: g_value_set_boolean (value, priv->min_height_set); break; + case PROP_NATURAL_WIDTH_SET: g_value_set_boolean (value, priv->natural_width_set); break; + case PROP_NATURAL_HEIGHT_SET: g_value_set_boolean (value, priv->natural_height_set); break; + case PROP_REQUEST_MODE: g_value_set_enum (value, priv->request_mode); break; + case PROP_ALLOCATION: g_value_set_boxed (value, &priv->allocation); break; + case PROP_DEPTH: - g_value_set_int (value, clutter_actor_get_depth (actor)); + g_value_set_float (value, clutter_actor_get_depth (actor)); break; + case PROP_OPACITY: g_value_set_uchar (value, priv->opacity); break; + case PROP_NAME: g_value_set_string (value, priv->name); break; + case PROP_VISIBLE: g_value_set_boolean (value, CLUTTER_ACTOR_IS_VISIBLE (actor)); break; + case PROP_MAPPED: g_value_set_boolean (value, CLUTTER_ACTOR_IS_MAPPED (actor)); break; + case PROP_REALIZED: g_value_set_boolean (value, CLUTTER_ACTOR_IS_REALIZED (actor)); break; + case PROP_HAS_CLIP: g_value_set_boolean (value, priv->has_clip); break; + case PROP_CLIP: { ClutterGeometry clip = { 0, }; @@ -2701,48 +2757,59 @@ clutter_actor_get_property (GObject *object, g_value_set_boxed (value, &clip); } break; + case PROP_CLIP_TO_ALLOCATION: g_value_set_boolean (value, priv->clip_to_allocation); break; + case PROP_SCALE_X: g_value_set_double (value, priv->scale_x); break; + case PROP_SCALE_Y: g_value_set_double (value, priv->scale_y); break; + case PROP_SCALE_CENTER_X: { gfloat center; clutter_actor_get_scale_center (actor, ¢er, NULL); - g_value_set_int (value, center); + g_value_set_float (value, center); } break; + case PROP_SCALE_CENTER_Y: { gfloat center; clutter_actor_get_scale_center (actor, NULL, ¢er); - g_value_set_int (value, center); + g_value_set_float (value, center); } break; + case PROP_SCALE_GRAVITY: g_value_set_enum (value, clutter_actor_get_scale_gravity (actor)); break; + case PROP_REACTIVE: g_value_set_boolean (value, clutter_actor_get_reactive (actor)); break; + case PROP_ROTATION_ANGLE_X: g_value_set_double (value, priv->rxang); break; + case PROP_ROTATION_ANGLE_Y: g_value_set_double (value, priv->ryang); break; + case PROP_ROTATION_ANGLE_Z: g_value_set_double (value, priv->rzang); break; + case PROP_ROTATION_CENTER_X: { ClutterVertex center; @@ -2755,6 +2822,7 @@ clutter_actor_get_property (GObject *object, g_value_set_boxed (value, ¢er); } break; + case PROP_ROTATION_CENTER_Y: { ClutterVertex center; @@ -2767,6 +2835,7 @@ clutter_actor_get_property (GObject *object, g_value_set_boxed (value, ¢er); } break; + case PROP_ROTATION_CENTER_Z: { ClutterVertex center; @@ -2779,9 +2848,11 @@ clutter_actor_get_property (GObject *object, g_value_set_boxed (value, ¢er); } break; + case PROP_ROTATION_CENTER_Z_GRAVITY: g_value_set_enum (value, clutter_actor_get_z_rotation_gravity (actor)); break; + case PROP_ANCHOR_X: { gfloat anchor_x; @@ -2790,9 +2861,10 @@ clutter_actor_get_property (GObject *object, &anchor_x, NULL, NULL); - g_value_set_int (value, anchor_x); + g_value_set_float (value, anchor_x); } break; + case PROP_ANCHOR_Y: { gfloat anchor_y; @@ -2801,15 +2873,18 @@ clutter_actor_get_property (GObject *object, NULL, &anchor_y, NULL); - g_value_set_int (value, anchor_y); + g_value_set_float (value, anchor_y); } break; + case PROP_ANCHOR_GRAVITY: g_value_set_enum (value, clutter_actor_get_anchor_point_gravity (actor)); break; + case PROP_SHOW_ON_SET_PARENT: g_value_set_boolean (value, priv->show_on_set_parent); break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -2896,12 +2971,12 @@ 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. */ - pspec = g_param_spec_int ("x", - "X coordinate", - "X coordinate of the actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("x", + "X coordinate", + "X coordinate of the actor", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_X, pspec); /** @@ -2911,12 +2986,12 @@ 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. */ - pspec = g_param_spec_int ("y", - "Y coordinate", - "Y coordinate of the actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("y", + "Y coordinate", + "Y coordinate of the actor", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_Y, pspec); /** @@ -2926,12 +3001,12 @@ 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. */ - pspec = g_param_spec_int ("width", - "Width", - "Width of the actor", - 0, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("width", + "Width", + "Width of the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_WIDTH, pspec); /** * ClutterActor:height: @@ -2940,12 +3015,12 @@ 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); + pspec = g_param_spec_float ("height", + "Height", + "Height of the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_HEIGHT, pspec); /** @@ -2958,12 +3033,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * 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); + pspec = g_param_spec_float ("fixed-x", + "Fixed X", + "Forced X position of the actor", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_FIXED_X, pspec); /** @@ -2976,12 +3051,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * 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); + pspec = g_param_spec_float ("fixed-y", + "Fixed Y", + "Forced Y position of the actor", + -G_MAXFLOAT, G_MAXFLOAT, + 0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_FIXED_Y, pspec); /** @@ -3014,13 +3089,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = clutter_param_spec_unit ("min-width", - "Min Width", - "Forced minimum width request " - "for the actor", - 0, CLUTTER_MAXUNIT, - 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("min-width", + "Min Width", + "Forced minimum width request for the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_MIN_WIDTH, pspec); /** @@ -3034,13 +3108,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = 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_float ("min-height", + "Min Height", + "Forced minimum height request for the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_MIN_HEIGHT, pspec); /** @@ -3054,13 +3127,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = 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_float ("natural-width", + "Natural Width", + "Forced natural width request for the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_NATURAL_WIDTH, pspec); /** @@ -3074,13 +3146,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = 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_float ("natural-height", + "Natural Height", + "Forced natural height request for the actor", + 0.0, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_NATURAL_HEIGHT, pspec); /** @@ -3224,16 +3295,16 @@ clutter_actor_class_init (ClutterActorClass *klass) /** * ClutterActor:depth: * - * Depth of the actor. + * The position of the actor on the Z axis * * Since: 0.6 */ - pspec = g_param_spec_int ("depth", - "Depth", - "Depth of actor", - -G_MAXINT, G_MAXINT, - 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("depth", + "Depth", + "Position on the Z axis", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_DEPTH, pspec); /** @@ -3245,8 +3316,8 @@ clutter_actor_class_init (ClutterActorClass *klass) pspec = g_param_spec_uchar ("opacity", "Opacity", "Opacity of actor", - 0, 0xff, - 0xff, + 0, 255, + 255, CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_OPACITY, pspec); @@ -3387,11 +3458,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 1.0 */ - pspec = g_param_spec_int ("scale-center-x", - "Scale-Center-X", - "Horizontal scale center", - G_MININT, G_MAXINT, 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("scale-center-x", + "Scale-Center-X", + "Horizontal scale center", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_SCALE_CENTER_X, pspec); /** @@ -3401,11 +3473,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 1.0 */ - pspec = g_param_spec_int ("scale-center-y", - "Scale-Center-Y", - "Vertical scale center", - G_MININT, G_MAXINT, 0, - CLUTTER_PARAM_READWRITE); + pspec = g_param_spec_float ("scale-center-y", + "Scale-Center-Y", + "Vertical scale center", + -G_MAXFLOAT, G_MAXFLOAT, + 0.0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_SCALE_CENTER_Y, pspec); /** @@ -3543,12 +3616,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = 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_float ("anchor-x", + "Anchor X", + "X coordinate of the anchor point", + -G_MAXFLOAT, G_MAXFLOAT, + 0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_ANCHOR_X, pspec); /** @@ -3559,12 +3632,12 @@ clutter_actor_class_init (ClutterActorClass *klass) * * Since: 0.8 */ - pspec = 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_float ("anchor-y", + "Anchor Y", + "Y coordinate of the anchor point", + -G_MAXFLOAT, G_MAXFLOAT, + 0, + CLUTTER_PARAM_READWRITE); g_object_class_install_property (object_class, PROP_ANCHOR_Y, pspec); /** diff --git a/clutter/clutter-interval.c b/clutter/clutter-interval.c index c4181945b..469c217db 100644 --- a/clutter/clutter-interval.c +++ b/clutter/clutter-interval.c @@ -265,8 +265,16 @@ clutter_interval_real_compute_value (ClutterInterval *interval, { gdouble ia, ib, res; - ia = g_value_get_double (initial); - ib = g_value_get_double (final); + if (value_type == G_TYPE_DOUBLE) + { + ia = g_value_get_double (initial); + ib = g_value_get_double (final); + } + else + { + ia = g_value_get_float (initial); + ib = g_value_get_float (final); + } res = (factor * (ib - ia)) + ia; diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am index 253cb64ed..82e104b87 100644 --- a/tests/conform/Makefile.am +++ b/tests/conform/Makefile.am @@ -78,6 +78,9 @@ test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@C test: @gtester -o=test-conformance-results.xml ./test-conformance +test-verbose: + @gtester --verbose -o=test-conformance-result.xml ./test-conformance + test-report-normal: @gtester -o=test-conformance-results.xml -k ./test-conformance \ && ( gtester-report test-conformance-results.xml \ diff --git a/tests/conform/test-anchors.c b/tests/conform/test-anchors.c index f3118b4fd..4549275da 100644 --- a/tests/conform/test-anchors.c +++ b/tests/conform/test-anchors.c @@ -20,8 +20,8 @@ #define NOTIFY_ROTATION_CENTER_Z (1 << 13) #define NOTIFY_ROTATION_CENTER_Z_GRAVITY (1 << 14) -#define RECT_WIDTH 100 -#define RECT_HEIGHT 80 +#define RECT_WIDTH 100.0 +#define RECT_HEIGHT 80.0 /* Allow the transformed position by off by a certain number of pixels */ @@ -36,7 +36,8 @@ typedef struct _TestState static const struct { ClutterGravity gravity; - gint x_pos, y_pos; + gfloat x_pos; + gfloat y_pos; } gravities[] = { { CLUTTER_GRAVITY_NORTH, RECT_WIDTH / 2, 0 }, @@ -50,23 +51,25 @@ static const struct { CLUTTER_GRAVITY_CENTER, RECT_WIDTH / 2, RECT_HEIGHT / 2 } }; -static const char * const -properties[] = - { "anchor-x", - "anchor-y", - "anchor-gravity", - "scale-x", - "scale-y", - "scale-center-x", - "scale-center-y", - "scale-gravity", - "rotation-angle-x", - "rotation-angle-y", - "rotation-angle-z", - "rotation-center-x", - "rotation-center-y", - "rotation-center-z", - "rotation-center-z-gravity" }; +static const char * const properties[] = { + "anchor-x", + "anchor-y", + "anchor-gravity", + "scale-x", + "scale-y", + "scale-center-x", + "scale-center-y", + "scale-gravity", + "rotation-angle-x", + "rotation-angle-y", + "rotation-angle-z", + "rotation-center-x", + "rotation-center-y", + "rotation-center-z", + "rotation-center-z-gravity" +}; + +static const int n_properties = G_N_ELEMENTS (properties); static void notify_cb (GObject *object, GParamSpec *pspec, TestState *state) @@ -75,10 +78,11 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state) int new_flags = 0; int flag = 1; - for (i = 0; i < G_N_ELEMENTS (properties); i++) + for (i = 0; i < n_properties; i++) { if (!strcmp (properties[i], pspec->name)) new_flags |= flag; + flag <<= 1; } @@ -87,43 +91,31 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state) state->notifications |= new_flags; } -#define assert_notifications(flags) \ - do \ - { \ - g_assert (state->notifications == (flags)); \ - state->notifications = 0; \ - } while (0) +#define assert_notifications(flags) G_STMT_START { \ + g_assert (state->notifications == (flags)); \ + state->notifications = 0; } G_STMT_END /* Helper macro to assert the transformed position. This needs to be a macro so that the assertion failure will report the right line number */ -#define assert_coords(state, x_1, y_1, x_2, y_2) \ - do \ - { \ - ClutterVertex verts[4]; \ - clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \ - check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \ - g_assert (approx_equal ((x_1), \ - CLUTTER_UNITS_TO_DEVICE (verts[0].x))); \ - g_assert (approx_equal ((y_1), \ - CLUTTER_UNITS_TO_DEVICE (verts[0].y))); \ - g_assert (approx_equal ((x_2), \ - CLUTTER_UNITS_TO_DEVICE (verts[3].x))); \ - g_assert (approx_equal ((y_2), \ - CLUTTER_UNITS_TO_DEVICE (verts[3].y))); \ - } while (0) +#define assert_coords(state, x_1, y_1, x_2, y_2) G_STMT_START { \ + ClutterVertex verts[4]; \ + clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \ + check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \ + g_assert (approx_equal ((x_1), CLUTTER_UNITS_TO_DEVICE (verts[0].x)));\ + g_assert (approx_equal ((y_1), CLUTTER_UNITS_TO_DEVICE (verts[0].y)));\ + g_assert (approx_equal ((x_2), CLUTTER_UNITS_TO_DEVICE (verts[3].x)));\ + g_assert (approx_equal ((y_2), CLUTTER_UNITS_TO_DEVICE (verts[3].y)));\ + } G_STMT_END #define assert_position(state, x, y) \ assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT) -#define assert_vertex_and_free(v, xc, yc, zc) \ - do \ - { \ - g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) \ - && approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) \ - && approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \ - g_boxed_free (CLUTTER_TYPE_VERTEX, v); \ - } while (0) +#define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \ + g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) && \ + approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) && \ + approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \ + g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END static inline gboolean approx_equal (int a, int b) @@ -133,7 +125,10 @@ approx_equal (int a, int b) static void check_coords (TestState *state, - gint x_1, gint y_1, gint x_2, gint y_2, + gint x_1, + gint y_1, + gint x_2, + gint y_2, const ClutterVertex *verts) { if (g_test_verbose ()) @@ -154,7 +149,7 @@ static void test_anchor_point (TestState *state) { ClutterActor *rect = state->rect; - gint anchor_x, anchor_y; + gfloat anchor_x, anchor_y; ClutterGravity anchor_gravity; int i; @@ -164,7 +159,8 @@ test_anchor_point (TestState *state) g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == 0); @@ -174,7 +170,8 @@ test_anchor_point (TestState *state) /* Change the anchor point */ clutter_actor_set_anchor_point (rect, 20, 30); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == 20); @@ -186,7 +183,8 @@ test_anchor_point (TestState *state) /* Move the anchor point */ clutter_actor_move_anchor_point (rect, 40, 50); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == 40); @@ -214,7 +212,8 @@ test_anchor_point (TestState *state) g_object_set (rect, "anchor-gravity", gravities[i].gravity, NULL); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == gravities[i].x_pos); @@ -232,7 +231,8 @@ test_anchor_point (TestState *state) it is set from the gravity */ clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == RECT_WIDTH); @@ -261,7 +261,8 @@ test_anchor_point (TestState *state) size when it is set from units */ clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2); g_object_get (rect, - "anchor-x", &anchor_x, "anchor-y", &anchor_y, + "anchor-x", &anchor_x, + "anchor-y", &anchor_y, "anchor-gravity", &anchor_gravity, NULL); g_assert (anchor_x == 20); @@ -281,7 +282,7 @@ test_scale_center (TestState *state) { ClutterActor *rect = state->rect; gdouble scale_x, scale_y; - gint center_x, center_y; + gfloat center_x, center_y; ClutterGravity gravity; int i; @@ -291,8 +292,10 @@ test_scale_center (TestState *state) g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_object_get (rect, - "scale-center-x", ¢er_x, "scale-center-y", ¢er_y, - "scale-x", &scale_x, "scale-y", &scale_y, + "scale-center-x", ¢er_x, + "scale-center-y", ¢er_y, + "scale-x", &scale_x, + "scale-y", &scale_y, "scale-gravity", &gravity, NULL); g_assert (center_x == 0); @@ -308,8 +311,10 @@ test_scale_center (TestState *state) g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_object_get (rect, - "scale-center-x", ¢er_x, "scale-center-y", ¢er_y, - "scale-x", &scale_x, "scale-y", &scale_y, + "scale-center-x", ¢er_x, + "scale-center-y", ¢er_y, + "scale-x", &scale_x, + "scale-y", &scale_y, "scale-gravity", &gravity, NULL); g_assert (center_x == 0); @@ -321,8 +326,12 @@ test_scale_center (TestState *state) assert_coords (state, 100, 200, 100 + RECT_WIDTH * 2, 200 + RECT_HEIGHT * 3); /* Change the scale and center */ - g_object_set (rect, "scale-x", 4.0, "scale-y", 2.0, - "scale-center-x", 10, "scale-center-y", 20, NULL); + g_object_set (rect, + "scale-x", 4.0, + "scale-y", 2.0, + "scale-center-x", 10.0, + "scale-center-y", 20.0, + NULL); g_assert (clutter_actor_get_x (rect) == 100); g_assert (clutter_actor_get_y (rect) == 200); g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); @@ -388,8 +397,10 @@ test_scale_center (TestState *state) gravity property changes */ clutter_actor_set_scale_full (rect, 4, 2, 10, 20); g_object_get (rect, - "scale-center-x", ¢er_x, "scale-center-y", ¢er_y, - "scale-x", &scale_x, "scale-y", &scale_y, + "scale-center-x", ¢er_x, + "scale-center-y", ¢er_y, + "scale-x", &scale_x, + "scale-y", &scale_y, "scale-gravity", &gravity, NULL); g_assert (center_x == 10); diff --git a/tests/conform/test-binding-pool.c b/tests/conform/test-binding-pool.c index 64cf11ee6..acbedfdb6 100644 --- a/tests/conform/test-binding-pool.c +++ b/tests/conform/test-binding-pool.c @@ -273,19 +273,19 @@ test_binding_pool (TestConformSimpleFixture *fixture, clutter_container_add (CLUTTER_CONTAINER (key_group), g_object_new (CLUTTER_TYPE_RECTANGLE, - "width", 50, - "height", 50, - "x", 0, "y", 0, + "width", 50.0, + "height", 50.0, + "x", 0.0, "y", 0.0, NULL), g_object_new (CLUTTER_TYPE_RECTANGLE, - "width", 50, - "height", 50, - "x", 75, "y", 0, + "width", 50.0, + "height", 50.0, + "x", 75.0, "y", 0.0, NULL), g_object_new (CLUTTER_TYPE_RECTANGLE, - "width", 50, - "height", 50, - "x", 150, "y", 0, + "width", 50.0, + "height", 50.0, + "x", 150.0, "y", 0.0, NULL), NULL); diff --git a/tests/interactive/test-animation.c b/tests/interactive/test-animation.c index 032400f63..3fde8a68a 100644 --- a/tests/interactive/test-animation.c +++ b/tests/interactive/test-animation.c @@ -65,10 +65,10 @@ on_button_press (ClutterActor *actor, animation = clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000, - "x", (int) new_x, - "y", (int) new_y, - "width", (int) new_width, - "height", (int) new_height, + "x", new_x, + "y", new_y, + "width", new_width, + "height", 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 746d62313..2abd6c39d 100644 --- a/tests/interactive/test-clutter-cairo-flowers.c +++ b/tests/interactive/test-clutter-cairo-flowers.c @@ -166,21 +166,19 @@ void foo(void) { g_usleep(10000000); } int test_clutter_cairo_flowers_main (int argc, char **argv) { - int i; - ClutterActor *stage; - ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; - Flower *flowers[N_FLOWERS]; + int i; + ClutterActor *stage; + ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; + Flower *flowers[N_FLOWERS]; - srand(time(NULL)); + srand (time (NULL)); clutter_init (&argc, &argv); stage = clutter_stage_get_default (); - clutter_stage_set_color (CLUTTER_STAGE (stage), - &stage_color); - - g_object_set(stage, "fullscreen", TRUE, NULL); + clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + clutter_stage_fullscreen (CLUTTER_STAGE (stage)); for (i=0; i< N_FLOWERS; i++) { @@ -192,14 +190,15 @@ test_clutter_cairo_flowers_main (int argc, char **argv) flowers[i]->rv = rand() % 5 + 1; flowers[i]->v = rand() % 10 + 2; - clutter_group_add (CLUTTER_GROUP(stage), flowers[i]->ctex); + clutter_container_add_actor (CLUTTER_CONTAINER (stage), + flowers[i]->ctex); clutter_actor_set_position (flowers[i]->ctex, flowers[i]->x, flowers[i]->y); } g_timeout_add (50, tick, flowers); - clutter_actor_show_all (CLUTTER_ACTOR (stage)); + clutter_actor_show (stage); g_signal_connect (stage, "key-press-event", G_CALLBACK (clutter_main_quit), @@ -207,6 +206,6 @@ test_clutter_cairo_flowers_main (int argc, char **argv) clutter_main(); - return 1; + return EXIT_SUCCESS; } diff --git a/tests/interactive/test-cogl-multitexture.c b/tests/interactive/test-cogl-multitexture.c index cddf2b4ca..df7360260 100644 --- a/tests/interactive/test-cogl-multitexture.c +++ b/tests/interactive/test-cogl-multitexture.c @@ -123,7 +123,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) state->group); timeline = clutter_timeline_new (TIMELINE_FRAME_COUNT, 26 /* fps */); - g_object_set (timeline, "loop", TRUE, NULL); + clutter_timeline_set_loop (timeline, TRUE); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), state); diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index 540d832a4..b7252b50a 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -371,7 +371,7 @@ test_cogl_tex_polygon_main (int argc, char *argv[]) /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ - g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ + clutter_timeline_set_loop (timeline, TRUE); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); clutter_timeline_start (timeline); diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 0325add6a..07f395db6 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -203,7 +203,7 @@ test_cogl_tex_tile_main (int argc, char *argv[]) /* Timeline for animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ - g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ + clutter_timeline_set_loop (timeline, TRUE); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox); clutter_timeline_start (timeline); diff --git a/tests/interactive/test-easing.c b/tests/interactive/test-easing.c index 296812da3..e39fc7e21 100644 --- a/tests/interactive/test-easing.c +++ b/tests/interactive/test-easing.c @@ -94,8 +94,8 @@ on_button_press (ClutterActor *actor, animation = clutter_actor_animate (rectangle, cur_mode, 2000, - "x", (int) event->x, - "y", (int) event->y, + "x", event->x, + "y", event->y, "color", &color, NULL); } diff --git a/tests/interactive/test-layout.c b/tests/interactive/test-layout.c index ecd5ce8e4..93783723e 100644 --- a/tests/interactive/test-layout.c +++ b/tests/interactive/test-layout.c @@ -551,14 +551,13 @@ my_thing_init (MyThing *thing) } ClutterActor * -my_thing_new (gint padding, - gint spacing) +my_thing_new (gfloat padding, + gfloat spacing) { return g_object_new (MY_TYPE_THING, - "padding", CLUTTER_UNITS_FROM_DEVICE (padding), - "spacing", CLUTTER_UNITS_FROM_DEVICE (spacing), + "padding", padding, + "spacing", spacing, NULL); - } /* test code */ @@ -591,13 +590,13 @@ static void increase_property_value (ClutterActor *actor, const char *property_name) { - ClutterUnit value; + gfloat value; g_object_get (G_OBJECT (actor), property_name, &value, NULL); - value = value + CLUTTER_UNITS_FROM_DEVICE (10); + value = value + 10.0; g_object_set (G_OBJECT (box), property_name, value, @@ -608,13 +607,13 @@ static void decrease_property_value (ClutterActor *actor, const char *property_name) { - ClutterUnit value; + gfloat value; g_object_get (G_OBJECT (actor), property_name, &value, NULL); - value = MAX (0, value - CLUTTER_UNITS_FROM_DEVICE (10)); + value = MAX (0, value - 10.0); g_object_set (G_OBJECT (box), property_name, value, diff --git a/tests/interactive/test-multistage.c b/tests/interactive/test-multistage.c index 21f6427ae..40caa40f6 100644 --- a/tests/interactive/test-multistage.c +++ b/tests/interactive/test-multistage.c @@ -73,7 +73,7 @@ on_button_press (ClutterActor *actor, clutter_stage_set_title (CLUTTER_STAGE(new_stage), win_title); timeline = clutter_timeline_new_for_duration (2000); - g_object_set (timeline, "loop", TRUE, NULL); + clutter_timeline_set_loop (timeline, TRUE); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); r_behave = clutter_behaviour_rotate_new (alpha, diff --git a/tests/interactive/test-paint-wrapper.c b/tests/interactive/test-paint-wrapper.c index ac346f5da..ac53221e5 100644 --- a/tests/interactive/test-paint-wrapper.c +++ b/tests/interactive/test-paint-wrapper.c @@ -209,7 +209,7 @@ test_paint_wrapper_main (int argc, char *argv[]) /* Create a timeline to manage animation */ timeline = clutter_timeline_new (360, 60); /* num frames, fps */ - g_object_set (timeline, "loop", TRUE, NULL); /* have it loop */ + clutter_timeline_set_loop (timeline, TRUE); /* fire a callback for frame change */ g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh); diff --git a/tests/interactive/test-rotate.c b/tests/interactive/test-rotate.c index 0c234714f..6fea09ca0 100644 --- a/tests/interactive/test-rotate.c +++ b/tests/interactive/test-rotate.c @@ -45,7 +45,7 @@ test_rotate_main (int argc, char *argv[]) /* Make a timeline */ timeline = clutter_timeline_new (200, 26); /* num frames, fps */ - g_object_set (timeline, "loop", TRUE, NULL); + clutter_timeline_set_loop (timeline, TRUE); /* Set an alpha func to power behaviour */ alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); diff --git a/tests/interactive/test-shader.c b/tests/interactive/test-shader.c index 1101d8246..ecb8d2251 100644 --- a/tests/interactive/test-shader.c +++ b/tests/interactive/test-shader.c @@ -218,7 +218,8 @@ set_shader_num (ClutterActor *actor, gint new_no) error = NULL; g_object_set (G_OBJECT (shader), - "fragment-source", shaders[shader_no].source, NULL); + "fragment-source", shaders[shader_no].source, + NULL); /* try to bind the shader, provoking an error we catch if there is issues * with the shader sources we've provided. At a later stage it should be