2006-12-04 Emmanuele Bassi <ebassi@openedhand.com>

* clutter/clutter-private.h: Add our own READABLE,
	WRITABLE and READWRITE paramspec flags, declaring the
	string components of the properties GParamSpec as static;
	this should shave off some bytes in the memory footprint
	and avoid relocations.

	* clutter/clutter-actor.c:
	* clutter/clutter-behaviour.c:
	* clutter/clutter-behaviour-opacity.c:
	* clutter/clutter-behaviour-path.c:
	* clutter/clutter-behavuour-scale.c:
	* clutter/clutter-clone-texture.c:
	* clutter/clutter-label.c:
	* clutter/clutter-rectangle.c:
	* clutter/clutter-stage.c:
	* clutter/clutter-texture.c:
	* clutter/clutter-timeline.c: Use the CLUTTER_PARAM_*
	macros we just added.

	* clutter/clutter-behaviour-scale.c: Add properties for
	the scale begin, scale end and gravity parameters.

	* clutter/clutter-behaviour-path.h: Mark the ClutterKnot
	memory management functions as public (for the bindings),
	since we use the slice allocator for copying knots around;
	add a clutter_knot_equal() function.

	* clutter/clutter-behaviour-path.c:
	(node_distance): Use clutter_knot_equal() as a fast path
	to avoid the sqrt() in case the nodes we are using are
	at the same position.
	(path_total_length): Additional check on the existence
	of the next node.

	* examples/behave.c: Do not leak the ClutterBehaviour
	objects around.
This commit is contained in:
Emmanuele Bassi
2006-12-04 16:26:35 +00:00
parent 28d83d3c1a
commit f83ffa3520
16 changed files with 249 additions and 62 deletions

View File

@ -71,6 +71,15 @@ struct _ClutterBehaviourScalePrivate
CLUTTER_TYPE_BEHAVIOUR_SCALE, \
ClutterBehaviourScalePrivate))
enum
{
PROP_0,
PROP_SCALE_BEGIN,
PROP_SCALE_END,
PROP_SCALE_GRAVITY
};
static void
scale_frame_foreach (ClutterActor *actor,
ClutterBehaviourScale *behave)
@ -139,12 +148,115 @@ clutter_behaviour_scale_alpha_notify (ClutterBehaviour *behave,
CLUTTER_BEHAVIOUR_SCALE (behave));
}
static void
clutter_behaviour_scale_set_property (GObject *gobject,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ClutterBehaviourScalePrivate *priv;
priv = CLUTTER_BEHAVIOUR_SCALE (gobject)->priv;
switch (prop_id)
{
case PROP_SCALE_BEGIN:
priv->scale_begin = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
break;
case PROP_SCALE_END:
priv->scale_end = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
break;
case PROP_SCALE_GRAVITY:
priv->gravity = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
}
}
static void
clutter_behaviour_scale_get_property (GObject *gobject,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ClutterBehaviourScalePrivate *priv;
priv = CLUTTER_BEHAVIOUR_SCALE (gobject)->priv;
switch (prop_id)
{
case PROP_SCALE_BEGIN:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->scale_begin));
break;
case PROP_SCALE_END:
g_value_set_double (value, CLUTTER_FIXED_TO_FLOAT (priv->scale_end));
break;
case PROP_SCALE_GRAVITY:
g_value_set_enum (value, priv->gravity);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break;
}
}
static void
clutter_behaviour_scale_class_init (ClutterBehaviourScaleClass *klass)
{
ClutterBehaviourClass *behave_class;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterBehaviourClass *behave_class = CLUTTER_BEHAVIOUR_CLASS (klass);
gobject_class->set_property = clutter_behaviour_scale_set_property;
gobject_class->get_property = clutter_behaviour_scale_get_property;
/**
* ClutterBehaviourScale:scale-begin:
*
* The initial scaling factor for the actors.
*
* Since: 0.2
*/
g_object_class_install_property (gobject_class,
PROP_SCALE_BEGIN,
g_param_spec_double ("scale-begin",
"Scale Begin",
"Initial scale",
1.0, G_MAXDOUBLE,
1.0,
CLUTTER_PARAM_READWRITE));
/**
* ClutterBehaviourScale:scale-end:
*
* The final scaling factor for the actors.
*
* Since: 0.2
*/
g_object_class_install_property (gobject_class,
PROP_SCALE_END,
g_param_spec_double ("scale-end",
"Scale End",
"Final scale",
1.0, G_MAXDOUBLE,
1.0,
CLUTTER_PARAM_READWRITE));
/**
* ClutterBehaviourScale:gravity:
*
* The gravity of the scaling.
*
* Since: 0.2
*/
g_object_class_install_property (gobject_class,
PROP_SCALE_GRAVITY,
g_param_spec_enum ("scale-gravity",
"Scale Gravity",
"The gravity of the scaling",
CLUTTER_TYPE_GRAVITY,
CLUTTER_GRAVITY_CENTER,
CLUTTER_PARAM_READWRITE));
behave_class = (ClutterBehaviourClass*) klass;
behave_class->alpha_notify = clutter_behaviour_scale_alpha_notify;