added direction paramenter to clutter_behaviour_ellipse_new (), made direction to be respected, unclamped angle values
This commit is contained in:
parent
7b85b34b6c
commit
b368f1833a
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
||||
2007-08-03 Tomas Frydrych <tf@openedhand.com>
|
||||
|
||||
* clutter/clutter-behaviour-ellipse.c:
|
||||
* clutter/clutter-behaviour-ellipse.h:
|
||||
(clutter_behaviour_ellipse_new):
|
||||
(clutter_behaviour_ellipse_newx):
|
||||
|
||||
Added direction parameter; made behaviour to respect direction
|
||||
parameter; unclumped angle_begin and angle_end values.
|
||||
|
||||
2007-08-02 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* NEWS:
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/* -*- mode:C; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Clutter.
|
||||
@ -188,19 +189,60 @@ clutter_behaviour_ellipse_alpha_notify (ClutterBehaviour *behave,
|
||||
knot3d knot;
|
||||
ClutterAngle angle;
|
||||
|
||||
if ((priv->angle_end >= priv->angle_begin) ==
|
||||
(priv->direction == CLUTTER_ROTATE_CW))
|
||||
if ((priv->angle_end >= priv->angle_begin &&
|
||||
priv->direction == CLUTTER_ROTATE_CW) ||
|
||||
(priv->angle_end < priv->angle_begin &&
|
||||
priv->direction == CLUTTER_ROTATE_CCW))
|
||||
{
|
||||
angle = abs (priv->angle_end - priv->angle_begin)
|
||||
* alpha
|
||||
angle = (priv->angle_end - priv->angle_begin) * alpha
|
||||
/ CLUTTER_ALPHA_MAX_ALPHA
|
||||
+ priv->angle_begin;
|
||||
}
|
||||
else if (priv->angle_end >= priv->angle_begin &&
|
||||
priv->direction == CLUTTER_ROTATE_CCW)
|
||||
{
|
||||
ClutterAngle diff;
|
||||
|
||||
/* Work out the angular length of the arch represented by the
|
||||
* end angle in CCW direction
|
||||
*/
|
||||
if (priv->angle_end > 1024)
|
||||
{
|
||||
gint rounds = priv->angle_end / 1024;
|
||||
ClutterAngle a1 = rounds * 1024;
|
||||
ClutterAngle a2 = 1024 - (priv->angle_end - a1);
|
||||
|
||||
diff = a1 + a2 + priv->angle_begin;
|
||||
}
|
||||
else
|
||||
{
|
||||
angle = priv->angle_begin
|
||||
- (abs (priv->angle_begin - priv->angle_end) * alpha)
|
||||
/ CLUTTER_ALPHA_MAX_ALPHA;
|
||||
diff = 1024 - priv->angle_end + priv->angle_begin;
|
||||
}
|
||||
|
||||
angle = priv->angle_begin - (diff * alpha / CLUTTER_ALPHA_MAX_ALPHA);
|
||||
}
|
||||
else if (priv->angle_end < priv->angle_begin &&
|
||||
priv->direction == CLUTTER_ROTATE_CW)
|
||||
{
|
||||
ClutterAngle diff;
|
||||
|
||||
/* Work out the angular length of the arch represented by the
|
||||
* begin angle in CW direction
|
||||
*/
|
||||
if (priv->angle_begin > 1024)
|
||||
{
|
||||
gint rounds = priv->angle_begin/ 1024;
|
||||
ClutterAngle a1 = rounds * 1024;
|
||||
ClutterAngle a2 = 1024 - (priv->angle_begin - a1);
|
||||
|
||||
diff = a1 + a2 + priv->angle_end;
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = 1024 - priv->angle_begin + priv->angle_end;
|
||||
}
|
||||
|
||||
angle = priv->angle_begin + (diff * alpha / CLUTTER_ALPHA_MAX_ALPHA);
|
||||
}
|
||||
|
||||
clutter_behaviour_ellipse_advance (self, angle, &knot);
|
||||
@ -354,7 +396,9 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
|
||||
g_param_spec_double ("angle-begin",
|
||||
"Angle Begin",
|
||||
"Initial angle",
|
||||
0.0, 360.0, 0.0,
|
||||
0.0,
|
||||
CLUTTER_ANGLE_MAX_DEG,
|
||||
0.0,
|
||||
CLUTTER_PARAM_READWRITE));
|
||||
/**
|
||||
* ClutterBehaviourEllipse:angle-end:
|
||||
@ -368,7 +412,9 @@ clutter_behaviour_ellipse_class_init (ClutterBehaviourEllipseClass *klass)
|
||||
g_param_spec_double ("angle-end",
|
||||
"Angle End",
|
||||
"Final angle",
|
||||
0.0, 360.0, 360.0,
|
||||
0.0,
|
||||
CLUTTER_ANGLE_MAX_DEG,
|
||||
360.0,
|
||||
CLUTTER_PARAM_READWRITE));
|
||||
/**
|
||||
* ClutterBehaviourEllipse:angle-tilt-x:
|
||||
@ -490,15 +536,13 @@ clutter_behaviour_ellipse_init (ClutterBehaviourEllipse * self)
|
||||
* @y: y coordiance of the center
|
||||
* @width: width of the ellipse
|
||||
* @height: height of the ellipse
|
||||
* @direction: #ClutterRotateDirection of rotation
|
||||
* @begin: angle in degrees at which movement begins
|
||||
* @end: angle in degrees at which movement ends
|
||||
*
|
||||
* Creates a behaviour that drives actors along an elliptical path with
|
||||
* given center, width and height; the movement begins at @angle_begin
|
||||
* degrees (with 0 corresponding to 12 o'clock) and ends at @angle_end degrees;
|
||||
* if @angle_end is greater than @angle_begin, the movement is in clockwise
|
||||
* direction, counter-clockwise otherwise.
|
||||
*
|
||||
* Return value: the newly created #ClutterBehaviourEllipse
|
||||
*
|
||||
* Since: 0.4
|
||||
@ -509,6 +553,7 @@ clutter_behaviour_ellipse_new (ClutterAlpha *alpha,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterRotateDirection direction,
|
||||
gdouble begin,
|
||||
gdouble end)
|
||||
{
|
||||
@ -524,6 +569,7 @@ clutter_behaviour_ellipse_new (ClutterAlpha *alpha,
|
||||
"center", ¢er,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"direction", direction,
|
||||
"angle-begin", begin,
|
||||
"angle-end", end,
|
||||
NULL);
|
||||
@ -536,6 +582,7 @@ clutter_behaviour_ellipse_new (ClutterAlpha *alpha,
|
||||
* @y: y coordiance of the center
|
||||
* @width: width of the ellipse
|
||||
* @height: height of the ellipse
|
||||
* @direction: #ClutterRotateDirection of rotation
|
||||
* @begin: #ClutterFixed angle in degrees at which movement begins
|
||||
* @end: #ClutterFixed angle in degrees at which movement ends
|
||||
*
|
||||
@ -552,6 +599,7 @@ clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterRotateDirection direction,
|
||||
ClutterFixed begin,
|
||||
ClutterFixed end)
|
||||
{
|
||||
@ -567,6 +615,7 @@ clutter_behaviour_ellipse_newx (ClutterAlpha * alpha,
|
||||
"center", ¢er,
|
||||
"width", width,
|
||||
"height", height,
|
||||
"direction", direction,
|
||||
"angle-begin", CLUTTER_ANGLE_FROM_DEGX (begin),
|
||||
"angle-end", CLUTTER_ANGLE_FROM_DEGX (end),
|
||||
NULL);
|
||||
|
@ -85,6 +85,7 @@ ClutterBehaviour * clutter_behaviour_ellipse_new (ClutterAlph
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterRotateDirection direction,
|
||||
gdouble begin,
|
||||
gdouble end);
|
||||
|
||||
@ -93,6 +94,7 @@ ClutterBehaviour * clutter_behaviour_ellipse_newx (ClutterAlph
|
||||
gint y,
|
||||
gint width,
|
||||
gint height,
|
||||
ClutterRotateDirection direction,
|
||||
ClutterFixed begin,
|
||||
ClutterFixed end);
|
||||
|
||||
|
@ -31,6 +31,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_ANGLE_MAX_DEG 1509949439.6
|
||||
|
||||
#define CLUTTER_TYPE_GEOMETRY (clutter_geometry_get_type ())
|
||||
#define CLUTTER_TYPE_KNOT (clutter_knot_get_type ())
|
||||
#define CLUTTER_TYPE_VERTEX (clutter_vertex_get_type ())
|
||||
|
@ -171,6 +171,7 @@ main (int argc, char *argv[])
|
||||
case PATH_ELLIPSE:
|
||||
p_behave =
|
||||
clutter_behaviour_ellipse_new (alpha, 200, 200, 400, 300,
|
||||
CLUTTER_ROTATE_CW,
|
||||
0.0, 360.0);
|
||||
|
||||
clutter_behaviour_ellipse_set_angle_tilt (CLUTTER_BEHAVIOUR_ELLIPSE (p_behave),
|
||||
|
Loading…
Reference in New Issue
Block a user