2007-11-28 Tomas Frydrych <tf@openedhand.com>

* clutter/NEWS:
	Started 0.6.0 section with comment on actor anchor point.

        * clutter/clutter/clutter-actor.c:
        * clutter/clutter/clutter-actor.h:
        * clutter/clutter/clutter-behaviour-scale.c:
        * clutter/clutter/clutter-deprecated.h:
	(clutter_actor_set_anchor_point):
	(clutter_actor_set_anchor_pointu):
	(clutter_actor_get_anchor_point):
	(clutter_actor_get_anchor_pointu):
	(clutter_actor_set_anchor_point_from_gravity):
	New anchor point API deprecating old gravity scaling, added
	comments on modelview matrix construction to ClutterActor
	documentation.

	(clutter_actor_set_scale_with_gravity):
	(clutter_actor_set_scale_with_gravityx):
	Deprecated; use clutter_actor_set_anchor_point_from_gravity() instead.
This commit is contained in:
Tomas Frydrych 2007-11-28 12:23:31 +00:00
parent 04afb1066c
commit 20a9bf142c
6 changed files with 310 additions and 169 deletions

View File

@ -1,3 +1,25 @@
2007-11-28 Tomas Frydrych <tf@openedhand.com>
* clutter/NEWS:
Started 0.6.0 section with comment on actor anchor point.
* clutter/clutter/clutter-actor.c:
* clutter/clutter/clutter-actor.h:
* clutter/clutter/clutter-behaviour-scale.c:
* clutter/clutter/clutter-deprecated.h:
(clutter_actor_set_anchor_point):
(clutter_actor_set_anchor_pointu):
(clutter_actor_get_anchor_point):
(clutter_actor_get_anchor_pointu):
(clutter_actor_set_anchor_point_from_gravity):
New anchor point API deprecating old gravity scaling, added
comments on modelview matrix construction to ClutterActor
documentation.
(clutter_actor_set_scale_with_gravity):
(clutter_actor_set_scale_with_gravityx):
Deprecated; use clutter_actor_set_anchor_point_from_gravity() instead.
2007-11-28 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-effect.[ch]: Add clutter_effect_template_construct()

8
NEWS
View File

@ -1,3 +1,11 @@
Clutter 0.6.0 (??/??/????)
========================
* List of changes between 0.4.0 and 0.6.0
o Scaling with gravity functionality was replaced by more generic and
powerful anchor point.
Clutter 0.4.0 (07/08/2007)
========================

View File

@ -32,7 +32,23 @@
* be a #ClutterActor, either by using one of the classes provided by
* Clutter, or by implementing a new #ClutterActor subclass.
*
* Ordering on/Notes on tranformations. FIXME.
* * Notes on actor transformation matrix
*
* The OpenGL modelview matrix for the actor is constructed from the actor
* settings by the following order of operations:
* <orderedlist>
* <listitem><para>Translation by actor x, y coords,</para></listitem>
* <listitem><para>Scaling by scale_x, scale_y,</para></listitem>
* <listitem><para>Negative translation by anchor point x, y,</para>
* </listitem>
* <listitem><para>Rotation around z axis,</para></listitem>
* <listitem><para>Rotation around y axis,</para></listitem>
* <listitem><para>Rotation around x axis,</para></listitem>
* <listitem><para>Translation by actor depth (z),</para></listitem>
* <listitem><para>Clip stencil is applied (not an operation on the matrix as
* such, but done as part of the transform set up).</para>
* </listitem>
* </orderedlist>
*
* Notes on clutter actor events:
* <orderedlist>
@ -158,6 +174,7 @@ struct _ClutterActorPrivate
gchar *name;
ClutterFixed scale_x, scale_y;
guint32 id; /* Unique ID */
ClutterUnit anchor_x, anchor_y;
};
enum
@ -733,8 +750,11 @@ static void
_clutter_actor_apply_modelview_transform (ClutterActor * self)
{
ClutterActorPrivate *priv = self->priv;
ClutterActor *parent;
if (clutter_actor_get_parent (self) != NULL)
parent = clutter_actor_get_parent (self);
if (parent != NULL)
{
cogl_translate (CLUTTER_UNITS_TO_INT (priv->coords.x1),
CLUTTER_UNITS_TO_INT (priv->coords.y1),
@ -753,6 +773,13 @@ _clutter_actor_apply_modelview_transform (ClutterActor * self)
cogl_scale (priv->scale_x, priv->scale_y);
}
if (parent && (priv->anchor_x || priv->anchor_y))
{
cogl_translate (CLUTTER_UNITS_TO_INT (-priv->anchor_x),
CLUTTER_UNITS_TO_INT (-priv->anchor_y),
0);
}
if (priv->rzang)
{
cogl_translate (priv->rzx, priv->rzy, 0);
@ -2393,111 +2420,6 @@ clutter_actor_get_scale (ClutterActor *self,
*scale_y = CLUTTER_FIXED_TO_FLOAT (self->priv->scale_y);
}
/**
* clutter_actor_set_scale_with_gravity:
* @self: A #ClutterActor
* @scale_x: scaling factor for x axis
* @scale_y: scaling factor for y axis
* @gravity: #ClutterGravity to apply to scaling.
*
* Scales the actor by scale_x, scale_y taking into consideration the
* required gravity.
*
* Since: 0.4
*/
void
clutter_actor_set_scale_with_gravity (ClutterActor *self,
gfloat scale_x,
gfloat scale_y,
ClutterGravity gravity)
{
clutter_actor_set_scale_with_gravityx (self,
CLUTTER_FLOAT_TO_FIXED (scale_x),
CLUTTER_FLOAT_TO_FIXED (scale_y),
gravity);
}
/**
* clutter_actor_set_scale_with_gravityx:
* @self: A #ClutterActor
* @scale_x: #ClutterFixed scaling factor for x axis
* @scale_y: #ClutterFixed scaling factor for y axis
* @gravity: #ClutterGravity to apply to scaling.
*
* Scales the actor by scale_x, scale_y taking into consideration the
* required gravity.
*
* Since: 0.4
*/
void
clutter_actor_set_scale_with_gravityx (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y,
ClutterGravity gravity)
{
ClutterActorBox box;
ClutterFixed sw, sh, w, h, x, y;
ClutterFixed old_scale_x, old_scale_y;
clutter_actor_get_scalex (self, &old_scale_x, &old_scale_y);
clutter_actor_set_scalex (self, scale_x, scale_y);
if (gravity == CLUTTER_GRAVITY_NONE ||
gravity == CLUTTER_GRAVITY_NORTH_WEST)
return;
clutter_actor_query_coords (self, &box);
w = CFX_QMUL (box.x2 - box.x1, old_scale_x);
h = CFX_QMUL (box.y2 - box.y1, old_scale_y);
sw = CFX_QMUL (box.x2 - box.x1, scale_x);
sh = CFX_QMUL (box.y2 - box.y1, scale_y);
x = box.x1;
y = box.y1;
switch (gravity)
{
case CLUTTER_GRAVITY_NORTH:
x = x - ((sw - w) / 2);
break;
case CLUTTER_GRAVITY_NORTH_EAST:
x = x + w - sw;
break;
case CLUTTER_GRAVITY_EAST:
x = x + w - sw;
y = y - ((sh - h) / 2);
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
x = x + w - sw;
y = y + h - sh;
break;
case CLUTTER_GRAVITY_SOUTH:
x = x - ((sw - w) / 2);
y = y + h - sh;
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
y = y + h - sh;
break;
case CLUTTER_GRAVITY_WEST:
y = y - ((sh - h) / 2);
break;
case CLUTTER_GRAVITY_CENTER:
x = x - ((sw - w) / 2);
y = y - ((sh - h) / 2);
default:
break;
}
box.x2 += (x - box.x1);
box.y2 += (y - box.y1);
box.x1 = x;
box.y1 = y;
clutter_actor_request_coords (self, &box);
}
/**
* clutter_actor_set_opacity:
* @self: A #ClutterActor
@ -3372,6 +3294,182 @@ clutter_actor_get_reactive (ClutterActor *actor)
return CLUTTER_ACTOR_IS_REACTIVE (actor);
}
/**
* clutter_actor_set_anchor_point:
* @actor: a #ClutterActor
* @anchor_x: X coordinace of the anchor point.
* @anchor_y: Y coordinace of the anchor point.
*
* Sets an anchor point for the @actor. The anchor point is a point in the
* coordianate space of the actor to which the actor position within its
* parent is relative; the default is 0,0, i.e., the top-left corner.
*
* Since: 0.6
*/
void
clutter_actor_set_anchor_point (ClutterActor *self,
gint anchor_x, gint anchor_y)
{
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
priv->anchor_x = CLUTTER_UNITS_FROM_DEVICE (anchor_x);
priv->anchor_y = CLUTTER_UNITS_FROM_DEVICE (anchor_y);
}
/**
* clutter_actor_get_anchor_point:
* @actor: a #ClutterActor
* @anchor_x: location for the X coordinace of the anchor point.
* @anchor_y: location for the X coordinace of the anchor point.
*
* Gets the current anchor point of the @actor.
*
* Since: 0.6
*/
void
clutter_actor_get_anchor_point (ClutterActor *self,
gint *anchor_x, gint *anchor_y)
{
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
if (anchor_x)
*anchor_x = CLUTTER_UNITS_TO_DEVICE (priv->anchor_x);
if (anchor_y)
*anchor_y = CLUTTER_UNITS_TO_DEVICE (priv->anchor_y);
}
/**
* clutter_actor_set_anchor_pointu:
* @actor: a #ClutterActor
* @anchor_x: X coordinace of the anchor point, in multiples of #ClutterUnit.
* @anchor_y: Y coordinace of the anchor point, in multiples of #ClutterUnit.
*
* Sets an anchor point for the @actor. The anchor point is a point in the
* coordinate space of the actor to which the actor position within its
* parent is relative; the default is 0,0, i.e., the top-left corner, of the
* actor.
*
* Since: 0.6
*/
void
clutter_actor_set_anchor_pointu (ClutterActor *self,
ClutterUnit anchor_x, ClutterUnit anchor_y)
{
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
priv->anchor_x = anchor_x;
priv->anchor_y = anchor_y;
}
/**
* clutter_actor_get_anchor_pointu:
* @actor: a #ClutterActor
* @anchor_x: location for the X coordinace of the anchor point, #ClutterUnit.
* @anchor_y: location for the X coordinace of the anchor point, #ClutterUnit.
*
* Gets the current anchor point of the @actor.
*
* Since: 0.6
*/
void
clutter_actor_get_anchor_pointu (ClutterActor *self,
ClutterUnit *anchor_x, ClutterUnit *anchor_y)
{
ClutterActorPrivate *priv;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
if (anchor_x)
*anchor_x = priv->anchor_x;
if (anchor_y)
*anchor_y = priv->anchor_y;
}
/**
* clutter_actor_set_anchor_point_from_gravity:
* @actor: a #ClutterActor
* @gravity: #ClutterGravity.
*
* Sets an anchor point the actor based on the given gravity (this is a
* convenience function wrapping #clutter_actor_set_anchor_point).
*
* Since: 0.6
*/
void
clutter_actor_set_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity)
{
ClutterActorPrivate *priv;
ClutterActorBox box;
ClutterUnit w, h, x, y;
g_return_if_fail (CLUTTER_IS_ACTOR (self));
priv = self->priv;
clutter_actor_query_coords (self, &box);
x = 0;
y = 0;
w = box.x2 - box.x1;
h = box.y2 - box.y1;
switch (gravity)
{
case CLUTTER_GRAVITY_NORTH:
x = w/2;
break;
case CLUTTER_GRAVITY_SOUTH:
x = w/2;
y = h;
break;
case CLUTTER_GRAVITY_EAST:
x = w;
y = h/2;
break;
case CLUTTER_GRAVITY_NORTH_EAST:
x = w;
break;
case CLUTTER_GRAVITY_SOUTH_EAST:
x = w;
y = h;
break;
case CLUTTER_GRAVITY_SOUTH_WEST:
y = h;
break;
case CLUTTER_GRAVITY_WEST:
y = h/2;
break;
case CLUTTER_GRAVITY_CENTER:
x = w/2;
y = h/2;
break;
case CLUTTER_GRAVITY_NONE:
case CLUTTER_GRAVITY_NORTH_WEST:
default:
break;
}
priv->anchor_x = x;
priv->anchor_y = y;
}
/*
* ClutterGeometry
*/

View File

@ -345,16 +345,6 @@ void clutter_actor_get_scale (ClutterActor *sel
gdouble *scale_x,
gdouble *scale_y);
void clutter_actor_set_scale_with_gravityx (ClutterActor *self,
ClutterFixed scale_x,
ClutterFixed scale_y,
ClutterGravity gravity);
void clutter_actor_set_scale_with_gravity (ClutterActor *self,
gfloat scale_x,
gfloat scale_y,
ClutterGravity gravity);
void clutter_actor_get_abs_size (ClutterActor *self,
guint *width,
guint *height);
@ -379,6 +369,21 @@ ClutterActor * clutter_get_actor_by_gid (guint32 id);
gboolean clutter_actor_should_pick_paint (ClutterActor *self);
void clutter_actor_set_anchor_point (ClutterActor *self,
gint offset_x,
gint offset_y);
void clutter_actor_get_anchor_point (ClutterActor *self,
gint *offset_x,
gint *offset_y);
void clutter_actor_set_anchor_pointu (ClutterActor *self,
ClutterUnit offset_x,
ClutterUnit offset_y);
void clutter_actor_get_anchor_pointu (ClutterActor *self,
ClutterUnit *offset_x,
ClutterUnit *offset_y);
void clutter_actor_set_anchor_point_from_gravity (ClutterActor *self,
ClutterGravity gravity);
G_END_DECLS
#endif /* _HAVE_CLUTTER_ACTOR_H */

View File

@ -82,7 +82,13 @@ scale_frame_foreach (ClutterBehaviour *behaviour,
ClutterFixed scale = GPOINTER_TO_UINT (data);
ClutterGravity gravity = priv->gravity;
clutter_actor_set_scale_with_gravityx (actor, scale, scale, gravity);
/* Don't mess with the actor anchor point of gravity is set to
* none
*/
if (gravity != CLUTTER_GRAVITY_NONE)
clutter_actor_set_anchor_point_from_gravity (actor, gravity);
clutter_actor_set_scalex (actor, scale, scale);
}
static void

View File

@ -31,5 +31,7 @@
#define clutter_actor_get_rxangx clutter_actor_get_rxangx_DEPRECATED_BY_clutter_actor_get_rotationx
#define clutter_actor_get_ryangx clutter_actor_get_ryangx_DEPRECATED_BY_clutter_actor_get_rotationx
#define clutter_actor_get_rzangx clutter_actor_get_rzangx_DEPRECATED_BY_clutter_actor_get_rotationx
#define clutter_actor_set_scale_with_gravity clutter_actor_set_scale_with_gravity_DEPRECATED_BY_clutter_actor_set_anchor_point_from_gravity
#define clutter_actor_set_scale_with_gravityx clutter_actor_set_scale_with_gravity_DEPRECATED_BY_clutter_actor_set_anchor_point_from_gravity
#endif /* CLUTTER_DEPRECATED_H */