gnomemm r1570 - in cluttermm/trunk: . clutter clutter/src examples
- From: arminb svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1570 - in cluttermm/trunk: . clutter clutter/src examples
- Date: Fri, 20 Jun 2008 13:37:37 +0000 (UTC)
Author: arminb
Date: Fri Jun 20 13:37:37 2008
New Revision: 1570
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1570&view=rev
Log:
2008-06-20 Armin Burgmeier <armin openismus com>
* clutter/src/Makefile_list_of_hg.am_fragment:
* clutter/src/effecttemplate.hg:
* clutter/src/effecttemplate.ccg: Wrapped ClutterEffectTemplate.
* clutter/src/alpha.hg: Wrap "alpha" and "timeline" properties.
* clutter/src/score.hg: Wrap new methods, properties and signals.
* clutter/cluttermm.h: Added effecttemplate.h to the includes.
* examples/Makefile.am:
* examples/effect.cc: Added a simple example to show how
Clutter::EffectTemplate can be used.
Added:
cluttermm/trunk/clutter/src/effecttemplate.ccg
cluttermm/trunk/clutter/src/effecttemplate.hg
cluttermm/trunk/examples/effect.cc
Modified:
cluttermm/trunk/ChangeLog
cluttermm/trunk/clutter/cluttermm.h
cluttermm/trunk/clutter/src/Makefile_list_of_hg.am_fragment
cluttermm/trunk/clutter/src/alpha.hg
cluttermm/trunk/clutter/src/score.hg
cluttermm/trunk/examples/Makefile.am
Modified: cluttermm/trunk/clutter/cluttermm.h
==============================================================================
--- cluttermm/trunk/clutter/cluttermm.h (original)
+++ cluttermm/trunk/clutter/cluttermm.h Fri Jun 20 13:37:37 2008
@@ -39,6 +39,7 @@
#include <cluttermm/behaviour-scale.h>
#include <cluttermm/clone-texture.h>
#include <cluttermm/color.h>
+#include <cluttermm/effecttemplate.h>
#include <cluttermm/entry.h>
#include <cluttermm/group.h>
#include <cluttermm/init.h>
Modified: cluttermm/trunk/clutter/src/Makefile_list_of_hg.am_fragment
==============================================================================
--- cluttermm/trunk/clutter/src/Makefile_list_of_hg.am_fragment (original)
+++ cluttermm/trunk/clutter/src/Makefile_list_of_hg.am_fragment Fri Jun 20 13:37:37 2008
@@ -28,5 +28,6 @@
score.hg \
shader.hg \
script.hg \
-scriptable.hg
+scriptable.hg \
+effecttemplate.hg
#layout.hg box.hg margin.hg
Modified: cluttermm/trunk/clutter/src/alpha.hg
==============================================================================
--- cluttermm/trunk/clutter/src/alpha.hg (original)
+++ cluttermm/trunk/clutter/src/alpha.hg Fri Jun 20 13:37:37 2008
@@ -68,8 +68,11 @@
void set_func(const SlotAlphaFunc& slot);
_IGNORE(clutter_alpha_set_func)
- // TODO: wrap pre-made alpha funcs?
+ _WRAP_PROPERTY("alpha", guint)
+ _WRAP_PROPERTY("timeline", Glib::RefPtr<Timeline>)
+ // We don't need the GClosure stuff in C++:
+ _IGNORE(clutter_alpha_set_closure)
};
/// @name Pre-defined Alpha functions
Added: cluttermm/trunk/clutter/src/effecttemplate.ccg
==============================================================================
--- (empty file)
+++ cluttermm/trunk/clutter/src/effecttemplate.ccg Fri Jun 20 13:37:37 2008
@@ -0,0 +1,119 @@
+/* Copyright (C) 2007 The cluttermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <clutter/clutter-effect.h>
+
+namespace Clutter
+{
+
+namespace
+{
+
+guint32 c_alpha_callback(ClutterAlpha* alpha, gpointer user_data)
+{
+ EffectTemplate::SlotAlphaFunc* alpha_func = static_cast<EffectTemplate::SlotAlphaFunc*>(user_data);
+ return (*alpha_func)(Glib::wrap(alpha, true));
+}
+
+void c_alpha_destroy_notify(gpointer data)
+{
+ delete static_cast<EffectTemplate::SlotAlphaFunc*>(data);
+}
+
+// We use this helper class instead of the ClutterEffectCompleteFuncs
+// because these don't have a GDestroyNotify.
+struct CompleteCallback: sigc::trackable
+{
+ EffectTemplate::SlotEffectCompleteFunc func;
+
+ static void create(const Glib::RefPtr<Timeline>& timeline, const Glib::RefPtr<Actor>& actor, const EffectTemplate::SlotEffectCompleteFunc& func)
+ {
+ CompleteCallback* cb = new CompleteCallback;
+ cb->func = func;
+ timeline->signal_completed().connect(sigc::bind(sigc::mem_fun(cb, &CompleteCallback::on_callback), actor));
+ }
+
+ void on_callback(const Glib::RefPtr<Actor>& actor)
+ {
+ func(actor);
+ // This causes the signal being disconnected from the timeline:
+ delete this;
+ }
+};
+
+}
+
+EffectTemplate::EffectTemplate(const Glib::RefPtr<Timeline>& timeline, const SlotAlphaFunc& alpha_func)
+:
+ _CONSTRUCT()
+{
+ clutter_effect_template_construct(gobj(), timeline->gobj(), c_alpha_callback, new SlotAlphaFunc(alpha_func), c_alpha_destroy_notify);
+}
+
+EffectTemplate::EffectTemplate(guint msecs, const SlotAlphaFunc& alpha_func)
+:
+ _CONSTRUCT()
+{
+ Glib::RefPtr<Timeline> timeline(Timeline::create(msecs));
+ clutter_effect_template_construct(gobj(), timeline->gobj(), c_alpha_callback, new SlotAlphaFunc(alpha_func), c_alpha_destroy_notify);
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::fade(const Glib::RefPtr<Actor>& actor, guint8 opacity_end, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_fade(gobj(), actor->gobj(), opacity_end, NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::depth(const Glib::RefPtr<Actor>& actor, int depth_end, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_depth(gobj(), actor->gobj(), depth_end, NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::move(const Glib::RefPtr<Actor>& actor, int x, int y, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_move(gobj(), actor->gobj(), x, y, NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::path(const Glib::RefPtr<Actor>& actor, const ClutterKnot* knots, guint n_knots, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_path(gobj(), actor->gobj(), knots, n_knots, NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::scale(const Glib::RefPtr<Actor>& actor, double x_scale_end, double y_scale_end, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_scale(gobj(), actor->gobj(), x_scale_end, y_scale_end, NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+Glib::RefPtr<Timeline> EffectTemplate::rotate(const Glib::RefPtr<Actor>& actor, RotateAxis axis, double angle_end, int center_x, int center_y, int center_z, RotateDirection direction, const SlotEffectCompleteFunc& func)
+{
+ Glib::RefPtr<Timeline> timeline(Glib::wrap(clutter_effect_rotate(gobj(), actor->gobj(), static_cast<ClutterRotateAxis>(axis), angle_end, center_x, center_y, center_z, static_cast<ClutterRotateDirection>(direction), NULL, NULL), true));
+ CompleteCallback::create(timeline, actor, func);
+ return timeline;
+}
+
+} // namespace Clutter
+
+//vim: ts=2,sw=2
Added: cluttermm/trunk/clutter/src/effecttemplate.hg
==============================================================================
--- (empty file)
+++ cluttermm/trunk/clutter/src/effecttemplate.hg Fri Jun 20 13:37:37 2008
@@ -0,0 +1,76 @@
+/* Copyright (C) 2007 The cluttermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <cluttermm/alpha.h>
+#include <cluttermm/actor.h>
+
+_DEFS(cluttermm,clutter)
+_PINCLUDE(glibmm/private/object_p.h)
+
+
+namespace Clutter
+{
+
+class EffectTemplate :
+ public Glib::Object
+{
+ _CLASS_GOBJECT(EffectTemplate, ClutterEffectTemplate, CLUTTER_EFFECT_TEMPLATE, Glib::Object, GObject)
+
+public:
+ typedef sigc::slot<guint32, const Glib::RefPtr<Alpha>&> SlotAlphaFunc;
+ typedef sigc::slot<void, const Glib::RefPtr<Actor>&> SlotEffectCompleteFunc;
+
+protected:
+ EffectTemplate(const Glib::RefPtr<Timeline>& timeline, const SlotAlphaFunc& alpha_func);
+ EffectTemplate(guint msecs, const SlotAlphaFunc& alpha_func);
+ _IGNORE(clutter_effect_template_new, clutter_effect_template_new_full,
+ clutter_effect_template_new_for_duration,
+ clutter_effect_template_construct)
+
+public:
+ _WRAP_CREATE(const Glib::RefPtr<Timeline>& timeline, const SlotAlphaFunc& alpha_func)
+ _WRAP_CREATE(guint msecs, const SlotAlphaFunc& alpha_func)
+
+ _WRAP_METHOD(void set_timeline_clone(bool setting), clutter_effect_template_set_timeline_clone)
+ _WRAP_METHOD(bool get_timeline_clone() const, clutter_effect_template_get_timeline_clone)
+
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_fade)
+ Glib::RefPtr<Timeline> fade(const Glib::RefPtr<Actor>& actor, guint8 opacity_end, const SlotEffectCompleteFunc& func);
+
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_depth)
+ Glib::RefPtr<Timeline> depth(const Glib::RefPtr<Actor>& actor, int depth_end, const SlotEffectCompleteFunc& func);
+
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_move)
+ Glib::RefPtr<Timeline> move(const Glib::RefPtr<Actor>& actor, int x, int y, const SlotEffectCompleteFunc& func);
+
+ // TODO: Use C++ container for knots
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_path)
+ Glib::RefPtr<Timeline> path(const Glib::RefPtr<Actor>& actor, const ClutterKnot* knots, guint n_knots, const SlotEffectCompleteFunc& func);
+
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_scale)
+ Glib::RefPtr<Timeline> scale(const Glib::RefPtr<Actor>& actor, double x_scale_end, double y_scale_end, const SlotEffectCompleteFunc& func);
+
+ _WRAP_METHOD_DOCS_ONLY(clutter_effect_rotate)
+ Glib::RefPtr<Timeline> rotate(const Glib::RefPtr<Actor>& actor, RotateAxis axis, double angle_end, int center_x, int center_y, int center_z, RotateDirection direction, const SlotEffectCompleteFunc& func);
+
+ _WRAP_PROPERTY("timeline", Glib::RefPtr<Timeline>)
+ _WRAP_PROPERTY("clone", bool)
+};
+
+} // namespace Clutter
+
+//vim: ts=2,sw=2
Modified: cluttermm/trunk/clutter/src/score.hg
==============================================================================
--- cluttermm/trunk/clutter/src/score.hg (original)
+++ cluttermm/trunk/clutter/src/score.hg Fri Jun 20 13:37:37 2008
@@ -49,19 +49,33 @@
*/
guint append(const Glib::RefPtr<Timeline>& timeline);
+ _WRAP_METHOD(void append_at_marker(const Glib::RefPtr<Timeline>& parent, const Glib::ustring& marker_name, const Glib::RefPtr<Timeline>& timeline), clutter_score_append_at_marker)
+
_WRAP_METHOD(void remove(guint id), clutter_score_remove)
_WRAP_METHOD(void remove_all(), clutter_score_remove_all)
_WRAP_METHOD(Glib::RefPtr<Timeline> get_timeline(guint id), clutter_score_get_timeline, refreturn)
_WRAP_METHOD(Glib::RefPtr<const Timeline> get_timeline(guint id) const, clutter_score_get_timeline, , refreturn, constversion)
+#m4 _CONVERSION(`GSList*', `Glib::SListHandle<Glib::RefPtr<Timeline> >', `$2(($3), Glib::OWNERSHIP_SHALLOW)')
+#m4 _CONVERSION(`GSList*', `Glib::SListHandle<Glib::RefPtr<const Timeline> >', `$2(($3), Glib::OWNERSHIP_SHALLOW)')
+ _WRAP_METHOD(Glib::SListHandle<Glib::RefPtr<Timeline> > list_timelines(), clutter_score_list_timelines)
+ _WRAP_METHOD(Glib::SListHandle<Glib::RefPtr<const Timeline> > list_timelines() const, clutter_score_list_timelines)
+
_WRAP_METHOD(void start(), clutter_score_start)
_WRAP_METHOD(void pause(), clutter_score_pause)
_WRAP_METHOD(void stop(), clutter_score_stop)
_WRAP_METHOD(void rewind(), clutter_score_rewind)
_WRAP_METHOD(bool is_playing() const, clutter_score_is_playing)
+ _WRAP_PROPERTY("loop", bool)
+
+#m4 _CONVERSION(`ClutterTimeline*', `const Glib::RefPtr<Timeline>&', `Glib::wrap(($3), true)')
+ _WRAP_SIGNAL(void completed(), "completed")
+ _WRAP_SIGNAL(void paused(), "paused")
+ _WRAP_SIGNAL(void started(), "started")
+ _WRAP_SIGNAL(void timeline_completed(const Glib::RefPtr<Timeline>& timeline), "timeline-completed")
+ _WRAP_SIGNAL(void timeline_started(const Glib::RefPtr<Timeline>& timeline), "timeline-started")
};
} // namespace Clutter
-// vim:ts=2,sw=2
Modified: cluttermm/trunk/examples/Makefile.am
==============================================================================
--- cluttermm/trunk/examples/Makefile.am (original)
+++ cluttermm/trunk/examples/Makefile.am Fri Jun 20 13:37:37 2008
@@ -2,11 +2,12 @@
include Makefile.am_fragment
-noinst_PROGRAMS = actors flowers simple-cairo embed-gtk
+noinst_PROGRAMS = actors flowers simple-cairo embed-gtk effect
actors_SOURCES = test-actors.cc
flowers_SOURCES = flowers.cc
simple_cairo_SOURCES = simple-cairo.cc
embed_gtk_SOURCES = embed-gtk.cc
+effect_SOURCES = effect.cc
#boxes_SOURCES = test-boxes.cc
EXTRA_DIST = actor.png
Added: cluttermm/trunk/examples/effect.cc
==============================================================================
--- (empty file)
+++ cluttermm/trunk/examples/effect.cc Fri Jun 20 13:37:37 2008
@@ -0,0 +1,46 @@
+#include <cluttermm.h>
+#include <cluttermm/init.h>
+// FIXME: remove this when enough stuff is wrapped
+#include <clutter/clutter.h>
+#include <iostream>
+
+#if defined (_MSC_VER) && !defined (_USE_MATH_DEFINES)
+#define _USE_MATH_DEFINES
+#endif
+
+void move_finished(const Glib::RefPtr<Clutter::Actor>& actor, const Glib::RefPtr<Clutter::EffectTemplate>& effect)
+{
+ // Restart
+ effect->move(actor, 450, 450, sigc::bind(sigc::ptr_fun(move_finished), effect));
+}
+
+int
+main (int argc, char *argv[])
+{
+ // initialize the C++ wrapper types
+ Clutter::init(&argc, &argv);
+
+ Clutter::Color stage_color (0x61, 0x64, 0x8c, 0xff);
+ Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::get_default ();
+ stage->set_size (800, 600);
+
+ stage->set_title ("Effect Test");
+ stage->set_color (stage_color);
+
+ Glib::RefPtr<Clutter::Timeline> timeline =
+ Clutter::Timeline::create (360, 60); // num frames, fps
+ //timeline->set_loop (true); // have it loop
+ Glib::RefPtr<Clutter::EffectTemplate> effect = Clutter::EffectTemplate::create(timeline, Clutter::ALPHA_RAMP);
+
+ Glib::RefPtr<Clutter::Texture> texture(Clutter::Texture::create());
+ texture->set_from_file("actor.png");
+
+ stage->add_actor(texture);
+ stage->show_all();
+
+ timeline->start();
+ effect->move(texture, 450, 450, sigc::bind(sigc::ptr_fun(move_finished), effect));
+
+ clutter_main ();
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]