2007-07-09 21:38:43 +00:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
* Jorn Baayen <jorn@openedhand.com>
|
|
|
|
* Emmanuele Bassi <ebassi@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 OpenedHand
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 12:56:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-07-09 21:38:43 +00:00
|
|
|
*/
|
|
|
|
|
2007-10-12 08:17:00 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2007-07-09 21:38:43 +00:00
|
|
|
#include "config.h"
|
2007-10-12 08:17:00 +00:00
|
|
|
#endif
|
2007-07-09 21:38:43 +00:00
|
|
|
|
2011-10-14 10:34:38 +00:00
|
|
|
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
|
|
|
|
2011-10-04 10:52:47 +00:00
|
|
|
#include "clutter-behaviour.h"
|
2007-07-09 21:38:43 +00:00
|
|
|
#include "clutter-behaviour-depth.h"
|
|
|
|
#include "clutter-enum-types.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-behaviour-depth
|
2010-11-06 15:54:21 +00:00
|
|
|
* @Title: ClutterBehaviourDepth
|
2007-11-19 16:35:46 +00:00
|
|
|
* @short_description: A behaviour controlling the Z position
|
2010-11-06 15:54:21 +00:00
|
|
|
* @Deprecated: 1.6: Use clutter_actor_animate() instead
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
|
|
|
* #ClutterBehaviourDepth is a simple #ClutterBehaviour controlling the
|
2007-08-05 23:13:27 +00:00
|
|
|
* depth of a set of actors between a start and end depth.
|
2007-08-04 08:59:18 +00:00
|
|
|
*
|
2007-08-04 09:42:01 +00:00
|
|
|
* #ClutterBehaviourDepth is available since Clutter 0.4.
|
2011-06-20 17:42:08 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use the #ClutterActor:depth property and
|
|
|
|
* clutter_actor_animate(), or #ClutterAnimator, or #ClutterState
|
|
|
|
* instead.
|
2007-07-09 21:38:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (ClutterBehaviourDepth,
|
|
|
|
clutter_behaviour_depth,
|
|
|
|
CLUTTER_TYPE_BEHAVIOUR);
|
|
|
|
|
|
|
|
struct _ClutterBehaviourDepthPrivate
|
|
|
|
{
|
2007-11-13 13:21:56 +00:00
|
|
|
gint depth_start;
|
|
|
|
gint depth_end;
|
2007-07-09 21:38:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2007-11-13 13:21:56 +00:00
|
|
|
PROP_DEPTH_START,
|
|
|
|
PROP_DEPTH_END
|
2007-07-09 21:38:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
alpha_notify_foreach (ClutterBehaviour *behaviour,
|
|
|
|
ClutterActor *actor,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
clutter_actor_set_depth (actor, GPOINTER_TO_INT (user_data));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_alpha_notify (ClutterBehaviour *behaviour,
|
2009-01-20 16:42:49 +00:00
|
|
|
gdouble alpha_value)
|
2007-07-09 21:38:43 +00:00
|
|
|
{
|
|
|
|
ClutterBehaviourDepthPrivate *priv;
|
2007-08-04 08:59:18 +00:00
|
|
|
gint depth;
|
2007-07-09 21:38:43 +00:00
|
|
|
|
|
|
|
priv = CLUTTER_BEHAVIOUR_DEPTH (behaviour)->priv;
|
|
|
|
|
2007-08-05 23:13:27 +00:00
|
|
|
/* Need to create factor as to avoid borking signedness */
|
2009-01-23 12:10:50 +00:00
|
|
|
depth = (alpha_value * (priv->depth_end - priv->depth_start))
|
|
|
|
+ priv->depth_start;
|
2007-07-09 21:38:43 +00:00
|
|
|
|
2011-10-17 09:24:25 +00:00
|
|
|
CLUTTER_NOTE (ANIMATION, "alpha: %.4f, depth: %d", alpha_value, depth);
|
2007-07-09 21:38:43 +00:00
|
|
|
|
|
|
|
clutter_behaviour_actors_foreach (behaviour,
|
|
|
|
alpha_notify_foreach,
|
|
|
|
GINT_TO_POINTER (depth));
|
|
|
|
}
|
|
|
|
|
2007-08-04 08:59:18 +00:00
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_applied (ClutterBehaviour *behaviour,
|
|
|
|
ClutterActor *actor)
|
|
|
|
{
|
|
|
|
ClutterBehaviourDepth *depth = CLUTTER_BEHAVIOUR_DEPTH (behaviour);
|
|
|
|
|
2007-11-13 13:21:56 +00:00
|
|
|
clutter_actor_set_depth (actor, depth->priv->depth_start);
|
2007-08-04 08:59:18 +00:00
|
|
|
}
|
|
|
|
|
2007-07-09 21:38:43 +00:00
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterBehaviourDepth *depth = CLUTTER_BEHAVIOUR_DEPTH (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2007-11-13 13:21:56 +00:00
|
|
|
case PROP_DEPTH_START:
|
|
|
|
depth->priv->depth_start = g_value_get_int (value);
|
2007-07-09 21:38:43 +00:00
|
|
|
break;
|
2007-11-13 13:21:56 +00:00
|
|
|
case PROP_DEPTH_END:
|
|
|
|
depth->priv->depth_end = g_value_get_int (value);
|
2007-07-09 21:38:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_get_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterBehaviourDepth *depth = CLUTTER_BEHAVIOUR_DEPTH (gobject);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2007-11-13 13:21:56 +00:00
|
|
|
case PROP_DEPTH_START:
|
|
|
|
g_value_set_int (value, depth->priv->depth_start);
|
2007-07-09 21:38:43 +00:00
|
|
|
break;
|
2007-11-13 13:21:56 +00:00
|
|
|
case PROP_DEPTH_END:
|
|
|
|
g_value_set_int (value, depth->priv->depth_end);
|
2007-07-09 21:38:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_class_init (ClutterBehaviourDepthClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBehaviourClass *behaviour_class = CLUTTER_BEHAVIOUR_CLASS (klass);
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (ClutterBehaviourDepthPrivate));
|
|
|
|
|
|
|
|
gobject_class->set_property = clutter_behaviour_depth_set_property;
|
|
|
|
gobject_class->get_property = clutter_behaviour_depth_get_property;
|
|
|
|
|
|
|
|
behaviour_class->alpha_notify = clutter_behaviour_depth_alpha_notify;
|
2007-08-04 08:59:18 +00:00
|
|
|
behaviour_class->applied = clutter_behaviour_depth_applied;
|
2007-07-09 21:38:43 +00:00
|
|
|
|
|
|
|
/**
|
2007-11-13 13:21:56 +00:00
|
|
|
* ClutterBehaviourDepth:depth-start:
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
2007-08-05 23:13:27 +00:00
|
|
|
* Start depth level to apply to the actors.
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-11-06 15:54:21 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6
|
2007-07-09 21:38:43 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
2007-11-13 13:21:56 +00:00
|
|
|
PROP_DEPTH_START,
|
|
|
|
g_param_spec_int ("depth-start",
|
2010-06-03 11:57:50 +00:00
|
|
|
P_("Start Depth"),
|
|
|
|
P_("Initial depth to apply"),
|
2007-07-09 21:38:43 +00:00
|
|
|
G_MININT, G_MAXINT, 0,
|
|
|
|
CLUTTER_PARAM_READWRITE));
|
|
|
|
/**
|
2007-11-13 13:21:56 +00:00
|
|
|
* ClutterBehaviourDepth:depth-end:
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
2007-08-05 23:13:27 +00:00
|
|
|
* End depth level to apply to the actors.
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-11-06 15:54:21 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6
|
2007-07-09 21:38:43 +00:00
|
|
|
*/
|
|
|
|
g_object_class_install_property (gobject_class,
|
2007-11-13 13:21:56 +00:00
|
|
|
PROP_DEPTH_END,
|
|
|
|
g_param_spec_int ("depth-end",
|
2010-06-03 11:57:50 +00:00
|
|
|
P_("End Depth"),
|
|
|
|
P_("Final depth to apply"),
|
2007-07-09 21:38:43 +00:00
|
|
|
G_MININT, G_MAXINT, 0,
|
|
|
|
CLUTTER_PARAM_READWRITE));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_depth_init (ClutterBehaviourDepth *depth)
|
|
|
|
{
|
|
|
|
depth->priv = G_TYPE_INSTANCE_GET_PRIVATE (depth,
|
|
|
|
CLUTTER_TYPE_BEHAVIOUR_DEPTH,
|
|
|
|
ClutterBehaviourDepthPrivate);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_behaviour_depth_new:
|
2010-09-09 14:41:37 +00:00
|
|
|
* @alpha: (allow-none): a #ClutterAlpha instance, or %NULL
|
2008-01-21 16:07:28 +00:00
|
|
|
* @depth_start: initial value of the depth
|
|
|
|
* @depth_end: final value of the depth
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
|
|
|
* Creates a new #ClutterBehaviourDepth which can be used to control
|
|
|
|
* the ClutterActor:depth property of a set of #ClutterActor<!-- -->s.
|
|
|
|
*
|
2010-09-09 14:41:37 +00:00
|
|
|
* If @alpha is not %NULL, the #ClutterBehaviour will take ownership
|
|
|
|
* of the #ClutterAlpha instance. In the case when @alpha is %NULL,
|
|
|
|
* it can be set later with clutter_behaviour_set_alpha().
|
|
|
|
*
|
2010-11-06 15:54:21 +00:00
|
|
|
* Return value: (transfer full): the newly created behaviour
|
2007-07-09 21:38:43 +00:00
|
|
|
*
|
|
|
|
* Since: 0.4
|
2010-11-06 15:54:21 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6
|
2007-07-09 21:38:43 +00:00
|
|
|
*/
|
|
|
|
ClutterBehaviour *
|
|
|
|
clutter_behaviour_depth_new (ClutterAlpha *alpha,
|
2007-11-13 13:21:56 +00:00
|
|
|
gint depth_start,
|
|
|
|
gint depth_end)
|
2007-07-09 21:38:43 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
|
|
|
|
|
|
|
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_DEPTH,
|
|
|
|
"alpha", alpha,
|
2007-11-13 13:21:56 +00:00
|
|
|
"depth-start", depth_start,
|
|
|
|
"depth-end", depth_end,
|
2007-07-09 21:38:43 +00:00
|
|
|
NULL);
|
|
|
|
}
|
2008-01-21 16:07:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_behaviour_depth_set_bounds:
|
|
|
|
* @behaviour: a #ClutterBehaviourDepth
|
|
|
|
* @depth_start: initial value of the depth
|
|
|
|
* @depth_end: final value of the depth
|
|
|
|
*
|
|
|
|
* Sets the boundaries of the @behaviour.
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
2010-11-06 15:54:21 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6
|
2008-01-21 16:07:28 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_behaviour_depth_set_bounds (ClutterBehaviourDepth *behaviour,
|
|
|
|
gint depth_start,
|
|
|
|
gint depth_end)
|
|
|
|
{
|
|
|
|
ClutterBehaviourDepthPrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_DEPTH (behaviour));
|
|
|
|
|
|
|
|
priv = behaviour->priv;
|
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (behaviour));
|
|
|
|
|
|
|
|
if (priv->depth_start != depth_start)
|
|
|
|
{
|
|
|
|
priv->depth_start = depth_start;
|
|
|
|
g_object_notify (G_OBJECT (behaviour), "depth-start");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->depth_end != depth_end)
|
|
|
|
{
|
|
|
|
priv->depth_end = depth_end;
|
|
|
|
g_object_notify (G_OBJECT (behaviour), "depth-end");
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (behaviour));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_behaviour_depth_get_bounds:
|
|
|
|
* @behaviour: a #ClutterBehaviourDepth
|
2010-09-08 14:37:58 +00:00
|
|
|
* @depth_start: (out): return location for the initial depth value, or %NULL
|
|
|
|
* @depth_end: (out): return location for the final depth value, or %NULL
|
2008-01-21 16:07:28 +00:00
|
|
|
*
|
|
|
|
* Gets the boundaries of the @behaviour
|
|
|
|
*
|
|
|
|
* Since: 0.6
|
2010-11-06 15:54:21 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6
|
2008-01-21 16:07:28 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_behaviour_depth_get_bounds (ClutterBehaviourDepth *behaviour,
|
|
|
|
gint *depth_start,
|
|
|
|
gint *depth_end)
|
|
|
|
{
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_DEPTH (behaviour));
|
|
|
|
|
|
|
|
if (depth_start)
|
|
|
|
*depth_start = behaviour->priv->depth_start;
|
|
|
|
|
|
|
|
if (depth_end)
|
|
|
|
*depth_end = behaviour->priv->depth_end;
|
|
|
|
}
|