clutter/actor: Remove rotation center

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1332
This commit is contained in:
Georges Basile Stavracas Neto 2020-06-26 18:39:14 -03:00 committed by Robert Mader
parent 2e086c74e7
commit dc4cb562b7
6 changed files with 25 additions and 478 deletions

View File

@ -183,15 +183,10 @@ ClutterLayoutInfo * _clutter_actor_peek_layout_info
struct _ClutterTransformInfo
{
/* rotation (angle and center) */
/* rotation */
gdouble rx_angle;
AnchorCoord rx_center;
gdouble ry_angle;
AnchorCoord ry_center;
gdouble rz_angle;
AnchorCoord rz_center;
/* scaling */
gdouble scale_x;

View File

@ -934,13 +934,6 @@ enum
PROP_ROTATION_ANGLE_X, /* XXX:2.0 rename to rotation-x */
PROP_ROTATION_ANGLE_Y, /* XXX:2.0 rename to rotation-y */
PROP_ROTATION_ANGLE_Z, /* XXX:2.0 rename to rotation-z */
PROP_ROTATION_CENTER_X, /* XXX:2.0 remove */
PROP_ROTATION_CENTER_Y, /* XXX:2.0 remove */
PROP_ROTATION_CENTER_Z, /* XXX:2.0 remove */
/* 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, /* XXX:2.0 remove */
PROP_ANCHOR_X, /* XXX:2.0 remove */
PROP_ANCHOR_Y, /* XXX:2.0 remove */
@ -3167,34 +3160,13 @@ clutter_actor_real_apply_transform (ClutterActor *self,
}
if (info->rz_angle)
{
/* XXX:2.0 remove anchor coord */
TRANSFORM_ABOUT_ANCHOR_COORD (self, transform,
&info->rz_center,
cogl_matrix_rotate (transform,
info->rz_angle,
0, 0, 1.0));
}
cogl_matrix_rotate (transform, info->rz_angle, 0, 0, 1.0);
if (info->ry_angle)
{
/* XXX:2.0 remove anchor coord */
TRANSFORM_ABOUT_ANCHOR_COORD (self, transform,
&info->ry_center,
cogl_matrix_rotate (transform,
info->ry_angle,
0, 1.0, 0));
}
cogl_matrix_rotate (transform, info->ry_angle, 0, 1.0, 0);
if (info->rx_angle)
{
/* XXX:2.0 remove anchor coord */
TRANSFORM_ABOUT_ANCHOR_COORD (self, transform,
&info->rx_center,
cogl_matrix_rotate (transform,
info->rx_angle,
1.0, 0, 0));
}
cogl_matrix_rotate (transform, info->rx_angle, 1.0, 0, 0);
/* XXX:2.0 remove anchor point translation */
if (!clutter_anchor_coord_is_zero (&info->anchor))
@ -4453,9 +4425,9 @@ clutter_actor_remove_child_internal (ClutterActor *self,
}
static const ClutterTransformInfo default_transform_info = {
0.0, { 0, }, /* rotation-x */
0.0, { 0, }, /* rotation-y */
0.0, { 0, }, /* rotation-z */
0.0, /* rotation-x */
0.0, /* rotation-y */
0.0, /* rotation-z */
1.0, 1.0, 1.0, { 0, }, /* scale */
@ -4840,63 +4812,6 @@ clutter_actor_get_rotation_angle (ClutterActor *self,
return retval;
}
/*< private >
* clutter_actor_set_rotation_center_internal:
* @self: a #ClutterActor
* @axis: the axis of the center to change
* @center: the coordinates of the rotation center
*
* Sets the rotation center on the given axis without affecting the
* rotation angle.
*/
static inline void
clutter_actor_set_rotation_center_internal (ClutterActor *self,
ClutterRotateAxis axis,
const graphene_point3d_t *center)
{
graphene_point3d_t v = GRAPHENE_POINT3D_INIT_ZERO;
GObject *obj = G_OBJECT (self);
ClutterTransformInfo *info;
info = _clutter_actor_get_transform_info (self);
if (center != NULL)
v = *center;
g_object_freeze_notify (obj);
switch (axis)
{
case CLUTTER_X_AXIS:
clutter_anchor_coord_set_units (&info->rx_center, v.x, v.y, v.z);
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_X]);
break;
case CLUTTER_Y_AXIS:
clutter_anchor_coord_set_units (&info->ry_center, v.x, v.y, v.z);
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_Y]);
break;
case CLUTTER_Z_AXIS:
/* if the previously set rotation center was fractional, then
* setting explicit coordinates will have to notify the
* :rotation-center-z-gravity property as well
*/
if (info->rz_center.is_fractional)
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_Z_GRAVITY]);
clutter_anchor_coord_set_units (&info->rz_center, v.x, v.y, v.z);
g_object_notify_by_pspec (obj, obj_props[PROP_ROTATION_CENTER_Z]);
break;
}
self->priv->transform_valid = FALSE;
g_object_thaw_notify (obj);
clutter_actor_queue_redraw (self);
}
static void
clutter_actor_set_scale_factor_internal (ClutterActor *self,
double factor,
@ -5310,34 +5225,6 @@ clutter_actor_set_property (GObject *object,
g_value_get_double (value));
break;
case PROP_ROTATION_CENTER_X: /* XXX:2.0 - remove */
clutter_actor_set_rotation_center_internal (actor,
CLUTTER_X_AXIS,
g_value_get_boxed (value));
break;
case PROP_ROTATION_CENTER_Y: /* XXX:2.0 - remove */
clutter_actor_set_rotation_center_internal (actor,
CLUTTER_Y_AXIS,
g_value_get_boxed (value));
break;
case PROP_ROTATION_CENTER_Z: /* XXX:2.0 - remove */
clutter_actor_set_rotation_center_internal (actor,
CLUTTER_Z_AXIS,
g_value_get_boxed (value));
break;
case PROP_ROTATION_CENTER_Z_GRAVITY: /* XXX:2.0 - remove */
{
const ClutterTransformInfo *info;
info = _clutter_actor_get_transform_info_or_defaults (actor);
clutter_actor_set_z_rotation_from_gravity (actor, info->rz_angle,
g_value_get_enum (value));
}
break;
case PROP_ANCHOR_X: /* XXX:2.0 - remove */
clutter_actor_set_anchor_coord (actor, CLUTTER_X_AXIS,
g_value_get_float (value));
@ -5759,49 +5646,6 @@ clutter_actor_get_property (GObject *object,
}
break;
case PROP_ROTATION_CENTER_X: /* XXX:2.0 - remove */
{
graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_X_AXIS,
&center.x,
&center.y,
&center.z);
g_value_set_boxed (value, &center);
}
break;
case PROP_ROTATION_CENTER_Y: /* XXX:2.0 - remove */
{
graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_Y_AXIS,
&center.x,
&center.y,
&center.z);
g_value_set_boxed (value, &center);
}
break;
case PROP_ROTATION_CENTER_Z: /* XXX:2.0 - remove */
{
graphene_point3d_t center;
clutter_actor_get_rotation (actor, CLUTTER_Z_AXIS,
&center.x,
&center.y,
&center.z);
g_value_set_boxed (value, &center);
}
break;
case PROP_ROTATION_CENTER_Z_GRAVITY: /* XXX:2.0 - remove */
g_value_set_enum (value, clutter_actor_get_z_rotation_gravity (actor));
break;
case PROP_ANCHOR_X: /* XXX:2.0 - remove */
{
const ClutterTransformInfo *info;
@ -7223,79 +7067,6 @@ clutter_actor_class_init (ClutterActorClass *klass)
G_PARAM_STATIC_STRINGS |
CLUTTER_PARAM_ANIMATABLE);
/**
* ClutterActor:rotation-center-x:
*
* The rotation center on the X axis.
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point instead
*/
obj_props[PROP_ROTATION_CENTER_X] = /* XXX:2.0 - remove */
g_param_spec_boxed ("rotation-center-x",
P_("Rotation Center X"),
P_("The rotation center on the X axis"),
GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED);
/**
* ClutterActor:rotation-center-y:
*
* The rotation center on the Y axis.
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point instead
*/
obj_props[PROP_ROTATION_CENTER_Y] = /* XXX:2.0 - remove */
g_param_spec_boxed ("rotation-center-y",
P_("Rotation Center Y"),
P_("The rotation center on the Y axis"),
GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED);
/**
* ClutterActor:rotation-center-z:
*
* The rotation center on the Z axis.
*
* Since: 0.6
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point instead
*/
obj_props[PROP_ROTATION_CENTER_Z] = /* XXX:2.0 - remove */
g_param_spec_boxed ("rotation-center-z",
P_("Rotation Center Z"),
P_("The rotation center on the Z axis"),
GRAPHENE_TYPE_POINT3D,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED);
/**
* ClutterActor:rotation-center-z-gravity:
*
* The rotation center on the Z axis expressed as a #ClutterGravity.
*
* Since: 1.0
*
* Deprecated: 1.12: Use #ClutterActor:pivot-point instead
*/
obj_props[PROP_ROTATION_CENTER_Z_GRAVITY] = /* XXX:2.0 - remove */
g_param_spec_enum ("rotation-center-z-gravity",
P_("Rotation Center Z Gravity"),
P_("Center point for rotation around the Z axis"),
CLUTTER_TYPE_GRAVITY,
CLUTTER_GRAVITY_NONE,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS |
G_PARAM_DEPRECATED);
/**
* ClutterActor:anchor-x:
*
@ -12076,191 +11847,6 @@ clutter_actor_get_pivot_point_z (ClutterActor *self)
return _clutter_actor_get_transform_info_or_defaults (self)->pivot_z;
}
/**
* clutter_actor_set_rotation:
* @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.
*
* The rotation center coordinates used depend on the value of @axis:
*
* - %CLUTTER_X_AXIS requires @y and @z
* - %CLUTTER_Y_AXIS requires @x and @z
* - %CLUTTER_Z_AXIS requires @x and @y
*
* The rotation coordinates are relative to the anchor point of the
* actor, set using clutter_actor_set_anchor_point(). If no anchor
* point is set, the upper left corner is assumed as the origin.
*
* Since: 0.8
*
* Deprecated: 1.12: Use clutter_actor_set_rotation_angle() and
* clutter_actor_set_pivot_point() instead.
*/
void
clutter_actor_set_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gdouble angle,
gfloat x,
gfloat y,
gfloat z)
{
graphene_point3d_t v;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
v.x = x;
v.y = y;
v.z = z;
g_object_freeze_notify (G_OBJECT (self));
clutter_actor_set_rotation_angle (self, axis, angle);
clutter_actor_set_rotation_center_internal (self, axis, &v);
g_object_thaw_notify (G_OBJECT (self));
}
/**
* clutter_actor_set_z_rotation_from_gravity:
* @self: a #ClutterActor
* @angle: the angle of rotation
* @gravity: the center point of the rotation
*
* Sets the rotation angle of @self around the Z axis using the center
* point specified as a compass point. For example to rotate such that
* the center of the actor remains static you can use
* %CLUTTER_GRAVITY_CENTER. If the actor changes size the center point
* will move accordingly.
*
* Since: 1.0
*
* Deprecated: 1.12: Use clutter_actor_set_rotation_angle() and
* clutter_actor_set_pivot_point() instead.
*/
void
clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
gdouble angle,
ClutterGravity gravity)
{
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
{
GObject *obj = G_OBJECT (self);
ClutterTransformInfo *info;
GParamSpec *pspec;
pspec = obj_props[PROP_ROTATION_ANGLE_Z];
info = _clutter_actor_get_transform_info (self);
g_object_freeze_notify (obj);
clutter_actor_set_rotation_angle_internal (self, angle, pspec);
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]);
g_object_thaw_notify (obj);
}
}
/**
* clutter_actor_get_rotation:
* @self: a #ClutterActor
* @axis: the axis of rotation
* @x: (out): return value for the X coordinate of the center of rotation
* @y: (out): return value for the Y coordinate of the center of rotation
* @z: (out): 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().
*
* Return value: the angle of rotation
*
* Since: 0.8
*
* Deprecated: 1.12: Use clutter_actor_get_rotation_angle() and
* clutter_actor_get_pivot_point() instead.
*/
gdouble
clutter_actor_get_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gfloat *x,
gfloat *y,
gfloat *z)
{
const ClutterTransformInfo *info;
const AnchorCoord *anchor_coord;
gdouble retval = 0;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), 0);
info = _clutter_actor_get_transform_info_or_defaults (self);
switch (axis)
{
case CLUTTER_X_AXIS:
anchor_coord = &info->rx_center;
retval = info->rx_angle;
break;
case CLUTTER_Y_AXIS:
anchor_coord = &info->ry_center;
retval = info->ry_angle;
break;
case CLUTTER_Z_AXIS:
anchor_coord = &info->rz_center;
retval = info->rz_angle;
break;
default:
anchor_coord = NULL;
retval = 0.0;
break;
}
clutter_anchor_coord_get_units (self, anchor_coord, x, y, z);
return retval;
}
/**
* clutter_actor_get_z_rotation_gravity:
* @self: A #ClutterActor
*
* Retrieves the center for the rotation around the Z axis as a
* compass direction. If the center was specified in pixels or units
* this will return %CLUTTER_GRAVITY_NONE.
*
* Return value: the Z rotation center
*
* Since: 1.0
*
* Deprecated: 1.12: Use the #ClutterActor:pivot-point instead of
* a #ClutterGravity
*/
ClutterGravity
clutter_actor_get_z_rotation_gravity (ClutterActor *self)
{
const ClutterTransformInfo *info;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), CLUTTER_GRAVITY_NONE);
info = _clutter_actor_get_transform_info_or_defaults (self);
return clutter_anchor_coord_get_gravity (&info->rz_center);
}
/**
* clutter_actor_set_clip:
* @self: A #ClutterActor
@ -14301,11 +13887,7 @@ clutter_actor_set_custom_property (ClutterScriptable *scriptable,
info = g_value_get_pointer (value);
clutter_actor_set_rotation (actor,
info->axis, info->angle,
info->center_x,
info->center_y,
info->center_z);
clutter_actor_set_rotation_angle (actor, info->axis, info->angle);
g_slice_free (RotationInfo, info);
@ -19631,7 +19213,7 @@ clutter_actor_get_easing_delay (ClutterActor *self)
*
* |[<!-- language="C" -->
* clutter_actor_set_easing_duration (actor, 1000);
* clutter_actor_set_rotation (actor, CLUTTER_Y_AXIS, 360.0, x, y, z);
* clutter_actor_set_rotation_angle (actor, CLUTTER_Y_AXIS, 360.0);
*
* transition = clutter_actor_get_transition (actor, "rotation-angle-y");
* g_signal_connect (transition, "stopped",

View File

@ -33,26 +33,6 @@
G_BEGIN_DECLS
CLUTTER_DEPRECATED_FOR(clutter_actor_set_rotation_angle)
void clutter_actor_set_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gdouble angle,
gfloat x,
gfloat y,
gfloat z);
CLUTTER_DEPRECATED_FOR(clutter_actor_set_rotation_angle and clutter_actor_set_pivot_point)
void clutter_actor_set_z_rotation_from_gravity (ClutterActor *self,
gdouble angle,
ClutterGravity gravity);
CLUTTER_DEPRECATED_FOR(clutter_actor_get_rotation_angle)
gdouble clutter_actor_get_rotation (ClutterActor *self,
ClutterRotateAxis axis,
gfloat *x,
gfloat *y,
gfloat *z);
CLUTTER_DEPRECATED
ClutterGravity clutter_actor_get_z_rotation_gravity (ClutterActor *self);
CLUTTER_DEPRECATED_FOR(clutter_actor_set_scale and clutter_actor_set_pivot_point)
void clutter_actor_set_scale_full (ClutterActor *self,
gdouble scale_x,

View File

@ -126,12 +126,7 @@ frame_cb (ClutterTimeline *timeline,
/* Rotate everything clockwise about stage center*/
if (oh->group != NULL)
clutter_actor_set_rotation (oh->group,
CLUTTER_Z_AXIS,
rotation,
oh->stage_width / 2,
oh->stage_height / 2,
0);
clutter_actor_set_rotation_angle (oh->group, CLUTTER_Z_AXIS, rotation);
for (i = 0; i < n_hands; i++)
{
@ -139,10 +134,9 @@ frame_cb (ClutterTimeline *timeline,
* to take into account any scaling.
*/
if (oh->hand[i] != NULL)
clutter_actor_set_rotation (oh->hand[i],
CLUTTER_Z_AXIS,
-6.0 * rotation,
0, 0, 0);
clutter_actor_set_rotation_angle (oh->hand[i],
CLUTTER_Z_AXIS,
-6.0 * rotation);
}
}
@ -205,6 +199,7 @@ test_actors_main (int argc, char *argv[])
/* create a new actor to hold other actors */
oh->group = clutter_actor_new ();
clutter_actor_set_pivot_point (oh->group, 0.5, 0.5);
clutter_actor_set_layout_manager (oh->group, clutter_fixed_layout_new ());
clutter_actor_set_name (oh->group, "Group");
g_signal_connect (oh->group, "destroy", G_CALLBACK (on_group_destroy), oh);

View File

@ -157,6 +157,7 @@ make_flower_actor (void)
"width", (gfloat) size,
"height", (gfloat) size,
NULL);
clutter_actor_set_pivot_point (ctex, 0.5, 0.5);
g_object_unref (canvas);
@ -182,12 +183,9 @@ tick (ClutterTimeline *timeline,
clutter_actor_set_position (flowers[i]->ctex,
flowers[i]->x, flowers[i]->y);
clutter_actor_set_rotation (flowers[i]->ctex,
CLUTTER_Z_AXIS,
flowers[i]->rot,
clutter_actor_get_width (flowers[i]->ctex)/2,
clutter_actor_get_height (flowers[i]->ctex)/2,
0);
clutter_actor_set_rotation_angle (flowers[i]->ctex,
CLUTTER_Z_AXIS,
flowers[i]->rot);
}
}

View File

@ -117,22 +117,18 @@ frame_cb (ClutterTimeline *timeline,
/* Rotate everything clockwise about stage center*/
clutter_actor_set_rotation (oh->group,
CLUTTER_Z_AXIS,
rotation,
oh->stage_width / 2,
oh->stage_height / 2,
0);
clutter_actor_set_rotation_angle (oh->group,
CLUTTER_Z_AXIS,
rotation);
for (i = 0; i < n_hands; i++)
{
/* Rotate each hand around there centers - to get this we need
* to take into account any scaling.
*/
clutter_actor_set_rotation (oh->hand[i],
CLUTTER_Z_AXIS,
-6.0 * rotation,
0, 0, 0);
clutter_actor_set_rotation_angle (oh->hand[i],
CLUTTER_Z_AXIS,
-6.0 * rotation);
}
}
@ -264,6 +260,7 @@ test_paint_wrapper_main (int argc, char *argv[])
/* create a new group to hold multiple actors in a group */
oh->group = clutter_actor_new();
clutter_actor_set_pivot_point (oh->group, 0.5, 0.5);
oh->hand = g_new (ClutterActor*, n_hands);