+2007-05-25 Tomas Frydrych <tf@openedhand.com>
+
+ * clutter/clutter-actor.c:
+ * clutter/clutter-actor.h:
+ Renamed clutter_actor_scalex() to clutter_actor_set_scale_with_gravityx
+ Added floating point version clutter_actor_set_scale_with_gravity.
+
+ * clutter/clutter-units.h:
+ * clutter/clutter-actor.h:
+ typedef ClutterUnit
+
+ * clutter/clutter-fixed.h:
+ * clutter/clutter-stage.c:
+ CLUTTER_ANGLE_FROM_DEG(), CLUTTER_ANGLE_FROM_DEGX()
+ renamed CLUTTER_DEGF_TO_CLUTTER_ANGLE to CLUTTER_ANGLE_FROM_DEGF
+
+ * clutter/clutter-behaviour-ellipse.h:
+ * clutter/clutter-behaviour-ellipse.c:
+ * examples/behave.c:
+ (clutter_behaviour_ellipse_new):
+ Changed signature to take angles in degrees, and x,y offsets.
+ (clutter_behaviour_ellipse_newx):
+ Fixed version clutter_behaviour_ellipse_new.
+ (clutter_behaviour_ellipse_set_center):
+ (clutter_behaviour_ellipse_get_center):
+ Changed signature to take x,y coords instead of ClutterKnot.
+
+ clutter/cogl/gl/cogl.c:
+ clutter/cogl/gles/cogl.c:
+ (cogl_setup_viewport):
+ Added z_camera calculation.
+
2007-05-25 Matthew Allum <mallum@openedhand.com>
* Makefile.am:
* tests/test-offscreen.c:
* tests/test-scale.c:
More tests.
-
+
2007-05-23 Tomas Frydrych <tf@openedhand.com>
* clutter/clutter-actor.c:
}
/**
- * clutter_actor_scalex:
+ * 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
* Since: 0.4
*/
void
-clutter_actor_scalex (ClutterActor *self,
- ClutterFixed scale_x,
- ClutterFixed scale_y,
- ClutterGravity gravity)
+clutter_actor_set_scale_with_gravityx (ClutterActor *self,
+ ClutterFixed scale_x,
+ ClutterFixed scale_y,
+ ClutterGravity gravity)
{
ClutterActorBox box;
gint32 sw, sh, w, h;
#include <glib-object.h>
#include <clutter/clutter-fixed.h>
+#include <clutter/clutter-units.h>
G_BEGIN_DECLS
CLUTTER_ACTOR_REALIZED = 1 << 2
} ClutterActorFlags;
-struct _ClutterActorBox { gint32 x1, y1, x2, y2; };
+struct _ClutterActorBox { ClutterUnit x1, y1, x2, y2; };
GType clutter_actor_box_get_type (void) G_GNUC_CONST;
gdouble *scale_x,
gdouble *scale_y);
-void clutter_actor_scalex (ClutterActor *self,
- ClutterFixed scale_x,
- ClutterFixed scale_y,
- ClutterGravity gravity);
+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,
priv->b = g_value_get_int (value) >> 1;
break;
case PROP_CENTER:
- clutter_behaviour_ellipse_set_center (el, g_value_get_boxed (value));
+ {
+ ClutterKnot * k = g_value_get_boxed (value);
+ if (k)
+ clutter_behaviour_ellipse_set_center (el, k->x, k->y);
+ }
+
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
/**
* clutter_behaviour_ellipse_new:
* @alpha: a #ClutterAlpha, or %NULL
- * @center: center of the ellipse as #ClutterKnot
+ * @x: x coordinace of the center
+ * @y: y coordiance of the center
* @width: width of the ellipse
* @height: height of the ellipse
- * @begin: #ClutterAngle at which movement begins
- * @end: #ClutterAngle at which movement ends
- * @tilt: #ClutterAngle with which the ellipse should be tilted around its
+ * @begin: angle in degrees at which movement begins
+ * @end: angle in degrees at which movement ends
+ * @tilt: angle in degrees with which the ellipse should be tilted around its
* center
*
* Creates a behaviour that drives actors along an elliptical path with
*/
ClutterBehaviour *
clutter_behaviour_ellipse_new (ClutterAlpha * alpha,
- ClutterKnot * center,
+ gint x,
+ gint y,
gint width,
gint height,
- ClutterAngle begin,
- ClutterAngle end,
- ClutterAngle tilt)
+ gdouble begin,
+ gdouble end,
+ gdouble tilt)
{
ClutterBehaviourEllipse *bc;
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
-
+
+ ClutterKnot center;
+ center.x = x;
+ center.y = y;
+
bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
"alpha", alpha,
- "center", center,
+ "center", ¢er,
"width", width,
"height", height,
- "angle-begin", begin,
- "angle-end", end,
- "angle-tilt", tilt,
+ "angle-begin", CLUTTER_ANGLE_FROM_DEG (begin),
+ "angle-end", CLUTTER_ANGLE_FROM_DEG (end),
+ "angle-tilt", CLUTTER_ANGLE_FROM_DEG (tilt),
NULL);
return CLUTTER_BEHAVIOUR (bc);
}
/**
+ * clutter_behaviour_ellipse_newx:
+ * @alpha: a #ClutterAlpha, or %NULL
+ * @x: x coordinace of the center
+ * @y: y coordiance of the center
+ * @width: width of the ellipse
+ * @height: height of the ellipse
+ * @begin: #ClutterFixed angle in degrees at which movement begins
+ * @end: #ClutterFixed angle in degrees at which movement ends
+ * @tilt: #ClutterFixed angle in degrees with which the ellipse should be tilted around its
+ * center
+ *
+ * Creates a behaviour that drives actors along an elliptical path with
+ * given center, width and height; the movement begins at angle_begin and
+ * ends at angle_end; if angle_end > angle_begin, the movement is in
+ * counter-clockwise direction, clockwise other wise.
+ *
+ * Return value: a #ClutterBehaviour
+ *
+ * Since: 0.4
+ */
+ClutterBehaviour *
+clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ ClutterFixed begin,
+ ClutterFixed end,
+ ClutterFixed tilt)
+{
+ ClutterBehaviourEllipse *bc;
+
+ g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
+
+ ClutterKnot center;
+ center.x = x;
+ center.y = y;
+
+ bc = g_object_new (CLUTTER_TYPE_BEHAVIOUR_ELLIPSE,
+ "alpha", alpha,
+ "center", ¢er,
+ "width", width,
+ "height", height,
+ "angle-begin", CLUTTER_ANGLE_FROM_DEGX (begin),
+ "angle-end", CLUTTER_ANGLE_FROM_DEGX (end),
+ "angle-tilt", CLUTTER_ANGLE_FROM_DEGX (tilt),
+ NULL);
+
+ return CLUTTER_BEHAVIOUR (bc);
+}
+
+
+/**
* clutter_behaviour_ellipse_set_center
* @self: a #ClutterBehaviourEllipse
- * @knot: a #ClutterKnot center for the ellipse
+ * @x: x coordinace of centre
+ * @y: y coordinace of centre
*
* Sets the center of the elliptical path to the point represented by knot.
*
*/
void
clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
- ClutterKnot * knot)
+ gint x,
+ gint y)
{
- if (self->priv->center.x != knot->x || self->priv->center.y != knot->y)
+ if (self->priv->center.x != x || self->priv->center.y != y)
{
g_object_ref (self);
- self->priv->center = *knot;
+ self->priv->center.x = x;
+ self->priv->center.y = y;
g_object_notify (G_OBJECT (self), "center");
g_object_unref (self);
}
/**
* clutter_behaviour_ellipse_get_center
* @self: a #ClutterBehaviourEllipse
- * @knot: a #ClutterKnot where to store the center of the ellipse
+ * @x: location to store the x coordinace of the center, or NULL
+ * @y: location to store the y coordinace of the center, or NULL
*
* Gets the center of the elliptical path path.
*
*/
void
clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * self,
- ClutterKnot * knot)
+ gint * x,
+ gint * y)
{
- *knot = self->priv->center;
+ if (x)
+ *x = self->priv->center.x;
+
+ if (y)
+ *y = self->priv->center.y;
}
GType clutter_behaviour_ellipse_get_type (void) G_GNUC_CONST;
ClutterBehaviour *clutter_behaviour_ellipse_new (ClutterAlpha * alpha,
- ClutterKnot * center,
- gint width,
- gint height,
- ClutterAngle start,
- ClutterAngle end,
- ClutterAngle tilt);
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gdouble start,
+ gdouble end,
+ gdouble tilt);
+
+ClutterBehaviour *clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ ClutterFixed start,
+ ClutterFixed end,
+ ClutterFixed tilt);
void clutter_behaviour_ellipse_set_center (ClutterBehaviourEllipse * self,
- ClutterKnot * knot);
+ gint x,
+ gint y);
+
void clutter_behaviour_ellipse_get_center (ClutterBehaviourEllipse * bs,
- ClutterKnot * knot);
+ gint * x,
+ gint * y);
void clutter_behaviour_ellipse_set_width (ClutterBehaviourEllipse * self,
gint width);
ClutterFixed scale = GPOINTER_TO_UINT (data);
ClutterGravity gravity = priv->gravity;
- clutter_actor_scalex (actor, scale, scale, gravity);
+ clutter_actor_set_scale_with_gravityx (actor, scale, scale, gravity);
}
static void
*/
typedef gint32 ClutterAngle; /* angle such that 1024 == 2*PI */
+#define CLUTTER_ANGLE_FROM_DEG(x) CLUTTER_FLOAT_TO_INT((x*1024.0)/360.0)
+
+#define CLUTTER_ANGLE_FROM_DEGF(x) CLUTTER_FLOAT_TO_INT(((float)x*1024.0f)/360.0f)
+#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0)
+
+#define CLUTTER_ANGLE_FROM_DEGX(x) CFX_INT(((x*1024)/360) + CFX_HALF)
+
#define CFX_Q 16 /* Decimal part size in bits */
#define CFX_ONE (1 << CFX_Q) /* 1 */
#define CFX_HALF 32768
#define CLUTTER_FIXED_MUL(x,y) ((x) >> 8) * ((y) >> 8)
#define CLUTTER_FIXED_DIV(x,y) ((((x) << 8)/(y)) << 8)
-#define CLUTTER_DEGF_TO_CLUTTER_ANGLE(x) CLUTTER_FLOAT_TO_INT ((x / 360.0) * 1024)
-
-#define CLUTTER_ANGLE_TO_DEGF(x) (((float)x * 360.0)/ 1024.0)
-
/* some handy short aliases to avoid exessively long lines */
#define CFX_INT CLUTTER_FIXED_INT
g_return_if_fail (CLUTTER_IS_STAGE (stage));
priv = stage->priv;
- priv->perspective.fovy = CLUTTER_DEGF_TO_CLUTTER_ANGLE(fovy);
+ priv->perspective.fovy = CLUTTER_ANGLE_FROM_DEGF(fovy);
priv->perspective.aspect = CLUTTER_FLOAT_TO_FIXED(aspect);
priv->perspective.z_near = CLUTTER_FLOAT_TO_FIXED(z_near);
priv->perspective.z_far = CLUTTER_FLOAT_TO_FIXED(z_far);
#include <clutter/clutter-fixed.h>
+G_BEGIN_DECLS
+
+typedef gint32 ClutterUnit;
+
/*
* Currently CLUTTER_UNIT maps directly onto ClutterFixed. Nevertheless, the
* _FROM_FIXED and _TO_FIXED macros should always be used in case that we
#define CLUTTER_UNITS_FROM_PANGO_UNIT(x) (x << 6)
+G_END_DECLS
+
#endif /* _HAVE_CLUTTER_UNITS_H */
ClutterFixed z_near,
ClutterFixed z_far)
{
+ GLfloat z_camera;
+
GE( glViewport (0, 0, width, height) );
GE( glMatrixMode (GL_PROJECTION) );
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
- GE( glTranslatef (-0.5f, -0.5f, -DEFAULT_Z_CAMERA) );
+ z_camera = CLUTTER_FIXED_TO_FLOAT (clutter_tani (fovy) >> 1);
+
+ GE( glTranslatef (-0.5f, -0.5f, -z_camera) );
GE( glScalef ( 1.0f / width,
-1.0f / height,
1.0f / width) );
{
gint width = (gint) w;
gint height = (gint) h;
-
+ ClutterFixed z_camera;
+
GE( glViewport (0, 0, width, height) );
GE( glMatrixMode (GL_PROJECTION) );
GE( glLoadIdentity () );
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
-
- GE( glTranslatex (-1 << 15,
- -1 << 15,
- -CLUTTER_FLOAT_TO_FIXED(DEFAULT_Z_CAMERA)) );
+ z_camera = clutter_tani (fovy) << 1;
+
+ GE( glTranslatex (-1 << 15, -1 << 15, -z_camera );
GE( glScalex ( CFX_ONE / width,
-CFX_ONE / height,
</para>
@alpha:
-@center:
+@x:
+@y:
@width:
@height:
@start:
</para>
@self:
-@knot:
+@x:
+@y:
<!-- ##### FUNCTION clutter_behaviour_ellipse_get_center ##### -->
</para>
@bs:
-@knot:
+@x:
+@y:
<!-- ##### FUNCTION clutter_behaviour_ellipse_get_angle_begin ##### -->
@CLUTTER_FEATURE_TEXTURE_RECTANGLE:
@CLUTTER_FEATURE_SYNC_TO_VBLANK:
+@CLUTTER_FEATURE_TEXTURE_YUV:
@CLUTTER_FEATURE_TEXTURE_READ_PIXELS:
<!-- ##### FUNCTION clutter_feature_available ##### -->
@fovy:
@aspect:
-@zNear:
-@zFar:
+@z_near:
+@z_far:
<!-- ##### FUNCTION clutter_perspective_copy ##### -->
<para>
@Returns:
-<!-- ##### FUNCTION clutter_texture_set_from_data ##### -->
-<para>
-
-</para>
-
-@texture:
-@data:
-@has_alpha:
-@width:
-@height:
-@rowstride:
-@bpp:
-
-
<!-- ##### FUNCTION clutter_texture_set_pixbuf ##### -->
<para>
@texture:
@pixbuf:
+@error:
+@Returns:
<!-- ##### FUNCTION clutter_texture_get_pixbuf ##### -->
break;
case PATH_ELLIPSE:
p_behave =
- clutter_behaviour_ellipse_new (alpha, &origin, 400, 300,
- 0, 1024, 0);
+ clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300,
+ 0.0, 360.0, 0.0);
break;
case PATH_BSPLINE: