mirror of
https://github.com/brl/mutter.git
synced 2024-12-22 11:02:05 +00:00
2006-08-15 Matthew Allum <mallum@openedhand.com>
* clutter/clutter-behaviour.c: * clutter/clutter-behaviour.h: * clutter/clutter-behaviours.c: * clutter/clutter-timeline.c: * clutter/clutter-timeline.h: * clutter/clutter.h: Make basic behaviour infrastructure actually work. * examples/Makefile.am: * examples/behave.c: Add a simple behaviour demo/test * clutter/clutter-media.c: (clutter_media_set_volume): Actuall set volume rather than position.. (Fixes #141)
This commit is contained in:
parent
c13b025083
commit
2c41d38fed
17
ChangeLog
17
ChangeLog
@ -1,3 +1,20 @@
|
||||
2006-08-15 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* clutter/clutter-behaviour.c:
|
||||
* clutter/clutter-behaviour.h:
|
||||
* clutter/clutter-behaviours.c:
|
||||
* clutter/clutter-timeline.c:
|
||||
* clutter/clutter-timeline.h:
|
||||
* clutter/clutter.h:
|
||||
Make basic behaviour infrastructure actually work.
|
||||
|
||||
* examples/Makefile.am:
|
||||
* examples/behave.c:
|
||||
Add a simple behaviour demo/test
|
||||
|
||||
* clutter/clutter-media.c: (clutter_media_set_volume):
|
||||
Actuall set volume rather than position.. (Fixes #141)
|
||||
|
||||
2006-08-14 Matthew Allum <mallum@openedhand.com>
|
||||
|
||||
* clutter/Makefile.am:
|
||||
|
@ -31,10 +31,9 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "clutter-behaviour.h"
|
||||
#include "clutter-enum-types.h"
|
||||
#include "clutter-private.h" /* for DBG */
|
||||
#include "clutter-timeline.h"
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-behaviour.h"
|
||||
|
||||
G_DEFINE_TYPE (ClutterBehaviour, clutter_behaviour, G_TYPE_OBJECT);
|
||||
|
||||
|
@ -3,8 +3,6 @@
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "clutter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CLUTTER_TYPE_BEHAVIOUR clutter_behaviour_get_type()
|
||||
|
@ -31,10 +31,12 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "clutter-timeline.h"
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-behaviour.h"
|
||||
#include "clutter-behaviours.h"
|
||||
#include "clutter-enum-types.h"
|
||||
#include "clutter-private.h" /* for DBG */
|
||||
#include "clutter-timeline.h"
|
||||
#include "clutter-main.h"
|
||||
|
||||
G_DEFINE_TYPE (ClutterBehaviourPath, \
|
||||
clutter_behaviour_path, \
|
||||
@ -99,6 +101,29 @@ clutter_behaviour_path_init (ClutterBehaviourPath *self)
|
||||
self->priv = priv = CLUTTER_BEHAVIOUR_PATH_GET_PRIVATE (self);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
function line(x0, x1, y0, y1)
|
||||
boolean steep := abs(y1 - y0) > abs(x1 - x0)
|
||||
if steep then
|
||||
swap(x0, y0)
|
||||
swap(x1, y1)
|
||||
if x0 > x1 then
|
||||
swap(x0, x1)
|
||||
swap(y0, y1)
|
||||
int deltax := x1 - x0
|
||||
int deltay := abs(y1 - y0)
|
||||
int error := 0
|
||||
int ystep
|
||||
int y := y0
|
||||
if y0 < y1 then ystep := 1 else ystep := -1
|
||||
for x from x0 to x1
|
||||
if steep then plot(y,x) else plot(x,y)
|
||||
error := error + deltay
|
||||
if 2
|
||||
|
||||
*/
|
||||
|
||||
ClutterBehaviour*
|
||||
clutter_behaviour_path_new (ClutterTimeline *timeline,
|
||||
gint x1,
|
||||
@ -203,6 +228,8 @@ clutter_behaviour_opacity_frame_foreach (ClutterActor *actor,
|
||||
|
||||
opacity += priv->opacity_start;
|
||||
|
||||
CLUTTER_DBG("alpha %i opacity %i\n", alpha, opacity);
|
||||
|
||||
clutter_actor_set_opacity (actor, opacity);
|
||||
}
|
||||
|
||||
@ -218,7 +245,7 @@ clutter_behaviour_opacity_frame (ClutterTimeline *timelime,
|
||||
clutter_behaviour_actors_foreach
|
||||
(CLUTTER_BEHAVIOUR(behave),
|
||||
(GFunc)clutter_behaviour_opacity_frame_foreach,
|
||||
GINT_TO_POINTER(frame_num));
|
||||
behave);
|
||||
}
|
||||
|
||||
ClutterBehaviour*
|
||||
|
@ -288,7 +288,7 @@ clutter_media_set_volume (ClutterMedia *media,
|
||||
{
|
||||
g_return_if_fail (CLUTTER_IS_MEDIA(media));
|
||||
|
||||
CLUTTER_MEDIA_GET_INTERFACE (media)->set_position (media, volume);
|
||||
CLUTTER_MEDIA_GET_INTERFACE (media)->set_volume (media, volume);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include <pango/pangoft2.h>
|
||||
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _ClutterMainContext ClutterMainContext;
|
||||
|
@ -636,7 +636,7 @@ clutter_texture_paint (ClutterActor *self)
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(texture->priv->target_type);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
opacity = clutter_actor_get_opacity(self);
|
||||
|
||||
|
@ -86,6 +86,32 @@ clutter_timeline_alpha_ramp_inc_func (ClutterTimeline *timeline)
|
||||
/ timeline->priv->nframes;
|
||||
}
|
||||
|
||||
guint32
|
||||
clutter_timeline_alpha_ramp_dec_func (ClutterTimeline *timeline)
|
||||
{
|
||||
return ((timeline->priv->nframes - timeline->priv->current_frame_num)
|
||||
* CLUTTER_TIMELINE_MAX_ALPHA)
|
||||
/ timeline->priv->nframes;
|
||||
}
|
||||
|
||||
guint32
|
||||
clutter_timeline_alpha_ramp_func (ClutterTimeline *timeline)
|
||||
{
|
||||
|
||||
if (timeline->priv->current_frame_num > (timeline->priv->nframes/2))
|
||||
{
|
||||
return (((timeline->priv->nframes) - timeline->priv->current_frame_num)
|
||||
* CLUTTER_TIMELINE_MAX_ALPHA)
|
||||
/ (timeline->priv->nframes/2);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (timeline->priv->current_frame_num * CLUTTER_TIMELINE_MAX_ALPHA)
|
||||
/ (timeline->priv->nframes/2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Object */
|
||||
|
||||
static void
|
||||
@ -269,6 +295,8 @@ clutter_timeline_init (ClutterTimeline *self)
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
|
||||
CLUTTER_TYPE_TIMELINE,
|
||||
ClutterTimelinePrivate);
|
||||
|
||||
self->priv->alpha_func = CLUTTER_ALPHA_RAMP_INC;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -323,21 +351,23 @@ timeline_timeout_func (gpointer data)
|
||||
|
||||
priv->last_frame_msecs = msecs;
|
||||
|
||||
/* Advance frames */
|
||||
priv->current_frame_num += nframes;;
|
||||
|
||||
/* Update alpha value */
|
||||
if (priv->alpha_func)
|
||||
priv->alpha = priv->alpha_func(timeline);
|
||||
|
||||
/* Advance frames */
|
||||
priv->current_frame_num += nframes;;
|
||||
|
||||
/* Handle loop or stop */
|
||||
if (priv->current_frame_num > priv->nframes)
|
||||
{
|
||||
priv->current_frame_num = priv->nframes;
|
||||
|
||||
if (nframes > 1)
|
||||
g_signal_emit (timeline, timeline_signals[SIGNAL_NEW_FRAME],
|
||||
0, priv->current_frame_num);
|
||||
{
|
||||
g_signal_emit (timeline, timeline_signals[SIGNAL_NEW_FRAME],
|
||||
0, priv->current_frame_num);
|
||||
}
|
||||
|
||||
if (priv->loop)
|
||||
clutter_timeline_rewind (timeline);
|
||||
@ -593,6 +623,19 @@ clutter_timeline_get_alpha (ClutterTimeline *timeline)
|
||||
return timeline->priv->alpha;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_timeline_set_alpha_func:
|
||||
* @timeline: A #ClutterTimeline
|
||||
* @func: A #ClutterTimelineAlphaFunc
|
||||
*
|
||||
*/
|
||||
void
|
||||
clutter_timeline_set_alpha_func (ClutterTimeline *timeline,
|
||||
ClutterTimelineAlphaFunc func)
|
||||
{
|
||||
timeline->priv->alpha_func = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_timeline_new:
|
||||
* @nframes: #ClutterTimeline number of frames
|
||||
|
@ -132,12 +132,22 @@ clutter_timeline_is_playing (ClutterTimeline *timeline);
|
||||
gint32
|
||||
clutter_timeline_get_alpha (ClutterTimeline *timeline);
|
||||
|
||||
void
|
||||
clutter_timeline_set_alpha_func (ClutterTimeline *timeline,
|
||||
ClutterTimelineAlphaFunc func);
|
||||
|
||||
guint32
|
||||
clutter_timeline_alpha_ramp_inc_func (ClutterTimeline *timeline);
|
||||
|
||||
guint32
|
||||
clutter_timeline_alpha_ramp_dec_func (ClutterTimeline *timeline);
|
||||
|
||||
guint32
|
||||
clutter_timeline_alpha_ramp_func (ClutterTimeline *timeline);
|
||||
|
||||
#define CLUTTER_ALPHA_RAMP_INC clutter_timeline_alpha_ramp_inc_func;
|
||||
#define CLUTTER_ALPHA_RAMP_INC clutter_timeline_alpha_ramp_inc_func
|
||||
#define CLUTTER_ALPHA_RAMP_DEC clutter_timeline_alpha_ramp_dec_func
|
||||
#define CLUTTER_ALPHA_RAMP clutter_timeline_alpha_ramp_func
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include "clutter-util.h"
|
||||
#include "clutter-event.h"
|
||||
#include "clutter-timeline.h"
|
||||
#include "clutter-behaviour.h"
|
||||
#include "clutter-behaviours.h"
|
||||
#include "clutter-stage.h"
|
||||
#include "clutter-actor.h"
|
||||
#include "clutter-rectangle.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
noinst_PROGRAMS = test video-player video-cube super-oh
|
||||
noinst_PROGRAMS = test video-player video-cube super-oh behave
|
||||
|
||||
INCLUDES = -I$(top_srcdir)/
|
||||
|
||||
@ -34,6 +34,15 @@ super_oh_LDFLAGS = \
|
||||
$(GCONF_LIBS) \
|
||||
$(top_builddir)/clutter/libclutter-@CLUTTER_MAJORMINOR@.la
|
||||
|
||||
behave_SOURCES = behave.c
|
||||
behave_CFLAGS = $(CLUTTER_CFLAGS) $(GST_CFLAGS) $(GCONF_CFLAGS)
|
||||
behave_LDFLAGS = \
|
||||
$(CLUTTER_LIBS) \
|
||||
$(GST_LIBS) \
|
||||
$(GCONF_LIBS) \
|
||||
$(top_builddir)/clutter/libclutter-@CLUTTER_MAJORMINOR@.la
|
||||
|
||||
|
||||
EXTRA_DIST = redhand.png \
|
||||
clutter-logo-800x600.png \
|
||||
media-actions-pause.png \
|
||||
|
51
examples/behave.c
Normal file
51
examples/behave.c
Normal file
@ -0,0 +1,51 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
ClutterTimeline *timeline;
|
||||
ClutterBehaviour *behave;
|
||||
ClutterActor *stage, *hand;
|
||||
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
|
||||
clutter_init (&argc, &argv);
|
||||
|
||||
stage = clutter_stage_get_default ();
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", NULL);
|
||||
|
||||
if (!pixbuf)
|
||||
g_error("pixbuf load failed");
|
||||
|
||||
clutter_stage_set_color (CLUTTER_STAGE (stage),
|
||||
&stage_color);
|
||||
|
||||
/* Make a hand */
|
||||
hand = clutter_texture_new_from_pixbuf (pixbuf);
|
||||
clutter_actor_set_position (hand, 100, 100);
|
||||
clutter_group_add (CLUTTER_GROUP (stage), hand);
|
||||
|
||||
/* Make a timeline */
|
||||
timeline = clutter_timeline_new (100, 30); /* num frames, fps */
|
||||
g_object_set(timeline, "loop", TRUE, 0);
|
||||
|
||||
/* Set an alpha func to power behaviour - ramp is constant rise/fall */
|
||||
clutter_timeline_set_alpha_func (timeline, CLUTTER_ALPHA_RAMP);
|
||||
|
||||
/* Create a behaviour for that time line */
|
||||
behave = clutter_behaviour_opacity_new (timeline, 0X33 ,0xff);
|
||||
|
||||
/* Apply it to our actor */
|
||||
clutter_behaviour_apply (behave, hand);
|
||||
|
||||
/* start the timeline */
|
||||
clutter_timeline_start (timeline);
|
||||
|
||||
clutter_group_show_all (CLUTTER_GROUP (stage));
|
||||
|
||||
clutter_main();
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user