mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 18:11:05 -05:00
Convert the rotation centers to be AnchorCoords
Currently only the Z axis rotation center can be set using a gravity but the other rotations also store their center as an AnchorCoord for consistency. Specifying the center as a gravity makes less sense for the other axes because the actors have no size along the Z axis. The rotation angles are now stored as gdoubles and the fixed point *x entry points have been removed. The Z rotation can now be set with a gravity center using the following new function: void clutter_actor_set_z_rotation_from_gravity (ClutterActor *self, gdouble angle, ClutterGravity gravity);
This commit is contained in:
parent
a8a986a1a2
commit
d5e5d35316
@ -250,21 +250,18 @@ struct _ClutterActorPrivate
|
|||||||
ClutterUnit clip[4];
|
ClutterUnit clip[4];
|
||||||
|
|
||||||
/* Rotation angles */
|
/* Rotation angles */
|
||||||
ClutterFixed rxang;
|
gdouble rxang;
|
||||||
ClutterFixed ryang;
|
gdouble ryang;
|
||||||
ClutterFixed rzang;
|
gdouble rzang;
|
||||||
|
|
||||||
/* Rotation center: X axis */
|
/* Rotation center: X axis */
|
||||||
ClutterUnit rxy;
|
AnchorCoord rx_center;
|
||||||
ClutterUnit rxz;
|
|
||||||
|
|
||||||
/* Rotation center: Y axis */
|
/* Rotation center: Y axis */
|
||||||
ClutterUnit ryx;
|
AnchorCoord ry_center;
|
||||||
ClutterUnit ryz;
|
|
||||||
|
|
||||||
/* Rotation center: Z axis */
|
/* Rotation center: Z axis */
|
||||||
ClutterUnit rzx;
|
AnchorCoord rz_center;
|
||||||
ClutterUnit rzy;
|
|
||||||
|
|
||||||
/* Anchor point coordinates */
|
/* Anchor point coordinates */
|
||||||
AnchorCoord anchor;
|
AnchorCoord anchor;
|
||||||
@ -353,6 +350,10 @@ enum
|
|||||||
PROP_ROTATION_CENTER_X,
|
PROP_ROTATION_CENTER_X,
|
||||||
PROP_ROTATION_CENTER_Y,
|
PROP_ROTATION_CENTER_Y,
|
||||||
PROP_ROTATION_CENTER_Z,
|
PROP_ROTATION_CENTER_Z,
|
||||||
|
/* This property only makes sense for the z rotation because the
|
||||||
|
others would depend on the actor having a size along the
|
||||||
|
z-axis */
|
||||||
|
PROP_ROTATION_CENTER_Z_GRAVITY,
|
||||||
|
|
||||||
PROP_ANCHOR_X,
|
PROP_ANCHOR_X,
|
||||||
PROP_ANCHOR_Y,
|
PROP_ANCHOR_Y,
|
||||||
@ -1422,6 +1423,9 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
|
|||||||
CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1),
|
CLUTTER_UNITS_TO_FLOAT (priv->allocation.y1),
|
||||||
0);
|
0);
|
||||||
|
|
||||||
|
if (priv->z)
|
||||||
|
cogl_translate (0, 0, priv->z);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* because the rotation involves translations, we must scale before
|
* because the rotation involves translations, we must scale before
|
||||||
* applying the rotations (if we apply the scale after the rotations,
|
* applying the rotations (if we apply the scale after the rotations,
|
||||||
@ -1433,43 +1437,19 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
|
|||||||
cogl_scale (priv->scale_x, priv->scale_y));
|
cogl_scale (priv->scale_x, priv->scale_y));
|
||||||
|
|
||||||
if (priv->rzang)
|
if (priv->rzang)
|
||||||
{
|
TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->rz_center,
|
||||||
cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->rzx),
|
cogl_rotate (priv->rzang,
|
||||||
CLUTTER_UNITS_TO_FLOAT (priv->rzy),
|
0, 0, 1.0));
|
||||||
0);
|
|
||||||
|
|
||||||
cogl_rotate (priv->rzang, 0, 0, 1.0);
|
|
||||||
|
|
||||||
cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->rzx),
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (-priv->rzy),
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->ryang)
|
if (priv->ryang)
|
||||||
{
|
TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->ry_center,
|
||||||
cogl_translate (CLUTTER_UNITS_TO_FLOAT (priv->ryx),
|
cogl_rotate (priv->ryang,
|
||||||
0,
|
0, 1.0, 0));
|
||||||
CLUTTER_UNITS_TO_FLOAT (priv->z + priv->ryz));
|
|
||||||
|
|
||||||
cogl_rotate (priv->ryang, 0, 1.0, 0);
|
|
||||||
|
|
||||||
cogl_translate (CLUTTER_UNITS_TO_FLOAT (-priv->ryx),
|
|
||||||
0,
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->ryz)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->rxang)
|
if (priv->rxang)
|
||||||
{
|
TRANSFORM_ABOUT_ANCHOR_COORD (self, &priv->rx_center,
|
||||||
cogl_translate (0,
|
cogl_rotate (priv->rxang,
|
||||||
CLUTTER_UNITS_TO_FLOAT (priv->rxy),
|
1.0, 0, 0));
|
||||||
CLUTTER_UNITS_TO_FLOAT (priv->z + priv->rxz));
|
|
||||||
|
|
||||||
cogl_rotate (priv->rxang, 1.0, 0, 0);
|
|
||||||
|
|
||||||
cogl_translate (0,
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (-priv->rxy),
|
|
||||||
CLUTTER_UNITS_TO_FLOAT (-(priv->z + priv->rxz)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!is_stage && !clutter_anchor_coord_is_zero (&priv->anchor))
|
if (!is_stage && !clutter_anchor_coord_is_zero (&priv->anchor))
|
||||||
{
|
{
|
||||||
@ -1477,9 +1457,6 @@ _clutter_actor_apply_modelview_transform (ClutterActor *self)
|
|||||||
clutter_anchor_coord_get_units (self, &priv->anchor, &x, &y, &z);
|
clutter_anchor_coord_get_units (self, &priv->anchor, &x, &y, &z);
|
||||||
cogl_translate (-x, -y, -z);
|
cogl_translate (-x, -y, -z);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->z)
|
|
||||||
cogl_translate (0, 0, priv->z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recursively applies the transforms associated with this actor and
|
/* Recursively applies the transforms associated with this actor and
|
||||||
@ -1602,17 +1579,13 @@ clutter_actor_paint (ClutterActor *self)
|
|||||||
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_PAINT);
|
CLUTTER_UNSET_PRIVATE_FLAGS (self, CLUTTER_ACTOR_IN_PAINT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fixed point, unit based rotation setter, to be used by
|
/* internal helper function set the rotation angle without affecting
|
||||||
* set_property() so that we don't lose precision in the
|
the center point
|
||||||
* center coordinates by converting them to and from units
|
|
||||||
*/
|
*/
|
||||||
static inline void
|
static void
|
||||||
clutter_actor_set_rotation_internal (ClutterActor *self,
|
clutter_actor_set_rotation_internal (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
ClutterRotateAxis axis,
|
||||||
ClutterFixed angle,
|
gdouble angle)
|
||||||
ClutterUnit center_x,
|
|
||||||
ClutterUnit center_y,
|
|
||||||
ClutterUnit center_z)
|
|
||||||
{
|
{
|
||||||
ClutterActorPrivate *priv = self->priv;
|
ClutterActorPrivate *priv = self->priv;
|
||||||
|
|
||||||
@ -1623,26 +1596,17 @@ clutter_actor_set_rotation_internal (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
case CLUTTER_X_AXIS:
|
case CLUTTER_X_AXIS:
|
||||||
priv->rxang = angle;
|
priv->rxang = angle;
|
||||||
priv->rxy = center_y;
|
|
||||||
priv->rxz = center_z;
|
|
||||||
g_object_notify (G_OBJECT (self), "rotation-angle-x");
|
g_object_notify (G_OBJECT (self), "rotation-angle-x");
|
||||||
g_object_notify (G_OBJECT (self), "rotation-center-x");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_Y_AXIS:
|
case CLUTTER_Y_AXIS:
|
||||||
priv->ryang = angle;
|
priv->ryang = angle;
|
||||||
priv->ryx = center_x;
|
|
||||||
priv->ryz = center_z;
|
|
||||||
g_object_notify (G_OBJECT (self), "rotation-angle-y");
|
g_object_notify (G_OBJECT (self), "rotation-angle-y");
|
||||||
g_object_notify (G_OBJECT (self), "rotation-center-y");
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_Z_AXIS:
|
case CLUTTER_Z_AXIS:
|
||||||
priv->rzang = angle;
|
priv->rzang = angle;
|
||||||
priv->rzx = center_x;
|
|
||||||
priv->rzy = center_y;
|
|
||||||
g_object_notify (G_OBJECT (self), "rotation-angle-z");
|
g_object_notify (G_OBJECT (self), "rotation-angle-z");
|
||||||
g_object_notify (G_OBJECT (self), "rotation-center-z");
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1788,86 +1752,63 @@ clutter_actor_set_property (GObject *object,
|
|||||||
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:
|
||||||
{
|
|
||||||
ClutterFixed angle;
|
|
||||||
|
|
||||||
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
|
|
||||||
clutter_actor_set_rotation_internal (actor,
|
clutter_actor_set_rotation_internal (actor,
|
||||||
CLUTTER_X_AXIS,
|
CLUTTER_X_AXIS,
|
||||||
angle,
|
g_value_get_double (value));
|
||||||
0,
|
|
||||||
priv->rxy,
|
|
||||||
priv->rxz);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_ANGLE_Y:
|
case PROP_ROTATION_ANGLE_Y:
|
||||||
{
|
|
||||||
ClutterFixed angle;
|
|
||||||
|
|
||||||
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
|
|
||||||
clutter_actor_set_rotation_internal (actor,
|
clutter_actor_set_rotation_internal (actor,
|
||||||
CLUTTER_Y_AXIS,
|
CLUTTER_Y_AXIS,
|
||||||
angle,
|
g_value_get_double (value));
|
||||||
priv->ryx,
|
|
||||||
0,
|
|
||||||
priv->ryz);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_ANGLE_Z:
|
case PROP_ROTATION_ANGLE_Z:
|
||||||
{
|
|
||||||
ClutterFixed angle;
|
|
||||||
|
|
||||||
angle = CLUTTER_FLOAT_TO_FIXED (g_value_get_double (value));
|
|
||||||
clutter_actor_set_rotation_internal (actor,
|
clutter_actor_set_rotation_internal (actor,
|
||||||
CLUTTER_Z_AXIS,
|
CLUTTER_Z_AXIS,
|
||||||
angle,
|
g_value_get_double (value));
|
||||||
priv->rzx,
|
|
||||||
priv->rzy,
|
|
||||||
0);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_X:
|
case PROP_ROTATION_CENTER_X:
|
||||||
{
|
{
|
||||||
ClutterVertex *center;
|
const ClutterVertex *center;
|
||||||
|
|
||||||
center = g_value_get_boxed (value);
|
if ((center = g_value_get_boxed (value)))
|
||||||
if (center)
|
clutter_actor_set_rotation (actor,
|
||||||
clutter_actor_set_rotation_internal (actor,
|
|
||||||
CLUTTER_X_AXIS,
|
CLUTTER_X_AXIS,
|
||||||
priv->rxang,
|
priv->rxang,
|
||||||
0,
|
center->x,
|
||||||
center->y,
|
center->y,
|
||||||
center->z);
|
center->z);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_Y:
|
case PROP_ROTATION_CENTER_Y:
|
||||||
{
|
{
|
||||||
ClutterVertex *center;
|
const ClutterVertex *center;
|
||||||
|
|
||||||
center = g_value_get_boxed (value);
|
if ((center = g_value_get_boxed (value)))
|
||||||
if (center)
|
clutter_actor_set_rotation (actor,
|
||||||
clutter_actor_set_rotation_internal (actor,
|
|
||||||
CLUTTER_Y_AXIS,
|
CLUTTER_Y_AXIS,
|
||||||
priv->ryang,
|
priv->ryang,
|
||||||
center->x,
|
center->x,
|
||||||
0,
|
center->y,
|
||||||
center->z);
|
center->z);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_Z:
|
case PROP_ROTATION_CENTER_Z:
|
||||||
{
|
{
|
||||||
ClutterVertex *center;
|
const ClutterVertex *center;
|
||||||
|
|
||||||
center = g_value_get_boxed (value);
|
if ((center = g_value_get_boxed (value)))
|
||||||
if (center)
|
clutter_actor_set_rotation (actor,
|
||||||
clutter_actor_set_rotation_internal (actor,
|
|
||||||
CLUTTER_Z_AXIS,
|
CLUTTER_Z_AXIS,
|
||||||
priv->rzang,
|
priv->rzang,
|
||||||
center->x,
|
center->x,
|
||||||
center->y,
|
center->y,
|
||||||
0);
|
center->z);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PROP_ROTATION_CENTER_Z_GRAVITY:
|
||||||
|
clutter_actor_set_z_rotation_from_gravity
|
||||||
|
(actor, priv->rzang, g_value_get_enum (value));
|
||||||
|
break;
|
||||||
case PROP_ANCHOR_X:
|
case PROP_ANCHOR_X:
|
||||||
{
|
{
|
||||||
int anchor_x = g_value_get_int (value);
|
int anchor_x = g_value_get_int (value);
|
||||||
@ -2025,44 +1966,47 @@ clutter_actor_get_property (GObject *object,
|
|||||||
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, CLUTTER_FIXED_TO_DOUBLE (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, CLUTTER_FIXED_TO_DOUBLE (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, CLUTTER_FIXED_TO_DOUBLE (priv->rzang));
|
g_value_set_double (value, priv->rzang);
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_X:
|
case PROP_ROTATION_CENTER_X:
|
||||||
{
|
{
|
||||||
ClutterVertex center = { 0, };
|
ClutterVertex center;
|
||||||
|
|
||||||
center.y = priv->rxy;
|
clutter_actor_get_rotationu (actor, CLUTTER_X_AXIS,
|
||||||
center.z = priv->rxz;
|
¢er.x, ¢er.y, ¢er.z);
|
||||||
|
|
||||||
g_value_set_boxed (value, ¢er);
|
g_value_set_boxed (value, ¢er);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_Y:
|
case PROP_ROTATION_CENTER_Y:
|
||||||
{
|
{
|
||||||
ClutterVertex center = { 0, };
|
ClutterVertex center;
|
||||||
|
|
||||||
center.x = priv->ryx;
|
clutter_actor_get_rotationu (actor, CLUTTER_Y_AXIS,
|
||||||
center.z = priv->ryz;
|
¢er.x, ¢er.y, ¢er.z);
|
||||||
|
|
||||||
g_value_set_boxed (value, ¢er);
|
g_value_set_boxed (value, ¢er);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PROP_ROTATION_CENTER_Z:
|
case PROP_ROTATION_CENTER_Z:
|
||||||
{
|
{
|
||||||
ClutterVertex center = { 0, };
|
ClutterVertex center;
|
||||||
|
|
||||||
center.x = priv->rzx;
|
clutter_actor_get_rotationu (actor, CLUTTER_Z_AXIS,
|
||||||
center.y = priv->rzy;
|
¢er.x, ¢er.y, ¢er.z);
|
||||||
|
|
||||||
g_value_set_boxed (value, ¢er);
|
g_value_set_boxed (value, ¢er);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PROP_ROTATION_CENTER_Z_GRAVITY:
|
||||||
|
g_value_set_enum (value, clutter_actor_get_z_rotation_gravity (actor));
|
||||||
|
break;
|
||||||
case PROP_ANCHOR_X:
|
case PROP_ANCHOR_X:
|
||||||
{
|
{
|
||||||
ClutterUnit anchor_x;
|
ClutterUnit anchor_x;
|
||||||
@ -2749,6 +2693,24 @@ clutter_actor_class_init (ClutterActorClass *klass)
|
|||||||
"The rotation center on the Z axis",
|
"The rotation center on the Z axis",
|
||||||
CLUTTER_TYPE_VERTEX,
|
CLUTTER_TYPE_VERTEX,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ClutterActor:rotation-center-z-gravity:
|
||||||
|
*
|
||||||
|
* The rotation center on the Z axis expressed as a #ClutterGravity.
|
||||||
|
*
|
||||||
|
* Since: 1.0
|
||||||
|
*/
|
||||||
|
pspec = g_param_spec_enum ("rotation-center-z-gravity",
|
||||||
|
"Rotation-Center-Z-Gravity",
|
||||||
|
"Center point for rotation around the Z axis",
|
||||||
|
CLUTTER_TYPE_GRAVITY,
|
||||||
|
CLUTTER_GRAVITY_NONE,
|
||||||
|
CLUTTER_PARAM_READWRITE);
|
||||||
|
g_object_class_install_property (object_class,
|
||||||
|
PROP_ROTATION_CENTER_Z_GRAVITY,
|
||||||
|
pspec);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterActor:anchor-x:
|
* ClutterActor:anchor-x:
|
||||||
*
|
*
|
||||||
@ -5538,42 +5500,35 @@ clutter_actor_set_rotationu (ClutterActor *self,
|
|||||||
ClutterUnit y,
|
ClutterUnit y,
|
||||||
ClutterUnit z)
|
ClutterUnit z)
|
||||||
{
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
clutter_actor_set_rotation_internal (self, axis,
|
priv = self->priv;
|
||||||
CLUTTER_FLOAT_TO_FIXED (angle),
|
|
||||||
x, y, z);
|
g_object_freeze_notify (G_OBJECT (self));
|
||||||
|
|
||||||
|
clutter_actor_set_rotation_internal (self, axis, angle);
|
||||||
|
|
||||||
|
switch (axis)
|
||||||
|
{
|
||||||
|
case CLUTTER_X_AXIS:
|
||||||
|
clutter_anchor_coord_set_units (&priv->rx_center, x, y, z);
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-x");
|
||||||
|
break;
|
||||||
|
case CLUTTER_Y_AXIS:
|
||||||
|
clutter_anchor_coord_set_units (&priv->ry_center, x, y, z);
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-y");
|
||||||
|
break;
|
||||||
|
case CLUTTER_Z_AXIS:
|
||||||
|
if (priv->rz_center.is_fractional)
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-z-gravity");
|
||||||
|
clutter_anchor_coord_set_units (&priv->rz_center, x, y, z);
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-z");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
g_object_thaw_notify (G_OBJECT (self));
|
||||||
* clutter_actor_set_rotationx:
|
|
||||||
* @self: a #ClutterActor
|
|
||||||
* @axis: the axis of rotation
|
|
||||||
* @angle: the angle of rotation
|
|
||||||
* @x: X coordinate of the rotation center
|
|
||||||
* @y: Y coordinate of the rotation center
|
|
||||||
* @z: Z coordinate of the rotation center
|
|
||||||
*
|
|
||||||
* Sets the rotation angle of @self around the given axis.
|
|
||||||
*
|
|
||||||
* This function is the fixed point variant of clutter_actor_set_rotation().
|
|
||||||
*
|
|
||||||
* Since: 0.6
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
clutter_actor_set_rotationx (ClutterActor *self,
|
|
||||||
ClutterRotateAxis axis,
|
|
||||||
ClutterFixed angle,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint z)
|
|
||||||
{
|
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
|
||||||
|
|
||||||
clutter_actor_set_rotation_internal (self, axis, angle,
|
|
||||||
CLUTTER_UNITS_FROM_DEVICE (x),
|
|
||||||
CLUTTER_UNITS_FROM_DEVICE (y),
|
|
||||||
CLUTTER_UNITS_FROM_DEVICE (z));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5610,9 +5565,37 @@ clutter_actor_set_rotation (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
clutter_actor_set_rotationx (self, axis,
|
clutter_actor_set_rotationu (self, axis, angle,
|
||||||
CLUTTER_FLOAT_TO_FIXED (angle),
|
CLUTTER_UNITS_FROM_DEVICE (x),
|
||||||
x, y, z);
|
CLUTTER_UNITS_FROM_DEVICE (y),
|
||||||
|
CLUTTER_UNITS_FROM_DEVICE (z));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
|
||||||
|
gdouble angle,
|
||||||
|
ClutterGravity gravity)
|
||||||
|
{
|
||||||
|
ClutterActorPrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (CLUTTER_IS_ACTOR (self));
|
||||||
|
|
||||||
|
if (gravity == CLUTTER_GRAVITY_NONE)
|
||||||
|
clutter_actor_set_rotation (self, CLUTTER_Z_AXIS, angle, 0, 0, 0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
priv = self->priv;
|
||||||
|
|
||||||
|
g_object_freeze_notify (G_OBJECT (self));
|
||||||
|
|
||||||
|
clutter_actor_set_rotation_internal (self, CLUTTER_Z_AXIS, angle);
|
||||||
|
|
||||||
|
clutter_anchor_coord_set_gravity (&priv->rz_center, gravity);
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-z-gravity");
|
||||||
|
g_object_notify (G_OBJECT (self), "rotation-center-z");
|
||||||
|
|
||||||
|
g_object_thaw_notify (G_OBJECT (self));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -5644,6 +5627,7 @@ clutter_actor_get_rotationu (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
ClutterActorPrivate *priv;
|
ClutterActorPrivate *priv;
|
||||||
gdouble retval = 0;
|
gdouble retval = 0;
|
||||||
|
AnchorCoord *anchor_coord = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
|
||||||
|
|
||||||
@ -5652,91 +5636,23 @@ clutter_actor_get_rotationu (ClutterActor *self,
|
|||||||
switch (axis)
|
switch (axis)
|
||||||
{
|
{
|
||||||
case CLUTTER_X_AXIS:
|
case CLUTTER_X_AXIS:
|
||||||
retval = CLUTTER_FIXED_TO_DOUBLE (priv->rxang);
|
anchor_coord = &priv->rx_center;
|
||||||
if (y)
|
|
||||||
*y = priv->rxy;
|
|
||||||
if (z)
|
|
||||||
*z = priv->rxz;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_Y_AXIS:
|
|
||||||
retval = CLUTTER_FIXED_TO_DOUBLE (priv->ryang);
|
|
||||||
if (x)
|
|
||||||
*x = priv->ryx;
|
|
||||||
if (z)
|
|
||||||
*z = priv->ryz;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_Z_AXIS:
|
|
||||||
retval = CLUTTER_FIXED_TO_DOUBLE (priv->rzang);
|
|
||||||
if (x)
|
|
||||||
*x = priv->rzx;
|
|
||||||
if (y)
|
|
||||||
*y = priv->rzy;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clutter_actor_get_rotationx:
|
|
||||||
* @self: a #ClutterActor
|
|
||||||
* @axis: the axis of rotation
|
|
||||||
* @x: return value for the X coordinate of the center of rotation
|
|
||||||
* @y: return value for the Y coordinate of the center of rotation
|
|
||||||
* @z: return value for the Z coordinate of the center of rotation
|
|
||||||
*
|
|
||||||
* Retrieves the angle and center of rotation on the given axis,
|
|
||||||
* set using clutter_actor_set_rotation().
|
|
||||||
*
|
|
||||||
* This function is the fixed point variant of clutter_actor_get_rotation().
|
|
||||||
*
|
|
||||||
* Return value: the angle of rotation as a fixed point value.
|
|
||||||
*
|
|
||||||
* Since: 0.6
|
|
||||||
*/
|
|
||||||
ClutterFixed
|
|
||||||
clutter_actor_get_rotationx (ClutterActor *self,
|
|
||||||
ClutterRotateAxis axis,
|
|
||||||
gint *x,
|
|
||||||
gint *y,
|
|
||||||
gint *z)
|
|
||||||
{
|
|
||||||
ClutterActorPrivate *priv;
|
|
||||||
ClutterFixed retval = 0;
|
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
|
|
||||||
|
|
||||||
priv = self->priv;
|
|
||||||
|
|
||||||
switch (axis)
|
|
||||||
{
|
|
||||||
case CLUTTER_X_AXIS:
|
|
||||||
retval = priv->rxang;
|
retval = priv->rxang;
|
||||||
if (y)
|
|
||||||
*y = CLUTTER_UNITS_TO_DEVICE (priv->rxy);
|
|
||||||
if (z)
|
|
||||||
*z = CLUTTER_UNITS_TO_DEVICE (priv->rxz);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_Y_AXIS:
|
case CLUTTER_Y_AXIS:
|
||||||
|
anchor_coord = &priv->ry_center;
|
||||||
retval = priv->ryang;
|
retval = priv->ryang;
|
||||||
if (x)
|
|
||||||
*x = CLUTTER_UNITS_TO_DEVICE (priv->ryx);
|
|
||||||
if (z)
|
|
||||||
*z = CLUTTER_UNITS_TO_DEVICE (priv->ryz);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CLUTTER_Z_AXIS:
|
case CLUTTER_Z_AXIS:
|
||||||
|
anchor_coord = &priv->rz_center;
|
||||||
retval = priv->rzang;
|
retval = priv->rzang;
|
||||||
if (x)
|
|
||||||
*x = CLUTTER_UNITS_TO_DEVICE (priv->rzx);
|
|
||||||
if (y)
|
|
||||||
*y = CLUTTER_UNITS_TO_DEVICE (priv->rzy);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clutter_anchor_coord_get_units (self, anchor_coord, x, y, z);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5765,11 +5681,26 @@ clutter_actor_get_rotation (ClutterActor *self,
|
|||||||
gint *y,
|
gint *y,
|
||||||
gint *z)
|
gint *z)
|
||||||
{
|
{
|
||||||
|
ClutterUnit xu, yu, zu;
|
||||||
|
gdouble angle;
|
||||||
|
|
||||||
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0);
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0);
|
||||||
|
|
||||||
return CLUTTER_FIXED_TO_FLOAT (clutter_actor_get_rotationx (self,
|
angle = clutter_actor_get_rotationu (self, axis, &xu, &yu, &zu);
|
||||||
axis,
|
|
||||||
x, y, z));
|
*x = CLUTTER_UNITS_TO_DEVICE (xu);
|
||||||
|
*y = CLUTTER_UNITS_TO_DEVICE (yu);
|
||||||
|
*z = CLUTTER_UNITS_TO_DEVICE (zu);
|
||||||
|
|
||||||
|
return angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
ClutterGravity
|
||||||
|
clutter_actor_get_z_rotation_gravity (ClutterActor *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0.0);
|
||||||
|
|
||||||
|
return clutter_anchor_coord_get_gravity (&self->priv->rz_center);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -6905,7 +6836,7 @@ out:
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
ClutterRotateAxis axis;
|
ClutterRotateAxis axis;
|
||||||
|
|
||||||
ClutterFixed angle;
|
gdouble angle;
|
||||||
|
|
||||||
ClutterUnit center_x;
|
ClutterUnit center_x;
|
||||||
ClutterUnit center_y;
|
ClutterUnit center_y;
|
||||||
@ -6925,7 +6856,7 @@ parse_rotation_array (ClutterActor *actor,
|
|||||||
/* angle */
|
/* angle */
|
||||||
element = json_array_get_element (array, 0);
|
element = json_array_get_element (array, 0);
|
||||||
if (JSON_NODE_TYPE (element) == JSON_NODE_VALUE)
|
if (JSON_NODE_TYPE (element) == JSON_NODE_VALUE)
|
||||||
info->angle = CLUTTER_FLOAT_TO_FIXED (json_node_get_double (element));
|
info->angle = json_node_get_double (element);
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@ -7138,7 +7069,7 @@ clutter_actor_set_custom_property (ClutterScriptable *scriptable,
|
|||||||
|
|
||||||
info = g_value_get_pointer (value);
|
info = g_value_get_pointer (value);
|
||||||
|
|
||||||
clutter_actor_set_rotation_internal (CLUTTER_ACTOR (scriptable),
|
clutter_actor_set_rotationu (CLUTTER_ACTOR (scriptable),
|
||||||
info->axis, info->angle,
|
info->axis, info->angle,
|
||||||
info->center_x,
|
info->center_x,
|
||||||
info->center_y,
|
info->center_y,
|
||||||
|
@ -390,33 +390,26 @@ void clutter_actor_set_rotation (ClutterActor
|
|||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint z);
|
gint z);
|
||||||
void clutter_actor_set_rotationx (ClutterActor *self,
|
|
||||||
ClutterRotateAxis axis,
|
|
||||||
ClutterFixed angle,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
gint z);
|
|
||||||
void clutter_actor_set_rotationu (ClutterActor *self,
|
void clutter_actor_set_rotationu (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
ClutterRotateAxis axis,
|
||||||
gdouble angle,
|
gdouble angle,
|
||||||
ClutterUnit x,
|
ClutterUnit x,
|
||||||
ClutterUnit y,
|
ClutterUnit y,
|
||||||
ClutterUnit z);
|
ClutterUnit z);
|
||||||
|
void clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
|
||||||
|
gdouble angle,
|
||||||
|
ClutterGravity gravity);
|
||||||
gdouble clutter_actor_get_rotation (ClutterActor *self,
|
gdouble clutter_actor_get_rotation (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
ClutterRotateAxis axis,
|
||||||
gint *x,
|
gint *x,
|
||||||
gint *y,
|
gint *y,
|
||||||
gint *z);
|
gint *z);
|
||||||
ClutterFixed clutter_actor_get_rotationx (ClutterActor *self,
|
|
||||||
ClutterRotateAxis axis,
|
|
||||||
gint *x,
|
|
||||||
gint *y,
|
|
||||||
gint *z);
|
|
||||||
gdouble clutter_actor_get_rotationu (ClutterActor *self,
|
gdouble clutter_actor_get_rotationu (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
ClutterRotateAxis axis,
|
||||||
ClutterUnit *x,
|
ClutterUnit *x,
|
||||||
ClutterUnit *y,
|
ClutterUnit *y,
|
||||||
ClutterUnit *z);
|
ClutterUnit *z);
|
||||||
|
ClutterGravity clutter_actor_get_z_rotation_gravity (ClutterActor *self);
|
||||||
|
|
||||||
void clutter_actor_set_opacity (ClutterActor *self,
|
void clutter_actor_set_opacity (ClutterActor *self,
|
||||||
guint8 opacity);
|
guint8 opacity);
|
||||||
|
@ -95,8 +95,8 @@ alpha_notify_foreach (ClutterBehaviour *behaviour,
|
|||||||
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour);
|
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour);
|
||||||
priv = rotate_behaviour->priv;
|
priv = rotate_behaviour->priv;
|
||||||
|
|
||||||
clutter_actor_set_rotationx (actor, priv->axis,
|
clutter_actor_set_rotation (actor, priv->axis,
|
||||||
angle,
|
CLUTTER_FIXED_TO_DOUBLE (angle),
|
||||||
priv->center_x,
|
priv->center_x,
|
||||||
priv->center_y,
|
priv->center_y,
|
||||||
priv->center_z);
|
priv->center_z);
|
||||||
|
Loading…
Reference in New Issue
Block a user