Move ClutterBehaviourEllipse to CoglFixed

Remove the wrong usage of ClutterFixed, and use CoglFixed instead
in the API and the implementation.
This commit is contained in:
Emmanuele Bassi 2009-03-09 17:03:00 +00:00
parent 045ad21921
commit 764dc3bac4
2 changed files with 273 additions and 280 deletions

View File

@ -83,14 +83,18 @@ struct _ClutterBehaviourEllipsePrivate
{ {
ClutterKnot center; ClutterKnot center;
/* a = width / 2 */
gint a; gint a;
/* b = height / 2 */
gint b; gint b;
gfloat angle_start; gdouble angle_start;
gfloat angle_end; gdouble angle_end;
gfloat angle_tilt_x;
gfloat angle_tilt_y; gdouble angle_tilt_x;
gfloat angle_tilt_z; gdouble angle_tilt_y;
gdouble angle_tilt_z;
ClutterRotateDirection direction; ClutterRotateDirection direction;
}; };
@ -210,17 +214,17 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave,
gfloat angle = 0; gfloat angle = 0;
knot3d knot; knot3d knot;
/* we do everything in single precision because it's easier, even
* though all the parameters are stored in double precision for
* consistency with the equivalent ClutterActor API
*/
start = priv->angle_start; start = priv->angle_start;
end = priv->angle_end; end = priv->angle_end;
if (priv->direction == CLUTTER_ROTATE_CW && start >= end) if (priv->direction == CLUTTER_ROTATE_CW && start >= end)
{
end += 360; end += 360;
}
else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end) else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end)
{
end -= 360; end -= 360;
}
angle = (end - start) * alpha + start; angle = (end - start) * alpha + start;
@ -246,24 +250,31 @@ clutter_behaviour_ellipse_set_property (GObject *gobject,
case PROP_ANGLE_START: case PROP_ANGLE_START:
priv->angle_start = g_value_get_double (value); priv->angle_start = g_value_get_double (value);
break; break;
case PROP_ANGLE_END: case PROP_ANGLE_END:
priv->angle_end = g_value_get_double (value); priv->angle_end = g_value_get_double (value);
break; break;
case PROP_ANGLE_TILT_X: case PROP_ANGLE_TILT_X:
priv->angle_tilt_x = g_value_get_double (value); priv->angle_tilt_x = g_value_get_double (value);
break; break;
case PROP_ANGLE_TILT_Y: case PROP_ANGLE_TILT_Y:
priv->angle_tilt_y = g_value_get_double (value); priv->angle_tilt_y = g_value_get_double (value);
break; break;
case PROP_ANGLE_TILT_Z: case PROP_ANGLE_TILT_Z:
priv->angle_tilt_z = g_value_get_double (value); priv->angle_tilt_z = g_value_get_double (value);
break; break;
case PROP_WIDTH: case PROP_WIDTH:
priv->a = g_value_get_int (value) / 2; clutter_behaviour_ellipse_set_width (el, g_value_get_int (value));
break; break;
case PROP_HEIGHT: case PROP_HEIGHT:
priv->b = g_value_get_int (value) / 2; clutter_behaviour_ellipse_set_height (el, g_value_get_int (value));
break; break;
case PROP_CENTER: case PROP_CENTER:
{ {
ClutterKnot *knot = g_value_get_boxed (value); ClutterKnot *knot = g_value_get_boxed (value);
@ -271,9 +282,11 @@ clutter_behaviour_ellipse_set_property (GObject *gobject,
clutter_behaviour_ellipse_set_center (el, knot->x, knot->y); clutter_behaviour_ellipse_set_center (el, knot->x, knot->y);
} }
break; break;
case PROP_DIRECTION: case PROP_DIRECTION:
priv->direction = g_value_get_enum (value); priv->direction = g_value_get_enum (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -295,30 +308,39 @@ clutter_behaviour_ellipse_get_property (GObject *gobject,
case PROP_ANGLE_START: case PROP_ANGLE_START:
g_value_set_double (value, priv->angle_start); g_value_set_double (value, priv->angle_start);
break; break;
case PROP_ANGLE_END: case PROP_ANGLE_END:
g_value_set_double (value, priv->angle_end); g_value_set_double (value, priv->angle_end);
break; break;
case PROP_ANGLE_TILT_X: case PROP_ANGLE_TILT_X:
g_value_set_double (value, priv->angle_tilt_x); g_value_set_double (value, priv->angle_tilt_x);
break; break;
case PROP_ANGLE_TILT_Y: case PROP_ANGLE_TILT_Y:
g_value_set_double (value, priv->angle_tilt_y); g_value_set_double (value, priv->angle_tilt_y);
break; break;
case PROP_ANGLE_TILT_Z: case PROP_ANGLE_TILT_Z:
g_value_set_double (value, priv->angle_tilt_z); g_value_set_double (value, priv->angle_tilt_z);
break; break;
case PROP_WIDTH: case PROP_WIDTH:
g_value_set_int (value, (priv->a * 2)); g_value_set_int (value, (priv->a * 2));
break; break;
case PROP_HEIGHT: case PROP_HEIGHT:
g_value_set_int (value, (priv->b * 2)); g_value_set_int (value, (priv->b * 2));
break; break;
case PROP_CENTER: case PROP_CENTER:
g_value_set_boxed (value, &priv->center); g_value_set_boxed (value, &priv->center);
break; break;
case PROP_DIRECTION: case PROP_DIRECTION:
g_value_set_enum (value, priv->direction); g_value_set_enum (value, priv->direction);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
break; break;
@ -349,6 +371,9 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
{ {
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
ClutterBehaviourClass *behave_class = CLUTTER_BEHAVIOUR_CLASS (klass); ClutterBehaviourClass *behave_class = CLUTTER_BEHAVIOUR_CLASS (klass);
GParamSpec *pspec = NULL;
g_type_class_add_private (klass, sizeof (ClutterBehaviourEllipsePrivate));
object_class->set_property = clutter_behaviour_ellipse_set_property; object_class->set_property = clutter_behaviour_ellipse_set_property;
object_class->get_property = clutter_behaviour_ellipse_get_property; object_class->get_property = clutter_behaviour_ellipse_get_property;
@ -363,15 +388,14 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_double ("angle-start",
PROP_ANGLE_START,
g_param_spec_double ("angle-start",
"Start Angle", "Start Angle",
"Initial angle", "Initial angle",
0.0, 360.0,
0.0, 0.0,
360.0, CLUTTER_PARAM_READWRITE);
0.0, g_object_class_install_property (object_class, PROP_ANGLE_START, pspec);
CLUTTER_PARAM_READWRITE));
/** /**
* ClutterBehaviourEllipse:angle-end: * ClutterBehaviourEllipse:angle-end:
* *
@ -379,85 +403,89 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_double ("angle-end",
PROP_ANGLE_END,
g_param_spec_double ("angle-end",
"End Angle", "End Angle",
"Final angle", "Final angle",
0.0, 360.0,
0.0, 0.0,
360.0, CLUTTER_PARAM_READWRITE);
0.0, g_object_class_install_property (object_class, PROP_ANGLE_END, pspec);
CLUTTER_PARAM_READWRITE));
/** /**
* ClutterBehaviourEllipse:angle-tilt-x: * ClutterBehaviourEllipse:angle-tilt-x:
* *
* The tilt angle for the rotation around center in x axis * The tilt angle for the rotation around center in X axis
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_double ("angle-tilt-x",
PROP_ANGLE_TILT_X,
g_param_spec_double ("angle-tilt-x",
"Angle x tilt", "Angle x tilt",
"Tilt of the ellipse around x axis", "Tilt of the ellipse around x axis",
0.0, 360.0, 360.0, 0.0, 360.0,
CLUTTER_PARAM_READWRITE)); 360.0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ANGLE_TILT_X, pspec);
/** /**
* ClutterBehaviourEllipse:angle-tilt-y: * ClutterBehaviourEllipse:angle-tilt-y:
* *
* The tilt angle for the rotation around center in y axis * The tilt angle for the rotation around center in Y axis
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_double ("angle-tilt-y",
PROP_ANGLE_TILT_Y,
g_param_spec_double ("angle-tilt-y",
"Angle y tilt", "Angle y tilt",
"Tilt of the ellipse around y axis", "Tilt of the ellipse around y axis",
0.0, 360.0, 360.0, 0.0, 360.0,
CLUTTER_PARAM_READWRITE)); 360.0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ANGLE_TILT_Y, pspec);
/** /**
* ClutterBehaviourEllipse:angle-tilt-z: * ClutterBehaviourEllipse:angle-tilt-z:
* *
* The tilt_z angle for the rotation * The tilt angle for the rotation on the Z axis
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_double ("angle-tilt-z",
PROP_ANGLE_TILT_Z,
g_param_spec_double ("angle-tilt-z",
"Angle z tilt", "Angle z tilt",
"Tilt of the ellipse around z axis", "Tilt of the ellipse around z axis",
0.0, 360.0, 360.0, 0.0, 360.0,
CLUTTER_PARAM_READWRITE)); 360.0,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ANGLE_TILT_Z, pspec);
/** /**
* ClutterBehaviourEllipse:width: * ClutterBehaviourEllipse:width:
* *
* Width of the ellipse. * Width of the ellipse, in pixels
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_int ("width",
PROP_WIDTH,
g_param_spec_int ("width",
"Width", "Width",
"Width of ellipse", "Width of the ellipse",
0, G_MAXINT, 100, 0, G_MAXINT,
CLUTTER_PARAM_READWRITE)); 100,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_WIDTH, pspec);
/** /**
* ClutterBehaviourEllipse:height: * ClutterBehaviourEllipse:height:
* *
* Height of the ellipse. * Height of the ellipse, in pixels
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_int ("height",
PROP_HEIGHT,
g_param_spec_int ("height",
"Height", "Height",
"Height of ellipse", "Height of ellipse",
0, G_MAXINT, 50, 0, G_MAXINT,
CLUTTER_PARAM_READWRITE)); 50,
CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_HEIGHT, pspec);
/** /**
* ClutterBehaviourEllipse:center: * ClutterBehaviourEllipse:center:
* *
@ -465,13 +493,12 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_boxed ("center",
PROP_CENTER,
g_param_spec_boxed ("center",
"Center", "Center",
"Center of ellipse", "Center of ellipse",
CLUTTER_TYPE_KNOT, CLUTTER_TYPE_KNOT,
CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CENTER, pspec);
/** /**
* ClutterBehaviourEllipse:direction: * ClutterBehaviourEllipse:direction:
@ -480,15 +507,13 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
* *
* Since: 0.4 * Since: 0.4
*/ */
g_object_class_install_property (object_class, pspec = g_param_spec_enum ("direction",
PROP_DIRECTION,
g_param_spec_enum ("direction",
"Direction", "Direction",
"Direction of rotation", "Direction of rotation",
CLUTTER_TYPE_ROTATE_DIRECTION, CLUTTER_TYPE_ROTATE_DIRECTION,
CLUTTER_ROTATE_CW, CLUTTER_ROTATE_CW,
CLUTTER_PARAM_READWRITE)); CLUTTER_PARAM_READWRITE);
g_type_class_add_private (klass, sizeof (ClutterBehaviourEllipsePrivate)); g_object_class_install_property (object_class, PROP_DIRECTION, pspec);
} }
static void static void
@ -502,6 +527,13 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self)
priv->angle_start = 0; priv->angle_start = 0;
priv->angle_end = 0; priv->angle_end = 0;
priv->a = 50;
priv->b = 25;
priv->angle_tilt_x = 360;
priv->angle_tilt_y = 360;
priv->angle_tilt_z = 360;
} }
/** /**
@ -516,10 +548,11 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self)
* @end: angle in degrees at which movement ends, between 0 and 360 * @end: angle in degrees at which movement ends, between 0 and 360
* *
* Creates a behaviour that drives actors along an elliptical path with * Creates a behaviour that drives actors along an elliptical path with
* given center, width and height; the movement starts at @angle_start * given center, width and height; the movement starts at @start
* degrees (with 0 corresponding to 12 o'clock) and ends at @angle_end * degrees (with 0 corresponding to 12 o'clock) and ends at @end
* degrees. Angles >= 360 degrees get clamped to the canonical interval * degrees. Angles greated than 360 degrees get clamped to the canonical
* <0, 360), if start == end, the behaviour will rotate by exacly 360 degrees. * interval <0, 360); if @start is equal to @end, the behaviour will
* rotate by exacly 360 degrees.
* *
* Return value: the newly created #ClutterBehaviourEllipse * Return value: the newly created #ClutterBehaviourEllipse
* *
@ -572,30 +605,34 @@ clutter_behaviour_ellipse_new (ClutterAlpha *alpha,
* Since: 0.4 * Since: 0.4
*/ */
ClutterBehaviour * ClutterBehaviour *
clutter_behaviour_ellipse_newx (ClutterAlpha * alpha, clutter_behaviour_ellipse_newx (ClutterAlpha *alpha,
gint x, gint x,
gint y, gint y,
gint width, gint width,
gint height, gint height,
ClutterRotateDirection direction, ClutterRotateDirection direction,
ClutterFixed start, CoglFixed start,
ClutterFixed end) CoglFixed end)
{ {
ClutterKnot center; ClutterKnot center;
gdouble real_start, real_end;
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL); g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
center.x = x; center.x = x;
center.y = y; center.y = y;
real_start = COGL_FIXED_TO_DOUBLE (start);
real_end = COGL_FIXED_TO_DOUBLE (end);
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE, return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
"alpha", alpha, "alpha", alpha,
"center", &center, "center", &center,
"width", width, "width", width,
"height", height, "height", height,
"direction", direction, "direction", direction,
"angle-start", (double)CLUTTER_FIXED_TO_FLOAT (start), "angle-start", real_start,
"angle-end", (double)CLUTTER_FIXED_TO_FLOAT (end), "angle-end", real_end,
NULL); NULL);
} }
@ -633,8 +670,8 @@ clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse *self,
/** /**
* clutter_behaviour_ellipse_get_center * clutter_behaviour_ellipse_get_center
* @self: a #ClutterBehaviourEllipse * @self: a #ClutterBehaviourEllipse
* @x: location to store the x coordinace of the center, or NULL * @x: return location for the X coordinate of the center, or %NULL
* @y: location to store the y coordinace of the center, or NULL * @y: return location for the Y coordinate of the center, or %NULL
* *
* Gets the center of the elliptical path path. * Gets the center of the elliptical path path.
* *
@ -669,7 +706,7 @@ clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse *self,
* Since: 0.4 * Since: 0.4
*/ */
void void
clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self, clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse *self,
gint width) gint width)
{ {
ClutterBehaviourEllipsePrivate *priv; ClutterBehaviourEllipsePrivate *priv;
@ -763,11 +800,20 @@ void
clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self,
gdouble angle_start) gdouble angle_start)
{ {
ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_start); ClutterBehaviourEllipsePrivate *priv;
gdouble new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_startx (self, new_angle); new_angle = clamp_angle (angle_start);
priv = self->priv;
if (priv->angle_start != new_angle)
{
priv->angle_start = new_angle;
g_object_notify (G_OBJECT (self), "angle-start");
}
} }
/** /**
@ -783,20 +829,11 @@ clutter_behaviour_ellipse_set_angle_start (ClutterBehaviourEllipse *self,
*/ */
void void
clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self,
ClutterFixed angle_start) CoglFixed angle_start)
{ {
ClutterBehaviourEllipsePrivate *priv; gdouble angle = COGL_FIXED_TO_DOUBLE (angle_start);
float new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_start)); clutter_behaviour_ellipse_set_angle_start (self, angle);
priv = self->priv;
if (priv->angle_start != new_angle)
{
priv->angle_start = new_angle;
g_object_notify (G_OBJECT (self), "angle-start");
}
} }
/** /**
@ -814,7 +851,7 @@ clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self)
{ {
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0); g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0.0);
return (double)self->priv->angle_start; return self->priv->angle_start;
} }
/** /**
@ -823,16 +860,16 @@ clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self)
* *
* Gets the angle at which movements starts. * Gets the angle at which movements starts.
* *
* Return value: angle, as #ClutterFixed, in degrees. * Return value: angle, as #CoglFixed, in degrees.
* *
* Since: 0.6 * Since: 0.6
*/ */
ClutterFixed CoglFixed
clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self) clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self)
{ {
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_start); return COGL_FIXED_FROM_DOUBLE (self->priv->angle_start);
} }
/** /**
@ -849,11 +886,21 @@ void
clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self,
gdouble angle_end) gdouble angle_end)
{ {
ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_end); ClutterBehaviourEllipsePrivate *priv;
gdouble new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_endx (self, new_angle); new_angle = clamp_angle (angle_end);
priv = self->priv;
if (priv->angle_end != new_angle)
{
priv->angle_end = new_angle;
g_object_notify (G_OBJECT (self), "angle-end");
}
} }
/** /**
@ -869,23 +916,11 @@ clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self,
*/ */
void void
clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self,
ClutterFixed angle_end) CoglFixed angle_end)
{ {
ClutterBehaviourEllipsePrivate *priv; gdouble angle = COGL_FIXED_TO_DOUBLE (angle_end);
float new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); clutter_behaviour_ellipse_set_angle_end (self, angle);
new_angle = clamp_angle (CLUTTER_FIXED_TO_FLOAT (angle_end));
priv = self->priv;
if (priv->angle_end != new_angle)
{
priv->angle_end = new_angle;
g_object_notify (G_OBJECT (self), "angle-end");
}
} }
/** /**
@ -912,16 +947,16 @@ clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self)
* *
* Gets the angle at which movements ends. * Gets the angle at which movements ends.
* *
* Return value: angle, as #ClutterFixed, in degrees * Return value: angle, as #CoglFixed, in degrees
* *
* Since: 0.4 * Since: 0.4
*/ */
ClutterFixed CoglFixed
clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self) clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self)
{ {
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0); g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self), 0);
return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_end); return COGL_FIXED_FROM_DOUBLE (self->priv->angle_end);
} }
/** /**
@ -940,19 +975,49 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis, ClutterRotateAxis axis,
gdouble angle_tilt) gdouble angle_tilt)
{ {
ClutterFixed new_angle = CLUTTER_FLOAT_TO_FIXED (angle_tilt); ClutterBehaviourEllipsePrivate *priv;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
clutter_behaviour_ellipse_set_angle_tiltx (self, axis, new_angle); priv = self->priv;
switch (axis)
{
case CLUTTER_X_AXIS:
if (priv->angle_tilt_x != angle_tilt)
{
priv->angle_tilt_x = angle_tilt;
g_object_notify (G_OBJECT (self), "angle-tilt-x");
}
break;
case CLUTTER_Y_AXIS:
if (priv->angle_tilt_y != angle_tilt)
{
priv->angle_tilt_y = angle_tilt;
g_object_notify (G_OBJECT (self), "angle-tilt-y");
}
break;
case CLUTTER_Z_AXIS:
if (priv->angle_tilt_z != angle_tilt)
{
priv->angle_tilt_z = angle_tilt;
g_object_notify (G_OBJECT (self), "angle-tilt-z");
}
break;
}
} }
/** /**
* clutter_behaviour_ellipse_set_angle_tiltx * clutter_behaviour_ellipse_set_angle_tiltx
* @self: a #ClutterBehaviourEllipse * @self: a #ClutterBehaviourEllipse
* @axis: a #ClutterRoateAxis * @axis: a #ClutterRoateAxis
* @angle_tilt: tilt, as #ClutterFixed, of the elipse around the center in the given * @angle_tilt: the tilt of the ellipse, in degrees as a fixed point
* axis in degrees. * value, around the center on the given axis
* *
* Sets the angle at which the ellipse should be tilted around it's center. * Sets the angle at which the ellipse should be tilted around it's center.
* *
@ -961,46 +1026,11 @@ clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self,
void void
clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis, ClutterRotateAxis axis,
ClutterFixed angle_tilt) CoglFixed angle_tilt)
{ {
ClutterBehaviourEllipsePrivate *priv; gdouble angle = COGL_FIXED_TO_DOUBLE (angle_tilt);
float new_angle;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); clutter_behaviour_ellipse_set_angle_tilt (self, axis, angle);
new_angle = CLUTTER_FIXED_TO_FLOAT (angle_tilt);
priv = self->priv;
switch (axis)
{
case CLUTTER_X_AXIS:
if (priv->angle_tilt_x != new_angle)
{
priv->angle_tilt_x = new_angle;
g_object_notify (G_OBJECT (self), "angle-tilt-x");
}
break;
case CLUTTER_Y_AXIS:
if (priv->angle_tilt_y != new_angle)
{
priv->angle_tilt_y = new_angle;
g_object_notify (G_OBJECT (self), "angle-tilt-y");
}
break;
case CLUTTER_Z_AXIS:
if (priv->angle_tilt_z != new_angle)
{
priv->angle_tilt_z = new_angle;
g_object_notify (G_OBJECT (self), "angle-tilt-z");
}
break;
default:
break;
}
} }
/** /**
@ -1024,13 +1054,15 @@ clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self,
{ {
case CLUTTER_X_AXIS: case CLUTTER_X_AXIS:
return self->priv->angle_tilt_x; return self->priv->angle_tilt_x;
case CLUTTER_Y_AXIS: case CLUTTER_Y_AXIS:
return self->priv->angle_tilt_y; return self->priv->angle_tilt_y;
case CLUTTER_Z_AXIS: case CLUTTER_Z_AXIS:
return self->priv->angle_tilt_z; return self->priv->angle_tilt_z;
} }
return 0; return 0.0;
} }
/** /**
@ -1038,13 +1070,13 @@ clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self,
* @self: a #ClutterBehaviourEllipse * @self: a #ClutterBehaviourEllipse
* @axis: a #ClutterRotateAxis * @axis: a #ClutterRotateAxis
* *
* Gets the tilt of the ellipse around the center in the given axis. * Gets the tilt of the ellipse around the center in the given axis
* *
* Return value: angle, as #ClutterFixed, in degrees * Return value: the tilt angle in degrees, as a fixed point value
* *
* Since: 0.4 * Since: 0.4
*/ */
ClutterFixed CoglFixed
clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis) ClutterRotateAxis axis)
{ {
@ -1053,11 +1085,13 @@ clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self,
switch (axis) switch (axis)
{ {
case CLUTTER_X_AXIS: case CLUTTER_X_AXIS:
return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_x); return COGL_FIXED_FROM_DOUBLE (self->priv->angle_tilt_x);
case CLUTTER_Y_AXIS: case CLUTTER_Y_AXIS:
return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_y); return COGL_FIXED_FROM_DOUBLE (self->priv->angle_tilt_y);
case CLUTTER_Z_AXIS: case CLUTTER_Z_AXIS:
return CLUTTER_FLOAT_TO_FIXED (self->priv->angle_tilt_z); return COGL_FIXED_FROM_DOUBLE (self->priv->angle_tilt_z);
} }
return 0; return 0;
@ -1081,35 +1115,30 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self,
gdouble angle_tilt_z) gdouble angle_tilt_z)
{ {
ClutterBehaviourEllipsePrivate *priv; ClutterBehaviourEllipsePrivate *priv;
float new_angle_x, new_angle_y, new_angle_z;
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self));
new_angle_x = (float)angle_tilt_x;
new_angle_y = (float)angle_tilt_y;
new_angle_z = (float)angle_tilt_z;
priv = self->priv; priv = self->priv;
g_object_freeze_notify (G_OBJECT (self)); g_object_freeze_notify (G_OBJECT (self));
if (priv->angle_tilt_x != new_angle_x) if (priv->angle_tilt_x != angle_tilt_x)
{ {
priv->angle_tilt_x = new_angle_x; priv->angle_tilt_x = angle_tilt_x;
g_object_notify (G_OBJECT (self), "angle-tilt-x"); g_object_notify (G_OBJECT (self), "angle-tilt-x");
} }
if (priv->angle_tilt_y != new_angle_y) if (priv->angle_tilt_y != angle_tilt_y)
{ {
priv->angle_tilt_y = new_angle_y; priv->angle_tilt_y = angle_tilt_y;
g_object_notify (G_OBJECT (self), "angle-tilt-y"); g_object_notify (G_OBJECT (self), "angle-tilt-y");
} }
if (priv->angle_tilt_z != new_angle_z) if (priv->angle_tilt_z != angle_tilt_z)
{ {
priv->angle_tilt_z = new_angle_z; priv->angle_tilt_z = angle_tilt_z;
g_object_notify (G_OBJECT (self), "angle-tilt-z"); g_object_notify (G_OBJECT (self), "angle-tilt-z");
} }
@ -1130,45 +1159,14 @@ clutter_behaviour_ellipse_set_tilt (ClutterBehaviourEllipse *self,
*/ */
void void
clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self,
ClutterFixed angle_tilt_x, CoglFixed angle_tilt_x,
ClutterFixed angle_tilt_y, CoglFixed angle_tilt_y,
ClutterFixed angle_tilt_z) CoglFixed angle_tilt_z)
{ {
ClutterBehaviourEllipsePrivate *priv; clutter_behaviour_ellipse_set_tilt (self,
float new_angle_x, new_angle_y, new_angle_z; COGL_FIXED_TO_DOUBLE (angle_tilt_x),
COGL_FIXED_TO_DOUBLE (angle_tilt_y),
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ELLIPSE (self)); COGL_FIXED_TO_DOUBLE (angle_tilt_z));
new_angle_x = CLUTTER_FIXED_TO_FLOAT (angle_tilt_x);
new_angle_y = CLUTTER_FIXED_TO_FLOAT (angle_tilt_y);
new_angle_z = CLUTTER_FIXED_TO_FLOAT (angle_tilt_z);
priv = self->priv;
g_object_freeze_notify (G_OBJECT (self));
if (priv->angle_tilt_x != new_angle_x)
{
priv->angle_tilt_x = new_angle_x;
g_object_notify (G_OBJECT (self), "angle-tilt-x");
}
if (priv->angle_tilt_y != new_angle_y)
{
priv->angle_tilt_y = new_angle_y;
g_object_notify (G_OBJECT (self), "angle-tilt-y");
}
if (priv->angle_tilt_z != new_angle_z)
{
priv->angle_tilt_z = new_angle_z;
g_object_notify (G_OBJECT (self), "angle-tilt-z");
}
g_object_thaw_notify (G_OBJECT (self));
} }
/** /**
@ -1220,9 +1218,9 @@ clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self,
*/ */
void void
clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self, clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self,
ClutterFixed *angle_tilt_x, CoglFixed *angle_tilt_x,
ClutterFixed *angle_tilt_y, CoglFixed *angle_tilt_y,
ClutterFixed *angle_tilt_z) CoglFixed *angle_tilt_z)
{ {
ClutterBehaviourEllipsePrivate *priv; ClutterBehaviourEllipsePrivate *priv;
@ -1231,13 +1229,13 @@ clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self,
priv = self->priv; priv = self->priv;
if (angle_tilt_x) if (angle_tilt_x)
*angle_tilt_x = priv->angle_tilt_x; *angle_tilt_x = COGL_FIXED_FROM_DOUBLE (priv->angle_tilt_x);
if (angle_tilt_y) if (angle_tilt_y)
*angle_tilt_y = priv->angle_tilt_y; *angle_tilt_y = COGL_FIXED_FROM_DOUBLE (priv->angle_tilt_y);
if (angle_tilt_z) if (angle_tilt_z)
*angle_tilt_z = priv->angle_tilt_z; *angle_tilt_z = COGL_FIXED_FROM_DOUBLE (priv->angle_tilt_z);
} }
/** /**

View File

@ -61,6 +61,14 @@ typedef struct _ClutterBehaviourEllipse ClutterBehaviourEllipse;
typedef struct _ClutterBehaviourEllipsePrivate ClutterBehaviourEllipsePrivate; typedef struct _ClutterBehaviourEllipsePrivate ClutterBehaviourEllipsePrivate;
typedef struct _ClutterBehaviourEllipseClass ClutterBehaviourEllipseClass; typedef struct _ClutterBehaviourEllipseClass ClutterBehaviourEllipseClass;
/**
* ClutterBehaviourEllipse:
*
* The #ClutterBehaviourEllipse struct contains only private data
* and should be accessed using the provided API
*
* Since: 0.4
*/
struct _ClutterBehaviourEllipse struct _ClutterBehaviourEllipse
{ {
/*< private >*/ /*< private >*/
@ -69,11 +77,9 @@ struct _ClutterBehaviourEllipse
}; };
/** /**
* ClutterBehaviourEllipseClass * ClutterBehaviourEllipseClass:
* @knot_reached: signal class handler for the
* ClutterBehaviourEllipse::knot_reached signal
* *
* Ellipse behaviour class * The #ClutterBehaviourEllipseClass struct contains only private data
* *
* Since: 0.4 * Since: 0.4
*/ */
@ -81,17 +87,6 @@ struct _ClutterBehaviourEllipseClass
{ {
/*< private >*/ /*< private >*/
ClutterBehaviourClass parent_class; ClutterBehaviourClass parent_class;
/*< public >*/
void (*knot_reached) (ClutterBehaviourEllipse *ellipseb,
const ClutterKnot *knot);
/*< private >*/
/* padding, for future expansion */
void (*_clutter_ellipse_1) (void);
void (*_clutter_ellipse_2) (void);
void (*_clutter_ellipse_3) (void);
void (*_clutter_ellipse_4) (void);
}; };
GType clutter_behaviour_ellipse_get_type (void) G_GNUC_CONST; GType clutter_behaviour_ellipse_get_type (void) G_GNUC_CONST;
@ -111,8 +106,8 @@ ClutterBehaviour * clutter_behaviour_ellipse_newx (ClutterAlph
gint width, gint width,
gint height, gint height,
ClutterRotateDirection direction, ClutterRotateDirection direction,
ClutterFixed start, CoglFixed start,
ClutterFixed end); CoglFixed end);
void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse *self,
gint x, gint x,
@ -136,31 +131,31 @@ void clutter_behaviour_ellipse_set_angle_start (ClutterBeha
gdouble angle_start); gdouble angle_start);
void clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_angle_startx (ClutterBehaviourEllipse *self,
ClutterFixed angle_start); CoglFixed angle_start);
ClutterFixed clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self); CoglFixed clutter_behaviour_ellipse_get_angle_startx (ClutterBehaviourEllipse *self);
gdouble clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self); gdouble clutter_behaviour_ellipse_get_angle_start (ClutterBehaviourEllipse *self);
void clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_angle_endx (ClutterBehaviourEllipse *self,
ClutterFixed angle_end); CoglFixed angle_end);
void clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_angle_end (ClutterBehaviourEllipse *self,
gdouble angle_end); gdouble angle_end);
ClutterFixed clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self); CoglFixed clutter_behaviour_ellipse_get_angle_endx (ClutterBehaviourEllipse *self);
gdouble clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self); gdouble clutter_behaviour_ellipse_get_angle_end (ClutterBehaviourEllipse *self);
void clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_angle_tiltx (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis, ClutterRotateAxis axis,
ClutterFixed angle_tilt); CoglFixed angle_tilt);
void clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_angle_tilt (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis, ClutterRotateAxis axis,
gdouble angle_tilt); gdouble angle_tilt);
ClutterFixed clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self, CoglFixed clutter_behaviour_ellipse_get_angle_tiltx (ClutterBehaviourEllipse *self,
ClutterRotateAxis axis); ClutterRotateAxis axis);
gdouble clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self, gdouble clutter_behaviour_ellipse_get_angle_tilt (ClutterBehaviourEllipse *self,
@ -172,9 +167,9 @@ void clutter_behaviour_ellipse_set_tilt (ClutterBeha
gdouble angle_tilt_z); gdouble angle_tilt_z);
void clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_set_tiltx (ClutterBehaviourEllipse *self,
ClutterFixed angle_tilt_x, CoglFixed angle_tilt_x,
ClutterFixed angle_tilt_y, CoglFixed angle_tilt_y,
ClutterFixed angle_tilt_z); CoglFixed angle_tilt_z);
void clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_get_tilt (ClutterBehaviourEllipse *self,
gdouble *angle_tilt_x, gdouble *angle_tilt_x,
@ -182,9 +177,9 @@ void clutter_behaviour_ellipse_get_tilt (ClutterBeha
gdouble *angle_tilt_z); gdouble *angle_tilt_z);
void clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self, void clutter_behaviour_ellipse_get_tiltx (ClutterBehaviourEllipse *self,
ClutterFixed *angle_tilt_x, CoglFixed *angle_tilt_x,
ClutterFixed *angle_tilt_y, CoglFixed *angle_tilt_y,
ClutterFixed *angle_tilt_z); CoglFixed *angle_tilt_z);
ClutterRotateDirection clutter_behaviour_ellipse_get_direction (ClutterBehaviourEllipse *self); ClutterRotateDirection clutter_behaviour_ellipse_get_direction (ClutterBehaviourEllipse *self);