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

* clutter/clutter-actor.h:
        * clutter/clutter-actor.c:
	Converted depth and rotation offsets to ClutterUnit.

	(clutter_actor_set_depthu):
	(clutter_actor_get_depthu):
	Additional ClutterUnit API.

	(_clutter_actor_apply_modelview_transform):
	Use cogl_translatex() in place of cogl_translate().
This commit is contained in:
Tomas Frydrych 2007-11-29 13:47:37 +00:00
parent 21435923b1
commit 9c77b0ab13
3 changed files with 94 additions and 27 deletions

View File

@ -1,3 +1,16 @@
2007-11-29 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.h:
* clutter/clutter-actor.c:
Converted depth and rotation offsets to ClutterUnit.
(clutter_actor_set_depthu):
(clutter_actor_get_depthu):
Additional ClutterUnit API.
(_clutter_actor_apply_modelview_transform):
Use cogl_translatex() in place of cogl_translate().
2007-11-29 Emmanuele Bassi <ebassi@openedhand.com> 2007-11-29 Emmanuele Bassi <ebassi@openedhand.com>
* *: Add svn:ignore property to every directory, so that * *: Add svn:ignore property to every directory, so that

View File

@ -167,8 +167,8 @@ struct _ClutterActorPrivate
ClutterGeometry clip; /* FIXME: Should be Units */ ClutterGeometry clip; /* FIXME: Should be Units */
guint has_clip : 1; guint has_clip : 1;
ClutterFixed rxang, ryang, rzang; /* Rotation*/ ClutterFixed rxang, ryang, rzang; /* Rotation*/
gint rzx, rzy, rxy, rxz, ryx, ryz; /* FIXME: Should be Units */ ClutterUnit rzx, rzy, rxy, rxz, ryx, ryz; /* FIXME: Should be Units */
gint z; ClutterUnit z;
guint8 opacity; guint8 opacity;
ClutterActor *parent_actor; ClutterActor *parent_actor;
gchar *name; gchar *name;
@ -756,8 +756,8 @@ _clutter_actor_apply_modelview_transform (ClutterActor * self)
if (parent != NULL) if (parent != NULL)
{ {
cogl_translate (CLUTTER_UNITS_TO_INT (priv->coords.x1), cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->coords.x1),
CLUTTER_UNITS_TO_INT (priv->coords.y1), CLUTTER_UNITS_TO_FIXED (priv->coords.y1),
0); 0);
} }
@ -775,34 +775,52 @@ _clutter_actor_apply_modelview_transform (ClutterActor * self)
if (parent && (priv->anchor_x || priv->anchor_y)) if (parent && (priv->anchor_x || priv->anchor_y))
{ {
cogl_translate (CLUTTER_UNITS_TO_INT (-priv->anchor_x), cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->anchor_x),
CLUTTER_UNITS_TO_INT (-priv->anchor_y), CLUTTER_UNITS_TO_FIXED (-priv->anchor_y),
0); 0);
} }
if (priv->rzang) if (priv->rzang)
{ {
cogl_translate (priv->rzx, priv->rzy, 0); cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->rzx),
CLUTTER_UNITS_TO_FIXED (priv->rzy),
0);
cogl_rotatex (priv->rzang, 0, 0, CFX_ONE); cogl_rotatex (priv->rzang, 0, 0, CFX_ONE);
cogl_translate (-priv->rzx, -priv->rzy, 0);
cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->rzx),
CLUTTER_UNITS_TO_FIXED (-priv->rzy),
0);
} }
if (priv->ryang) if (priv->ryang)
{ {
cogl_translate (priv->ryx, 0, priv->z + priv->ryz); cogl_translatex (CLUTTER_UNITS_TO_FIXED (priv->ryx),
0,
CLUTTER_UNITS_TO_FIXED (priv->z + priv->ryz));
cogl_rotatex (priv->ryang, 0, CFX_ONE, 0); cogl_rotatex (priv->ryang, 0, CFX_ONE, 0);
cogl_translate (-priv->ryx, 0, -(priv->z + priv->ryz));
cogl_translatex (CLUTTER_UNITS_TO_FIXED (-priv->ryx),
0,
CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->ryz)));
} }
if (priv->rxang) if (priv->rxang)
{ {
cogl_translate (0, priv->rxy, priv->z + priv->rxz); cogl_translatex (0,
CLUTTER_UNITS_TO_FIXED (priv->rxy),
CLUTTER_UNITS_TO_FIXED (priv->z + priv->rxz));
cogl_rotatex (priv->rxang, CFX_ONE, 0, 0); cogl_rotatex (priv->rxang, CFX_ONE, 0, 0);
cogl_translate (0, -priv->rxy, -(priv->z + priv->rxz));
cogl_translatex (0,
CLUTTER_UNITS_TO_FIXED (-priv->rxy),
CLUTTER_UNITS_TO_FIXED (-(priv->z + priv->rxz)));
} }
if (priv->z) if (priv->z)
cogl_translate (0, 0, priv->z); cogl_translatex (0, 0, priv->z);
if (priv->has_clip) if (priv->has_clip)
cogl_clip_set (&(priv->clip)); cogl_clip_set (&(priv->clip));
@ -2772,6 +2790,21 @@ clutter_actor_get_gid (ClutterActor *self)
void void
clutter_actor_set_depth (ClutterActor *self, clutter_actor_set_depth (ClutterActor *self,
gint depth) gint depth)
{
clutter_actor_set_depthu (self, CLUTTER_UNITS_FROM_DEVICE (depth));
}
/**
* clutter_actor_set_depthu:
* @self: a #ClutterActor
* @depth: Z co-ord in #ClutterUnit
*
* Sets the Z co-ordinate of @self to @depth in #ClutterUnit, the Units of
* which are dependant on the perspective setup.
*/
void
clutter_actor_set_depthu (ClutterActor *self,
ClutterUnit depth)
{ {
ClutterActorPrivate *priv; ClutterActorPrivate *priv;
@ -2818,6 +2851,24 @@ clutter_actor_get_depth (ClutterActor *self)
{ {
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), -1); g_return_val_if_fail (CLUTTER_IS_ACTOR (self), -1);
return CLUTTER_UNITS_TO_DEVICE (self->priv->z);
}
/**
* clutter_actor_get_depthu:
* @self: a #ClutterActor
*
* Retrieves the depth of @self.
*
* Return value: the depth of a #ClutterActor in #ClutterUnit
*
* Since: 0.6
*/
ClutterUnit
clutter_actor_get_depthu (ClutterActor *self)
{
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), -1);
return self->priv->z; return self->priv->z;
} }
@ -2854,20 +2905,20 @@ clutter_actor_set_rotationx (ClutterActor *self,
{ {
case CLUTTER_X_AXIS: case CLUTTER_X_AXIS:
priv->rxang = angle; priv->rxang = angle;
priv->rxy = y; priv->rxy = CLUTTER_UNITS_FROM_DEVICE (y);
priv->rxz = z; priv->rxz = CLUTTER_UNITS_FROM_DEVICE (z);
break; break;
case CLUTTER_Y_AXIS: case CLUTTER_Y_AXIS:
priv->ryang = angle; priv->ryang = angle;
priv->ryx = x; priv->ryx = CLUTTER_UNITS_FROM_DEVICE (x);
priv->ryz = z; priv->ryz = CLUTTER_UNITS_FROM_DEVICE (z);
break; break;
case CLUTTER_Z_AXIS: case CLUTTER_Z_AXIS:
priv->rzang = angle; priv->rzang = angle;
priv->rzx = x; priv->rzx = CLUTTER_UNITS_FROM_DEVICE (x);
priv->rzy = y; priv->rzy = CLUTTER_UNITS_FROM_DEVICE (y);
break; break;
} }
@ -2946,25 +2997,25 @@ clutter_actor_get_rotationx (ClutterActor *self,
case CLUTTER_X_AXIS: case CLUTTER_X_AXIS:
retval = priv->rxang; retval = priv->rxang;
if (y) if (y)
*y = priv->rxy; *y = CLUTTER_UNITS_TO_DEVICE (priv->rxy);
if (z) if (z)
*z = priv->rxz; *z = CLUTTER_UNITS_TO_DEVICE (priv->rxz);
break; break;
case CLUTTER_Y_AXIS: case CLUTTER_Y_AXIS:
retval = priv->ryang; retval = priv->ryang;
if (x) if (x)
*x = priv->ryx; *x = CLUTTER_UNITS_TO_DEVICE (priv->ryx);
if (z) if (z)
*z = priv->ryz; *z = CLUTTER_UNITS_TO_DEVICE (priv->ryz);
break; break;
case CLUTTER_Z_AXIS: case CLUTTER_Z_AXIS:
retval = priv->rzang; retval = priv->rzang;
if (x) if (x)
*x = priv->rzx; *x = CLUTTER_UNITS_TO_DEVICE (priv->rzx);
if (y) if (y)
*y = priv->rzy; *y = CLUTTER_UNITS_TO_DEVICE (priv->rzy);
break; break;
} }

View File

@ -347,6 +347,9 @@ void clutter_actor_lower_bottom (ClutterActor *sel
void clutter_actor_set_depth (ClutterActor *self, void clutter_actor_set_depth (ClutterActor *self,
gint depth); gint depth);
gint clutter_actor_get_depth (ClutterActor *self); gint clutter_actor_get_depth (ClutterActor *self);
void clutter_actor_set_depthu (ClutterActor *self,
ClutterUnit depth);
ClutterUnit clutter_actor_get_depthu (ClutterActor *self);
void clutter_actor_set_reactive (ClutterActor *actor, void clutter_actor_set_reactive (ClutterActor *actor,
gboolean reactive); gboolean reactive);
gboolean clutter_actor_get_reactive (ClutterActor *actor); gboolean clutter_actor_get_reactive (ClutterActor *actor);