gnomemm r1986 - in clutter-gtkmm/trunk: . clutter-gtk clutter-gtk/clutter-gtkmm clutter-gtk/src examples examples/events



Author: siavashs
Date: Sun Jan 11 21:43:58 2009
New Revision: 1986
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1986&view=rev

Log:
* Hand coded utility functions, ported events example from C API

  * clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.cc:
  * clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.h: Hand coded
  utility functions
  * clutter-gtkmm/trunk/examples/events/Makefile.am:
  * clutter-gtkmm/trunk/examples/events/event.cc:
  * clutter-gtkmm/trunk/examples/events/event.h:
  * clutter-gtkmm/trunk/examples/events/main.cc: New example ported from
  clutter-gtk
  * clutter-gtk/clutter-gtkmm.h:
  * clutter-gtk/clutter-gtkmm/Makefile.am:
  * clutter-gtk/clutter-gtkmm/init.cc:
  * clutter-gtk/src/embed.hg: Updated Copyright
  * configure.in:
  * examples/Makefile.am:
  * examples/actor.png: Renamed to redhand.png
  * examples/embed-gtk.cc: Removed

Added:
   clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.cc
   clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.h
   clutter-gtkmm/trunk/examples/events/
   clutter-gtkmm/trunk/examples/events/Makefile.am
   clutter-gtkmm/trunk/examples/events/event.cc
   clutter-gtkmm/trunk/examples/events/event.h
   clutter-gtkmm/trunk/examples/events/main.cc
   clutter-gtkmm/trunk/examples/events/main.o
   clutter-gtkmm/trunk/examples/redhand.png
      - copied, changed from r1985, /clutter-gtkmm/trunk/examples/actor.png
Removed:
   clutter-gtkmm/trunk/examples/actor.png
   clutter-gtkmm/trunk/examples/embed-gtk.cc
Modified:
   clutter-gtkmm/trunk/ChangeLog
   clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm.h
   clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/Makefile.am
   clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/init.cc
   clutter-gtkmm/trunk/clutter-gtk/src/embed.hg
   clutter-gtkmm/trunk/configure.in
   clutter-gtkmm/trunk/examples/Makefile.am

Modified: clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm.h
==============================================================================
--- clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm.h	(original)
+++ clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm.h	Sun Jan 11 21:43:58 2009
@@ -1,6 +1,6 @@
-/* cluttermm-gtk - a C++ wrapper for clutter-gtk
+/* clutter-gtkmm - a C++ wrapper for clutter-gtk
  *
- * Copyright 2007 The cluttermm Development Team
+ * Copyright 2008-2009 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
@@ -29,5 +29,6 @@
 #include <clutter-gtkmm/init.h>
 #include <clutter-gtkmm/embed.h>
 #include <clutter-gtkmm/viewport.h>
+#include <clutter-gtkmm/utility.h>
 
 #endif /* #ifndef LIBCLUTTER_GTKMM_H */

Modified: clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/Makefile.am
==============================================================================
--- clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/Makefile.am	(original)
+++ clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/Makefile.am	Sun Jan 11 21:43:58 2009
@@ -10,8 +10,8 @@
 sublib_cflags = $(CLUTTER_GTKMM_CFLAGS)
 sublib_topdir = clutter-gtk
 
-files_extra_h = wrap_init.h init.h
-files_extra_cc = init.cc
+files_extra_h = wrap_init.h init.h utility.h
+files_extra_cc = init.cc utility.cc
 
 include $(top_srcdir)/build_shared/Makefile_build_gensrc.am_fragment
 

Modified: clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/init.cc
==============================================================================
--- clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/init.cc	(original)
+++ clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/init.cc	Sun Jan 11 21:43:58 2009
@@ -1,6 +1,6 @@
 // -*- c++ -*-
 /*
- * Copyright 2008 Jonathon Jongsma
+ * Copyright 2008-2009 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

Added: clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.cc
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.cc	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,99 @@
+// -*- c++ -*-
+/*
+ * Copyright 2008-2009 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-gtkmm/utility.h>
+#include <clutter-gtk/clutter-gtk.h>
+
+namespace Clutter
+{
+namespace Gtk
+{
+
+void get_fg_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_fg_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_bg_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_bg_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_text_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_text_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_base_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_base_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_text_aa_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_text_aa_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_light_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_light_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_mid_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_mid_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+void get_dark_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color)
+{
+  gtk_clutter_get_dark_color(widget.gobj(), GtkStateType(state), color.gobj());
+}
+
+Glib::RefPtr<Texture> create_texture_from_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
+{
+  return Glib::wrap(CLUTTER_TEXTURE(gtk_clutter_texture_new_from_pixbuf(pixbuf->gobj())));
+}
+
+Glib::RefPtr<Texture> create_texture_from_stock(::Gtk::Widget& widget, const Glib::ustring& stock_id, ::Gtk::IconSize size)
+{
+  return Glib::wrap(CLUTTER_TEXTURE(gtk_clutter_texture_new_from_stock(widget.gobj(), stock_id.c_str(), GtkIconSize(int(size)))));
+}
+
+Glib::RefPtr<Texture> create_texture_from_icon_name(::Gtk::Widget& widget, const Glib::ustring& icon_name, ::Gtk::IconSize size)
+{
+  return Glib::wrap(CLUTTER_TEXTURE(gtk_clutter_texture_new_from_icon_name(widget.gobj(), icon_name.c_str(), GtkIconSize(int(size)))));
+}
+
+void set_texture_from_pixbuf(const Glib::RefPtr<Texture>& texture, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf)
+{
+  gtk_clutter_texture_set_from_pixbuf(texture->gobj(), pixbuf->gobj());
+}
+
+void set_texture_from_stock(const Glib::RefPtr<Texture>& texture, ::Gtk::Widget& widget, const Glib::ustring& stock_id, ::Gtk::IconSize size)
+{
+  gtk_clutter_texture_set_from_stock(texture->gobj(), widget.gobj(), stock_id.c_str(), GtkIconSize(int(size)));
+}
+
+void set_texture_from_icon_name(const Glib::RefPtr<Texture>& texture, ::Gtk::Widget& widget, const Glib::ustring& icon_name, ::Gtk::IconSize size)
+{
+  gtk_clutter_texture_set_from_icon_name(texture->gobj(), widget.gobj(), icon_name.c_str(), GtkIconSize(int(size)));
+}
+
+} //namespace Gtk
+} //namespace Clutter

Added: clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.h
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/clutter-gtk/clutter-gtkmm/utility.h	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,49 @@
+// -*- c++ -*-
+#ifndef _LIBCLUTTER_GTKMM_UTILITY_H
+#define _LIBCLUTTER_GTKMM_UTILITY_H
+/*
+ * Copyright 2008-2009 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 <gtkmm/widget.h>
+#include <cluttermm/texture.h>
+
+namespace Clutter
+{
+namespace Gtk
+{
+
+void get_fg_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_bg_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_text_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_base_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_text_aa_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_light_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_mid_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+void get_dark_color(::Gtk::Widget& widget, ::Gtk::StateType state, Color& color);
+Glib::RefPtr<Texture> create_texture_from_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
+Glib::RefPtr<Texture> create_texture_from_stock(::Gtk::Widget& widget, const Glib::ustring& stock_id, ::Gtk::IconSize size);
+Glib::RefPtr<Texture> create_texture_from_icon_name(::Gtk::Widget& widget, const Glib::ustring& icon_name, ::Gtk::IconSize size);
+void set_texture_from_pixbuf(const Glib::RefPtr<Texture>& texture, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
+void set_texture_from_stock(const Glib::RefPtr<Texture>& texture, ::Gtk::Widget& widget, const Glib::ustring& stock_id, ::Gtk::IconSize size);
+void set_texture_from_icon_name(const Glib::RefPtr<Texture>& texture, ::Gtk::Widget& widget, const Glib::ustring& icon_name, ::Gtk::IconSize size);
+
+} //namespace Gtk
+} //namespace Clutter
+
+#endif //_LIBCLUTTER_GTKMM_UTILITY_H
+

Modified: clutter-gtkmm/trunk/clutter-gtk/src/embed.hg
==============================================================================
--- clutter-gtkmm/trunk/clutter-gtk/src/embed.hg	(original)
+++ clutter-gtkmm/trunk/clutter-gtk/src/embed.hg	Sun Jan 11 21:43:58 2009
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007 The cluttermm Development Team
+/* Copyright (C) 2008-2009 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

Modified: clutter-gtkmm/trunk/configure.in
==============================================================================
--- clutter-gtkmm/trunk/configure.in	(original)
+++ clutter-gtkmm/trunk/configure.in	Sun Jan 11 21:43:58 2009
@@ -120,6 +120,7 @@
     docs/reference/Doxyfile
 
   examples/Makefile
+    examples/events/Makefile
   tests/Makefile
 ])
 :

Modified: clutter-gtkmm/trunk/examples/Makefile.am
==============================================================================
--- clutter-gtkmm/trunk/examples/Makefile.am	(original)
+++ clutter-gtkmm/trunk/examples/Makefile.am	Sun Jan 11 21:43:58 2009
@@ -1,9 +1,6 @@
-SUBDIRS = 
+SUBDIRS = events
 
 include Makefile.am_fragment
 
-noinst_PROGRAMS = embed-gtk
-embed_gtk_SOURCES = embed-gtk.cc
-
-EXTRA_DIST = actor.png
+EXTRA_DIST = redhand.png
 

Added: clutter-gtkmm/trunk/examples/events/Makefile.am
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/examples/events/Makefile.am	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,6 @@
+include $(top_srcdir)/examples/Makefile.am_fragment
+
+#Build the executable, but don't install it.
+noinst_PROGRAMS = events
+events_SOURCES = main.cc event.cc event.h
+

Added: clutter-gtkmm/trunk/examples/events/event.cc
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/examples/events/event.cc	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,147 @@
+#include "event.h"
+
+Event::Event()
+: label_x("Rotate x-axis")
+, label_y("Rotate y-axis")
+, label_z("Rotate z-axis")
+, label_opacity("Adjust opacity")
+, adjustment_x(0.0, 0.0, 360.0)
+, adjustment_y(0.0, 0.0, 360.0)
+, adjustment_z(0.0, 0.0, 360.0)
+, adjustment_opacity(255.0, 0.0, 255.0)
+, spin_x(adjustment_x)
+, spin_y(adjustment_y)
+, spin_z(adjustment_z)
+, spin_opacity(adjustment_opacity)
+{
+  set_title("Gtkmm-Cluttermm Interaction demo");
+  set_default_size(800, 600);
+  set_resizable(false);
+  set_border_width(12);
+
+  vbox.set_spacing(12);
+  add(vbox);
+
+  gtk_entry.set_text("Enter some text");
+  vbox.pack_start(gtk_entry);
+  gtk_entry.signal_changed().connect(sigc::mem_fun(*this, &Event::on_gtk_entry_changed));
+
+  hbox.set_spacing(12);
+  vbox.pack_start(hbox, true, true);
+
+  hbox.pack_start(embed, true, true);
+
+  stage = embed.get_stage();
+  Clutter::Color stage_color;
+  Clutter::Gtk::get_bg_color(*this, Gtk::STATE_NORMAL, stage_color);
+  stage->set_color(stage_color);
+  embed.set_size_request(640, 480);
+  stage->signal_captured_event().connect(sigc::mem_fun(*this, &Event::on_stage_capture));
+
+  hand = Clutter::Texture::create_from_file("../redhand.png");
+  if(!hand)
+    g_error("Unable to load pixbuf\n");
+
+  stage->add_actor(hand);
+  unsigned int width, height;
+  hand->get_size(width, height);
+  hand->set_position((CLUTTER_STAGE_WIDTH()/2) - (width/2), (CLUTTER_STAGE_HEIGHT()/2) - (height/2));
+  hand->set_reactive();
+  hand->signal_button_press_event().connect(sigc::mem_fun(*this, &Event::on_hand_button_press));
+
+  Clutter::Color text_color;
+  //Clutter::Gtk::get_text_color(*this, Gtk::STATE_NORMAL, text_color);
+  clutter_entry = Clutter::Text::create("Sans 10", "", text_color);
+  stage->add_actor(clutter_entry);
+  clutter_entry->set_position(0, 0);
+  clutter_entry->set_size(500, 20);
+
+  vbox2.set_spacing(6);
+  hbox.pack_start(vbox2);
+
+  hbox_x.set_spacing(6);
+  vbox2.pack_start(hbox_x, false, true);
+
+  hbox_x.pack_start(label_x, true, true);
+  hbox_x.pack_start(spin_x, true, true);
+  spin_x.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_x_changed));
+  
+  hbox_y.set_spacing(6);
+  vbox2.pack_start(hbox_y, false, true);
+
+  hbox_y.pack_start(label_y, true, true);
+  hbox_y.pack_start(spin_y, true, true);
+  spin_y.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_y_changed));
+
+  hbox_z.set_spacing(6);
+  vbox2.pack_start(hbox_z, false, true);
+
+  hbox_z.pack_start(label_z, true, true);
+  hbox_z.pack_start(spin_z, true, true);
+  spin_z.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_z_changed));
+
+  hbox_opacity.set_spacing(6);
+  vbox2.pack_start(hbox_opacity, false, true);
+
+  hbox_opacity.pack_start(label_opacity, true, true);
+  hbox_opacity.pack_start(spin_opacity, true, true);
+  spin_opacity.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_opacity_changed));
+
+  show_all();
+
+  /* Only show/show_all the stage after parent show. widget_show will call
+   * show on the stage.
+  */
+  stage->show_all();
+}
+
+Event::~Event()
+{
+}
+
+void Event::on_gtk_entry_changed()
+{
+  clutter_entry->set_text(gtk_entry.get_text());
+}
+
+bool Event::on_stage_capture(Clutter::Event* event)
+{
+  if (event->type == CLUTTER_BUTTON_RELEASE)
+    {
+      int x, y;
+
+      clutter_event_get_coords(event, &x, &y);
+
+      g_print("Event captured at (%d, %d)\n", x, y);
+    }
+
+  return false;
+}
+
+bool Event::on_hand_button_press(Clutter::ButtonEvent* event)
+{
+  g_print("Button press on hand ('%s')\n", g_type_name(G_OBJECT_TYPE(hand->gobj())));
+
+  return false;
+}
+
+void Event::on_x_changed()
+{
+  hand->set_rotation(Clutter::X_AXIS, spin_x.get_value(), 0, hand->get_height() / 2, 0);
+}
+
+void Event::on_y_changed()
+{
+  hand->set_rotation(Clutter::Y_AXIS, spin_y.get_value(), hand->get_width() / 2, 0, 0);
+}
+
+void Event::on_z_changed()
+{
+  hand->set_rotation(Clutter::Z_AXIS, spin_z.get_value(), hand->get_width() / 2, hand->get_height() / 2, 0);
+}
+
+void Event::on_opacity_changed()
+{
+  hand->set_opacity(spin_opacity.get_value());
+}
+

Added: clutter-gtkmm/trunk/examples/events/event.h
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/examples/events/event.h	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,33 @@
+#include <gtkmm.h>
+#include <cluttermm.h>
+#include <clutter-gtkmm.h>
+
+class Event : public Gtk::Window
+{
+public:
+  Event();
+  ~Event();
+
+protected:
+  virtual void on_gtk_entry_changed();
+  virtual bool on_stage_capture(Clutter::Event* event);
+  virtual bool on_hand_button_press(Clutter::ButtonEvent* event);
+  virtual void on_x_changed();
+  virtual void on_y_changed();
+  virtual void on_z_changed();
+  virtual void on_opacity_changed();
+
+  Gtk::VBox vbox, vbox2;
+  Gtk::HBox hbox, hbox_x, hbox_y, hbox_z, hbox_opacity;
+  Gtk::Entry gtk_entry;
+  Gtk::Button button;
+  Gtk::Label label_x, label_y, label_z, label_opacity;
+  Gtk::Adjustment adjustment_x, adjustment_y, adjustment_z, adjustment_opacity;
+  Gtk::SpinButton spin_x, spin_y, spin_z, spin_opacity;
+
+  Clutter::Gtk::Embed embed;
+  Glib::RefPtr<Clutter::Stage> stage;
+  Glib::RefPtr<Clutter::Texture> hand;
+  Glib::RefPtr<Clutter::Text> clutter_entry;
+  
+};

Added: clutter-gtkmm/trunk/examples/events/main.cc
==============================================================================
--- (empty file)
+++ clutter-gtkmm/trunk/examples/events/main.cc	Sun Jan 11 21:43:58 2009
@@ -0,0 +1,19 @@
+#include <gtkmm.h>
+#include <clutter-gtkmm.h>
+
+#include "event.h"
+
+int main(int argc, char** argv)
+{
+	// init cluttermm-gtk
+	Clutter::Gtk::init(&argc, &argv);
+
+	// init gtkmm
+	Gtk::Main kit(argc, argv);
+
+	Event event;
+
+  kit.run(event);
+
+  return 0;
+}

Added: clutter-gtkmm/trunk/examples/events/main.o
==============================================================================
Binary files (empty file) and clutter-gtkmm/trunk/examples/events/main.o	Sun Jan 11 21:43:58 2009 differ

Copied: clutter-gtkmm/trunk/examples/redhand.png (from r1985, /clutter-gtkmm/trunk/examples/actor.png)
==============================================================================
Binary files. No diff available.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]