Compare commits

...

5 Commits

Author SHA1 Message Date
Emmanuele Bassi 7f2df858c7 Snapshot/WIP 2012-03-21 17:55:26 +00:00
Emmanuele Bassi 85674cedf4 Add ClutterTransitionGroup
The TransitionGroup class is a logical container for running multiple
transitions.

TransitionGroup is not a Score: it is a Transition that advances each
Transition it contains using the delta between frames. This means that
a TransitionGroup is essentially a small "master clock" that fully
drives all transitions.
2012-03-21 17:43:49 +00:00
Emmanuele Bassi ff621b9f4e timeline: Add an internal function for advancing a timeline
There are cases when we want to advance a timeline from another time
source. We cannot use _clutter_timeline_do_tick() directly, as that
assumes that the timeline is already playing, so we'll need to create a
wrapper that toggles the playing flag around it.
2012-03-21 16:21:08 +00:00
Emmanuele Bassi 7ab24f39d2 osx: Fix compilation warnings
https://bugzilla.gnome.org/show_bug.cgi?id=672536
2012-03-21 14:01:31 +00:00
Emmanuele Bassi a997782969 Fix fallback profile counter macro 2012-03-21 14:01:11 +00:00
15 changed files with 487 additions and 16 deletions

View File

@ -93,6 +93,7 @@ source_h = \
$(srcdir)/clutter-image.h \
$(srcdir)/clutter-input-device.h \
$(srcdir)/clutter-interval.h \
$(srcdir)/clutter-keyframe-transition.h \
$(srcdir)/clutter-keysyms.h \
$(srcdir)/clutter-layout-manager.h \
$(srcdir)/clutter-layout-meta.h \
@ -123,6 +124,7 @@ source_h = \
$(srcdir)/clutter-text.h \
$(srcdir)/clutter-text-buffer.h \
$(srcdir)/clutter-timeline.h \
$(srcdir)/clutter-transition-group.h \
$(srcdir)/clutter-transition.h \
$(srcdir)/clutter-types.h \
$(srcdir)/clutter-units.h \
@ -171,6 +173,7 @@ source_c = \
$(srcdir)/clutter-image.c \
$(srcdir)/clutter-input-device.c \
$(srcdir)/clutter-interval.c \
$(srcdir)/clutter-keyframe-transition.c \
$(srcdir)/clutter-keysyms-table.c \
$(srcdir)/clutter-layout-manager.c \
$(srcdir)/clutter-layout-meta.c \
@ -202,6 +205,7 @@ source_c = \
$(srcdir)/clutter-texture.c \
$(srcdir)/clutter-text.c \
$(srcdir)/clutter-text-buffer.c \
$(srcdir)/clutter-transition-group.c \
$(srcdir)/clutter-transition.c \
$(srcdir)/clutter-timeline.c \
$(srcdir)/clutter-units.c \

View File

@ -0,0 +1,16 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "clutter-keyframe-transition.h"
typedef struct _KeyFrame
{
double key;
GValue value;
} KeyFrame;
struct _ClutterKeyframeTransitionPrivate
{
GArray *frames;
};

View File

@ -0,0 +1,59 @@
#ifndef __CLUTTER_KEYFRAME_TRANSITION_H__
#define __CLUTTER_KEYFRAME_TRANSITION_H__
#include <clutter/clutter-types.h>
#include <clutter/clutter-property-transition.h>
G_BEGIN_DECLS
typedef struct _ClutterKeyframeTransitionPrivate ClutterKeyframeTransitionPrivate;
typedef struct _ClutterKeyframeTransitionClass ClutterKeyframeTransitionClass;
/**
* ClutterKeyframeTransition:
*
* FIXME
*
* Since: 1.12
*/
struct _ClutterKeyframeTransition
{
/*< private >*/
ClutterPropertyTransition parent_instance;
ClutterKeyframeTransitionPrivate *priv;
};
/**
* ClutterKeyframeTransitionClass:
*
* FIXME
*
* Since: 1.12
*/
struct _ClutterKeyframeTransitionClass
{
/*< private >*/
ClutterPropertyTransitionClass parent_class;
gpointer _padding[8];
};
GType clutter_keyframe_transition_get_type (void) G_GNUC_CONST;
ClutterTransition * clutter_keyframe_transition_new (const char *property_name);
void clutter_keyframe_transition_set_key_frames (ClutterKeyframeTransition *transition,
guint n_key_frames,
const double *key_frames);
void clutter_keyframe_transition_set_values (ClutterKeyframeTransition *transition,
guint n_values,
const GValue *values);
void clutter_keyframe_transition_set (ClutterKeyframeTransition *transition,
GType gtype,
guint n_values,
...);
G_END_DECLS
#endif /* __CLUTTER_KEYFRAME_TRANSITION_H__ */

View File

@ -44,6 +44,9 @@ void _clutter_master_clock_remove_timeline (Clutter
void _clutter_master_clock_start_running (ClutterMasterClock *master_clock);
void _clutter_master_clock_ensure_next_iteration (ClutterMasterClock *master_clock);
void _clutter_timeline_advance (ClutterTimeline *timeline,
gint64 tick_time);
gint64 _clutter_timeline_get_delta (ClutterTimeline *timeline);
void _clutter_timeline_do_tick (ClutterTimeline *timeline,
gint64 tick_time);

View File

@ -56,7 +56,7 @@ void _clutter_profile_resume (void);
#define CLUTTER_STATIC_COUNTER(A,B,C,D) extern void G_PASTE (_clutter_dummy_decl, __COUNTER__) (void)
#else
#define CLUTTER_STATIC_TIMER(A,B,C,D,E) extern void G_PASTE (_clutter_dummy_decl, __LINE__) (void)
#define CLUTTER_STATIC_TIMER(A,B,C,D,E) extern void G_PASTE (_clutter_dummy_decl, __LINE__) (void)
#define CLUTTER_STATIC_COUNTER(A,B,C,D) extern void G_PASTE (_clutter_dummy_decl, __LINE__) (void)
#endif
#define CLUTTER_COUNTER_INC(A,B) G_STMT_START { } G_STMT_END
#define CLUTTER_COUNTER_DEC(A,B) G_STMT_START { } G_STMT_END

View File

@ -1577,7 +1577,22 @@ clutter_timeline_get_delta (ClutterTimeline *timeline)
return timeline->priv->msecs_delta;
}
/*
void
_clutter_timeline_advance (ClutterTimeline *timeline,
gint64 tick_time)
{
g_object_ref (timeline);
timeline->priv->is_playing = TRUE;
_clutter_timeline_do_tick (timeline, tick_time);
timeline->priv->is_playing = FALSE;
g_object_unref (timeline);
}
/*< private >
* clutter_timeline_do_tick
* @timeline: a #ClutterTimeline
* @tick_time: time of advance
@ -1593,8 +1608,6 @@ _clutter_timeline_do_tick (ClutterTimeline *timeline,
{
ClutterTimelinePrivate *priv;
g_return_if_fail (CLUTTER_IS_TIMELINE (timeline));
priv = timeline->priv;
/* Check the is_playing variable before performing the timeline tick.

View File

@ -0,0 +1,225 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2012 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/>.
*
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
*/
/**
* SECTION:clutter-transition-group
* @Title: ClutterTransitionGroup
* @Short_Description: Group transitions together
*
* The #ClutterTransitionGroup allows running multiple #ClutterTransition
* instances concurrently.
*
* The transitions inside a group will run within the boundaries of the
* group; for instance, if a transition has a duration of 10 seconds, and
* the group that contains it has a duration of 5 seconds, only the first
* 5 seconds of the transition will be played.
*
* #ClutterTransitionGroup is available since Clutter 1.12
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "clutter-transition-group.h"
#include "clutter-debug.h"
#include "clutter-private.h"
struct _ClutterTransitionGroupPrivate
{
GPtrArray *transitions;
};
static GQuark quark_transition_group = 0;
G_DEFINE_TYPE (ClutterTransitionGroup, clutter_transition_group, CLUTTER_TYPE_TRANSITION)
static void
clutter_transition_group_new_frame (ClutterTimeline *timeline,
gint elapsed)
{
ClutterTransitionGroupPrivate *priv;
gint64 msecs;
guint i;
priv = CLUTTER_TRANSITION_GROUP (timeline)->priv;
/* get the time elapsed since the last ::new-frame... */
msecs = clutter_timeline_get_delta (timeline);
for (i = 0; i < priv->transitions->len; i++)
{
ClutterTimeline *t = g_ptr_array_index (priv->transitions, i);
/* ... and advance every timeline */
_clutter_timeline_advance (t, msecs);
}
}
static void
clutter_transition_group_finalize (GObject *gobject)
{
ClutterTransitionGroupPrivate *priv;
priv = CLUTTER_TRANSITION_GROUP (gobject)->priv;
g_ptr_array_unref (priv->transitions);
G_OBJECT_CLASS (clutter_transition_group_parent_class)->finalize (gobject);
}
static void
clutter_transition_group_class_init (ClutterTransitionGroupClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
ClutterTimelineClass *timeline_class = CLUTTER_TIMELINE_CLASS (klass);
quark_transition_group = g_quark_from_static_string ("-clutter-transition-group");
gobject_class->finalize = clutter_transition_group_finalize;
timeline_class->new_frame = clutter_transition_group_new_frame;
}
static void
clutter_transition_group_init (ClutterTransitionGroup *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
CLUTTER_TYPE_TRANSITION_GROUP,
ClutterTransitionGroupPrivate);
self->priv->transitions = g_ptr_array_new ();
g_ptr_array_set_free_func (self->priv->transitions, g_object_unref);
}
/**
* clutter_transition_group_new:
*
* Creates a new #ClutterTransitionGroup instance.
*
* Return value: the newly created #ClutterTransitionGroup. Use
* g_object_unref() when done to deallocate the resources it
* uses
*
* Since: 1.12
*/
ClutterTransition *
clutter_transition_group_new (void)
{
return g_object_new (CLUTTER_TYPE_TRANSITION_GROUP, NULL);
}
/**
* clutter_transition_group_add_transition:
* @group: a #ClutterTransitionGroup
* @transition: a #ClutterTransition
*
* Adds @transition to @group.
*
* This function acquires a reference on @transition that will be released
* when calling clutter_transition_group_remove_transition().
*
* Since: 1.12
*/
void
clutter_transition_group_add_transition (ClutterTransitionGroup *group,
ClutterTransition *transition)
{
gpointer old_group;
g_return_if_fail (CLUTTER_IS_TRANSITION_GROUP (group));
g_return_if_fail (CLUTTER_IS_TRANSITION (transition));
old_group = g_object_get_qdata (G_OBJECT (transition), quark_transition_group);
if (old_group != NULL)
{
g_critical ("The transition of type '%s' already is inside "
"a transition group.",
G_OBJECT_TYPE_NAME (transition));
return;
}
g_ptr_array_add (group->priv->transitions, g_object_ref (transition));
g_object_set_qdata (G_OBJECT (transition),
quark_transition_group,
group);
}
/**
* clutter_transition_group_remove_transition:
* @group: a #ClutterTransitionGroup
* @transition: a #ClutterTransition
*
* Removes @transition from @group.
*
* This function releases the reference acquired on @transition when
* calling clutter_transition_group_add_transition().
*
* Since: 1.12
*/
void
clutter_transition_group_remove_transition (ClutterTransitionGroup *group,
ClutterTransition *transition)
{
gpointer old_group;
g_return_if_fail (CLUTTER_IS_TRANSITION_GROUP (group));
old_group = g_object_get_qdata (G_OBJECT (transition), quark_transition_group);
if (old_group != group)
{
g_critical ("The transition of type '%s' does not match the "
"transition that is being removed from.",
G_OBJECT_TYPE_NAME (transition));
return;
}
g_object_set_qdata (G_OBJECT (transition),
quark_transition_group,
group);
g_ptr_array_remove (group->priv->transitions, transition);
}
/**
* clutter_transition_group_remove_all:
* @group: a #ClutterTransitionGroup
*
* Removes all transitions from @group.
*
* This function releases the reference acquired when calling
* clutter_transition_group_add_transition().
*
* Since: 1.12
*/
void
clutter_transition_group_remove_all (ClutterTransitionGroup *group)
{
g_return_if_fail (CLUTTER_IS_TRANSITION_GROUP (group));
g_ptr_array_remove_range (group->priv->transitions,
0,
group->priv->transitions->len);
}

View File

@ -0,0 +1,86 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2012 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/>.
*
* Author: Emmanuele Bassi <ebassi@linux.intel.com>
*/
#ifndef __CLUTTER_TRANSITION_GROUP_H__
#define __CLUTTER_TRANSITION_GROUP_H__
#include <clutter/clutter-types.h>
#include <clutter/clutter-transition.h>
G_BEGIN_DECLS
#define CLUTTER_TYPE_TRANSITION_GROUP (clutter_transition_group_get_type ())
#define CLUTTER_TRANSITION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CLUTTER_TYPE_TRANSITION_GROUP, ClutterTransitionGroup))
#define CLUTTER_IS_TRANSITION_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CLUTTER_TYPE_TRANSITION_GROUP))
#define CLUTTER_TRANSITION_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CLUTTER_TYPE_TRANSITION_GROUP, ClutterTransitionGroupClass))
#define CLUTTER_IS_TRANSITION_GROUP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CLUTTER_TYPE_TRANSITION_GROUP))
#define CLUTTER_TRANSITION_GROUP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), CLUTTER_TYPE_TRANSITION_GROUP, ClutterTransitionGroup))
typedef struct _ClutterTransitionGroupPrivate ClutterTransitionGroupPrivate;
typedef struct _ClutterTransitionGroupClass ClutterTransitionGroupClass;
/**
* ClutterTransitionGroup:
*
* The <structname>ClutterTransitionGroup</structname> structure contains
* private data and should only be accessed using the provided API.
*
* Since: 1.12
*/
struct _ClutterTransitionGroup
{
/*< private >*/
ClutterTransition parent_instance;
ClutterTransitionGroupPrivate *priv;
};
/**
* ClutterTransitionGroupClass:
*
* The <structname>ClutterTransitionGroupClass</structname> structure
* contains only private data.
*
* Since: 1.12
*/
struct _ClutterTransitionGroupClass
{
/*< private >*/
ClutterTransitionClass parent_class;
gpointer _padding[8];
};
GType clutter_transition_group_get_type (void) G_GNUC_CONST;
ClutterTransition * clutter_transition_group_new (void);
void clutter_transition_group_add_transition (ClutterTransitionGroup *group,
ClutterTransition *transition);
void clutter_transition_group_remove_transition (ClutterTransitionGroup *group,
ClutterTransition *transition);
void clutter_transition_group_remove_all (ClutterTransitionGroup *group);
G_END_DECLS
#endif /* __CLUTTER_TRANSITION_GROUP_H__ */

View File

@ -56,14 +56,16 @@ typedef struct _ClutterActorIter ClutterActorIter;
typedef struct _ClutterPaintNode ClutterPaintNode;
typedef struct _ClutterContent ClutterContent; /* dummy */
typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAnimatable ClutterAnimatable; /* dummy */
typedef struct _ClutterAnimator ClutterAnimator;
typedef struct _ClutterInterval ClutterInterval;
typedef struct _ClutterState ClutterState;
typedef struct _ClutterTimeline ClutterTimeline;
typedef struct _ClutterTransition ClutterTransition;
typedef struct _ClutterAlpha ClutterAlpha;
typedef struct _ClutterAnimator ClutterAnimator;
typedef struct _ClutterState ClutterState;
typedef struct _ClutterInterval ClutterInterval;
typedef struct _ClutterAnimatable ClutterAnimatable; /* dummy */
typedef struct _ClutterTimeline ClutterTimeline;
typedef struct _ClutterTransition ClutterTransition;
typedef struct _ClutterPropertyTransition ClutterPropertyTransition;
typedef struct _ClutterKeyframeTransition ClutterKeyframeTransition;
typedef struct _ClutterTransitionGroup ClutterTransitionGroup;
typedef struct _ClutterAction ClutterAction;
typedef struct _ClutterConstraint ClutterConstraint;

View File

@ -73,6 +73,7 @@
#include "clutter-image.h"
#include "clutter-input-device.h"
#include "clutter-interval.h"
#include "clutter-keyframe-transition.h"
#include "clutter-keysyms.h"
#include "clutter-layout-manager.h"
#include "clutter-layout-meta.h"
@ -102,6 +103,7 @@
#include "clutter-texture.h"
#include "clutter-text.h"
#include "clutter-timeline.h"
#include "clutter-transition-group.h"
#include "clutter-transition.h"
#include "clutter-units.h"
#include "clutter-version.h"

View File

@ -1369,6 +1369,11 @@ clutter_timeline_stop
clutter_timeout_pool_add
clutter_timeout_pool_new
clutter_timeout_pool_remove
clutter_transition_group_add_transition
clutter_transition_group_get_type
clutter_transition_group_new
clutter_transition_group_remove_transition
clutter_transition_group_remove_all
clutter_transition_get_animatable
clutter_transition_get_interval
clutter_transition_get_type

View File

@ -173,10 +173,35 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
return self;
}
- (void) dealloc
{
if (trackingRect)
{
[self removeTrackingRect:trackingRect];
trackingRect = 0;
}
[super dealloc];
}
- (NSTrackingRectTag) trackingRect
{
return tracking_rect;
}
- (ClutterActor *) clutterStage
{
return stage_osx->wrapper;
}
- (void) drawRect: (NSRect) bounds
{
_clutter_stage_do_paint (CLUTTER_STAGE (self->stage_osx->wrapper), NULL);
ClutterActor *stage = [self clutterStage];
_clutter_stage_do_paint (CLUTTER_STAGE (stage), NULL);
cogl_flush ();
[[self openGLContext] flushBuffer];
}
@ -194,7 +219,12 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
- (BOOL) isOpaque
{
if (clutter_stage_get_use_alpha (CLUTTER_STAGE (self->stage_osx->wrapper)))
ClutterActor *stage = [self clutterStage];
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
return YES;
if (clutter_stage_get_use_alpha (CLUTTER_STAGE (stage)))
return NO;
return YES;
@ -202,9 +232,13 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
- (void) reshape
{
ClutterActor *stage;
stage_osx->requisition_width = [self bounds].size.width;
stage_osx->requisition_height = [self bounds].size.height;
clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper),
stage = [self clutterStage];
clutter_actor_set_size (stage,
stage_osx->requisition_width,
stage_osx->requisition_height);
@ -219,7 +253,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window);
#define EVENT_HANDLER(event) \
-(void)event:(NSEvent *) theEvent { \
_clutter_event_osx_put (theEvent, self->stage_osx->wrapper); \
_clutter_event_osx_put (theEvent, stage_osx->wrapper); \
}
EVENT_HANDLER(mouseDown)
@ -396,7 +430,7 @@ clutter_stage_osx_show (ClutterStageWindow *stage_window,
* though.
*/
nspoint = [self->window mouseLocationOutsideOfEventStream];
if ([self->window mouse:nspoint inRect:[self->view frame]])
if ([self->view mouse:nspoint inRect:[self->view frame]])
{
NSEvent *event;

View File

@ -155,6 +155,7 @@
<xi:include href="xml/clutter-transition.xml"/>
<xi:include href="xml/clutter-animatable.xml"/>
<xi:include href="xml/clutter-property-transition.xml"/>
<xi:include href="xml/clutter-transition-group.xml"/>
</chapter>
<chapter>

View File

@ -3161,3 +3161,23 @@ ClutterImagePrivate
clutter_image_get_type
clutter_image_error_quark
</SECTION>
<SECTION>
<FILE>clutter-transition-group</FILE>
ClutterTransitionGroup
ClutterTransitionGroupClass
clutter_transition_group_new
clutter_transition_group_add_transition
clutter_transition_group_remove_transition
clutter_transition_group_remove_all
<SUBSECTION Standard>
CLUTTER_TYPE_TRANSITION_GROUP
CLUTTER_TRANSITION_GROUP
CLUTTER_TRANSITION_GROUP_CLASS
CLUTTER_IS_TRANSITION_GROUP
CLUTTER_IS_TRANSITION_GROUP_CLASS
CLUTTER_TRANSITION_GROUP_GET_CLASS
<SUBSECTION Private>
ClutterTransitionGroupPrivate
clutter_transition_group_get_type
</SECTION>

View File

@ -72,3 +72,4 @@ clutter_text_get_type
clutter_texture_get_type
clutter_timeline_get_type
clutter_transition_get_type
clutter_transition_group_get_type