mutter/clutter/clutter-actor-private.h

302 lines
11 KiB
C
Raw Normal View History

2010-10-21 08:13:00 -04:00
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* 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
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CLUTTER_ACTOR_PRIVATE_H__
#define __CLUTTER_ACTOR_PRIVATE_H__
#include <clutter/clutter-actor.h>
G_BEGIN_DECLS
2010-12-09 10:06:12 -05:00
/*< private >
* ClutterRedrawFlags:
* @CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION: Tells clutter the maximum
* extents of what needs to be redrawn lies within the actors
* current allocation. (Only use this for 2D actors though because
* any actor with depth may be projected outside of its allocation)
*
* Flags passed to the clutter_actor_queue_redraw_with_clip ()
* function
*
* Since: 1.6
*/
typedef enum
{
CLUTTER_REDRAW_CLIPPED_TO_ALLOCATION = 1 << 0
} ClutterRedrawFlags;
2010-12-09 10:06:12 -05:00
/*< private >
* ClutterActorTraverseFlags:
* CLUTTER_ACTOR_TRAVERSE_DEPTH_FIRST: Traverse the graph in
* a depth first order.
* CLUTTER_ACTOR_TRAVERSE_BREADTH_FIRST: Traverse the graph in a
* breadth first order.
*
* Controls some options for how clutter_actor_traverse() iterates
* through the graph.
*/
typedef enum {
CLUTTER_ACTOR_TRAVERSE_DEPTH_FIRST = 1L<<0,
CLUTTER_ACTOR_TRAVERSE_BREADTH_FIRST = 1L<<1
} ClutterActorTraverseFlags;
2010-12-09 10:06:12 -05:00
/*< private >
* ClutterActorTraverseVisitFlags:
* CLUTTER_ACTOR_TRAVERSE_VISIT_CONTINUE: Continue traversing as
* normal
* CLUTTER_ACTOR_TRAVERSE_VISIT_SKIP_CHILDREN: Don't traverse the
* children of the last visited actor. (Not applicable when using
2010-12-09 10:06:12 -05:00
* %CLUTTER_ACTOR_TRAVERSE_DEPTH_FIRST_POST_ORDER since the children
* are visited before having an opportunity to bail out)
* CLUTTER_ACTOR_TRAVERSE_VISIT_BREAK: Immediately bail out without
* visiting any more actors.
*
* Each time an actor is visited during a scenegraph traversal the
* ClutterTraverseCallback can return a set of flags that may affect
* the continuing traversal. It may stop traversal completely, just
* skip over children for the current actor or continue as normal.
*/
typedef enum {
CLUTTER_ACTOR_TRAVERSE_VISIT_CONTINUE = 1L<<0,
CLUTTER_ACTOR_TRAVERSE_VISIT_SKIP_CHILDREN = 1L<<1,
CLUTTER_ACTOR_TRAVERSE_VISIT_BREAK = 1L<<2
} ClutterActorTraverseVisitFlags;
2010-12-09 10:06:12 -05:00
/*< private >
* ClutterTraverseCallback:
*
* The callback prototype used with clutter_actor_traverse. The
* returned flags can be used to affect the continuing traversal
* either by continuing as normal, skipping over children of an
* actor or bailing out completely.
*/
typedef ClutterActorTraverseVisitFlags (*ClutterTraverseCallback) (ClutterActor *actor,
2010-12-09 10:06:12 -05:00
gint depth,
gpointer user_data);
2010-12-09 10:06:12 -05:00
/*< private >
* ClutterForeachCallback:
* @actor: The actor being iterated
* @user_data: The private data specified when starting the iteration
*
* A generic callback for iterating over actor, such as with
* _clutter_actor_foreach_child. The difference when compared to
* #ClutterCallback is that it returns a boolean so it is possible to break
* out of an iteration early.
*
* Return value: %TRUE to continue iterating or %FALSE to break iteration
* early.
*/
typedef gboolean (*ClutterForeachCallback) (ClutterActor *actor,
2010-12-09 10:06:12 -05:00
gpointer user_data);
typedef struct _AnchorCoord AnchorCoord;
typedef struct _SizeRequest SizeRequest;
typedef struct _ClutterLayoutInfo ClutterLayoutInfo;
typedef struct _ClutterTransformInfo ClutterTransformInfo;
actor: Implement implicit animatable properties Clutter is meant to be, and I quote from the README, a toolkit: for creating fast, compelling, portable, and dynamic graphical user interfaces and yet the default mode of operation for setting an actor's state on the scene graph (position, size, opacity, rotation, scaling, depth, etc.) is *not* dynamic. We assume a static UI, and then animate it. This is the wrong way to design an API for a toolkit meant to be used to create animated user interfaces. The default mode of operation should be to implicitly animate every state transition, and only allow skipping the animation if the user consciously decides to do so — i.e. the design tenet of the API should be to make The Right Thing™ by default, and make it really hard (or even impossible) to do The Wrong Thing™. So we should identify "animatable" properties, i.e. those properties that should be implicitly animated by ClutterActor, and use the animation framework we provide to tween the transitions between the current state and the desired state; the implicit animation should happen when setting these properties using the public accessors, and not through some added functionality. For instance, the following: clutter_actor_set_position (actor, newX, newY); should not make the actor jump to the (newX, newY) point; it should tween the actor's position between the current point and the desired point. Since we have to maintain backward compatibility with existing applications, we still need to mark the transitions explicitly, but we can be smart about it, and treat transition states as a stack that can be pushed and popped, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_restore_easing_state (actor); And we can even start stacking animations, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_set_depth (actor, newDepth); clutter_actor_restore_easing_state (actor); clutter_actor_restore_easing_state (actor); And so on, and so forth. The implementation takes advantage of the newly added Transition API, which uses only ClutterTimeline sub-classes and ClutterInterval, to cut down the amount of signal emissions and memory management of object instances; as well of using the ClutterAnimatable interface for custom properties and interpolation of values.
2012-03-15 07:09:11 -04:00
typedef struct _ClutterAnimationInfo ClutterAnimationInfo;
/* Internal helper struct to represent a point that can be stored in
either direct pixel coordinates or as a fraction of the actor's
size. It is used for the anchor point, scale center and rotation
centers. */
struct _AnchorCoord
{
gboolean is_fractional;
union
{
/* Used when is_fractional == TRUE */
struct
{
gdouble x;
gdouble y;
} fraction;
/* Use when is_fractional == FALSE */
ClutterVertex units;
} v;
};
struct _SizeRequest
{
guint age;
gfloat for_size;
gfloat min_size;
gfloat natural_size;
};
/*< private >
* ClutterLayoutInfo:
* @fixed_x: the fixed position of the actor, set using clutter_actor_set_x()
* @fixed_y: the fixed position of the actor, set using clutter_actor_set_y()
* @margin: the composed margin of the actor
* @x_align: the horizontal alignment, if the actor expands horizontally
* @y_align: the vertical alignment, if the actor expands vertically
* @min_width: the minimum width, set using clutter_actor_set_min_width()
* @min_height: the minimum height, set using clutter_actor_set_min_height()
* @natural_width: the natural width, set using clutter_actor_set_natural_width()
* @natural_height: the natural height, set using clutter_actor_set_natural_height()
*
* Ancillary layout information for an actor.
*/
struct _ClutterLayoutInfo
{
/* fixed position coordinates */
float fixed_x;
float fixed_y;
ClutterMargin margin;
guint x_align : 4;
guint y_align : 4;
float min_width;
float min_height;
float natural_width;
float natural_height;
};
const ClutterLayoutInfo * _clutter_actor_get_layout_info_or_defaults (ClutterActor *self);
ClutterLayoutInfo * _clutter_actor_get_layout_info (ClutterActor *self);
struct _ClutterTransformInfo
{
/* rotation (angle and center) */
gdouble rx_angle;
AnchorCoord rx_center;
gdouble ry_angle;
AnchorCoord ry_center;
gdouble rz_angle;
AnchorCoord rz_center;
/* scaling */
gdouble scale_x;
gdouble scale_y;
AnchorCoord scale_center;
/* anchor point */
AnchorCoord anchor;
actor: Implement implicit animatable properties Clutter is meant to be, and I quote from the README, a toolkit: for creating fast, compelling, portable, and dynamic graphical user interfaces and yet the default mode of operation for setting an actor's state on the scene graph (position, size, opacity, rotation, scaling, depth, etc.) is *not* dynamic. We assume a static UI, and then animate it. This is the wrong way to design an API for a toolkit meant to be used to create animated user interfaces. The default mode of operation should be to implicitly animate every state transition, and only allow skipping the animation if the user consciously decides to do so — i.e. the design tenet of the API should be to make The Right Thing™ by default, and make it really hard (or even impossible) to do The Wrong Thing™. So we should identify "animatable" properties, i.e. those properties that should be implicitly animated by ClutterActor, and use the animation framework we provide to tween the transitions between the current state and the desired state; the implicit animation should happen when setting these properties using the public accessors, and not through some added functionality. For instance, the following: clutter_actor_set_position (actor, newX, newY); should not make the actor jump to the (newX, newY) point; it should tween the actor's position between the current point and the desired point. Since we have to maintain backward compatibility with existing applications, we still need to mark the transitions explicitly, but we can be smart about it, and treat transition states as a stack that can be pushed and popped, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_restore_easing_state (actor); And we can even start stacking animations, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_set_depth (actor, newDepth); clutter_actor_restore_easing_state (actor); clutter_actor_restore_easing_state (actor); And so on, and so forth. The implementation takes advantage of the newly added Transition API, which uses only ClutterTimeline sub-classes and ClutterInterval, to cut down the amount of signal emissions and memory management of object instances; as well of using the ClutterAnimatable interface for custom properties and interpolation of values.
2012-03-15 07:09:11 -04:00
/* depth */
gfloat depth;
};
const ClutterTransformInfo * _clutter_actor_get_transform_info_or_defaults (ClutterActor *self);
ClutterTransformInfo * _clutter_actor_get_transform_info (ClutterActor *self);
actor: Implement implicit animatable properties Clutter is meant to be, and I quote from the README, a toolkit: for creating fast, compelling, portable, and dynamic graphical user interfaces and yet the default mode of operation for setting an actor's state on the scene graph (position, size, opacity, rotation, scaling, depth, etc.) is *not* dynamic. We assume a static UI, and then animate it. This is the wrong way to design an API for a toolkit meant to be used to create animated user interfaces. The default mode of operation should be to implicitly animate every state transition, and only allow skipping the animation if the user consciously decides to do so — i.e. the design tenet of the API should be to make The Right Thing™ by default, and make it really hard (or even impossible) to do The Wrong Thing™. So we should identify "animatable" properties, i.e. those properties that should be implicitly animated by ClutterActor, and use the animation framework we provide to tween the transitions between the current state and the desired state; the implicit animation should happen when setting these properties using the public accessors, and not through some added functionality. For instance, the following: clutter_actor_set_position (actor, newX, newY); should not make the actor jump to the (newX, newY) point; it should tween the actor's position between the current point and the desired point. Since we have to maintain backward compatibility with existing applications, we still need to mark the transitions explicitly, but we can be smart about it, and treat transition states as a stack that can be pushed and popped, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_restore_easing_state (actor); And we can even start stacking animations, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_set_depth (actor, newDepth); clutter_actor_restore_easing_state (actor); clutter_actor_restore_easing_state (actor); And so on, and so forth. The implementation takes advantage of the newly added Transition API, which uses only ClutterTimeline sub-classes and ClutterInterval, to cut down the amount of signal emissions and memory management of object instances; as well of using the ClutterAnimatable interface for custom properties and interpolation of values.
2012-03-15 07:09:11 -04:00
typedef struct _AState {
guint easing_duration;
guint easing_delay;
actor: Implement implicit animatable properties Clutter is meant to be, and I quote from the README, a toolkit: for creating fast, compelling, portable, and dynamic graphical user interfaces and yet the default mode of operation for setting an actor's state on the scene graph (position, size, opacity, rotation, scaling, depth, etc.) is *not* dynamic. We assume a static UI, and then animate it. This is the wrong way to design an API for a toolkit meant to be used to create animated user interfaces. The default mode of operation should be to implicitly animate every state transition, and only allow skipping the animation if the user consciously decides to do so — i.e. the design tenet of the API should be to make The Right Thing™ by default, and make it really hard (or even impossible) to do The Wrong Thing™. So we should identify "animatable" properties, i.e. those properties that should be implicitly animated by ClutterActor, and use the animation framework we provide to tween the transitions between the current state and the desired state; the implicit animation should happen when setting these properties using the public accessors, and not through some added functionality. For instance, the following: clutter_actor_set_position (actor, newX, newY); should not make the actor jump to the (newX, newY) point; it should tween the actor's position between the current point and the desired point. Since we have to maintain backward compatibility with existing applications, we still need to mark the transitions explicitly, but we can be smart about it, and treat transition states as a stack that can be pushed and popped, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_restore_easing_state (actor); And we can even start stacking animations, e.g.: clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_position (actor, newX, newY); clutter_actor_save_easing_state (actor); clutter_actor_set_easing_duration (actor, 500); clutter_actor_set_easing_mode (actor, CLUTTER_LINEAR); clutter_actor_set_opacity (actor, newOpacity); clutter_actor_set_depth (actor, newDepth); clutter_actor_restore_easing_state (actor); clutter_actor_restore_easing_state (actor); And so on, and so forth. The implementation takes advantage of the newly added Transition API, which uses only ClutterTimeline sub-classes and ClutterInterval, to cut down the amount of signal emissions and memory management of object instances; as well of using the ClutterAnimatable interface for custom properties and interpolation of values.
2012-03-15 07:09:11 -04:00
ClutterAnimationMode easing_mode;
} AState;
struct _ClutterAnimationInfo
{
GArray *states;
AState *cur_state;
GHashTable *transitions;
};
const ClutterAnimationInfo * _clutter_actor_get_animation_info_or_defaults (ClutterActor *self);
ClutterAnimationInfo * _clutter_actor_get_animation_info (ClutterActor *self);
ClutterTransition * _clutter_actor_create_transition (ClutterActor *self,
GParamSpec *pspec,
...);
ClutterTransition * _clutter_actor_get_transition (ClutterActor *self,
GParamSpec *pspec);
void _clutter_actor_update_transition (ClutterActor *self,
GParamSpec *pspec,
...);
gboolean _clutter_actor_foreach_child (ClutterActor *self,
ClutterForeachCallback callback,
2010-12-09 10:06:12 -05:00
gpointer user_data);
void _clutter_actor_traverse (ClutterActor *actor,
ClutterActorTraverseFlags flags,
ClutterTraverseCallback before_children_callback,
ClutterTraverseCallback after_children_callback,
2010-12-09 10:06:12 -05:00
gpointer user_data);
ClutterActor *_clutter_actor_get_stage_internal (ClutterActor *actor);
void _clutter_actor_apply_modelview_transform (ClutterActor *self,
CoglMatrix *matrix);
void _clutter_actor_apply_relative_transformation_matrix (ClutterActor *self,
ClutterActor *ancestor,
CoglMatrix *matrix);
2010-12-09 10:06:12 -05:00
void _clutter_actor_rerealize (ClutterActor *self,
ClutterCallback callback,
gpointer data);
void _clutter_actor_set_opacity_override (ClutterActor *self,
gint opacity);
gint _clutter_actor_get_opacity_override (ClutterActor *self);
void _clutter_actor_set_in_clone_paint (ClutterActor *self,
gboolean is_in_clone_paint);
void _clutter_actor_set_enable_model_view_transform (ClutterActor *self,
gboolean enable);
void _clutter_actor_set_enable_paint_unmapped (ClutterActor *self,
gboolean enable);
void _clutter_actor_set_has_pointer (ClutterActor *self,
gboolean has_pointer);
void _clutter_actor_queue_redraw_with_clip (ClutterActor *self,
ClutterRedrawFlags flags,
ClutterPaintVolume *clip_volume);
void _clutter_actor_queue_redraw_full (ClutterActor *self,
ClutterRedrawFlags flags,
ClutterPaintVolume *volume,
ClutterEffect *effect);
ClutterPaintVolume *_clutter_actor_get_queue_redraw_clip (ClutterActor *self);
void _clutter_actor_set_queue_redraw_clip (ClutterActor *self,
ClutterPaintVolume *clip_volume);
void _clutter_actor_finish_queue_redraw (ClutterActor *self,
ClutterPaintVolume *clip);
gboolean _clutter_actor_set_default_paint_volume (ClutterActor *self,
GType check_gtype,
ClutterPaintVolume *volume);
const gchar * _clutter_actor_get_debug_name (ClutterActor *self);
void _clutter_actor_push_clone_paint (void);
void _clutter_actor_pop_clone_paint (void);
guint32 _clutter_actor_get_pick_id (ClutterActor *self);
void _clutter_actor_shader_pre_paint (ClutterActor *actor,
gboolean repeat);
void _clutter_actor_shader_post_paint (ClutterActor *actor);
G_END_DECLS
#endif /* __CLUTTER_ACTOR_PRIVATE_H__ */