2007-04-16 06:25:30 -04:00
|
|
|
/*
|
|
|
|
* Clutter.
|
|
|
|
*
|
|
|
|
* An OpenGL based 'interactive canvas' library.
|
|
|
|
*
|
|
|
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 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 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2007-04-16 06:25:30 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:clutter-behaviour-rotate
|
2007-11-19 11:35:46 -05:00
|
|
|
* @short_description: A behaviour controlling rotation
|
2007-04-16 06:25:30 -04:00
|
|
|
*
|
|
|
|
* A #ClutterBehaviourRotate rotate actors between a starting and ending
|
2007-04-16 06:25:41 -04:00
|
|
|
* angle on a given axis.
|
|
|
|
*
|
|
|
|
* The #ClutterBehaviourRotate is available since version 0.4.
|
2011-06-20 13:42:08 -04:00
|
|
|
*
|
|
|
|
* Deprecated: 1.6: Use the #ClutterActor rotation properties and
|
|
|
|
* clutter_actor_animate(), or #ClutterAnimator, or #ClutterState
|
|
|
|
* instead.
|
2007-04-16 06:25:30 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
2011-10-14 06:34:38 -04:00
|
|
|
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
2012-07-06 06:58:19 -04:00
|
|
|
#include "deprecated/clutter-actor.h"
|
2011-10-14 06:34:38 -04:00
|
|
|
|
2012-04-25 12:13:29 -04:00
|
|
|
#include "clutter-alpha.h"
|
2011-10-04 06:52:47 -04:00
|
|
|
#include "clutter-behaviour.h"
|
|
|
|
#include "clutter-behaviour-rotate.h"
|
2010-11-06 11:54:21 -04:00
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-enum-types.h"
|
|
|
|
#include "clutter-main.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
G_DEFINE_TYPE (ClutterBehaviourRotate,
|
|
|
|
clutter_behaviour_rotate,
|
|
|
|
CLUTTER_TYPE_BEHAVIOUR);
|
|
|
|
|
|
|
|
struct _ClutterBehaviourRotatePrivate
|
|
|
|
{
|
2009-03-09 13:03:37 -04:00
|
|
|
gdouble angle_start;
|
|
|
|
gdouble angle_end;
|
2007-04-16 06:25:30 -04:00
|
|
|
|
|
|
|
ClutterRotateAxis axis;
|
|
|
|
ClutterRotateDirection direction;
|
2007-08-18 08:39:36 -04:00
|
|
|
|
|
|
|
gint center_x;
|
|
|
|
gint center_y;
|
|
|
|
gint center_z;
|
2007-04-16 06:25:30 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#define CLUTTER_BEHAVIOUR_ROTATE_GET_PRIVATE(obj) \
|
|
|
|
(G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
|
|
|
|
CLUTTER_TYPE_BEHAVIOUR_ROTATE, \
|
|
|
|
ClutterBehaviourRotatePrivate))
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
2007-11-13 08:21:56 -05:00
|
|
|
PROP_ANGLE_START,
|
2007-04-16 06:25:30 -04:00
|
|
|
PROP_ANGLE_END,
|
|
|
|
PROP_AXIS,
|
2007-07-24 18:32:37 -04:00
|
|
|
PROP_DIRECTION,
|
2007-07-25 08:17:44 -04:00
|
|
|
PROP_CENTER_X,
|
|
|
|
PROP_CENTER_Y,
|
2010-06-21 05:20:32 -04:00
|
|
|
PROP_CENTER_Z,
|
|
|
|
|
|
|
|
PROP_LAST
|
2007-04-16 06:25:30 -04:00
|
|
|
};
|
|
|
|
|
2010-06-21 05:20:32 -04:00
|
|
|
static GParamSpec *obj_props[PROP_LAST];
|
|
|
|
|
2009-02-18 12:57:17 -05:00
|
|
|
typedef struct {
|
2009-03-09 13:03:37 -04:00
|
|
|
gdouble angle;
|
2009-02-18 12:57:17 -05:00
|
|
|
} RotateFrameClosure;
|
|
|
|
|
2007-12-17 12:16:49 -05:00
|
|
|
static void
|
2007-07-25 08:17:44 -04:00
|
|
|
alpha_notify_foreach (ClutterBehaviour *behaviour,
|
|
|
|
ClutterActor *actor,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2009-02-18 12:57:17 -05:00
|
|
|
RotateFrameClosure *closure = data;
|
2007-11-18 10:36:04 -05:00
|
|
|
ClutterBehaviourRotate *rotate_behaviour;
|
2007-07-25 08:17:44 -04:00
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour);
|
|
|
|
priv = rotate_behaviour->priv;
|
|
|
|
|
2009-01-23 10:55:41 -05:00
|
|
|
clutter_actor_set_rotation (actor, priv->axis,
|
2009-03-09 13:03:37 -04:00
|
|
|
closure->angle,
|
2009-01-23 10:55:41 -05:00
|
|
|
priv->center_x,
|
|
|
|
priv->center_y,
|
|
|
|
priv->center_z);
|
2007-07-25 08:17:44 -04:00
|
|
|
}
|
|
|
|
|
2009-03-09 13:03:37 -04:00
|
|
|
static inline float
|
|
|
|
clamp_angle (float a)
|
2007-12-17 12:16:49 -05:00
|
|
|
{
|
2009-03-09 13:03:37 -04:00
|
|
|
float a1, a2;
|
2007-12-17 12:16:49 -05:00
|
|
|
gint rounds;
|
|
|
|
|
2009-01-20 11:20:54 -05:00
|
|
|
rounds = a / 360.0;
|
|
|
|
a1 = rounds * 360.0;
|
2007-12-17 12:16:49 -05:00
|
|
|
a2 = a - a1;
|
|
|
|
|
|
|
|
return a2;
|
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
static void
|
|
|
|
clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour,
|
2009-01-20 11:42:49 -05:00
|
|
|
gdouble alpha_value)
|
2007-04-16 06:25:30 -04:00
|
|
|
{
|
|
|
|
ClutterBehaviourRotate *rotate_behaviour;
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
2009-02-18 12:57:17 -05:00
|
|
|
RotateFrameClosure closure;
|
2009-03-09 13:03:37 -04:00
|
|
|
gdouble start, end;
|
2007-04-16 06:25:30 -04:00
|
|
|
|
|
|
|
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour);
|
|
|
|
priv = rotate_behaviour->priv;
|
|
|
|
|
2009-02-18 12:57:17 -05:00
|
|
|
closure.angle = 0;
|
|
|
|
start = priv->angle_start;
|
|
|
|
end = priv->angle_end;
|
2007-12-17 12:16:49 -05:00
|
|
|
|
|
|
|
if (priv->direction == CLUTTER_ROTATE_CW && start >= end)
|
2009-03-09 13:03:37 -04:00
|
|
|
end += 360.0;
|
2007-12-17 12:16:49 -05:00
|
|
|
else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end)
|
2009-03-09 13:03:37 -04:00
|
|
|
end -= 360.0;
|
2007-12-17 12:16:49 -05:00
|
|
|
|
2009-03-09 13:03:37 -04:00
|
|
|
closure.angle = (end - start) * alpha_value + start;
|
2007-04-16 06:25:30 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
clutter_behaviour_actors_foreach (behaviour,
|
|
|
|
alpha_notify_foreach,
|
2009-02-18 12:57:17 -05:00
|
|
|
&closure);
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_rotate_set_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2007-07-24 18:32:37 -04:00
|
|
|
ClutterBehaviourRotate *rotate;
|
2007-04-16 06:25:30 -04:00
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
2007-07-24 18:32:37 -04:00
|
|
|
rotate = CLUTTER_BEHAVIOUR_ROTATE (gobject);
|
|
|
|
priv = rotate->priv;
|
2007-04-16 06:25:30 -04:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2007-11-13 08:21:56 -05:00
|
|
|
case PROP_ANGLE_START:
|
2009-03-09 13:03:37 -04:00
|
|
|
priv->angle_start = g_value_get_double (value);
|
2007-04-16 06:25:41 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_ANGLE_END:
|
2009-03-09 13:03:37 -04:00
|
|
|
priv->angle_end = g_value_get_double (value);
|
2007-04-16 06:25:41 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_AXIS:
|
|
|
|
priv->axis = g_value_get_enum (value);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_DIRECTION:
|
|
|
|
priv->direction = g_value_get_enum (value);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_X:
|
|
|
|
clutter_behaviour_rotate_set_center (rotate,
|
|
|
|
g_value_get_int (value),
|
|
|
|
priv->center_y,
|
|
|
|
priv->center_z);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_Y:
|
|
|
|
clutter_behaviour_rotate_set_center (rotate,
|
|
|
|
priv->center_x,
|
|
|
|
g_value_get_int (value),
|
|
|
|
priv->center_z);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_Z:
|
|
|
|
clutter_behaviour_rotate_set_center (rotate,
|
|
|
|
priv->center_x,
|
|
|
|
priv->center_y,
|
|
|
|
g_value_get_int (value));
|
2007-07-24 18:32:37 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_rotate_get_property (GObject *gobject,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
priv = CLUTTER_BEHAVIOUR_ROTATE (gobject)->priv;
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2007-11-13 08:21:56 -05:00
|
|
|
case PROP_ANGLE_START:
|
2009-03-09 13:03:37 -04:00
|
|
|
g_value_set_double (value, priv->angle_start);
|
2007-04-16 06:25:41 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_ANGLE_END:
|
2009-03-09 13:03:37 -04:00
|
|
|
g_value_set_double (value, priv->angle_end);
|
2007-04-16 06:25:41 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_AXIS:
|
|
|
|
g_value_set_enum (value, priv->axis);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
case PROP_DIRECTION:
|
|
|
|
g_value_set_enum (value, priv->direction);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_X:
|
|
|
|
g_value_set_int (value, priv->center_x);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_Y:
|
|
|
|
g_value_set_int (value, priv->center_y);
|
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
case PROP_CENTER_Z:
|
|
|
|
g_value_set_int (value, priv->center_z);
|
2007-07-24 18:32:37 -04:00
|
|
|
break;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_rotate_class_init (ClutterBehaviourRotateClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
ClutterBehaviourClass *behaviour_class = CLUTTER_BEHAVIOUR_CLASS (klass);
|
2009-03-09 13:03:37 -04:00
|
|
|
GParamSpec *pspec = NULL;
|
|
|
|
|
|
|
|
g_type_class_add_private (klass, sizeof (ClutterBehaviourRotatePrivate));
|
2007-04-16 06:25:30 -04:00
|
|
|
|
|
|
|
gobject_class->set_property = clutter_behaviour_rotate_set_property;
|
|
|
|
gobject_class->get_property = clutter_behaviour_rotate_get_property;
|
|
|
|
|
|
|
|
behaviour_class->alpha_notify = clutter_behaviour_rotate_alpha_notify;
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
2007-11-13 08:21:56 -05:00
|
|
|
* ClutterBehaviourRotate:angle-start:
|
2007-04-16 06:25:41 -04:00
|
|
|
*
|
2007-11-13 08:21:56 -05:00
|
|
|
* The initial angle from whence the rotation should start.
|
2007-04-16 06:25:41 -04:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_double ("angle-start",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Angle Begin"),
|
|
|
|
P_("Initial angle"),
|
2009-03-09 13:03:37 -04:00
|
|
|
0.0, 360.0,
|
|
|
|
0.0,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_ANGLE_START] = pspec;
|
2007-04-16 06:25:30 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
2007-11-13 08:21:56 -05:00
|
|
|
PROP_ANGLE_START,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* ClutterBehaviourRotate:angle-end:
|
|
|
|
*
|
|
|
|
* The final angle to where the rotation should end.
|
2007-12-17 12:16:49 -05:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_double ("angle-end",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Angle End"),
|
|
|
|
P_("Final angle"),
|
2009-03-09 13:03:37 -04:00
|
|
|
0.0, 360.0,
|
|
|
|
0.0,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_ANGLE_END] = pspec;
|
2007-04-16 06:25:30 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_ANGLE_END,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* ClutterBehaviourRotate:axis:
|
|
|
|
*
|
|
|
|
* The axis of rotation.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_enum ("axis",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Axis"),
|
|
|
|
P_("Axis of rotation"),
|
2009-03-09 13:03:37 -04:00
|
|
|
CLUTTER_TYPE_ROTATE_AXIS,
|
|
|
|
CLUTTER_Z_AXIS,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_AXIS] = pspec;
|
2007-04-16 06:25:30 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_AXIS,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* ClutterBehaviourRotate:direction:
|
|
|
|
*
|
|
|
|
* The direction of the rotation.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_enum ("direction",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Direction"),
|
|
|
|
P_("Direction of rotation"),
|
2009-03-09 13:03:37 -04:00
|
|
|
CLUTTER_TYPE_ROTATE_DIRECTION,
|
|
|
|
CLUTTER_ROTATE_CW,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_DIRECTION] = pspec;
|
2007-04-16 06:25:30 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_DIRECTION,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
|
|
|
|
2007-07-24 18:32:37 -04:00
|
|
|
/**
|
2007-07-25 08:17:44 -04:00
|
|
|
* ClutterBehaviourRotate:center-x:
|
2007-07-24 18:32:37 -04:00
|
|
|
*
|
2007-12-17 12:16:49 -05:00
|
|
|
* The x center of rotation.
|
2007-07-24 18:32:37 -04:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-07-24 18:32:37 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_int ("center-x",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Center X"),
|
|
|
|
P_("X coordinate of the center of rotation"),
|
2009-03-09 13:03:37 -04:00
|
|
|
-G_MAXINT, G_MAXINT,
|
|
|
|
0,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_CENTER_X] = pspec;
|
2007-07-24 18:32:37 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
2007-07-25 08:17:44 -04:00
|
|
|
PROP_CENTER_X,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
2007-07-25 08:17:44 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* ClutterBehaviourRotate:center-y:
|
|
|
|
*
|
2007-12-17 12:16:49 -05:00
|
|
|
* The y center of rotation.
|
2007-07-25 08:17:44 -04:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-07-25 08:17:44 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_int ("center-y",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Center Y"),
|
|
|
|
P_("Y coordinate of the center of rotation"),
|
2009-03-09 13:03:37 -04:00
|
|
|
-G_MAXINT, G_MAXINT,
|
|
|
|
0,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_CENTER_Y] = pspec;
|
2007-07-25 08:17:44 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_CENTER_Y,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
/**
|
|
|
|
* ClutterBehaviourRotate:center-z:
|
|
|
|
*
|
2007-12-17 12:16:49 -05:00
|
|
|
* The z center of rotation.
|
2007-07-25 08:17:44 -04:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-07-25 08:17:44 -04:00
|
|
|
*/
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec = g_param_spec_int ("center-z",
|
2010-06-03 07:57:50 -04:00
|
|
|
P_("Center Z"),
|
|
|
|
P_("Z coordinate of the center of rotation"),
|
2009-03-09 13:03:37 -04:00
|
|
|
-G_MAXINT, G_MAXINT,
|
|
|
|
0,
|
|
|
|
CLUTTER_PARAM_READWRITE);
|
2010-06-21 05:20:32 -04:00
|
|
|
obj_props[PROP_CENTER_Z] = pspec;
|
2007-07-25 08:17:44 -04:00
|
|
|
g_object_class_install_property (gobject_class,
|
|
|
|
PROP_CENTER_Z,
|
2009-03-09 13:03:37 -04:00
|
|
|
pspec);
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
clutter_behaviour_rotate_init (ClutterBehaviourRotate *rotate)
|
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
rotate->priv = priv = CLUTTER_BEHAVIOUR_ROTATE_GET_PRIVATE (rotate);
|
|
|
|
|
2009-03-09 13:03:37 -04:00
|
|
|
priv->angle_start = priv->angle_end = 0;
|
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
priv->axis = CLUTTER_Z_AXIS;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
priv->direction = CLUTTER_ROTATE_CW;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
priv->center_x = priv->center_y = priv->center_z = 0;
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_new:
|
2010-09-09 10:41:37 -04:00
|
|
|
* @alpha: (allow-none): a #ClutterAlpha instance, or %NULL
|
2007-04-16 06:25:41 -04:00
|
|
|
* @axis: the rotation axis
|
|
|
|
* @direction: the rotation direction
|
2007-12-17 12:16:49 -05:00
|
|
|
* @angle_start: the starting angle in degrees, between 0 and 360.
|
|
|
|
* @angle_end: the final angle in degrees, between 0 and 360.
|
2007-04-16 06:25:41 -04:00
|
|
|
*
|
|
|
|
* Creates a new #ClutterBehaviourRotate. This behaviour will rotate actors
|
2007-11-13 08:21:56 -05:00
|
|
|
* bound to it on @axis, following @direction, between @angle_start and
|
2007-12-17 12:16:49 -05:00
|
|
|
* @angle_end. Angles >= 360 degrees will be clamped to the canonical interval
|
|
|
|
* <0, 360), if angle_start == angle_end, the behaviour will carry out a
|
|
|
|
* single rotation of 360 degrees.
|
2007-04-16 06:25:41 -04:00
|
|
|
*
|
2010-09-09 10:41:37 -04: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().
|
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
* Return value: the newly created #ClutterBehaviourRotate.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
ClutterBehaviour *
|
|
|
|
clutter_behaviour_rotate_new (ClutterAlpha *alpha,
|
|
|
|
ClutterRotateAxis axis,
|
|
|
|
ClutterRotateDirection direction,
|
2007-11-13 08:21:56 -05:00
|
|
|
gdouble angle_start,
|
2007-04-16 06:25:30 -04:00
|
|
|
gdouble angle_end)
|
|
|
|
{
|
2007-08-18 08:39:36 -04:00
|
|
|
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL);
|
|
|
|
|
|
|
|
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ROTATE,
|
|
|
|
"alpha", alpha,
|
|
|
|
"axis", axis,
|
|
|
|
"direction", direction,
|
2007-11-13 08:21:56 -05:00
|
|
|
"angle-start", angle_start,
|
2007-08-18 08:39:36 -04:00
|
|
|
"angle-end", angle_end,
|
|
|
|
NULL);
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_get_axis:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterRotateAxis used by the rotate behaviour.
|
|
|
|
*
|
|
|
|
* Return value: the rotation axis
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
ClutterRotateAxis
|
|
|
|
clutter_behaviour_rotate_get_axis (ClutterBehaviourRotate *rotate)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate), CLUTTER_Z_AXIS);
|
|
|
|
|
|
|
|
return rotate->priv->axis;
|
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_set_axis:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
|
|
|
* @axis: a #ClutterRotateAxis
|
|
|
|
*
|
|
|
|
* Sets the axis used by the rotate behaviour.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_set_axis (ClutterBehaviourRotate *rotate,
|
|
|
|
ClutterRotateAxis axis)
|
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
|
|
|
priv = rotate->priv;
|
|
|
|
|
|
|
|
if (priv->axis != axis)
|
|
|
|
{
|
|
|
|
priv->axis = axis;
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_AXIS]);
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_get_direction:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
|
|
|
*
|
|
|
|
* Retrieves the #ClutterRotateDirection used by the rotate behaviour.
|
|
|
|
*
|
|
|
|
* Return value: the rotation direction
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
ClutterRotateDirection
|
|
|
|
clutter_behaviour_rotate_get_direction (ClutterBehaviourRotate *rotate)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate),
|
|
|
|
CLUTTER_ROTATE_CW);
|
|
|
|
|
|
|
|
return rotate->priv->direction;
|
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_set_direction:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
|
|
|
* @direction: the rotation direction
|
|
|
|
*
|
|
|
|
* Sets the rotation direction used by the rotate behaviour.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_set_direction (ClutterBehaviourRotate *rotate,
|
|
|
|
ClutterRotateDirection direction)
|
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
|
|
|
priv = rotate->priv;
|
|
|
|
|
|
|
|
if (priv->direction != direction)
|
|
|
|
{
|
|
|
|
priv->direction = direction;
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_DIRECTION]);
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-04-16 06:25:41 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_get_bounds:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
2011-07-27 03:14:10 -04:00
|
|
|
* @angle_start: (out): return value for the initial angle
|
|
|
|
* @angle_end: (out): return value for the final angle
|
2007-04-16 06:25:41 -04:00
|
|
|
*
|
|
|
|
* Retrieves the rotation boundaries of the rotate behaviour.
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-04-16 06:25:41 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_get_bounds (ClutterBehaviourRotate *rotate,
|
2007-11-13 08:21:56 -05:00
|
|
|
gdouble *angle_start,
|
2007-04-16 06:25:30 -04:00
|
|
|
gdouble *angle_end)
|
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
|
|
|
priv = rotate->priv;
|
|
|
|
|
2007-11-13 08:21:56 -05:00
|
|
|
if (angle_start)
|
2009-03-09 13:03:37 -04:00
|
|
|
*angle_start = priv->angle_start;
|
2007-04-16 06:25:30 -04:00
|
|
|
|
|
|
|
if (angle_end)
|
2009-03-09 13:03:37 -04:00
|
|
|
*angle_end = priv->angle_end;
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
2007-08-07 10:03:58 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_set_bounds:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
2007-12-17 12:16:49 -05:00
|
|
|
* @angle_start: initial angle in degrees, between 0 and 360.
|
|
|
|
* @angle_end: final angle in degrees, between 0 and 360.
|
2007-08-07 10:03:58 -04:00
|
|
|
*
|
2007-12-17 12:16:49 -05:00
|
|
|
* Sets the initial and final angles of a rotation behaviour; angles >= 360
|
|
|
|
* degrees get clamped to the canonical interval <0, 360).
|
2007-08-07 10:03:58 -04:00
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-08-07 10:03:58 -04:00
|
|
|
*/
|
2007-04-16 06:25:30 -04:00
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_set_bounds (ClutterBehaviourRotate *rotate,
|
2007-11-13 08:21:56 -05:00
|
|
|
gdouble angle_start,
|
2007-04-16 06:25:30 -04:00
|
|
|
gdouble angle_end)
|
|
|
|
{
|
2009-03-09 13:03:37 -04:00
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
2007-04-16 06:25:30 -04:00
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
2009-03-09 13:03:37 -04:00
|
|
|
priv = rotate->priv;
|
|
|
|
|
|
|
|
g_object_freeze_notify (G_OBJECT (rotate));
|
|
|
|
|
|
|
|
if (priv->angle_start != angle_start)
|
|
|
|
{
|
|
|
|
priv->angle_start = clamp_angle (angle_start);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_ANGLE_START]);
|
2009-03-09 13:03:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->angle_end != angle_end)
|
|
|
|
{
|
|
|
|
priv->angle_end = clamp_angle (angle_end);
|
|
|
|
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_ANGLE_END]);
|
2009-03-09 13:03:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (rotate));
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|
|
|
|
|
2007-07-24 18:32:37 -04:00
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_set_center:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
2007-07-25 08:17:44 -04:00
|
|
|
* @x: X axis center of rotation
|
|
|
|
* @y: Y axis center of rotation
|
|
|
|
* @z: Z axis center of rotation
|
2007-07-24 18:32:37 -04:00
|
|
|
*
|
|
|
|
* Sets the center of rotation. The coordinates are relative to the plane
|
|
|
|
* normal to the rotation axis set with clutter_behaviour_rotate_set_axis().
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-07-24 18:32:37 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_set_center (ClutterBehaviourRotate *rotate,
|
2007-07-25 08:17:44 -04:00
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint z)
|
2007-07-24 18:32:37 -04:00
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
|
|
|
priv = rotate->priv;
|
|
|
|
|
2007-08-18 08:39:36 -04:00
|
|
|
g_object_freeze_notify (G_OBJECT (rotate));
|
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
if (priv->center_x != x)
|
2007-07-24 18:32:37 -04:00
|
|
|
{
|
2007-07-25 08:17:44 -04:00
|
|
|
priv->center_x = x;
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_X]);
|
2007-07-25 08:17:44 -04:00
|
|
|
}
|
2007-07-24 18:32:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
if (priv->center_y != y)
|
|
|
|
{
|
|
|
|
priv->center_y = y;
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_Y]);
|
2007-07-25 08:17:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (priv->center_z != z)
|
|
|
|
{
|
|
|
|
priv->center_z = z;
|
2011-03-03 06:35:46 -05:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_Z]);
|
2007-07-24 18:32:37 -04:00
|
|
|
}
|
2007-08-18 08:39:36 -04:00
|
|
|
|
|
|
|
g_object_thaw_notify (G_OBJECT (rotate));
|
2007-07-24 18:32:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* clutter_behaviour_rotate_get_center:
|
|
|
|
* @rotate: a #ClutterBehaviourRotate
|
2010-09-08 10:37:58 -04:00
|
|
|
* @x: (out): return location for the X center of rotation
|
|
|
|
* @y: (out): return location for the Y center of rotation
|
|
|
|
* @z: (out): return location for the Z center of rotation
|
2007-07-24 18:32:37 -04:00
|
|
|
*
|
|
|
|
* Retrieves the center of rotation set using
|
|
|
|
* clutter_behaviour_rotate_set_center().
|
|
|
|
*
|
2012-08-27 04:48:36 -04:00
|
|
|
*
|
2007-07-24 18:32:37 -04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
clutter_behaviour_rotate_get_center (ClutterBehaviourRotate *rotate,
|
2007-07-25 08:17:44 -04:00
|
|
|
gint *x,
|
|
|
|
gint *y,
|
|
|
|
gint *z)
|
2007-07-24 18:32:37 -04:00
|
|
|
{
|
|
|
|
ClutterBehaviourRotatePrivate *priv;
|
|
|
|
|
|
|
|
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate));
|
|
|
|
|
|
|
|
priv = rotate->priv;
|
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
if (x)
|
|
|
|
*x = priv->center_x;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
if (y)
|
|
|
|
*y = priv->center_y;
|
2009-03-09 13:03:37 -04:00
|
|
|
|
2007-07-25 08:17:44 -04:00
|
|
|
if (z)
|
2007-08-18 08:39:36 -04:00
|
|
|
*z = priv->center_z;
|
2007-04-16 06:25:30 -04:00
|
|
|
}
|