gnomemm r1987 - in clutter-gtkmm/trunk: . examples/events
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1987 - in clutter-gtkmm/trunk: . examples/events
- Date: Mon, 12 Jan 2009 09:08:52 +0000 (UTC)
Author: murrayc
Date: Mon Jan 12 09:08:52 2009
New Revision: 1987
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1987&view=rev
Log:
2009-01-12 Murray Cumming <murrayc murrayc com>
* examples/events/event.[h|cc]: Correct the coding style to match
gtkmm examples: Use of m_, use of Gtk::PACK*, use of std::cout,
no unnecessary virtuals.
Removed:
clutter-gtkmm/trunk/examples/events/main.o
Modified:
clutter-gtkmm/trunk/ChangeLog
clutter-gtkmm/trunk/examples/events/event.cc
clutter-gtkmm/trunk/examples/events/event.h
Modified: clutter-gtkmm/trunk/examples/events/event.cc
==============================================================================
--- clutter-gtkmm/trunk/examples/events/event.cc (original)
+++ clutter-gtkmm/trunk/examples/events/event.cc Mon Jan 12 09:08:52 2009
@@ -1,98 +1,100 @@
#include "event.h"
+#include <iostream>
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)
+: m_label_x("Rotate x-axis"),
+ m_label_y("Rotate y-axis"),
+ m_label_z("Rotate z-axis"),
+ m_label_opacity("Adjust opacity"),
+ m_adjustment_x(0.0, 0.0, 360.0),
+ m_adjustment_y(0.0, 0.0, 360.0),
+ m_adjustment_z(0.0, 0.0, 360.0),
+ m_adjustment_opacity(255.0, 0.0, 255.0),
+ m_spin_x(m_adjustment_x),
+ m_spin_y(m_adjustment_y),
+ m_spin_z(m_adjustment_z),
+ m_spin_opacity(m_adjustment_opacity)
{
- set_title("Gtkmm-Cluttermm Interaction demo");
+ set_title("clutter-gtkmm Interaction demo");
set_default_size(800, 600);
set_resizable(false);
set_border_width(12);
- vbox.set_spacing(12);
- add(vbox);
+ m_vbox.set_spacing(12);
+ add(m_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));
+ m_gtk_entry.set_text("Enter some text");
+ m_vbox.pack_start(m_gtk_entry);
+ m_gtk_entry.signal_changed().connect(sigc::mem_fun(*this, &Event::on_gtk_entry_changed));
- hbox.set_spacing(12);
- vbox.pack_start(hbox, true, true);
+ m_hbox.set_spacing(12);
+ m_vbox.pack_start(m_hbox);
- hbox.pack_start(embed, true, true);
+ m_hbox.pack_start(m_embed);
- stage = embed.get_stage();
+ m_stage = m_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));
+ m_stage->set_color(stage_color);
+ m_embed.set_size_request(640, 480);
+ m_stage->signal_captured_event().connect(sigc::mem_fun(*this, &Event::on_stage_capture));
- hand = Clutter::Texture::create_from_file("../redhand.png");
- if(!hand)
+ m_hand = Clutter::Texture::create_from_file("../redhand.png");
+ if(!m_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));
+ m_stage->add_actor(m_hand);
+ guint width = 0;
+ guint height = 0;
+ m_hand->get_size(width, height);
+ m_hand->set_position((CLUTTER_STAGE_WIDTH()/2) - (width/2), (CLUTTER_STAGE_HEIGHT()/2) - (height/2));
+ m_hand->set_reactive();
+ m_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));
+ m_clutter_entry = Clutter::Text::create("Sans 10", "", text_color);
+ m_stage->add_actor(m_clutter_entry);
+ m_clutter_entry->set_position(0, 0);
+ m_clutter_entry->set_size(500, 20);
+
+ m_vbox2.set_spacing(6);
+ m_hbox.pack_start(m_vbox2);
+
+ m_hbox_x.set_spacing(6);
+ m_vbox2.pack_start(m_hbox_x, Gtk::PACK_SHRINK);
+
+ m_hbox_x.pack_start(m_label_x);
+ m_hbox_x.pack_start(m_spin_x);
+ m_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);
+ m_hbox_y.set_spacing(6);
+ m_vbox2.pack_start(m_hbox_y, Gtk::PACK_SHRINK);
- 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));
+ m_hbox_y.pack_start(m_label_y);
+ m_hbox_y.pack_start(m_spin_y);
+ m_spin_y.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_y_changed));
+
+ m_hbox_z.set_spacing(6);
+ m_vbox2.pack_start(m_hbox_z, Gtk::PACK_SHRINK);
+
+ m_hbox_z.pack_start(m_label_z);
+ m_hbox_z.pack_start(m_spin_z);
+ m_spin_z.signal_value_changed().connect(sigc::mem_fun(*this, &Event::on_z_changed));
+
+ m_hbox_opacity.set_spacing(6);
+ m_vbox2.pack_start(m_hbox_opacity, Gtk::PACK_SHRINK);
+
+ m_hbox_opacity.pack_start(m_label_opacity);
+ m_hbox_opacity.pack_start(m_spin_opacity);
+ m_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();
+ m_stage->show_all();
}
Event::~Event()
@@ -101,47 +103,47 @@
void Event::on_gtk_entry_changed()
{
- clutter_entry->set_text(gtk_entry.get_text());
+ m_clutter_entry->set_text(m_gtk_entry.get_text());
}
bool Event::on_stage_capture(Clutter::Event* event)
{
- if (event->type == CLUTTER_BUTTON_RELEASE)
- {
- int x, y;
+ if(event->type == CLUTTER_BUTTON_RELEASE)
+ {
+ int x = 0;
+ int y = 0;
+ clutter_event_get_coords(event, &x, &y);
- clutter_event_get_coords(event, &x, &y);
-
- g_print("Event captured at (%d, %d)\n", x, y);
- }
+ std::cout << "Event captured at (" << x << ", " << y << ")" << std::endl;
+ }
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())));
+ g_print("Button press on hand ('%s')\n", g_type_name(G_OBJECT_TYPE(m_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);
+ m_hand->set_rotation(Clutter::X_AXIS, m_spin_x.get_value(), 0, m_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);
+ m_hand->set_rotation(Clutter::Y_AXIS, m_spin_y.get_value(), m_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);
+ m_hand->set_rotation(Clutter::Z_AXIS, m_spin_z.get_value(), m_hand->get_width() / 2, m_hand->get_height() / 2, 0);
}
void Event::on_opacity_changed()
{
- hand->set_opacity(spin_opacity.get_value());
+ m_hand->set_opacity(m_spin_opacity.get_value());
}
Modified: clutter-gtkmm/trunk/examples/events/event.h
==============================================================================
--- clutter-gtkmm/trunk/examples/events/event.h (original)
+++ clutter-gtkmm/trunk/examples/events/event.h Mon Jan 12 09:08:52 2009
@@ -9,25 +9,25 @@
~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();
+ void on_gtk_entry_changed();
+ bool on_stage_capture(Clutter::Event* event);
+ bool on_hand_button_press(Clutter::ButtonEvent* event);
+ void on_x_changed();
+ void on_y_changed();
+ void on_z_changed();
+ 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;
+ Gtk::VBox m_vbox, m_vbox2;
+ Gtk::HBox m_hbox, m_hbox_x, m_hbox_y, m_hbox_z, m_hbox_opacity;
+ Gtk::Entry m_gtk_entry;
+ Gtk::Button m_button;
+ Gtk::Label m_label_x, m_label_y, m_label_z, m_label_opacity;
+ Gtk::Adjustment m_adjustment_x, m_adjustment_y, m_adjustment_z, m_adjustment_opacity;
+ Gtk::SpinButton m_spin_x, m_spin_y, m_spin_z, m_spin_opacity;
- Clutter::Gtk::Embed embed;
- Glib::RefPtr<Clutter::Stage> stage;
- Glib::RefPtr<Clutter::Texture> hand;
- Glib::RefPtr<Clutter::Text> clutter_entry;
-
+ Clutter::Gtk::Embed m_embed;
+ Glib::RefPtr<Clutter::Stage> m_stage;
+ Glib::RefPtr<Clutter::Texture> m_hand;
+ Glib::RefPtr<Clutter::Text> m_clutter_entry;
};
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]