[cluttermm] Adds the Stage example from the reference manual.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cluttermm] Adds the Stage example from the reference manual.
- Date: Mon, 17 Mar 2014 10:24:45 +0000 (UTC)
commit 1c768b4d0fcafb473ee80dfb645650d177f2b8d6
Author: Ian Martin <martin_id vodafone co nz>
Date: Fri Mar 14 20:48:59 2014 +1300
Adds the Stage example from the reference manual.
examples/Makefile.am | 3 +-
examples/example-stage.cc | 68 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+), 1 deletions(-)
---
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 9be61c2..2c255b0 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -15,7 +15,7 @@
## You should have received a copy of the GNU Lesser General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-check_PROGRAMS = actors
+check_PROGRAMS = actors stage
dist_noinst_DATA = actor.png test-boxes.cc
@@ -27,3 +27,4 @@ AM_CXXFLAGS = $(CLUTTERMM_WXXFLAGS)
LDADD = $(CLUTTERMM_LIBS) $(local_libs)
actors_SOURCES = test-actors.cc
+stage_SOURCES = example-stage.cc
diff --git a/examples/example-stage.cc b/examples/example-stage.cc
new file mode 100644
index 0000000..bfcda66
--- /dev/null
+++ b/examples/example-stage.cc
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2008 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+// c++ -Wall -g `pkg-config --cflags --libs cluttermm-1.0` -o stage example-stage.cc
+
+/**A simple ClutterStage. */
+#include <cluttermm.h>
+#include <iostream>
+
+namespace
+{
+
+bool on_stage_button_press(Clutter::ButtonEvent* event)
+{
+ float x = 0;
+ float y = 0;
+ // TODO: Wrap properly
+ clutter_event_get_coords(reinterpret_cast<Clutter::Event*>(event), &x, &y);
+
+ std::cout << "Stage clicked at (" << x << ", " << y << ")\n";
+
+ return true; // stop further handling of this event
+}
+
+} // anonymous namespace
+
+int main(int argc, char** argv)
+{
+ try
+ {
+ Clutter::init(&argc, &argv);
+
+ // Get the stage and set its size and color:
+ Glib::RefPtr<Clutter::Stage> stage = Clutter::Stage::create();
+ stage->set_size(200, 200);
+ //stage->set_background_color(Clutter::Color(0, 0, 0)); // black
+
+ stage->show();
+
+ // Connect a signal handler to handle mouse clicks:
+ stage->signal_button_press_event().connect(&on_stage_button_press);
+
+ // Start the main loop, so we can respond to events:
+ Clutter::main();
+ }
+ catch (const Glib::Error& error)
+ {
+ std::cerr << "returned an error." << std::endl;
+ std::cerr << "Exception: " << error.what() << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]