| 1 |
/* |
| 2 |
* Clutter. |
| 3 |
* |
| 4 |
* An OpenGL based 'interactive canvas' library. |
| 5 |
* |
| 6 |
* Authored By Matthew Allum <[email protected]> |
| 7 |
* |
| 8 |
* Copyright (C) 2007 OpenedHand |
| 9 |
* |
| 10 |
* This library is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Lesser General Public |
| 12 |
* License as published by the Free Software Foundation; either |
| 13 |
* version 2 of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This library is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
* Lesser General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU Lesser General Public |
| 21 |
* License along with this library. If not, see <http://www.gnu.org/licenses/>. |
| 22 |
*/ |
| 23 |
|
| 24 |
/** |
| 25 |
* SECTION:clutter-behaviour-rotate |
| 26 |
* @short_description: A behaviour controlling rotation |
| 27 |
* |
| 28 |
* A #ClutterBehaviourRotate rotate actors between a starting and ending |
| 29 |
* angle on a given axis. |
| 30 |
* |
| 31 |
* The #ClutterBehaviourRotate is available since version 0.4. |
| 32 |
* |
| 33 |
* Deprecated: 1.6: Use the #ClutterActor rotation properties and |
| 34 |
* clutter_actor_animate(), or #ClutterAnimator, or #ClutterState |
| 35 |
* instead. |
| 36 |
*/ |
| 37 |
|
| 38 |
#ifdef HAVE_CONFIG_H |
| 39 |
#include "config.h" |
| 40 |
#endif |
| 41 |
|
| 42 |
#include <math.h> |
| 43 |
|
| 44 |
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS |
| 45 |
#include "deprecated/clutter-actor.h" |
| 46 |
|
| 47 |
#include "clutter-alpha.h" |
| 48 |
#include "clutter-behaviour.h" |
| 49 |
#include "clutter-behaviour-rotate.h" |
| 50 |
#include "clutter-debug.h" |
| 51 |
#include "clutter-enum-types.h" |
| 52 |
#include "clutter-main.h" |
| 53 |
#include "clutter-private.h" |
| 54 |
|
| 55 |
struct _ClutterBehaviourRotatePrivate |
| 56 |
{ |
| 57 |
gdouble angle_start; |
| 58 |
gdouble angle_end; |
| 59 |
|
| 60 |
ClutterRotateAxis axis; |
| 61 |
ClutterRotateDirection direction; |
| 62 |
|
| 63 |
gint center_x; |
| 64 |
gint center_y; |
| 65 |
gint center_z; |
| 66 |
}; |
| 67 |
|
| 68 |
enum |
| 69 |
{ |
| 70 |
PROP_0, |
| 71 |
|
| 72 |
PROP_ANGLE_START, |
| 73 |
PROP_ANGLE_END, |
| 74 |
PROP_AXIS, |
| 75 |
PROP_DIRECTION, |
| 76 |
PROP_CENTER_X, |
| 77 |
PROP_CENTER_Y, |
| 78 |
PROP_CENTER_Z, |
| 79 |
|
| 80 |
PROP_LAST |
| 81 |
}; |
| 82 |
|
| 83 |
static GParamSpec *obj_props[PROP_LAST]; |
| 84 |
|
| 85 |
G_DEFINE_TYPE_WITH_PRIVATE (ClutterBehaviourRotate, |
| 86 |
clutter_behaviour_rotate, |
| 87 |
CLUTTER_TYPE_BEHAVIOUR) |
| 88 |
|
| 89 |
typedef struct { |
| 90 |
gdouble angle; |
| 91 |
} RotateFrameClosure; |
| 92 |
|
| 93 |
static void |
| 94 |
alpha_notify_foreach (ClutterBehaviour *behaviour, |
| 95 |
ClutterActor *actor, |
| 96 |
gpointer data) |
| 97 |
{ |
| 98 |
RotateFrameClosure *closure = data; |
| 99 |
ClutterBehaviourRotate *rotate_behaviour; |
| 100 |
ClutterBehaviourRotatePrivate *priv; |
| 101 |
|
| 102 |
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour); |
| 103 |
priv = rotate_behaviour->priv; |
| 104 |
|
| 105 |
clutter_actor_set_rotation (actor, priv->axis, |
| 106 |
closure->angle, |
| 107 |
priv->center_x, |
| 108 |
priv->center_y, |
| 109 |
priv->center_z); |
| 110 |
} |
| 111 |
|
| 112 |
static inline float |
| 113 |
clamp_angle (float a) |
| 114 |
{ |
| 115 |
float a1, a2; |
| 116 |
gint rounds; |
| 117 |
|
| 118 |
rounds = a / 360.0; |
| 119 |
a1 = rounds * 360.0; |
| 120 |
a2 = a - a1; |
| 121 |
|
| 122 |
return a2; |
| 123 |
} |
| 124 |
|
| 125 |
static void |
| 126 |
clutter_behaviour_rotate_alpha_notify (ClutterBehaviour *behaviour, |
| 127 |
gdouble alpha_value) |
| 128 |
{ |
| 129 |
ClutterBehaviourRotate *rotate_behaviour; |
| 130 |
ClutterBehaviourRotatePrivate *priv; |
| 131 |
RotateFrameClosure closure; |
| 132 |
gdouble start, end; |
| 133 |
|
| 134 |
rotate_behaviour = CLUTTER_BEHAVIOUR_ROTATE (behaviour); |
| 135 |
priv = rotate_behaviour->priv; |
| 136 |
|
| 137 |
closure.angle = 0; |
| 138 |
start = priv->angle_start; |
| 139 |
end = priv->angle_end; |
| 140 |
|
| 141 |
if (priv->direction == CLUTTER_ROTATE_CW && start >= end) |
| 142 |
end += 360.0; |
| 143 |
else if (priv->direction == CLUTTER_ROTATE_CCW && start <= end) |
| 144 |
end -= 360.0; |
| 145 |
|
| 146 |
closure.angle = (end - start) * alpha_value + start; |
| 147 |
|
| 148 |
clutter_behaviour_actors_foreach (behaviour, |
| 149 |
alpha_notify_foreach, |
| 150 |
&closure); |
| 151 |
} |
| 152 |
|
| 153 |
static void |
| 154 |
clutter_behaviour_rotate_set_property (GObject *gobject, |
| 155 |
guint prop_id, |
| 156 |
const GValue *value, |
| 157 |
GParamSpec *pspec) |
| 158 |
{ |
| 159 |
ClutterBehaviourRotate *rotate; |
| 160 |
ClutterBehaviourRotatePrivate *priv; |
| 161 |
|
| 162 |
rotate = CLUTTER_BEHAVIOUR_ROTATE (gobject); |
| 163 |
priv = rotate->priv; |
| 164 |
|
| 165 |
switch (prop_id) |
| 166 |
{ |
| 167 |
case PROP_ANGLE_START: |
| 168 |
priv->angle_start = g_value_get_double (value); |
| 169 |
break; |
| 170 |
|
| 171 |
case PROP_ANGLE_END: |
| 172 |
priv->angle_end = g_value_get_double (value); |
| 173 |
break; |
| 174 |
|
| 175 |
case PROP_AXIS: |
| 176 |
priv->axis = g_value_get_enum (value); |
| 177 |
break; |
| 178 |
|
| 179 |
case PROP_DIRECTION: |
| 180 |
priv->direction = g_value_get_enum (value); |
| 181 |
break; |
| 182 |
|
| 183 |
case PROP_CENTER_X: |
| 184 |
clutter_behaviour_rotate_set_center (rotate, |
| 185 |
g_value_get_int (value), |
| 186 |
priv->center_y, |
| 187 |
priv->center_z); |
| 188 |
break; |
| 189 |
|
| 190 |
case PROP_CENTER_Y: |
| 191 |
clutter_behaviour_rotate_set_center (rotate, |
| 192 |
priv->center_x, |
| 193 |
g_value_get_int (value), |
| 194 |
priv->center_z); |
| 195 |
break; |
| 196 |
|
| 197 |
case PROP_CENTER_Z: |
| 198 |
clutter_behaviour_rotate_set_center (rotate, |
| 199 |
priv->center_x, |
| 200 |
priv->center_y, |
| 201 |
g_value_get_int (value)); |
| 202 |
break; |
| 203 |
|
| 204 |
default: |
| 205 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 206 |
break; |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
static void |
| 211 |
clutter_behaviour_rotate_get_property (GObject *gobject, |
| 212 |
guint prop_id, |
| 213 |
GValue *value, |
| 214 |
GParamSpec *pspec) |
| 215 |
{ |
| 216 |
ClutterBehaviourRotatePrivate *priv; |
| 217 |
|
| 218 |
priv = CLUTTER_BEHAVIOUR_ROTATE (gobject)->priv; |
| 219 |
|
| 220 |
switch (prop_id) |
| 221 |
{ |
| 222 |
case PROP_ANGLE_START: |
| 223 |
g_value_set_double (value, priv->angle_start); |
| 224 |
break; |
| 225 |
|
| 226 |
case PROP_ANGLE_END: |
| 227 |
g_value_set_double (value, priv->angle_end); |
| 228 |
break; |
| 229 |
|
| 230 |
case PROP_AXIS: |
| 231 |
g_value_set_enum (value, priv->axis); |
| 232 |
break; |
| 233 |
|
| 234 |
case PROP_DIRECTION: |
| 235 |
g_value_set_enum (value, priv->direction); |
| 236 |
break; |
| 237 |
|
| 238 |
case PROP_CENTER_X: |
| 239 |
g_value_set_int (value, priv->center_x); |
| 240 |
break; |
| 241 |
|
| 242 |
case PROP_CENTER_Y: |
| 243 |
g_value_set_int (value, priv->center_y); |
| 244 |
break; |
| 245 |
|
| 246 |
case PROP_CENTER_Z: |
| 247 |
g_value_set_int (value, priv->center_z); |
| 248 |
break; |
| 249 |
|
| 250 |
default: |
| 251 |
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); |
| 252 |
break; |
| 253 |
} |
| 254 |
} |
| 255 |
|
| 256 |
static void |
| 257 |
clutter_behaviour_rotate_class_init (ClutterBehaviourRotateClass *klass) |
| 258 |
{ |
| 259 |
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); |
| 260 |
ClutterBehaviourClass *behaviour_class = CLUTTER_BEHAVIOUR_CLASS (klass); |
| 261 |
GParamSpec *pspec = NULL; |
| 262 |
|
| 263 |
gobject_class->set_property = clutter_behaviour_rotate_set_property; |
| 264 |
gobject_class->get_property = clutter_behaviour_rotate_get_property; |
| 265 |
|
| 266 |
behaviour_class->alpha_notify = clutter_behaviour_rotate_alpha_notify; |
| 267 |
|
| 268 |
/** |
| 269 |
* ClutterBehaviourRotate:angle-start: |
| 270 |
* |
| 271 |
* The initial angle from whence the rotation should start. |
| 272 |
* |
| 273 |
* Since: 0.4 |
| 274 |
*/ |
| 275 |
pspec = g_param_spec_double ("angle-start", |
| 276 |
P_("Angle Begin"), |
| 277 |
P_("Initial angle"), |
| 278 |
0.0, 360.0, |
| 279 |
0.0, |
| 280 |
CLUTTER_PARAM_READWRITE); |
| 281 |
obj_props[PROP_ANGLE_START] = pspec; |
| 282 |
g_object_class_install_property (gobject_class, |
| 283 |
PROP_ANGLE_START, |
| 284 |
pspec); |
| 285 |
|
| 286 |
/** |
| 287 |
* ClutterBehaviourRotate:angle-end: |
| 288 |
* |
| 289 |
* The final angle to where the rotation should end. |
| 290 |
* |
| 291 |
* Since: 0.4 |
| 292 |
*/ |
| 293 |
pspec = g_param_spec_double ("angle-end", |
| 294 |
P_("Angle End"), |
| 295 |
P_("Final angle"), |
| 296 |
0.0, 360.0, |
| 297 |
0.0, |
| 298 |
CLUTTER_PARAM_READWRITE); |
| 299 |
obj_props[PROP_ANGLE_END] = pspec; |
| 300 |
g_object_class_install_property (gobject_class, |
| 301 |
PROP_ANGLE_END, |
| 302 |
pspec); |
| 303 |
|
| 304 |
/** |
| 305 |
* ClutterBehaviourRotate:axis: |
| 306 |
* |
| 307 |
* The axis of rotation. |
| 308 |
* |
| 309 |
* Since: 0.4 |
| 310 |
*/ |
| 311 |
pspec = g_param_spec_enum ("axis", |
| 312 |
P_("Axis"), |
| 313 |
P_("Axis of rotation"), |
| 314 |
CLUTTER_TYPE_ROTATE_AXIS, |
| 315 |
CLUTTER_Z_AXIS, |
| 316 |
CLUTTER_PARAM_READWRITE); |
| 317 |
obj_props[PROP_AXIS] = pspec; |
| 318 |
g_object_class_install_property (gobject_class, |
| 319 |
PROP_AXIS, |
| 320 |
pspec); |
| 321 |
|
| 322 |
/** |
| 323 |
* ClutterBehaviourRotate:direction: |
| 324 |
* |
| 325 |
* The direction of the rotation. |
| 326 |
* |
| 327 |
* Since: 0.4 |
| 328 |
*/ |
| 329 |
pspec = g_param_spec_enum ("direction", |
| 330 |
P_("Direction"), |
| 331 |
P_("Direction of rotation"), |
| 332 |
CLUTTER_TYPE_ROTATE_DIRECTION, |
| 333 |
CLUTTER_ROTATE_CW, |
| 334 |
CLUTTER_PARAM_READWRITE); |
| 335 |
obj_props[PROP_DIRECTION] = pspec; |
| 336 |
g_object_class_install_property (gobject_class, |
| 337 |
PROP_DIRECTION, |
| 338 |
pspec); |
| 339 |
|
| 340 |
/** |
| 341 |
* ClutterBehaviourRotate:center-x: |
| 342 |
* |
| 343 |
* The x center of rotation. |
| 344 |
* |
| 345 |
* Since: 0.4 |
| 346 |
*/ |
| 347 |
pspec = g_param_spec_int ("center-x", |
| 348 |
P_("Center X"), |
| 349 |
P_("X coordinate of the center of rotation"), |
| 350 |
-G_MAXINT, G_MAXINT, |
| 351 |
0, |
| 352 |
CLUTTER_PARAM_READWRITE); |
| 353 |
obj_props[PROP_CENTER_X] = pspec; |
| 354 |
g_object_class_install_property (gobject_class, |
| 355 |
PROP_CENTER_X, |
| 356 |
pspec); |
| 357 |
|
| 358 |
/** |
| 359 |
* ClutterBehaviourRotate:center-y: |
| 360 |
* |
| 361 |
* The y center of rotation. |
| 362 |
* |
| 363 |
* Since: 0.4 |
| 364 |
*/ |
| 365 |
pspec = g_param_spec_int ("center-y", |
| 366 |
P_("Center Y"), |
| 367 |
P_("Y coordinate of the center of rotation"), |
| 368 |
-G_MAXINT, G_MAXINT, |
| 369 |
0, |
| 370 |
CLUTTER_PARAM_READWRITE); |
| 371 |
obj_props[PROP_CENTER_Y] = pspec; |
| 372 |
g_object_class_install_property (gobject_class, |
| 373 |
PROP_CENTER_Y, |
| 374 |
pspec); |
| 375 |
|
| 376 |
/** |
| 377 |
* ClutterBehaviourRotate:center-z: |
| 378 |
* |
| 379 |
* The z center of rotation. |
| 380 |
* |
| 381 |
* Since: 0.4 |
| 382 |
*/ |
| 383 |
pspec = g_param_spec_int ("center-z", |
| 384 |
P_("Center Z"), |
| 385 |
P_("Z coordinate of the center of rotation"), |
| 386 |
-G_MAXINT, G_MAXINT, |
| 387 |
0, |
| 388 |
CLUTTER_PARAM_READWRITE); |
| 389 |
obj_props[PROP_CENTER_Z] = pspec; |
| 390 |
g_object_class_install_property (gobject_class, |
| 391 |
PROP_CENTER_Z, |
| 392 |
pspec); |
| 393 |
} |
| 394 |
|
| 395 |
static void |
| 396 |
clutter_behaviour_rotate_init (ClutterBehaviourRotate *self) |
| 397 |
{ |
| 398 |
self->priv = clutter_behaviour_rotate_get_instance_private (self); |
| 399 |
|
| 400 |
self->priv->angle_start = 0.0; |
| 401 |
self->priv->angle_end = 0.0; |
| 402 |
|
| 403 |
self->priv->axis = CLUTTER_Z_AXIS; |
| 404 |
self->priv->direction = CLUTTER_ROTATE_CW; |
| 405 |
|
| 406 |
self->priv->center_x = 0; |
| 407 |
self->priv->center_y = 0; |
| 408 |
self->priv->center_z = 0; |
| 409 |
} |
| 410 |
|
| 411 |
/** |
| 412 |
* clutter_behaviour_rotate_new: |
| 413 |
* @alpha: (allow-none): a #ClutterAlpha instance, or %NULL |
| 414 |
* @axis: the rotation axis |
| 415 |
* @direction: the rotation direction |
| 416 |
* @angle_start: the starting angle in degrees, between 0 and 360. |
| 417 |
* @angle_end: the final angle in degrees, between 0 and 360. |
| 418 |
* |
| 419 |
* Creates a new #ClutterBehaviourRotate. This behaviour will rotate actors |
| 420 |
* bound to it on @axis, following @direction, between @angle_start and |
| 421 |
* @angle_end. Angles >= 360 degrees will be clamped to the canonical interval |
| 422 |
* <0, 360), if angle_start == angle_end, the behaviour will carry out a |
| 423 |
* single rotation of 360 degrees. |
| 424 |
* |
| 425 |
* If @alpha is not %NULL, the #ClutterBehaviour will take ownership |
| 426 |
* of the #ClutterAlpha instance. In the case when @alpha is %NULL, |
| 427 |
* it can be set later with clutter_behaviour_set_alpha(). |
| 428 |
* |
| 429 |
* Return value: the newly created #ClutterBehaviourRotate. |
| 430 |
* |
| 431 |
* Since: 0.4 |
| 432 |
*/ |
| 433 |
ClutterBehaviour * |
| 434 |
clutter_behaviour_rotate_new (ClutterAlpha *alpha, |
| 435 |
ClutterRotateAxis axis, |
| 436 |
ClutterRotateDirection direction, |
| 437 |
gdouble angle_start, |
| 438 |
gdouble angle_end) |
| 439 |
{ |
| 440 |
g_return_val_if_fail (alpha == NULL || CLUTTER_IS_ALPHA (alpha), NULL); |
| 441 |
|
| 442 |
return g_object_new (CLUTTER_TYPE_BEHAVIOUR_ROTATE, |
| 443 |
"alpha", alpha, |
| 444 |
"axis", axis, |
| 445 |
"direction", direction, |
| 446 |
"angle-start", angle_start, |
| 447 |
"angle-end", angle_end, |
| 448 |
NULL); |
| 449 |
} |
| 450 |
|
| 451 |
/** |
| 452 |
* clutter_behaviour_rotate_get_axis: |
| 453 |
* @rotate: a #ClutterBehaviourRotate |
| 454 |
* |
| 455 |
* Retrieves the #ClutterRotateAxis used by the rotate behaviour. |
| 456 |
* |
| 457 |
* Return value: the rotation axis |
| 458 |
* |
| 459 |
* Since: 0.4 |
| 460 |
*/ |
| 461 |
ClutterRotateAxis |
| 462 |
clutter_behaviour_rotate_get_axis (ClutterBehaviourRotate *rotate) |
| 463 |
{ |
| 464 |
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate), CLUTTER_Z_AXIS); |
| 465 |
|
| 466 |
return rotate->priv->axis; |
| 467 |
} |
| 468 |
|
| 469 |
/** |
| 470 |
* clutter_behaviour_rotate_set_axis: |
| 471 |
* @rotate: a #ClutterBehaviourRotate |
| 472 |
* @axis: a #ClutterRotateAxis |
| 473 |
* |
| 474 |
* Sets the axis used by the rotate behaviour. |
| 475 |
* |
| 476 |
* Since: 0.4 |
| 477 |
*/ |
| 478 |
void |
| 479 |
clutter_behaviour_rotate_set_axis (ClutterBehaviourRotate *rotate, |
| 480 |
ClutterRotateAxis axis) |
| 481 |
{ |
| 482 |
ClutterBehaviourRotatePrivate *priv; |
| 483 |
|
| 484 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 485 |
|
| 486 |
priv = rotate->priv; |
| 487 |
|
| 488 |
if (priv->axis != axis) |
| 489 |
{ |
| 490 |
priv->axis = axis; |
| 491 |
|
| 492 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_AXIS]); |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
/** |
| 497 |
* clutter_behaviour_rotate_get_direction: |
| 498 |
* @rotate: a #ClutterBehaviourRotate |
| 499 |
* |
| 500 |
* Retrieves the #ClutterRotateDirection used by the rotate behaviour. |
| 501 |
* |
| 502 |
* Return value: the rotation direction |
| 503 |
* |
| 504 |
* Since: 0.4 |
| 505 |
*/ |
| 506 |
ClutterRotateDirection |
| 507 |
clutter_behaviour_rotate_get_direction (ClutterBehaviourRotate *rotate) |
| 508 |
{ |
| 509 |
g_return_val_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate), |
| 510 |
CLUTTER_ROTATE_CW); |
| 511 |
|
| 512 |
return rotate->priv->direction; |
| 513 |
} |
| 514 |
|
| 515 |
/** |
| 516 |
* clutter_behaviour_rotate_set_direction: |
| 517 |
* @rotate: a #ClutterBehaviourRotate |
| 518 |
* @direction: the rotation direction |
| 519 |
* |
| 520 |
* Sets the rotation direction used by the rotate behaviour. |
| 521 |
* |
| 522 |
* Since: 0.4 |
| 523 |
*/ |
| 524 |
void |
| 525 |
clutter_behaviour_rotate_set_direction (ClutterBehaviourRotate *rotate, |
| 526 |
ClutterRotateDirection direction) |
| 527 |
{ |
| 528 |
ClutterBehaviourRotatePrivate *priv; |
| 529 |
|
| 530 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 531 |
|
| 532 |
priv = rotate->priv; |
| 533 |
|
| 534 |
if (priv->direction != direction) |
| 535 |
{ |
| 536 |
priv->direction = direction; |
| 537 |
|
| 538 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_DIRECTION]); |
| 539 |
} |
| 540 |
} |
| 541 |
|
| 542 |
/** |
| 543 |
* clutter_behaviour_rotate_get_bounds: |
| 544 |
* @rotate: a #ClutterBehaviourRotate |
| 545 |
* @angle_start: (out): return value for the initial angle |
| 546 |
* @angle_end: (out): return value for the final angle |
| 547 |
* |
| 548 |
* Retrieves the rotation boundaries of the rotate behaviour. |
| 549 |
* |
| 550 |
* Since: 0.4 |
| 551 |
*/ |
| 552 |
void |
| 553 |
clutter_behaviour_rotate_get_bounds (ClutterBehaviourRotate *rotate, |
| 554 |
gdouble *angle_start, |
| 555 |
gdouble *angle_end) |
| 556 |
{ |
| 557 |
ClutterBehaviourRotatePrivate *priv; |
| 558 |
|
| 559 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 560 |
|
| 561 |
priv = rotate->priv; |
| 562 |
|
| 563 |
if (angle_start) |
| 564 |
*angle_start = priv->angle_start; |
| 565 |
|
| 566 |
if (angle_end) |
| 567 |
*angle_end = priv->angle_end; |
| 568 |
} |
| 569 |
|
| 570 |
/** |
| 571 |
* clutter_behaviour_rotate_set_bounds: |
| 572 |
* @rotate: a #ClutterBehaviourRotate |
| 573 |
* @angle_start: initial angle in degrees, between 0 and 360. |
| 574 |
* @angle_end: final angle in degrees, between 0 and 360. |
| 575 |
* |
| 576 |
* Sets the initial and final angles of a rotation behaviour; angles >= 360 |
| 577 |
* degrees get clamped to the canonical interval <0, 360). |
| 578 |
* |
| 579 |
* Since: 0.4 |
| 580 |
*/ |
| 581 |
void |
| 582 |
clutter_behaviour_rotate_set_bounds (ClutterBehaviourRotate *rotate, |
| 583 |
gdouble angle_start, |
| 584 |
gdouble angle_end) |
| 585 |
{ |
| 586 |
ClutterBehaviourRotatePrivate *priv; |
| 587 |
|
| 588 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 589 |
|
| 590 |
priv = rotate->priv; |
| 591 |
|
| 592 |
g_object_freeze_notify (G_OBJECT (rotate)); |
| 593 |
|
| 594 |
if (priv->angle_start != angle_start) |
| 595 |
{ |
| 596 |
priv->angle_start = clamp_angle (angle_start); |
| 597 |
|
| 598 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_ANGLE_START]); |
| 599 |
} |
| 600 |
|
| 601 |
if (priv->angle_end != angle_end) |
| 602 |
{ |
| 603 |
priv->angle_end = clamp_angle (angle_end); |
| 604 |
|
| 605 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_ANGLE_END]); |
| 606 |
} |
| 607 |
|
| 608 |
g_object_thaw_notify (G_OBJECT (rotate)); |
| 609 |
} |
| 610 |
|
| 611 |
/** |
| 612 |
* clutter_behaviour_rotate_set_center: |
| 613 |
* @rotate: a #ClutterBehaviourRotate |
| 614 |
* @x: X axis center of rotation |
| 615 |
* @y: Y axis center of rotation |
| 616 |
* @z: Z axis center of rotation |
| 617 |
* |
| 618 |
* Sets the center of rotation. The coordinates are relative to the plane |
| 619 |
* normal to the rotation axis set with clutter_behaviour_rotate_set_axis(). |
| 620 |
* |
| 621 |
* Since: 0.4 |
| 622 |
*/ |
| 623 |
void |
| 624 |
clutter_behaviour_rotate_set_center (ClutterBehaviourRotate *rotate, |
| 625 |
gint x, |
| 626 |
gint y, |
| 627 |
gint z) |
| 628 |
{ |
| 629 |
ClutterBehaviourRotatePrivate *priv; |
| 630 |
|
| 631 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 632 |
|
| 633 |
priv = rotate->priv; |
| 634 |
|
| 635 |
g_object_freeze_notify (G_OBJECT (rotate)); |
| 636 |
|
| 637 |
if (priv->center_x != x) |
| 638 |
{ |
| 639 |
priv->center_x = x; |
| 640 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_X]); |
| 641 |
} |
| 642 |
|
| 643 |
if (priv->center_y != y) |
| 644 |
{ |
| 645 |
priv->center_y = y; |
| 646 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_Y]); |
| 647 |
} |
| 648 |
|
| 649 |
if (priv->center_z != z) |
| 650 |
{ |
| 651 |
priv->center_z = z; |
| 652 |
g_object_notify_by_pspec (G_OBJECT (rotate), obj_props[PROP_CENTER_Z]); |
| 653 |
} |
| 654 |
|
| 655 |
g_object_thaw_notify (G_OBJECT (rotate)); |
| 656 |
} |
| 657 |
|
| 658 |
/** |
| 659 |
* clutter_behaviour_rotate_get_center: |
| 660 |
* @rotate: a #ClutterBehaviourRotate |
| 661 |
* @x: (out): return location for the X center of rotation |
| 662 |
* @y: (out): return location for the Y center of rotation |
| 663 |
* @z: (out): return location for the Z center of rotation |
| 664 |
* |
| 665 |
* Retrieves the center of rotation set using |
| 666 |
* clutter_behaviour_rotate_set_center(). |
| 667 |
* |
| 668 |
* Since: 0.4 |
| 669 |
*/ |
| 670 |
void |
| 671 |
clutter_behaviour_rotate_get_center (ClutterBehaviourRotate *rotate, |
| 672 |
gint *x, |
| 673 |
gint *y, |
| 674 |
gint *z) |
| 675 |
{ |
| 676 |
ClutterBehaviourRotatePrivate *priv; |
| 677 |
|
| 678 |
g_return_if_fail (CLUTTER_IS_BEHAVIOUR_ROTATE (rotate)); |
| 679 |
|
| 680 |
priv = rotate->priv; |
| 681 |
|
| 682 |
if (x) |
| 683 |
*x = priv->center_x; |
| 684 |
|
| 685 |
if (y) |
| 686 |
*y = priv->center_y; |
| 687 |
|
| 688 |
if (z) |
| 689 |
*z = priv->center_z; |
| 690 |
} |