mirror of
https://github.com/brl/mutter.git
synced 2025-04-25 19:29:38 +00:00
2007-08-06 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-behaviour-depth.c: Modify to work like all other behvaiours in not forcing increasing order in behaviour 'limits'. (#436) Rename limit min/max props to start/end. * tests/test-depth.c: Simplify test-case to work with above change and without multiple ramps * clutter/clutter-behaviour-rotate.c: Handle CW rotation when end > start and similar for CCW just like ellipse behaviour.
This commit is contained in:
parent
e1d439f9c9
commit
7949cfe30a
21
ChangeLog
21
ChangeLog
@ -1,3 +1,24 @@
|
|||||||
|
2007-08-06 Matthew Allum <mallum@openedhand.com>
|
||||||
|
|
||||||
|
* clutter/clutter-behaviour-depth.c:
|
||||||
|
Modify to work like all other behvaiours in not forcing
|
||||||
|
increasing order in behaviour 'limits'. (#436)
|
||||||
|
Rename limit min/max props to start/end.
|
||||||
|
|
||||||
|
* tests/test-depth.c:
|
||||||
|
Simplify test-case to work with above change and
|
||||||
|
without multiple ramps
|
||||||
|
|
||||||
|
* clutter/clutter-behaviour-rotate.c:
|
||||||
|
Handle CW rotation when end > start and similar for CCW just
|
||||||
|
like ellipse behaviour.
|
||||||
|
|
||||||
|
2007-08-05 Matthew Allum <mallum@openedhand.com>
|
||||||
|
|
||||||
|
* README:
|
||||||
|
* clutter/clutter-actor.c:
|
||||||
|
Document show/hide_all behaviour correctly.
|
||||||
|
|
||||||
2007-08-05 Emmanuele Bassi <ebassi@openedhand.com>
|
2007-08-05 Emmanuele Bassi <ebassi@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-behaviour-depth.c: Fix typo in the description.
|
* clutter/clutter-behaviour-depth.c: Fix typo in the description.
|
||||||
|
@ -39,20 +39,7 @@
|
|||||||
* @short_description: Behaviour controlling the depth
|
* @short_description: Behaviour controlling the depth
|
||||||
*
|
*
|
||||||
* #ClutterBehaviourDepth is a simple #ClutterBehaviour controlling the
|
* #ClutterBehaviourDepth is a simple #ClutterBehaviour controlling the
|
||||||
* depth of a set of actors.
|
* depth of a set of actors between a start and end depth.
|
||||||
*
|
|
||||||
* The minimum and maximum depth are controlled by the
|
|
||||||
* ClutterBehaviourDepth:min-depth and ClutterBehaviourDepth:max-depth
|
|
||||||
* properties. The direction of the motion on the depth axis is controlled
|
|
||||||
* by the #ClutterAlpha object. If you want to make a #ClutterActor
|
|
||||||
* controlled by the #ClutterBehaviourDepth behaviour move from a depth of
|
|
||||||
* 0 to a depth of 100 you will have to use an increasing alpha function,
|
|
||||||
* like %CLUTTER_ALPHA_RAMP_INC. On the other hand, if you want to make
|
|
||||||
* the same actor move from a depth of 100 to a depth of 0 you will have
|
|
||||||
* to use a decreasing alpha function, like %CLUTTER_ALPHA_RAMP_DEC. Using
|
|
||||||
* a minimum depth greater than the maximum depth and a decreasing alpha
|
|
||||||
* function, or using a maximum depth greater than the minimum depth and
|
|
||||||
* an increasing alpha function will result in an undefined behaviour.
|
|
||||||
*
|
*
|
||||||
* #ClutterBehaviourDepth is available since Clutter 0.4.
|
* #ClutterBehaviourDepth is available since Clutter 0.4.
|
||||||
*/
|
*/
|
||||||
@ -63,16 +50,16 @@ G_DEFINE_TYPE (ClutterBehaviourDepth,
|
|||||||
|
|
||||||
struct _ClutterBehaviourDepthPrivate
|
struct _ClutterBehaviourDepthPrivate
|
||||||
{
|
{
|
||||||
gint min_depth;
|
gint start_depth;
|
||||||
gint max_depth;
|
gint end_depth;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PROP_0,
|
PROP_0,
|
||||||
|
|
||||||
PROP_MIN_DEPTH,
|
PROP_START_DEPTH,
|
||||||
PROP_MAX_DEPTH
|
PROP_END_DEPTH
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -87,27 +74,16 @@ static void
|
|||||||
clutter_behaviour_depth_alpha_notify (ClutterBehaviour *behaviour,
|
clutter_behaviour_depth_alpha_notify (ClutterBehaviour *behaviour,
|
||||||
guint32 alpha_value)
|
guint32 alpha_value)
|
||||||
{
|
{
|
||||||
|
ClutterFixed factor;
|
||||||
ClutterBehaviourDepthPrivate *priv;
|
ClutterBehaviourDepthPrivate *priv;
|
||||||
gint depth;
|
gint depth;
|
||||||
|
|
||||||
priv = CLUTTER_BEHAVIOUR_DEPTH (behaviour)->priv;
|
priv = CLUTTER_BEHAVIOUR_DEPTH (behaviour)->priv;
|
||||||
|
|
||||||
if (priv->max_depth > priv->min_depth)
|
/* Need to create factor as to avoid borking signedness */
|
||||||
{
|
factor = CLUTTER_INT_TO_FIXED (alpha_value) / CLUTTER_ALPHA_MAX_ALPHA;
|
||||||
depth = alpha_value
|
depth = priv->start_depth +
|
||||||
* (priv->max_depth - priv->min_depth)
|
CLUTTER_FIXED_INT(factor * (priv->end_depth - priv->start_depth));
|
||||||
/ CLUTTER_ALPHA_MAX_ALPHA;
|
|
||||||
|
|
||||||
depth += priv->min_depth;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
depth = alpha_value
|
|
||||||
* (priv->min_depth - priv->max_depth)
|
|
||||||
/ CLUTTER_ALPHA_MAX_ALPHA;
|
|
||||||
|
|
||||||
depth += priv->max_depth;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLUTTER_NOTE (BEHAVIOUR, "alpha: %d, depth: %d", alpha_value, depth);
|
CLUTTER_NOTE (BEHAVIOUR, "alpha: %d, depth: %d", alpha_value, depth);
|
||||||
|
|
||||||
@ -122,7 +98,7 @@ clutter_behaviour_depth_applied (ClutterBehaviour *behaviour,
|
|||||||
{
|
{
|
||||||
ClutterBehaviourDepth *depth = CLUTTER_BEHAVIOUR_DEPTH (behaviour);
|
ClutterBehaviourDepth *depth = CLUTTER_BEHAVIOUR_DEPTH (behaviour);
|
||||||
|
|
||||||
clutter_actor_set_depth (actor, depth->priv->min_depth);
|
clutter_actor_set_depth (actor, depth->priv->start_depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -135,11 +111,11 @@ clutter_behaviour_depth_set_property (GObject *gobject,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MIN_DEPTH:
|
case PROP_START_DEPTH:
|
||||||
depth->priv->min_depth = g_value_get_int (value);
|
depth->priv->start_depth = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_DEPTH:
|
case PROP_END_DEPTH:
|
||||||
depth->priv->max_depth = g_value_get_int (value);
|
depth->priv->end_depth = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
@ -157,11 +133,11 @@ clutter_behaviour_depth_get_property (GObject *gobject,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MIN_DEPTH:
|
case PROP_START_DEPTH:
|
||||||
g_value_set_int (value, depth->priv->min_depth);
|
g_value_set_int (value, depth->priv->start_depth);
|
||||||
break;
|
break;
|
||||||
case PROP_MAX_DEPTH:
|
case PROP_END_DEPTH:
|
||||||
g_value_set_int (value, depth->priv->max_depth);
|
g_value_set_int (value, depth->priv->end_depth);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
||||||
@ -184,31 +160,31 @@ clutter_behaviour_depth_class_init (ClutterBehaviourDepthClass *klass)
|
|||||||
behaviour_class->applied = clutter_behaviour_depth_applied;
|
behaviour_class->applied = clutter_behaviour_depth_applied;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ClutterBehaviourDepth:min-depth:
|
* ClutterBehaviourDepth:start-depth:
|
||||||
*
|
*
|
||||||
* Minimum depth level to apply to the actors.
|
* Start depth level to apply to the actors.
|
||||||
*
|
*
|
||||||
* Since: 0.4
|
* Since: 0.4
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_MIN_DEPTH,
|
PROP_START_DEPTH,
|
||||||
g_param_spec_int ("min-depth",
|
g_param_spec_int ("start-depth",
|
||||||
"Minimum Depth",
|
"Start Depth",
|
||||||
"Minimum depth to apply",
|
"Start depth to apply",
|
||||||
G_MININT, G_MAXINT, 0,
|
G_MININT, G_MAXINT, 0,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
/**
|
/**
|
||||||
* ClutterBehaviourDepth:max-depth:
|
* ClutterBehaviourDepth:end-depth:
|
||||||
*
|
*
|
||||||
* Maximum depth level to apply to the actors.
|
* End depth level to apply to the actors.
|
||||||
*
|
*
|
||||||
* Since: 0.4
|
* Since: 0.4
|
||||||
*/
|
*/
|
||||||
g_object_class_install_property (gobject_class,
|
g_object_class_install_property (gobject_class,
|
||||||
PROP_MAX_DEPTH,
|
PROP_END_DEPTH,
|
||||||
g_param_spec_int ("max-depth",
|
g_param_spec_int ("end-depth",
|
||||||
"Maximum Depth",
|
"End Depth",
|
||||||
"Maximum depth to apply",
|
"End depth to apply",
|
||||||
G_MININT, G_MAXINT, 0,
|
G_MININT, G_MAXINT, 0,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
@ -224,8 +200,8 @@ clutter_behaviour_depth_init (ClutterBehaviourDepth *depth)
|
|||||||
/**
|
/**
|
||||||
* clutter_behaviour_depth_new:
|
* clutter_behaviour_depth_new:
|
||||||
* @alpha: a #ClutterAlpha or %NULL
|
* @alpha: a #ClutterAlpha or %NULL
|
||||||
* @min_depth: minimum depth level
|
* @start_depth: start depth
|
||||||
* @max_depth: maximum depth level
|
* @end_depth: end depth
|
||||||
*
|
*
|
||||||
* Creates a new #ClutterBehaviourDepth which can be used to control
|
* Creates a new #ClutterBehaviourDepth which can be used to control
|
||||||
* the ClutterActor:depth property of a set of #ClutterActor<!-- -->s.
|
* the ClutterActor:depth property of a set of #ClutterActor<!-- -->s.
|
||||||
@ -236,14 +212,14 @@ clutter_behaviour_depth_init (ClutterBehaviourDepth *depth)
|
|||||||
*/
|
*/
|
||||||
ClutterBehaviour *
|
ClutterBehaviour *
|
||||||
clutter_behaviour_depth_new (ClutterAlpha *alpha,
|
clutter_behaviour_depth_new (ClutterAlpha *alpha,
|
||||||
gint min_depth,
|
gint start_depth,
|
||||||
gint max_depth)
|
gint end_depth)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
||||||
|
|
||||||
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_DEPTH,
|
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_DEPTH,
|
||||||
"alpha", alpha,
|
"alpha", alpha,
|
||||||
"min-depth", min_depth,
|
"start-depth", start_depth,
|
||||||
"max-depth", max_depth,
|
"end-depth", end_depth,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
@ -118,7 +118,7 @@ static void
|
|||||||
clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
|
clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
|
||||||
guint32 alpha_value)
|
guint32 alpha_value)
|
||||||
{
|
{
|
||||||
ClutterFixed factor, angle;
|
ClutterFixed factor, angle, diff;
|
||||||
ClutterBehaviourRotate *rotate_behaviour;
|
ClutterBehaviourRotate *rotate_behaviour;
|
||||||
ClutterBehaviourRotatePrivate *priv;
|
ClutterBehaviourRotatePrivate *priv;
|
||||||
|
|
||||||
@ -131,12 +131,66 @@ clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
|
|||||||
switch (priv->direction)
|
switch (priv->direction)
|
||||||
{
|
{
|
||||||
case CLUTTER_ROTATE_CW:
|
case CLUTTER_ROTATE_CW:
|
||||||
angle = CLUTTER_FIXED_MUL (factor, (priv->angle_end - priv->angle_begin));
|
if (priv->angle_end >= priv->angle_begin)
|
||||||
angle += priv->angle_begin;
|
{
|
||||||
|
angle = CLUTTER_FIXED_MUL (factor,
|
||||||
|
(priv->angle_end - priv->angle_begin));
|
||||||
|
angle += priv->angle_begin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Work out the angular length of the arch represented by the
|
||||||
|
* end angle in CCW direction
|
||||||
|
*/
|
||||||
|
if (priv->angle_end > CLUTTER_INT_TO_FIXED(360))
|
||||||
|
{
|
||||||
|
ClutterFixed rounds, a1, a2;
|
||||||
|
|
||||||
|
rounds = priv->angle_begin / 360;
|
||||||
|
a1 = rounds * 360;
|
||||||
|
a2 = CLUTTER_INT_TO_FIXED(360) - (priv->angle_begin - a1);
|
||||||
|
|
||||||
|
diff = a1 + a2 + priv->angle_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diff = CLUTTER_INT_TO_FIXED(360)
|
||||||
|
- priv->angle_begin + priv->angle_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
angle = CLUTTER_FIXED_MUL (diff, factor);
|
||||||
|
angle += priv->angle_begin;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CLUTTER_ROTATE_CCW:
|
case CLUTTER_ROTATE_CCW:
|
||||||
angle = CLUTTER_FIXED_MUL (factor, (priv->angle_begin - priv->angle_end));
|
if (priv->angle_end <= priv->angle_begin)
|
||||||
angle += priv->angle_end;
|
{
|
||||||
|
angle = CLUTTER_FIXED_MUL (factor,
|
||||||
|
(priv->angle_begin - priv->angle_end));
|
||||||
|
angle += priv->angle_end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Work out the angular length of the arch represented by the
|
||||||
|
* end angle in CCW direction
|
||||||
|
*/
|
||||||
|
if (priv->angle_end > CLUTTER_INT_TO_FIXED(360))
|
||||||
|
{
|
||||||
|
ClutterFixed rounds, a1, a2;
|
||||||
|
|
||||||
|
rounds = priv->angle_begin / 360;
|
||||||
|
a1 = rounds * 360;
|
||||||
|
a2 = CLUTTER_INT_TO_FIXED(360) - (priv->angle_end - a1);
|
||||||
|
|
||||||
|
diff = a1 + a2 + priv->angle_begin;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
diff = CLUTTER_INT_TO_FIXED(360)
|
||||||
|
- priv->angle_end + priv->angle_begin;
|
||||||
|
}
|
||||||
|
angle = priv->angle_begin - CLUTTER_FIXED_MUL (diff, factor);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +311,9 @@ clutter_behaviour_rotate_class_init (ClutterBehaviourRotateClass *klass)
|
|||||||
g_param_spec_double ("angle-begin",
|
g_param_spec_double ("angle-begin",
|
||||||
"Angle Begin",
|
"Angle Begin",
|
||||||
"Initial angle",
|
"Initial angle",
|
||||||
0.0, 359.0, 0.0,
|
0.0,
|
||||||
|
CLUTTER_ANGLE_MAX_DEG,
|
||||||
|
0.0,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
/**
|
/**
|
||||||
* ClutterBehaviourRotate:angle-end:
|
* ClutterBehaviourRotate:angle-end:
|
||||||
@ -271,7 +327,9 @@ clutter_behaviour_rotate_class_init (ClutterBehaviourRotateClass *klass)
|
|||||||
g_param_spec_double ("angle-end",
|
g_param_spec_double ("angle-end",
|
||||||
"Angle End",
|
"Angle End",
|
||||||
"Final angle",
|
"Final angle",
|
||||||
0.0, 359.0, 359.0,
|
0.0,
|
||||||
|
CLUTTER_ANGLE_MAX_DEG,
|
||||||
|
360.0,
|
||||||
CLUTTER_PARAM_READWRITE));
|
CLUTTER_PARAM_READWRITE));
|
||||||
/**
|
/**
|
||||||
* ClutterBehaviourRotate:axis:
|
* ClutterBehaviourRotate:axis:
|
||||||
|
@ -1,12 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <clutter/clutter.h>
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
/* this is a rather contrieved test case emulating a CLUTTER_ALPHA_RAMP
|
|
||||||
* with two half-ramps. it shows that the direction of the motion on the
|
|
||||||
* Z axis of a ClutterBehaviourDepth is controlled by the ClutterAlpha
|
|
||||||
* and not by the minimum and maximum depth.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static gboolean zoom_in = TRUE;
|
static gboolean zoom_in = TRUE;
|
||||||
static ClutterBehaviour *d_behave = NULL;
|
static ClutterBehaviour *d_behave = NULL;
|
||||||
|
|
||||||
@ -14,33 +8,25 @@ static void
|
|||||||
timeline_completed (ClutterTimeline *timeline,
|
timeline_completed (ClutterTimeline *timeline,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
ClutterAlpha *alpha;
|
gint start_depth, end_depth;
|
||||||
gint min_depth, max_depth;
|
|
||||||
|
|
||||||
if (zoom_in)
|
if (zoom_in)
|
||||||
{
|
{
|
||||||
alpha = clutter_alpha_new_full (timeline,
|
start_depth = 100;
|
||||||
CLUTTER_ALPHA_RAMP_INC,
|
end_depth = 0;
|
||||||
NULL, NULL);
|
|
||||||
min_depth = -100;
|
|
||||||
max_depth = 0;
|
|
||||||
zoom_in = FALSE;
|
zoom_in = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alpha = clutter_alpha_new_full (timeline,
|
start_depth = 0;
|
||||||
CLUTTER_ALPHA_RAMP_DEC,
|
end_depth = 100;
|
||||||
NULL, NULL);
|
|
||||||
min_depth = 0;
|
|
||||||
max_depth = -100;
|
|
||||||
zoom_in = TRUE;
|
zoom_in = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_object_set (G_OBJECT (d_behave),
|
g_object_set (G_OBJECT (d_behave),
|
||||||
"min-depth", min_depth,
|
"start-depth", start_depth,
|
||||||
"max-depth", max_depth,
|
"end-depth", end_depth,
|
||||||
NULL);
|
NULL);
|
||||||
clutter_behaviour_set_alpha (d_behave, alpha);
|
|
||||||
|
|
||||||
clutter_timeline_rewind (timeline);
|
clutter_timeline_rewind (timeline);
|
||||||
clutter_timeline_start (timeline);
|
clutter_timeline_start (timeline);
|
||||||
@ -86,9 +72,9 @@ main (int argc, char *argv[])
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
d_behave = clutter_behaviour_depth_new (clutter_alpha_new_full (timeline,
|
d_behave = clutter_behaviour_depth_new (clutter_alpha_new_full (timeline,
|
||||||
CLUTTER_ALPHA_RAMP_DEC,
|
CLUTTER_ALPHA_RAMP_INC,
|
||||||
NULL, NULL),
|
NULL, NULL),
|
||||||
0, -100);
|
0, 100);
|
||||||
clutter_behaviour_apply (d_behave, hand);
|
clutter_behaviour_apply (d_behave, hand);
|
||||||
clutter_behaviour_apply (d_behave, label);
|
clutter_behaviour_apply (d_behave, label);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user