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.
This commit is contained in:
Emmanuele Bassi 2009-05-31 15:15:46 +01:00
parent bafa448666
commit c759aeb6a7
16 changed files with 346 additions and 252 deletions

View File

@ -2369,91 +2369,109 @@ clutter_actor_set_property (GObject *object,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterActor *actor = CLUTTER_ACTOR (object);
ClutterActor *actor; ClutterActorPrivate *priv = actor->priv;
ClutterActorPrivate *priv;
actor = CLUTTER_ACTOR(object);
priv = actor->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_X: case PROP_X:
clutter_actor_set_x (actor, g_value_get_int (value)); clutter_actor_set_x (actor, g_value_get_float (value));
break; break;
case PROP_Y: case PROP_Y:
clutter_actor_set_y (actor, g_value_get_int (value)); clutter_actor_set_y (actor, g_value_get_float (value));
break; break;
case PROP_WIDTH: case PROP_WIDTH:
clutter_actor_set_width (actor, g_value_get_int (value)); clutter_actor_set_width (actor, g_value_get_float (value));
break; break;
case PROP_HEIGHT: case PROP_HEIGHT:
clutter_actor_set_height (actor, g_value_get_int (value)); clutter_actor_set_height (actor, g_value_get_float (value));
break; break;
case PROP_FIXED_X: 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; break;
case PROP_FIXED_Y: 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; break;
case PROP_FIXED_POSITION_SET: case PROP_FIXED_POSITION_SET:
clutter_actor_set_fixed_position_set (actor, g_value_get_boolean (value)); clutter_actor_set_fixed_position_set (actor, g_value_get_boolean (value));
break; break;
case PROP_MIN_WIDTH: 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; break;
case PROP_MIN_HEIGHT: 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; break;
case PROP_NATURAL_WIDTH: 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; break;
case PROP_NATURAL_HEIGHT: 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; break;
case PROP_MIN_WIDTH_SET: case PROP_MIN_WIDTH_SET:
clutter_actor_set_min_width_set (actor, g_value_get_boolean (value)); clutter_actor_set_min_width_set (actor, g_value_get_boolean (value));
break; break;
case PROP_MIN_HEIGHT_SET: case PROP_MIN_HEIGHT_SET:
clutter_actor_set_min_height_set (actor, g_value_get_boolean (value)); clutter_actor_set_min_height_set (actor, g_value_get_boolean (value));
break; break;
case PROP_NATURAL_WIDTH_SET: case PROP_NATURAL_WIDTH_SET:
clutter_actor_set_natural_width_set (actor, g_value_get_boolean (value)); clutter_actor_set_natural_width_set (actor, g_value_get_boolean (value));
break; break;
case PROP_NATURAL_HEIGHT_SET: case PROP_NATURAL_HEIGHT_SET:
clutter_actor_set_natural_height_set (actor, g_value_get_boolean (value)); clutter_actor_set_natural_height_set (actor, g_value_get_boolean (value));
break; break;
case PROP_REQUEST_MODE: case PROP_REQUEST_MODE:
clutter_actor_set_request_mode (actor, g_value_get_enum (value)); clutter_actor_set_request_mode (actor, g_value_get_enum (value));
break; break;
case PROP_DEPTH: case PROP_DEPTH:
clutter_actor_set_depth (actor, g_value_get_int (value)); clutter_actor_set_depth (actor, g_value_get_float (value));
break; break;
case PROP_OPACITY: case PROP_OPACITY:
clutter_actor_set_opacity (actor, g_value_get_uchar (value)); clutter_actor_set_opacity (actor, g_value_get_uchar (value));
break; break;
case PROP_NAME: case PROP_NAME:
clutter_actor_set_name (actor, g_value_get_string (value)); clutter_actor_set_name (actor, g_value_get_string (value));
break; break;
case PROP_VISIBLE: case PROP_VISIBLE:
if (g_value_get_boolean (value) == TRUE) if (g_value_get_boolean (value) == TRUE)
clutter_actor_show (actor); clutter_actor_show (actor);
else else
clutter_actor_hide (actor); clutter_actor_hide (actor);
break; break;
case PROP_SCALE_X: case PROP_SCALE_X:
clutter_actor_set_scale (actor, clutter_actor_set_scale (actor,
g_value_get_double (value), g_value_get_double (value),
priv->scale_y); priv->scale_y);
break; break;
case PROP_SCALE_Y: case PROP_SCALE_Y:
clutter_actor_set_scale (actor, clutter_actor_set_scale (actor,
priv->scale_x, priv->scale_x,
g_value_get_double (value)); g_value_get_double (value));
break; break;
case PROP_SCALE_CENTER_X: case PROP_SCALE_CENTER_X:
{ {
gint center_x = g_value_get_int (value); gfloat center_x = g_value_get_float (value);
gfloat center_y; gfloat center_y;
clutter_anchor_coord_get_units (actor, &priv->scale_center, clutter_anchor_coord_get_units (actor, &priv->scale_center,
@ -2467,9 +2485,10 @@ clutter_actor_set_property (GObject *object,
center_y); center_y);
} }
break; break;
case PROP_SCALE_CENTER_Y: case PROP_SCALE_CENTER_Y:
{ {
gint center_y = g_value_get_int (value); gfloat center_y = g_value_get_float (value);
gfloat center_x; gfloat center_x;
clutter_anchor_coord_get_units (actor, &priv->scale_center, clutter_anchor_coord_get_units (actor, &priv->scale_center,
@ -2483,21 +2502,24 @@ clutter_actor_set_property (GObject *object,
center_y); center_y);
} }
break; break;
case PROP_SCALE_GRAVITY: case PROP_SCALE_GRAVITY:
clutter_actor_set_scale_with_gravity (actor, clutter_actor_set_scale_with_gravity (actor,
priv->scale_x, priv->scale_x,
priv->scale_y, priv->scale_y,
g_value_get_enum (value)); g_value_get_enum (value));
break; break;
case PROP_CLIP: case PROP_CLIP:
{ {
ClutterGeometry *geom = g_value_get_boxed (value); const ClutterGeometry *geom = g_value_get_boxed (value);
clutter_actor_set_clip (actor, clutter_actor_set_clip (actor,
geom->x, geom->y, geom->x, geom->y,
geom->width, geom->height); geom->width, geom->height);
} }
break; break;
case PROP_CLIP_TO_ALLOCATION: case PROP_CLIP_TO_ALLOCATION:
if (priv->clip_to_allocation != g_value_get_boolean (value)) 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); clutter_actor_queue_redraw (actor);
} }
break; break;
case PROP_REACTIVE: case PROP_REACTIVE:
clutter_actor_set_reactive (actor, g_value_get_boolean (value)); clutter_actor_set_reactive (actor, g_value_get_boolean (value));
break; break;
case PROP_ROTATION_ANGLE_X: case PROP_ROTATION_ANGLE_X:
clutter_actor_set_rotation_internal (actor, clutter_actor_set_rotation_internal (actor,
CLUTTER_X_AXIS, CLUTTER_X_AXIS,
g_value_get_double (value)); g_value_get_double (value));
break; break;
case PROP_ROTATION_ANGLE_Y: case PROP_ROTATION_ANGLE_Y:
clutter_actor_set_rotation_internal (actor, clutter_actor_set_rotation_internal (actor,
CLUTTER_Y_AXIS, CLUTTER_Y_AXIS,
g_value_get_double (value)); g_value_get_double (value));
break; break;
case PROP_ROTATION_ANGLE_Z: case PROP_ROTATION_ANGLE_Z:
clutter_actor_set_rotation_internal (actor, clutter_actor_set_rotation_internal (actor,
CLUTTER_Z_AXIS, CLUTTER_Z_AXIS,
g_value_get_double (value)); g_value_get_double (value));
break; break;
case PROP_ROTATION_CENTER_X: case PROP_ROTATION_CENTER_X:
{ {
const ClutterVertex *center; const ClutterVertex *center;
@ -2536,6 +2563,7 @@ clutter_actor_set_property (GObject *object,
center->z); center->z);
} }
break; break;
case PROP_ROTATION_CENTER_Y: case PROP_ROTATION_CENTER_Y:
{ {
const ClutterVertex *center; const ClutterVertex *center;
@ -2549,6 +2577,7 @@ clutter_actor_set_property (GObject *object,
center->z); center->z);
} }
break; break;
case PROP_ROTATION_CENTER_Z: case PROP_ROTATION_CENTER_Z:
{ {
const ClutterVertex *center; const ClutterVertex *center;
@ -2562,13 +2591,15 @@ clutter_actor_set_property (GObject *object,
center->z); center->z);
} }
break; break;
case PROP_ROTATION_CENTER_Z_GRAVITY: case PROP_ROTATION_CENTER_Z_GRAVITY:
clutter_actor_set_z_rotation_from_gravity clutter_actor_set_z_rotation_from_gravity (actor, priv->rzang,
(actor, priv->rzang, g_value_get_enum (value)); g_value_get_enum (value));
break; break;
case PROP_ANCHOR_X: case PROP_ANCHOR_X:
{ {
gint anchor_x = g_value_get_int (value); gfloat anchor_x = g_value_get_float (value);
gfloat anchor_y; gfloat anchor_y;
clutter_anchor_coord_get_units (actor, &priv->anchor, 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); clutter_actor_set_anchor_point (actor, anchor_x, anchor_y);
} }
break; break;
case PROP_ANCHOR_Y: case PROP_ANCHOR_Y:
{ {
gint anchor_y = g_value_get_int (value); gfloat anchor_y = g_value_get_int (value);
gfloat anchor_x; gfloat anchor_x;
clutter_anchor_coord_get_units (actor, &priv->anchor, clutter_anchor_coord_get_units (actor, &priv->anchor,
&anchor_x, &anchor_x,
@ -2590,13 +2622,16 @@ clutter_actor_set_property (GObject *object,
clutter_actor_set_anchor_point (actor, anchor_x, anchor_y); clutter_actor_set_anchor_point (actor, anchor_x, anchor_y);
} }
break; break;
case PROP_ANCHOR_GRAVITY: case PROP_ANCHOR_GRAVITY:
clutter_actor_set_anchor_point_from_gravity (actor, clutter_actor_set_anchor_point_from_gravity (actor,
g_value_get_enum (value)); g_value_get_enum (value));
break; break;
case PROP_SHOW_ON_SET_PARENT: case PROP_SHOW_ON_SET_PARENT:
priv->show_on_set_parent = g_value_get_boolean (value); priv->show_on_set_parent = g_value_get_boolean (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -2609,86 +2644,107 @@ clutter_actor_get_property (GObject *object,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
ClutterActor *actor; ClutterActor *actor = CLUTTER_ACTOR (object);
ClutterActorPrivate *priv; ClutterActorPrivate *priv = actor->priv;
actor = CLUTTER_ACTOR(object);
priv = actor->priv;
switch (prop_id) switch (prop_id)
{ {
case PROP_X: case PROP_X:
g_value_set_int (value, clutter_actor_get_x (actor)); g_value_set_float (value, clutter_actor_get_x (actor));
break; break;
case PROP_Y: case PROP_Y:
g_value_set_int (value, clutter_actor_get_y (actor)); g_value_set_float (value, clutter_actor_get_y (actor));
break; break;
case PROP_WIDTH: case PROP_WIDTH:
g_value_set_int (value, clutter_actor_get_width (actor)); g_value_set_float (value, clutter_actor_get_width (actor));
break; break;
case PROP_HEIGHT: case PROP_HEIGHT:
g_value_set_int (value, clutter_actor_get_height (actor)); g_value_set_float (value, clutter_actor_get_height (actor));
break; break;
case PROP_FIXED_X: case PROP_FIXED_X:
clutter_value_set_unit (value, priv->fixed_x); g_value_set_float (value, priv->fixed_x);
break; break;
case PROP_FIXED_Y: case PROP_FIXED_Y:
clutter_value_set_unit (value, priv->fixed_y); g_value_set_float (value, priv->fixed_y);
break; break;
case PROP_FIXED_POSITION_SET: case PROP_FIXED_POSITION_SET:
g_value_set_boolean (value, priv->position_set); g_value_set_boolean (value, priv->position_set);
break; break;
case PROP_MIN_WIDTH: case PROP_MIN_WIDTH:
clutter_value_set_unit (value, priv->request_min_width); g_value_set_float (value, priv->request_min_width);
break; break;
case PROP_MIN_HEIGHT: case PROP_MIN_HEIGHT:
clutter_value_set_unit (value, priv->request_min_height); g_value_set_float (value, priv->request_min_height);
break; break;
case PROP_NATURAL_WIDTH: case PROP_NATURAL_WIDTH:
clutter_value_set_unit (value, priv->request_natural_width); g_value_set_float (value, priv->request_natural_width);
break; break;
case PROP_NATURAL_HEIGHT: case PROP_NATURAL_HEIGHT:
clutter_value_set_unit (value, priv->request_natural_height); g_value_set_float (value, priv->request_natural_height);
break; break;
case PROP_MIN_WIDTH_SET: case PROP_MIN_WIDTH_SET:
g_value_set_boolean (value, priv->min_width_set); g_value_set_boolean (value, priv->min_width_set);
break; break;
case PROP_MIN_HEIGHT_SET: case PROP_MIN_HEIGHT_SET:
g_value_set_boolean (value, priv->min_height_set); g_value_set_boolean (value, priv->min_height_set);
break; break;
case PROP_NATURAL_WIDTH_SET: case PROP_NATURAL_WIDTH_SET:
g_value_set_boolean (value, priv->natural_width_set); g_value_set_boolean (value, priv->natural_width_set);
break; break;
case PROP_NATURAL_HEIGHT_SET: case PROP_NATURAL_HEIGHT_SET:
g_value_set_boolean (value, priv->natural_height_set); g_value_set_boolean (value, priv->natural_height_set);
break; break;
case PROP_REQUEST_MODE: case PROP_REQUEST_MODE:
g_value_set_enum (value, priv->request_mode); g_value_set_enum (value, priv->request_mode);
break; break;
case PROP_ALLOCATION: case PROP_ALLOCATION:
g_value_set_boxed (value, &priv->allocation); g_value_set_boxed (value, &priv->allocation);
break; break;
case PROP_DEPTH: case PROP_DEPTH:
g_value_set_int (value, clutter_actor_get_depth (actor)); g_value_set_float (value, clutter_actor_get_depth (actor));
break; break;
case PROP_OPACITY: case PROP_OPACITY:
g_value_set_uchar (value, priv->opacity); g_value_set_uchar (value, priv->opacity);
break; break;
case PROP_NAME: case PROP_NAME:
g_value_set_string (value, priv->name); g_value_set_string (value, priv->name);
break; break;
case PROP_VISIBLE: case PROP_VISIBLE:
g_value_set_boolean (value, CLUTTER_ACTOR_IS_VISIBLE (actor)); g_value_set_boolean (value, CLUTTER_ACTOR_IS_VISIBLE (actor));
break; break;
case PROP_MAPPED: case PROP_MAPPED:
g_value_set_boolean (value, CLUTTER_ACTOR_IS_MAPPED (actor)); g_value_set_boolean (value, CLUTTER_ACTOR_IS_MAPPED (actor));
break; break;
case PROP_REALIZED: case PROP_REALIZED:
g_value_set_boolean (value, CLUTTER_ACTOR_IS_REALIZED (actor)); g_value_set_boolean (value, CLUTTER_ACTOR_IS_REALIZED (actor));
break; break;
case PROP_HAS_CLIP: case PROP_HAS_CLIP:
g_value_set_boolean (value, priv->has_clip); g_value_set_boolean (value, priv->has_clip);
break; break;
case PROP_CLIP: case PROP_CLIP:
{ {
ClutterGeometry clip = { 0, }; ClutterGeometry clip = { 0, };
@ -2701,48 +2757,59 @@ clutter_actor_get_property (GObject *object,
g_value_set_boxed (value, &clip); g_value_set_boxed (value, &clip);
} }
break; break;
case PROP_CLIP_TO_ALLOCATION: case PROP_CLIP_TO_ALLOCATION:
g_value_set_boolean (value, priv->clip_to_allocation); g_value_set_boolean (value, priv->clip_to_allocation);
break; break;
case PROP_SCALE_X: case PROP_SCALE_X:
g_value_set_double (value, priv->scale_x); g_value_set_double (value, priv->scale_x);
break; break;
case PROP_SCALE_Y: case PROP_SCALE_Y:
g_value_set_double (value, priv->scale_y); g_value_set_double (value, priv->scale_y);
break; break;
case PROP_SCALE_CENTER_X: case PROP_SCALE_CENTER_X:
{ {
gfloat center; gfloat center;
clutter_actor_get_scale_center (actor, &center, NULL); clutter_actor_get_scale_center (actor, &center, NULL);
g_value_set_int (value, center); g_value_set_float (value, center);
} }
break; break;
case PROP_SCALE_CENTER_Y: case PROP_SCALE_CENTER_Y:
{ {
gfloat center; gfloat center;
clutter_actor_get_scale_center (actor, NULL, &center); clutter_actor_get_scale_center (actor, NULL, &center);
g_value_set_int (value, center); g_value_set_float (value, center);
} }
break; break;
case PROP_SCALE_GRAVITY: case PROP_SCALE_GRAVITY:
g_value_set_enum (value, clutter_actor_get_scale_gravity (actor)); g_value_set_enum (value, clutter_actor_get_scale_gravity (actor));
break; break;
case PROP_REACTIVE: case PROP_REACTIVE:
g_value_set_boolean (value, clutter_actor_get_reactive (actor)); g_value_set_boolean (value, clutter_actor_get_reactive (actor));
break; break;
case PROP_ROTATION_ANGLE_X: case PROP_ROTATION_ANGLE_X:
g_value_set_double (value, priv->rxang); g_value_set_double (value, priv->rxang);
break; break;
case PROP_ROTATION_ANGLE_Y: case PROP_ROTATION_ANGLE_Y:
g_value_set_double (value, priv->ryang); g_value_set_double (value, priv->ryang);
break; break;
case PROP_ROTATION_ANGLE_Z: case PROP_ROTATION_ANGLE_Z:
g_value_set_double (value, priv->rzang); g_value_set_double (value, priv->rzang);
break; break;
case PROP_ROTATION_CENTER_X: case PROP_ROTATION_CENTER_X:
{ {
ClutterVertex center; ClutterVertex center;
@ -2755,6 +2822,7 @@ clutter_actor_get_property (GObject *object,
g_value_set_boxed (value, &center); g_value_set_boxed (value, &center);
} }
break; break;
case PROP_ROTATION_CENTER_Y: case PROP_ROTATION_CENTER_Y:
{ {
ClutterVertex center; ClutterVertex center;
@ -2767,6 +2835,7 @@ clutter_actor_get_property (GObject *object,
g_value_set_boxed (value, &center); g_value_set_boxed (value, &center);
} }
break; break;
case PROP_ROTATION_CENTER_Z: case PROP_ROTATION_CENTER_Z:
{ {
ClutterVertex center; ClutterVertex center;
@ -2779,9 +2848,11 @@ clutter_actor_get_property (GObject *object,
g_value_set_boxed (value, &center); g_value_set_boxed (value, &center);
} }
break; break;
case PROP_ROTATION_CENTER_Z_GRAVITY: case PROP_ROTATION_CENTER_Z_GRAVITY:
g_value_set_enum (value, clutter_actor_get_z_rotation_gravity (actor)); g_value_set_enum (value, clutter_actor_get_z_rotation_gravity (actor));
break; break;
case PROP_ANCHOR_X: case PROP_ANCHOR_X:
{ {
gfloat anchor_x; gfloat anchor_x;
@ -2790,9 +2861,10 @@ clutter_actor_get_property (GObject *object,
&anchor_x, &anchor_x,
NULL, NULL,
NULL); NULL);
g_value_set_int (value, anchor_x); g_value_set_float (value, anchor_x);
} }
break; break;
case PROP_ANCHOR_Y: case PROP_ANCHOR_Y:
{ {
gfloat anchor_y; gfloat anchor_y;
@ -2801,15 +2873,18 @@ clutter_actor_get_property (GObject *object,
NULL, NULL,
&anchor_y, &anchor_y,
NULL); NULL);
g_value_set_int (value, anchor_y); g_value_set_float (value, anchor_y);
} }
break; break;
case PROP_ANCHOR_GRAVITY: case PROP_ANCHOR_GRAVITY:
g_value_set_enum (value, clutter_actor_get_anchor_point_gravity (actor)); g_value_set_enum (value, clutter_actor_get_anchor_point_gravity (actor));
break; break;
case PROP_SHOW_ON_SET_PARENT: case PROP_SHOW_ON_SET_PARENT:
g_value_set_boolean (value, priv->show_on_set_parent); g_value_set_boolean (value, priv->show_on_set_parent);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -2896,12 +2971,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* position for the actor. If read, returns the fixed position if any, * position for the actor. If read, returns the fixed position if any,
* otherwise the allocation if available, otherwise 0. * otherwise the allocation if available, otherwise 0.
*/ */
pspec = g_param_spec_int ("x", pspec = g_param_spec_float ("x",
"X coordinate", "X coordinate",
"X coordinate of the actor", "X coordinate of the actor",
-G_MAXINT, G_MAXINT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_X, pspec); 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 * position for the actor. If read, returns the fixed position if
* any, otherwise the allocation if available, otherwise 0. * any, otherwise the allocation if available, otherwise 0.
*/ */
pspec = g_param_spec_int ("y", pspec = g_param_spec_float ("y",
"Y coordinate", "Y coordinate",
"Y coordinate of the actor", "Y coordinate of the actor",
-G_MAXINT, G_MAXINT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_Y, pspec); 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 * natural size request of the actor to the given width. If read, returns
* the allocated width if available, otherwise the width request. * the allocated width if available, otherwise the width request.
*/ */
pspec = g_param_spec_int ("width", pspec = g_param_spec_float ("width",
"Width", "Width",
"Width of the actor", "Width of the actor",
0, G_MAXINT, 0.0, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_WIDTH, pspec); g_object_class_install_property (object_class, PROP_WIDTH, pspec);
/** /**
* ClutterActor:height: * 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 * natural size request of the actor to the given height. If read, returns
* the allocated height if available, otherwise the height request. * the allocated height if available, otherwise the height request.
*/ */
pspec = g_param_spec_int ("height", pspec = g_param_spec_float ("height",
"Height", "Height",
"Height of the actor", "Height of the actor",
0, G_MAXINT, 0.0, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_HEIGHT, pspec); g_object_class_install_property (object_class, PROP_HEIGHT, pspec);
/** /**
@ -2958,12 +3033,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("fixed-x", pspec = g_param_spec_float ("fixed-x",
"Fixed X", "Fixed X",
"Forced X position of the actor", "Forced X position of the actor",
CLUTTER_MINUNIT, CLUTTER_MAXUNIT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_FIXED_X, pspec); g_object_class_install_property (object_class, PROP_FIXED_X, pspec);
/** /**
@ -2976,12 +3051,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("fixed-y", pspec = g_param_spec_float ("fixed-y",
"Fixed Y", "Fixed Y",
"Forced Y position of the actor", "Forced Y position of the actor",
CLUTTER_MINUNIT, CLUTTER_MAXUNIT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_FIXED_Y, pspec); g_object_class_install_property (object_class, PROP_FIXED_Y, pspec);
/** /**
@ -3014,13 +3089,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("min-width", pspec = g_param_spec_float ("min-width",
"Min Width", "Min Width",
"Forced minimum width request " "Forced minimum width request for the actor",
"for the actor", 0.0, G_MAXFLOAT,
0, CLUTTER_MAXUNIT, 0.0,
0, CLUTTER_PARAM_READWRITE);
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_MIN_WIDTH, pspec); g_object_class_install_property (object_class, PROP_MIN_WIDTH, pspec);
/** /**
@ -3034,13 +3108,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("min-height", pspec = g_param_spec_float ("min-height",
"Min Height", "Min Height",
"Forced minimum height request " "Forced minimum height request for the actor",
"for the actor", 0.0, G_MAXFLOAT,
0, CLUTTER_MAXUNIT, 0.0,
0, CLUTTER_PARAM_READWRITE);
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_MIN_HEIGHT, pspec); g_object_class_install_property (object_class, PROP_MIN_HEIGHT, pspec);
/** /**
@ -3054,13 +3127,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("natural-width", pspec = g_param_spec_float ("natural-width",
"Natural Width", "Natural Width",
"Forced natural width request " "Forced natural width request for the actor",
"for the actor", 0.0, G_MAXFLOAT,
0, CLUTTER_MAXUNIT, 0.0,
0, CLUTTER_PARAM_READWRITE);
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_NATURAL_WIDTH, pspec); g_object_class_install_property (object_class, PROP_NATURAL_WIDTH, pspec);
/** /**
@ -3074,13 +3146,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = clutter_param_spec_unit ("natural-height", pspec = g_param_spec_float ("natural-height",
"Natural Height", "Natural Height",
"Forced natural height request " "Forced natural height request for the actor",
"for the actor", 0.0, G_MAXFLOAT,
0, CLUTTER_MAXUNIT, 0.0,
0, CLUTTER_PARAM_READWRITE);
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_NATURAL_HEIGHT, pspec); g_object_class_install_property (object_class, PROP_NATURAL_HEIGHT, pspec);
/** /**
@ -3224,16 +3295,16 @@ clutter_actor_class_init (ClutterActorClass *klass)
/** /**
* ClutterActor:depth: * ClutterActor:depth:
* *
* Depth of the actor. * The position of the actor on the Z axis
* *
* Since: 0.6 * Since: 0.6
*/ */
pspec = g_param_spec_int ("depth", pspec = g_param_spec_float ("depth",
"Depth", "Depth",
"Depth of actor", "Position on the Z axis",
-G_MAXINT, G_MAXINT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0.0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_DEPTH, pspec); 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", pspec = g_param_spec_uchar ("opacity",
"Opacity", "Opacity",
"Opacity of actor", "Opacity of actor",
0, 0xff, 0, 255,
0xff, 255,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_OPACITY, pspec); g_object_class_install_property (object_class, PROP_OPACITY, pspec);
@ -3387,11 +3458,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 1.0 * Since: 1.0
*/ */
pspec = g_param_spec_int ("scale-center-x", pspec = g_param_spec_float ("scale-center-x",
"Scale-Center-X", "Scale-Center-X",
"Horizontal scale center", "Horizontal scale center",
G_MININT, G_MAXINT, 0, -G_MAXFLOAT, G_MAXFLOAT,
CLUTTER_PARAM_READWRITE); 0.0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SCALE_CENTER_X, pspec); 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 * Since: 1.0
*/ */
pspec = g_param_spec_int ("scale-center-y", pspec = g_param_spec_float ("scale-center-y",
"Scale-Center-Y", "Scale-Center-Y",
"Vertical scale center", "Vertical scale center",
G_MININT, G_MAXINT, 0, -G_MAXFLOAT, G_MAXFLOAT,
CLUTTER_PARAM_READWRITE); 0.0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SCALE_CENTER_Y, pspec); 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 * Since: 0.8
*/ */
pspec = g_param_spec_int ("anchor-x", pspec = g_param_spec_float ("anchor-x",
"Anchor X", "Anchor X",
"X coordinate of the anchor point", "X coordinate of the anchor point",
-G_MAXINT, G_MAXINT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ANCHOR_X, pspec); g_object_class_install_property (object_class, PROP_ANCHOR_X, pspec);
/** /**
@ -3559,12 +3632,12 @@ clutter_actor_class_init (ClutterActorClass *klass)
* *
* Since: 0.8 * Since: 0.8
*/ */
pspec = g_param_spec_int ("anchor-y", pspec = g_param_spec_float ("anchor-y",
"Anchor Y", "Anchor Y",
"Y coordinate of the anchor point", "Y coordinate of the anchor point",
-G_MAXINT, G_MAXINT, -G_MAXFLOAT, G_MAXFLOAT,
0, 0,
CLUTTER_PARAM_READWRITE); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ANCHOR_Y, pspec); g_object_class_install_property (object_class, PROP_ANCHOR_Y, pspec);
/** /**

View File

@ -265,8 +265,16 @@ clutter_interval_real_compute_value (ClutterInterval *interval,
{ {
gdouble ia, ib, res; gdouble ia, ib, res;
ia = g_value_get_double (initial); if (value_type == G_TYPE_DOUBLE)
ib = g_value_get_double (final); {
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; res = (factor * (ib - ia)) + ia;

View File

@ -78,6 +78,9 @@ test_conformance_LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@C
test: test:
@gtester -o=test-conformance-results.xml ./test-conformance @gtester -o=test-conformance-results.xml ./test-conformance
test-verbose:
@gtester --verbose -o=test-conformance-result.xml ./test-conformance
test-report-normal: test-report-normal:
@gtester -o=test-conformance-results.xml -k ./test-conformance \ @gtester -o=test-conformance-results.xml -k ./test-conformance \
&& ( gtester-report test-conformance-results.xml \ && ( gtester-report test-conformance-results.xml \

View File

@ -20,8 +20,8 @@
#define NOTIFY_ROTATION_CENTER_Z (1 << 13) #define NOTIFY_ROTATION_CENTER_Z (1 << 13)
#define NOTIFY_ROTATION_CENTER_Z_GRAVITY (1 << 14) #define NOTIFY_ROTATION_CENTER_Z_GRAVITY (1 << 14)
#define RECT_WIDTH 100 #define RECT_WIDTH 100.0
#define RECT_HEIGHT 80 #define RECT_HEIGHT 80.0
/* Allow the transformed position by off by a certain number of /* Allow the transformed position by off by a certain number of
pixels */ pixels */
@ -36,7 +36,8 @@ typedef struct _TestState
static const struct static const struct
{ {
ClutterGravity gravity; ClutterGravity gravity;
gint x_pos, y_pos; gfloat x_pos;
gfloat y_pos;
} gravities[] = } gravities[] =
{ {
{ CLUTTER_GRAVITY_NORTH, RECT_WIDTH / 2, 0 }, { CLUTTER_GRAVITY_NORTH, RECT_WIDTH / 2, 0 },
@ -50,23 +51,25 @@ static const struct
{ CLUTTER_GRAVITY_CENTER, RECT_WIDTH / 2, RECT_HEIGHT / 2 } { CLUTTER_GRAVITY_CENTER, RECT_WIDTH / 2, RECT_HEIGHT / 2 }
}; };
static const char * const static const char * const properties[] = {
properties[] = "anchor-x",
{ "anchor-x", "anchor-y",
"anchor-y", "anchor-gravity",
"anchor-gravity", "scale-x",
"scale-x", "scale-y",
"scale-y", "scale-center-x",
"scale-center-x", "scale-center-y",
"scale-center-y", "scale-gravity",
"scale-gravity", "rotation-angle-x",
"rotation-angle-x", "rotation-angle-y",
"rotation-angle-y", "rotation-angle-z",
"rotation-angle-z", "rotation-center-x",
"rotation-center-x", "rotation-center-y",
"rotation-center-y", "rotation-center-z",
"rotation-center-z", "rotation-center-z-gravity"
"rotation-center-z-gravity" }; };
static const int n_properties = G_N_ELEMENTS (properties);
static void static void
notify_cb (GObject *object, GParamSpec *pspec, TestState *state) 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 new_flags = 0;
int flag = 1; 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)) if (!strcmp (properties[i], pspec->name))
new_flags |= flag; new_flags |= flag;
flag <<= 1; flag <<= 1;
} }
@ -87,43 +91,31 @@ notify_cb (GObject *object, GParamSpec *pspec, TestState *state)
state->notifications |= new_flags; state->notifications |= new_flags;
} }
#define assert_notifications(flags) \ #define assert_notifications(flags) G_STMT_START { \
do \ g_assert (state->notifications == (flags)); \
{ \ state->notifications = 0; } G_STMT_END
g_assert (state->notifications == (flags)); \
state->notifications = 0; \
} while (0)
/* Helper macro to assert the transformed position. This needs to be a /* Helper macro to assert the transformed position. This needs to be a
macro so that the assertion failure will report the right line macro so that the assertion failure will report the right line
number */ number */
#define assert_coords(state, x_1, y_1, x_2, y_2) \ #define assert_coords(state, x_1, y_1, x_2, y_2) G_STMT_START { \
do \ ClutterVertex verts[4]; \
{ \ clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \
ClutterVertex verts[4]; \ check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \
clutter_actor_get_abs_allocation_vertices ((state)->rect, verts); \ g_assert (approx_equal ((x_1), CLUTTER_UNITS_TO_DEVICE (verts[0].x)));\
check_coords ((state), (x_1), (y_1), (x_2), (y_2), verts); \ g_assert (approx_equal ((y_1), CLUTTER_UNITS_TO_DEVICE (verts[0].y)));\
g_assert (approx_equal ((x_1), \ g_assert (approx_equal ((x_2), CLUTTER_UNITS_TO_DEVICE (verts[3].x)));\
CLUTTER_UNITS_TO_DEVICE (verts[0].x))); \ g_assert (approx_equal ((y_2), CLUTTER_UNITS_TO_DEVICE (verts[3].y)));\
g_assert (approx_equal ((y_1), \ } G_STMT_END
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_position(state, x, y) \ #define assert_position(state, x, y) \
assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT) assert_coords((state), (x), (y), (x) + RECT_WIDTH, (y) + RECT_HEIGHT)
#define assert_vertex_and_free(v, xc, yc, zc) \ #define assert_vertex_and_free(v, xc, yc, zc) G_STMT_START { \
do \ g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) && \
{ \ approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) && \
g_assert (approx_equal (CLUTTER_UNITS_TO_DEVICE (v->x), xc) \ approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \
&& approx_equal (CLUTTER_UNITS_TO_DEVICE (v->y), yc) \ g_boxed_free (CLUTTER_TYPE_VERTEX, v); } G_STMT_END
&& approx_equal (CLUTTER_UNITS_TO_DEVICE (v->z), zc)); \
g_boxed_free (CLUTTER_TYPE_VERTEX, v); \
} while (0)
static inline gboolean static inline gboolean
approx_equal (int a, int b) approx_equal (int a, int b)
@ -133,7 +125,10 @@ approx_equal (int a, int b)
static void static void
check_coords (TestState *state, 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) const ClutterVertex *verts)
{ {
if (g_test_verbose ()) if (g_test_verbose ())
@ -154,7 +149,7 @@ static void
test_anchor_point (TestState *state) test_anchor_point (TestState *state)
{ {
ClutterActor *rect = state->rect; ClutterActor *rect = state->rect;
gint anchor_x, anchor_y; gfloat anchor_x, anchor_y;
ClutterGravity anchor_gravity; ClutterGravity anchor_gravity;
int i; 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_width (rect) == RECT_WIDTH);
g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == 0); g_assert (anchor_x == 0);
@ -174,7 +170,8 @@ test_anchor_point (TestState *state)
/* Change the anchor point */ /* Change the anchor point */
clutter_actor_set_anchor_point (rect, 20, 30); clutter_actor_set_anchor_point (rect, 20, 30);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == 20); g_assert (anchor_x == 20);
@ -186,7 +183,8 @@ test_anchor_point (TestState *state)
/* Move the anchor point */ /* Move the anchor point */
clutter_actor_move_anchor_point (rect, 40, 50); clutter_actor_move_anchor_point (rect, 40, 50);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == 40); 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_set (rect, "anchor-gravity", gravities[i].gravity, NULL);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == gravities[i].x_pos); g_assert (anchor_x == gravities[i].x_pos);
@ -232,7 +231,8 @@ test_anchor_point (TestState *state)
it is set from the gravity */ it is set from the gravity */
clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2); clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == RECT_WIDTH); g_assert (anchor_x == RECT_WIDTH);
@ -261,7 +261,8 @@ test_anchor_point (TestState *state)
size when it is set from units */ size when it is set from units */
clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2); clutter_actor_set_size (rect, RECT_WIDTH * 2, RECT_HEIGHT * 2);
g_object_get (rect, g_object_get (rect,
"anchor-x", &anchor_x, "anchor-y", &anchor_y, "anchor-x", &anchor_x,
"anchor-y", &anchor_y,
"anchor-gravity", &anchor_gravity, "anchor-gravity", &anchor_gravity,
NULL); NULL);
g_assert (anchor_x == 20); g_assert (anchor_x == 20);
@ -281,7 +282,7 @@ test_scale_center (TestState *state)
{ {
ClutterActor *rect = state->rect; ClutterActor *rect = state->rect;
gdouble scale_x, scale_y; gdouble scale_x, scale_y;
gint center_x, center_y; gfloat center_x, center_y;
ClutterGravity gravity; ClutterGravity gravity;
int i; 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_width (rect) == RECT_WIDTH);
g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT);
g_object_get (rect, g_object_get (rect,
"scale-center-x", &center_x, "scale-center-y", &center_y, "scale-center-x", &center_x,
"scale-x", &scale_x, "scale-y", &scale_y, "scale-center-y", &center_y,
"scale-x", &scale_x,
"scale-y", &scale_y,
"scale-gravity", &gravity, "scale-gravity", &gravity,
NULL); NULL);
g_assert (center_x == 0); 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_width (rect) == RECT_WIDTH);
g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT); g_assert (clutter_actor_get_height (rect) == RECT_HEIGHT);
g_object_get (rect, g_object_get (rect,
"scale-center-x", &center_x, "scale-center-y", &center_y, "scale-center-x", &center_x,
"scale-x", &scale_x, "scale-y", &scale_y, "scale-center-y", &center_y,
"scale-x", &scale_x,
"scale-y", &scale_y,
"scale-gravity", &gravity, "scale-gravity", &gravity,
NULL); NULL);
g_assert (center_x == 0); 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); assert_coords (state, 100, 200, 100 + RECT_WIDTH * 2, 200 + RECT_HEIGHT * 3);
/* Change the scale and center */ /* Change the scale and center */
g_object_set (rect, "scale-x", 4.0, "scale-y", 2.0, g_object_set (rect,
"scale-center-x", 10, "scale-center-y", 20, NULL); "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_x (rect) == 100);
g_assert (clutter_actor_get_y (rect) == 200); g_assert (clutter_actor_get_y (rect) == 200);
g_assert (clutter_actor_get_width (rect) == RECT_WIDTH); g_assert (clutter_actor_get_width (rect) == RECT_WIDTH);
@ -388,8 +397,10 @@ test_scale_center (TestState *state)
gravity property changes */ gravity property changes */
clutter_actor_set_scale_full (rect, 4, 2, 10, 20); clutter_actor_set_scale_full (rect, 4, 2, 10, 20);
g_object_get (rect, g_object_get (rect,
"scale-center-x", &center_x, "scale-center-y", &center_y, "scale-center-x", &center_x,
"scale-x", &scale_x, "scale-y", &scale_y, "scale-center-y", &center_y,
"scale-x", &scale_x,
"scale-y", &scale_y,
"scale-gravity", &gravity, "scale-gravity", &gravity,
NULL); NULL);
g_assert (center_x == 10); g_assert (center_x == 10);

View File

@ -273,19 +273,19 @@ test_binding_pool (TestConformSimpleFixture *fixture,
clutter_container_add (CLUTTER_CONTAINER (key_group), clutter_container_add (CLUTTER_CONTAINER (key_group),
g_object_new (CLUTTER_TYPE_RECTANGLE, g_object_new (CLUTTER_TYPE_RECTANGLE,
"width", 50, "width", 50.0,
"height", 50, "height", 50.0,
"x", 0, "y", 0, "x", 0.0, "y", 0.0,
NULL), NULL),
g_object_new (CLUTTER_TYPE_RECTANGLE, g_object_new (CLUTTER_TYPE_RECTANGLE,
"width", 50, "width", 50.0,
"height", 50, "height", 50.0,
"x", 75, "y", 0, "x", 75.0, "y", 0.0,
NULL), NULL),
g_object_new (CLUTTER_TYPE_RECTANGLE, g_object_new (CLUTTER_TYPE_RECTANGLE,
"width", 50, "width", 50.0,
"height", 50, "height", 50.0,
"x", 150, "y", 0, "x", 150.0, "y", 0.0,
NULL), NULL),
NULL); NULL);

View File

@ -65,10 +65,10 @@ on_button_press (ClutterActor *actor,
animation = animation =
clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000, clutter_actor_animate (actor, CLUTTER_EASE_IN_EXPO, 2000,
"x", (int) new_x, "x", new_x,
"y", (int) new_y, "y", new_y,
"width", (int) new_width, "width", new_width,
"height", (int) new_height, "height", new_height,
"color", &new_color, "color", &new_color,
"rotation-angle-z", new_angle, "rotation-angle-z", new_angle,
"fixed::rotation-center-z", &vertex, "fixed::rotation-center-z", &vertex,

View File

@ -166,21 +166,19 @@ void foo(void) { g_usleep(10000000); }
int int
test_clutter_cairo_flowers_main (int argc, char **argv) test_clutter_cairo_flowers_main (int argc, char **argv)
{ {
int i; int i;
ClutterActor *stage; ClutterActor *stage;
ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff };
Flower *flowers[N_FLOWERS]; Flower *flowers[N_FLOWERS];
srand(time(NULL)); srand (time (NULL));
clutter_init (&argc, &argv); clutter_init (&argc, &argv);
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
&stage_color); clutter_stage_fullscreen (CLUTTER_STAGE (stage));
g_object_set(stage, "fullscreen", TRUE, NULL);
for (i=0; i< N_FLOWERS; i++) 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]->rv = rand() % 5 + 1;
flowers[i]->v = rand() % 10 + 2; 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, clutter_actor_set_position (flowers[i]->ctex,
flowers[i]->x, flowers[i]->y); flowers[i]->x, flowers[i]->y);
} }
g_timeout_add (50, tick, flowers); 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_signal_connect (stage, "key-press-event",
G_CALLBACK (clutter_main_quit), G_CALLBACK (clutter_main_quit),
@ -207,6 +206,6 @@ test_clutter_cairo_flowers_main (int argc, char **argv)
clutter_main(); clutter_main();
return 1; return EXIT_SUCCESS;
} }

View File

@ -123,7 +123,7 @@ test_cogl_multitexture_main (int argc, char *argv[])
state->group); state->group);
timeline = clutter_timeline_new (TIMELINE_FRAME_COUNT, 26 /* fps */); 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); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), state);

View File

@ -371,7 +371,7 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
/* Timeline for animation */ /* Timeline for animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */ 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); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox);
clutter_timeline_start (timeline); clutter_timeline_start (timeline);

View File

@ -203,7 +203,7 @@ test_cogl_tex_tile_main (int argc, char *argv[])
/* Timeline for animation */ /* Timeline for animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */ 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); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), coglbox);
clutter_timeline_start (timeline); clutter_timeline_start (timeline);

View File

@ -94,8 +94,8 @@ on_button_press (ClutterActor *actor,
animation = animation =
clutter_actor_animate (rectangle, cur_mode, 2000, clutter_actor_animate (rectangle, cur_mode, 2000,
"x", (int) event->x, "x", event->x,
"y", (int) event->y, "y", event->y,
"color", &color, "color", &color,
NULL); NULL);
} }

View File

@ -551,14 +551,13 @@ my_thing_init (MyThing *thing)
} }
ClutterActor * ClutterActor *
my_thing_new (gint padding, my_thing_new (gfloat padding,
gint spacing) gfloat spacing)
{ {
return g_object_new (MY_TYPE_THING, return g_object_new (MY_TYPE_THING,
"padding", CLUTTER_UNITS_FROM_DEVICE (padding), "padding", padding,
"spacing", CLUTTER_UNITS_FROM_DEVICE (spacing), "spacing", spacing,
NULL); NULL);
} }
/* test code */ /* test code */
@ -591,13 +590,13 @@ static void
increase_property_value (ClutterActor *actor, increase_property_value (ClutterActor *actor,
const char *property_name) const char *property_name)
{ {
ClutterUnit value; gfloat value;
g_object_get (G_OBJECT (actor), g_object_get (G_OBJECT (actor),
property_name, &value, property_name, &value,
NULL); NULL);
value = value + CLUTTER_UNITS_FROM_DEVICE (10); value = value + 10.0;
g_object_set (G_OBJECT (box), g_object_set (G_OBJECT (box),
property_name, value, property_name, value,
@ -608,13 +607,13 @@ static void
decrease_property_value (ClutterActor *actor, decrease_property_value (ClutterActor *actor,
const char *property_name) const char *property_name)
{ {
ClutterUnit value; gfloat value;
g_object_get (G_OBJECT (actor), g_object_get (G_OBJECT (actor),
property_name, &value, property_name, &value,
NULL); NULL);
value = MAX (0, value - CLUTTER_UNITS_FROM_DEVICE (10)); value = MAX (0, value - 10.0);
g_object_set (G_OBJECT (box), g_object_set (G_OBJECT (box),
property_name, value, property_name, value,

View File

@ -73,7 +73,7 @@ on_button_press (ClutterActor *actor,
clutter_stage_set_title (CLUTTER_STAGE(new_stage), win_title); clutter_stage_set_title (CLUTTER_STAGE(new_stage), win_title);
timeline = clutter_timeline_new_for_duration (2000); 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); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
r_behave = clutter_behaviour_rotate_new (alpha, r_behave = clutter_behaviour_rotate_new (alpha,

View File

@ -209,7 +209,7 @@ test_paint_wrapper_main (int argc, char *argv[])
/* Create a timeline to manage animation */ /* Create a timeline to manage animation */
timeline = clutter_timeline_new (360, 60); /* num frames, fps */ 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 */ /* fire a callback for frame change */
g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh); g_signal_connect (timeline, "new-frame", G_CALLBACK (frame_cb), oh);

View File

@ -45,7 +45,7 @@ test_rotate_main (int argc, char *argv[])
/* Make a timeline */ /* Make a timeline */
timeline = clutter_timeline_new (200, 26); /* num frames, fps */ 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 */ /* Set an alpha func to power behaviour */
alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);

View File

@ -218,7 +218,8 @@ set_shader_num (ClutterActor *actor, gint new_no)
error = NULL; error = NULL;
g_object_set (G_OBJECT (shader), 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 /* 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 * with the shader sources we've provided. At a later stage it should be