actor: Consolidate rotation angle internal setter
Use the GParamSpec, instead of the rotation axis enumeration, to simplify the caller code, similarly to how we handle scaling and translation factors.
This commit is contained in:
parent
f99abad4a4
commit
b10e7057ad
@ -4363,47 +4363,35 @@ clutter_actor_get_translation (ClutterActor *self,
|
|||||||
/*< private >
|
/*< private >
|
||||||
* clutter_actor_set_rotation_angle_internal:
|
* clutter_actor_set_rotation_angle_internal:
|
||||||
* @self: a #ClutterActor
|
* @self: a #ClutterActor
|
||||||
* @axis: the axis of the angle to change
|
|
||||||
* @angle: the angle of rotation
|
* @angle: the angle of rotation
|
||||||
|
* @pspec: the #GParamSpec of the property
|
||||||
*
|
*
|
||||||
* Sets the rotation angle on the given axis without affecting the
|
* Sets the rotation angle on the given axis without affecting the
|
||||||
* rotation center point.
|
* rotation center point.
|
||||||
*/
|
*/
|
||||||
static inline void
|
static inline void
|
||||||
clutter_actor_set_rotation_angle_internal (ClutterActor *self,
|
clutter_actor_set_rotation_angle_internal (ClutterActor *self,
|
||||||
ClutterRotateAxis axis,
|
gdouble angle,
|
||||||
gdouble angle)
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
GObject *obj = G_OBJECT (self);
|
|
||||||
ClutterTransformInfo *info;
|
ClutterTransformInfo *info;
|
||||||
|
|
||||||
info = _clutter_actor_get_transform_info (self);
|
info = _clutter_actor_get_transform_info (self);
|
||||||
|
|
||||||
g_object_freeze_notify (obj);
|
if (pspec == obj_props[PROP_ROTATION_ANGLE_X])
|
||||||
|
|
||||||
switch (axis)
|
|
||||||
{
|
|
||||||
case CLUTTER_X_AXIS:
|
|
||||||
info->rx_angle = angle;
|
info->rx_angle = angle;
|
||||||
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_ANGLE_X]);
|
else if (pspec == obj_props[PROP_ROTATION_ANGLE_Y])
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_Y_AXIS:
|
|
||||||
info->ry_angle = angle;
|
info->ry_angle = angle;
|
||||||
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_ANGLE_Y]);
|
else if (pspec == obj_props[PROP_ROTATION_ANGLE_Z])
|
||||||
break;
|
|
||||||
|
|
||||||
case CLUTTER_Z_AXIS:
|
|
||||||
info->rz_angle = angle;
|
info->rz_angle = angle;
|
||||||
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_ANGLE_Z]);
|
else
|
||||||
break;
|
g_assert_not_reached ();
|
||||||
}
|
|
||||||
|
|
||||||
self->priv->transform_valid = FALSE;
|
self->priv->transform_valid = FALSE;
|
||||||
|
|
||||||
g_object_thaw_notify (obj);
|
|
||||||
|
|
||||||
clutter_actor_queue_redraw (self);
|
clutter_actor_queue_redraw (self);
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), pspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11799,12 +11787,14 @@ clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
|
|||||||
{
|
{
|
||||||
GObject *obj = G_OBJECT (self);
|
GObject *obj = G_OBJECT (self);
|
||||||
ClutterTransformInfo *info;
|
ClutterTransformInfo *info;
|
||||||
|
GParamSpec *pspec;
|
||||||
|
|
||||||
|
pspec = obj_props[PROP_ROTATION_ANGLE_Z];
|
||||||
info = _clutter_actor_get_transform_info (self);
|
info = _clutter_actor_get_transform_info (self);
|
||||||
|
|
||||||
g_object_freeze_notify (obj);
|
g_object_freeze_notify (obj);
|
||||||
|
|
||||||
clutter_actor_set_rotation_angle_internal (self, CLUTTER_Z_AXIS, angle);
|
clutter_actor_set_rotation_angle_internal (self, angle, pspec);
|
||||||
|
|
||||||
clutter_anchor_coord_set_gravity (&info->rz_center, gravity);
|
clutter_anchor_coord_set_gravity (&info->rz_center, gravity);
|
||||||
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_Z_GRAVITY]);
|
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_Z_GRAVITY]);
|
||||||
@ -14544,21 +14534,11 @@ clutter_actor_set_animatable_property (ClutterActor *actor,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_ROTATION_ANGLE_X:
|
case PROP_ROTATION_ANGLE_X:
|
||||||
clutter_actor_set_rotation_angle_internal (actor,
|
|
||||||
CLUTTER_X_AXIS,
|
|
||||||
g_value_get_double (value));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_ROTATION_ANGLE_Y:
|
case PROP_ROTATION_ANGLE_Y:
|
||||||
clutter_actor_set_rotation_angle_internal (actor,
|
|
||||||
CLUTTER_Y_AXIS,
|
|
||||||
g_value_get_double (value));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PROP_ROTATION_ANGLE_Z:
|
case PROP_ROTATION_ANGLE_Z:
|
||||||
clutter_actor_set_rotation_angle_internal (actor,
|
clutter_actor_set_rotation_angle_internal (actor,
|
||||||
CLUTTER_Z_AXIS,
|
g_value_get_double (value),
|
||||||
g_value_get_double (value));
|
pspec);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_CONTENT_BOX:
|
case PROP_CONTENT_BOX:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user