gnomemm r1655 - in cluttermm/trunk: . examples
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1655 - in cluttermm/trunk: . examples
- Date: Wed, 30 Jul 2008 10:46:03 +0000 (UTC)
Author: murrayc
Date: Wed Jul 30 10:46:02 2008
New Revision: 1655
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1655&view=rev
Log:
2008-07-30 Murray Cumming <murrayc murrayc com>
* examples/simple-cairo.cc: Removed this. It was not
being built and it is now in clutter-cairomm anyway.
* examples/effect.cc:
* examples/test-actors.cc:
* examples/test-boxes.cc: Corrected the syntax
formatting.
Removed:
cluttermm/trunk/examples/simple-cairo.cc
Modified:
cluttermm/trunk/ChangeLog
cluttermm/trunk/examples/effect.cc
cluttermm/trunk/examples/test-actors.cc
cluttermm/trunk/examples/test-boxes.cc
Modified: cluttermm/trunk/examples/effect.cc
==============================================================================
--- cluttermm/trunk/examples/effect.cc (original)
+++ cluttermm/trunk/examples/effect.cc Wed Jul 30 10:46:02 2008
@@ -2,38 +2,38 @@
#include <cluttermm/init.h>
#include <iostream>
-void move_finished(const Glib::RefPtr<Clutter::Actor>& actor, const Glib::RefPtr<Clutter::EffectTemplate>& effect)
+void on_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));
+ effect->move(actor, 450, 450, sigc::bind(sigc::ptr_fun(on_move_finished), effect));
}
int
main (int argc, char *argv[])
{
- // initialize the C++ wrapper types
- Clutter::init(&argc, &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);
+ 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);
+ stage->set_title ("Effect Test");
+ stage->set_color (stage_color);
- Glib::RefPtr<Clutter::Timeline> timeline =
- Clutter::Timeline::create (360, 60); // num frames, fps
- Glib::RefPtr<Clutter::EffectTemplate> effect = Clutter::EffectTemplate::create(timeline, Clutter::ALPHA_RAMP);
+ Glib::RefPtr<Clutter::Timeline> timeline =
+ Clutter::Timeline::create (360, 60); // num frames, fps
+ 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");
+ Glib::RefPtr<Clutter::Texture> texture(Clutter::Texture::create());
+ texture->set_from_file("actor.png");
- stage->add_actor(texture);
- stage->show_all();
+ stage->add_actor(texture);
+ stage->show_all();
- timeline->start();
- effect->move(texture, 450, 450, sigc::bind(sigc::ptr_fun(move_finished), effect));
+ timeline->start();
+ effect->move(texture, 450, 450, sigc::bind(sigc::ptr_fun(on_move_finished), effect));
- Clutter::main();
- return 0;
+ Clutter::main();
+ return 0;
}
Modified: cluttermm/trunk/examples/test-actors.cc
==============================================================================
--- cluttermm/trunk/examples/test-actors.cc (original)
+++ cluttermm/trunk/examples/test-actors.cc Wed Jul 30 10:46:02 2008
@@ -9,211 +9,211 @@
unsigned int get_radius(unsigned int num_actors)
{
- return (Clutter::Stage::get_default()->get_height()
- + Clutter::Stage::get_default()->get_height()) / num_actors;
+ return (Clutter::Stage::get_default()->get_height()
+ + Clutter::Stage::get_default()->get_height()) / num_actors;
}
struct SuperOH
{
- std::vector<Glib::RefPtr<Clutter::Actor> > hands;
- Glib::RefPtr<Clutter::Actor> bgtex;
- Glib::RefPtr<Clutter::Group> group;
+ std::vector<Glib::RefPtr<Clutter::Actor> > hands;
+ Glib::RefPtr<Clutter::Actor> bgtex;
+ Glib::RefPtr<Clutter::Group> group;
};
-bool on_button_press (Clutter::ButtonEvent *event, const Glib::RefPtr<Clutter::Stage>& stage)
+bool on_button_press(Clutter::ButtonEvent *event, const Glib::RefPtr<Clutter::Stage>& stage)
{
- g_print ("*** button press event (button:%d) ***\n",
- event->button);
+ g_print("*** button press event (button:%d) ***\n",
+ event->button);
- Glib::RefPtr<Clutter::Actor> e = stage->get_actor_at_pos(event->x, event->y);
- if(e) e->hide();
+ Glib::RefPtr<Clutter::Actor> e = stage->get_actor_at_pos(event->x, event->y);
+ if(e)
+ e->hide();
- return false;
+ return false;
}
-bool on_key_release (Clutter::KeyEvent *event)
+bool on_key_release(Clutter::KeyEvent *event)
{
- g_print ("*** key press event (key:%c) ***\n",
- Clutter::key_event_symbol(event));
+ g_print("*** key press event (key:%c) ***\n",
+ Clutter::key_event_symbol(event));
- if(Clutter::key_event_symbol(event) == CLUTTER_q)
- Clutter::main_quit();
+ if(Clutter::key_event_symbol(event) == CLUTTER_q)
+ Clutter::main_quit();
- return false;
+ return false;
}
// Timeline handler
-void on_new_frame (int frame_num, SuperOH* oh)
+void on_new_frame(int frame_num, SuperOH* oh)
{
- // Rotate everything clockwise about stage center
- oh->group->set_rotation (Clutter::Z_AXIS,
- frame_num,
- Clutter::Stage::get_default ()->get_width () / 2,
- Clutter::Stage::get_default ()->get_height () / 2,
- 0);
-
- for (unsigned int i = 0; i < oh->hands.size(); i++)
- {
- double scale_x, scale_y;
-
- oh->hands[i]->get_scale (scale_x, scale_y);
-
- /* Rotate each hand around their centers - to get this we need
- * to take into account any scaling.
- *
- * FIXME: scaling causes drift so disabled for now. Need rotation
- * unit based functions to fix.
- */
- oh->hands[i]->set_rotation (Clutter::Z_AXIS,
- - 6.0 * frame_num, 0, 0, 0);
- }
+ // Rotate everything clockwise about stage center
+ oh->group->set_rotation(Clutter::Z_AXIS,
+ frame_num,
+ Clutter::Stage::get_default()->get_width() / 2,
+ Clutter::Stage::get_default()->get_height() / 2,
+ 0);
+
+ for(unsigned int i = 0; i < oh->hands.size(); i++)
+ {
+ double scale_x = 0;
+ double scale_y = 0;
+ oh->hands[i]->get_scale(scale_x, scale_y);
+
+ /* Rotate each hand around their centers - to get this we need
+ * to take into account any scaling.
+ *
+ * TODO: scaling causes drift so disabled for now. Need rotation
+ * unit based functions to fix.
+ */
+ oh->hands[i]->set_rotation(Clutter::Z_AXIS,
+ - 6.0 * frame_num, 0, 0, 0);
+ }
}
} // anonymous namespace
int main(int argc, char *argv[])
{
- Glib::OptionEntry entry;
- entry.set_short_name('n');
- entry.set_long_name("num-actors");
- entry.set_description("Number of actors");
- entry.set_arg_description("ACTORS");
-
- Glib::OptionGroup group("actor", "Specifies actor properties");
- int num_actors = N_ACTORS;
- group.add_entry(entry, num_actors);
-
- Glib::OptionContext context;
- context.set_main_group(group);
+ Glib::OptionEntry entry;
+ entry.set_short_name('n');
+ entry.set_long_name("num-actors");
+ entry.set_description("Number of actors");
+ entry.set_arg_description("ACTORS");
+
+ Glib::OptionGroup group("actor", "Specifies actor properties");
+ int num_actors = N_ACTORS;
+ group.add_entry(entry, num_actors);
+
+ Glib::OptionContext context;
+ context.set_main_group(group);
+
+ try
+ {
+ // TODO: Pass context to init as soon as that init() overload has been
+ // uncommented in cluttermm. This depends on a clutter release with
+ // clutter bug #1033 fixed.
+ // initialize the C++ wrapper types
+ Clutter::init(&argc, &argv); //, context);
+ }
+ catch(const Glib::Exception& ex)
+ {
+ std::cerr << "Failed to initialize clutter: " << ex.what() << std::endl;
+ return -1;
+ }
+
+ 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("Actors Test");
+ stage->set_color(stage_color);
+
+ SuperOH oh;
+
+ // Create a timeline to manage animation
+ Glib::RefPtr<Clutter::Timeline> timeline =
+ Clutter::Timeline::create(360, 60); // num frames, fps
+ timeline->set_loop(true); // have it loop
+
+ // fire a callback for frame change
+ timeline->signal_new_frame().connect
+ (sigc::bind(sigc::ptr_fun(on_new_frame), &oh));
+
+ // TODO: these next 3 objects are not currently used in the example, but
+ // they cause problems on application exit. If they are commented out, the
+ // program runs and exits without problems. There seems to be some sort of
+ // reference-counting issue
+ // Perhaps that's clutter bug #856.
+
+ // Set up some behaviours to handle scaling
+ Glib::RefPtr<Clutter::Alpha> alpha =
+ Clutter::Alpha::create(timeline, Clutter::ALPHA_SINE);
+
+ Glib::RefPtr<Clutter::BehaviourScale> scaler_1 =
+ Clutter::BehaviourScale::create(alpha,
+ 0.5, 0.5,
+ 1.0, 1.0);
+
+ Glib::RefPtr<Clutter::BehaviourScale> scaler_2 =
+ Clutter::BehaviourScale::create(alpha,
+ 1.0, 1.0,
+ 0.5, 0.5);
+
+ // create a new group to hold multiple actors in a group
+ oh.group = Clutter::Group::create();
+
+ oh.hands.reserve(num_actors);
+ for(int i = 0; i < num_actors; i++)
+ {
+ int radius = get_radius(num_actors);
- try
+ // Create a texture from file, then clone it to save resources
+ if(i == 0)
{
- // TODO: Pass context to init as soon as that init() overload has been
- // uncommented in cluttermm. This depends on a clutter release with
- // clutter bug #1033 fixed.
- // initialize the C++ wrapper types
- Clutter::init(&argc, &argv); //, context);
+ try
+ {
+ Glib::RefPtr<Clutter::Texture> texture(Clutter::Texture::create());
+ texture->set_from_file("actor.png");
+ oh.hands.push_back(texture);
+ }
+ catch(const Glib::Exception& ex)
+ {
+ std::cerr << "Could not load texture: " << ex.what() << std::endl;
+ return -1;
+ }
}
- catch(const Glib::Exception& ex)
+ else
{
- std::cerr << "Failed to initialize clutter: " << ex.what() << std::endl;
- return -1;
+ oh.hands.push_back(Clutter::CloneTexture::create
+ (Glib::RefPtr<Clutter::Texture>::cast_dynamic
+ (oh.hands[0])));
}
- 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 ("Actors Test");
- stage->set_color (stage_color);
-
- SuperOH oh;
-
- // Create a timeline to manage animation
- Glib::RefPtr<Clutter::Timeline> timeline =
- Clutter::Timeline::create (360, 60); // num frames, fps
- timeline->set_loop (true); // have it loop
-
- // fire a callback for frame change
- timeline->signal_new_frame ().connect
- (sigc::bind (sigc::ptr_fun(on_new_frame), &oh));
-
- // TODO: these next 3 objects are not currently used in the example, but
- // they cause problems on application exit. If they are commented out, the
- // program runs and exits without problems. There seems to be some sort of
- // reference-counting issue
- // Perhaps that's clutter bug #856.
-
- // Set up some behaviours to handle scaling
- Glib::RefPtr<Clutter::Alpha> alpha =
- Clutter::Alpha::create (timeline, Clutter::ALPHA_SINE);
-
- Glib::RefPtr<Clutter::BehaviourScale> scaler_1 =
- Clutter::BehaviourScale::create (alpha,
- 0.5, 0.5,
- 1.0, 1.0);
-
- Glib::RefPtr<Clutter::BehaviourScale> scaler_2 =
- Clutter::BehaviourScale::create (alpha,
- 1.0, 1.0,
- 0.5, 0.5);
-
- // create a new group to hold multiple actors in a group
- oh.group = Clutter::Group::create();
-
- oh.hands.reserve(num_actors);
- for (int i = 0; i < num_actors; i++)
- {
- gint x, y, w, h;
- gint radius = get_radius(num_actors);
-
- // Create a texture from file, then clone it to save resources
- if (i == 0)
- {
- try
- {
- Glib::RefPtr<Clutter::Texture> texture(Clutter::Texture::create());
- texture->set_from_file("actor.png");
- oh.hands.push_back (texture);
- }
- catch(const Glib::Exception& ex)
- {
- std::cerr << "Could not load texture: " << ex.what() << std::endl;
- return -1;
- }
- }
- else
- {
- oh.hands.push_back(Clutter::CloneTexture::create
- (Glib::RefPtr<Clutter::Texture>::cast_dynamic
- (oh.hands[0])));
- }
-
- // Place around a circle
- w = oh.hands[0]->get_width ();
- h = oh.hands[0]->get_height ();
-
- x = Clutter::Stage::get_default ()->get_width () / 2
- + radius
- * cos (i * M_PI / (num_actors / 2))
- - w / 2;
- y = Clutter::Stage::get_default ()->get_height () / 2
- + radius
- * sin (i * M_PI / (num_actors / 2))
- - h / 2;
-
- oh.hands[i]->set_position (x, y);
- oh.hands[i]->move_anchor_point_from_gravity(Clutter::GRAVITY_CENTER);
-
- // Add to our group group
- oh.group->add_actor(oh.hands[i]);
-
-#if 1 /* FIXME: disabled as causes drift - see comment above */
- if (i % 2)
- scaler_1->apply (oh.hands[i]);
- else
- scaler_2->apply (oh.hands[i]);
+ // Place around a circle
+ int w = oh.hands[0]->get_width();
+ int h = oh.hands[0]->get_height();
+
+ int x = Clutter::Stage::get_default()->get_width() / 2
+ + radius
+ * cos(i * M_PI / (num_actors / 2))
+ - w / 2;
+ int y = Clutter::Stage::get_default()->get_height() / 2
+ + radius
+ * sin(i * M_PI / (num_actors / 2))
+ - h / 2;
+
+ oh.hands[i]->set_position(x, y);
+ oh.hands[i]->move_anchor_point_from_gravity(Clutter::GRAVITY_CENTER);
+
+ // Add to our group group
+ oh.group->add_actor(oh.hands[i]);
+
+#if 1 /* TODO: disabled as causes drift - see comment above */
+ if(i % 2)
+ scaler_1->apply(oh.hands[i]);
+ else
+ scaler_2->apply(oh.hands[i]);
#endif
- }
+ }
- oh.group->show_all ();
+ oh.group->show_all();
- // Add the group to the stage
- stage->add_actor (oh.group);
+ // Add the group to the stage
+ stage->add_actor(oh.group);
- // Show everying ( and map window )
- stage->show_all ();
+ // Show everying ( and map window )
+ stage->show_all();
- stage->signal_button_press_event ().connect (sigc::bind (sigc::ptr_fun
- (on_button_press), stage));
+ stage->signal_button_press_event().connect(sigc::bind(sigc::ptr_fun
+ (on_button_press), stage));
- stage->signal_key_release_event ().connect (sigc::ptr_fun(on_key_release));
+ stage->signal_key_release_event().connect(sigc::ptr_fun(on_key_release));
- // and start it
- timeline->start ();
+ // and start it
+ timeline->start();
- // TODO: wrap clutter_main ?
- Clutter::main();
+ // TODO: wrap clutter_main ?
+ Clutter::main();
- return 0;
+ return 0;
}
Modified: cluttermm/trunk/examples/test-boxes.cc
==============================================================================
--- cluttermm/trunk/examples/test-boxes.cc (original)
+++ cluttermm/trunk/examples/test-boxes.cc Wed Jul 30 10:46:02 2008
@@ -3,110 +3,111 @@
#include <clutter/clutter.h>
static bool
-on_button_press_cb (ClutterButtonEvent *event, const Glib::RefPtr<Clutter::Stage>& stage)
+on_button_press_cb(ClutterButtonEvent* event, const Glib::RefPtr<Clutter::Stage>& stage)
{
- gint x, y;
+ int x = 0;
+ int y = 0;
+ clutter_event_get_coords(reinterpret_cast<ClutterEvent*>(event), &x, &y);
- clutter_event_get_coords (reinterpret_cast<ClutterEvent*>(event), &x, &y);
- Glib::RefPtr<Clutter::Actor> rect = stage->get_actor_at_pos (x, y);
- if (!rect)
+ Glib::RefPtr<Clutter::Actor> rect = stage->get_actor_at_pos(x, y);
+ if(!rect)
return false;
- if (!Glib::RefPtr<Clutter::Rectangle>::cast_dynamic(rect))
- {
- g_print ("[!] No rectangle selected (%s selected instead)\n",
- g_type_name (G_OBJECT_TYPE (rect->gobj())));
- return false;
- }
+ if(!Glib::RefPtr<Clutter::Rectangle>::cast_dynamic(rect))
+ {
+ g_print("[!] No rectangle selected (%s selected instead)\n",
+ g_type_name(G_OBJECT_TYPE(rect->gobj())));
+
+ return false;
+ }
- g_print ("[*] Picked rectangle at (%d, %d)\n", x, y);
+ g_print("[*] Picked rectangle at (%d, %d)\n", x, y);
return false;
}
static bool
-on_key_press_cb (ClutterKeyEvent *event)
+on_key_press_cb(ClutterKeyEvent* event)
{
- if (clutter_key_event_symbol (event) == CLUTTER_Escape)
- clutter_main_quit ();
+ if(clutter_key_event_symbol(event) == CLUTTER_Escape)
+ clutter_main_quit();
return true;
}
int
-main (int argc, char *argv[])
+main(int argc, char* argv[])
{
- Glib::RefPtr<Clutter::Stage> stage;
- Glib::RefPtr<Clutter::VBox> vbox;
- Clutter::Color stage_color (0x00, 0x00, 0x00);
- Clutter::Color label_color (0xff, 0xff, 0xff, 0x99);
- gint i, j;
-
- Clutter::init (&argc, &argv);
-
- stage = Clutter::Stage::get_default ();
- stage->set_size (800, 600);
- stage->set_color (stage_color);
-
- stage->signal_button_press_event ().connect (
- sigc::bind(sigc::ptr_fun(&on_button_press_cb), stage));
- stage->signal_key_press_event ().connect (sigc::ptr_fun(&on_key_press_cb));
-
- vbox = Clutter::VBox::create ();
-
- vbox->set_default_padding (10, 0, 10, 0);
- vbox->set_position (100, 100);
- stage->add_actor (vbox);
- vbox->show ();
+ Glib::RefPtr<Clutter::Stage> stage;
+ Glib::RefPtr<Clutter::VBox> vbox;
+ Clutter::Color stage_color(0x00, 0x00, 0x00);
+ Clutter::Color label_color(0xff, 0xff, 0xff, 0x99);
+
+ Clutter::init(&argc, &argv);
+
+ stage = Clutter::Stage::get_default();
+ stage->set_size(800, 600);
+ stage->set_color(stage_color);
+
+ stage->signal_button_press_event().connect(
+ sigc::bind(sigc::ptr_fun(&on_button_press_cb), stage));
+ stage->signal_key_press_event().connect(sigc::ptr_fun(&on_key_press_cb));
- for (i = 0; i < 3; i++)
+ vbox = Clutter::VBox::create();
+
+ vbox->set_default_padding(10, 0, 10, 0);
+ vbox->set_position(100, 100);
+ stage->add_actor(vbox);
+ vbox->show();
+
+ for(int i = 0; i < 3; i++)
+ {
+ Glib::RefPtr<Clutter::HBox> hbox = Clutter::HBox::create();
+
+ for(int j = 0; j < 3; j++)
{
- Glib::RefPtr<Clutter::HBox> hbox = Clutter::HBox::create ();
+ Glib::RefPtr<Clutter::Rectangle> rect;
+ Clutter::Padding rect_padding;
- for (j = 0; j < 3; j++)
- {
- Glib::RefPtr<Clutter::Rectangle> rect;
- Clutter::Padding rect_padding;
-
- rect = Clutter::Rectangle::create (label_color);
- rect->set_size (100, 100);
-
- rect_padding.top = rect_padding.bottom = 0;
- rect_padding.left = CLUTTER_UNITS_FROM_INT (10);
- rect_padding.right = CLUTTER_UNITS_FROM_INT (10);
-
- hbox->pack (rect,
- Clutter::PACK_START,
- rect_padding);
- rect->show ();
-
- g_print ("rect[%d][%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
- i, j,
- rect->get_x (),
- rect->get_y (),
- rect->get_width (),
- rect->get_height ());
- }
-
- vbox->pack (hbox);
- hbox->show ();
-
- g_print ("hbox[%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
- i,
- hbox->get_x (),
- hbox->get_y (),
- hbox->get_width (),
- hbox->get_height ());
+ rect = Clutter::Rectangle::create(label_color);
+ rect->set_size(100, 100);
+ rect_padding.top = rect_padding.bottom = 0;
+ rect_padding.left = CLUTTER_UNITS_FROM_INT(10);
+ rect_padding.right = CLUTTER_UNITS_FROM_INT(10);
+
+ hbox->pack(rect,
+ Clutter::PACK_START,
+ rect_padding);
+ rect->show();
+
+ g_print("rect[%d][%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
+ i, j,
+ rect->get_x(),
+ rect->get_y(),
+ rect->get_width(),
+ rect->get_height());
}
- stage->show_all ();
+ vbox->pack(hbox);
+ hbox->show();
+
+ g_print("hbox[%d] - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
+ i,
+ hbox->get_x(),
+ hbox->get_y(),
+ hbox->get_width(),
+ hbox->get_height());
+
+ }
+
+ stage->show_all();
- g_print ("vbox - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
- vbox->get_x (),
- vbox->get_y (),
- vbox->get_width (),
- vbox->get_height ());
+ g_print("vbox - (x:%3d, y:%3d, w:%3d, h:%3d)\n",
+ vbox->get_x(),
+ vbox->get_y(),
+ vbox->get_width(),
+ vbox->get_height());
- clutter_main ();
+ clutter_main();
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]