diff options
author | David Robillard <d@drobilla.net> | 2011-12-10 05:21:00 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-12-10 05:21:00 +0000 |
commit | a7a3bce6d878c1150946a99f85bc58fc4fcd6256 (patch) | |
tree | c57547203382a68a043911cf917e303b69955277 | |
parent | 985d9b8babb2faac0de62cb684fc14c7910e9909 (diff) | |
download | ganv-a7a3bce6d878c1150946a99f85bc58fc4fcd6256.tar.gz ganv-a7a3bce6d878c1150946a99f85bc58fc4fcd6256.tar.bz2 ganv-a7a3bce6d878c1150946a99f85bc58fc4fcd6256.zip |
Fix event handling.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3852 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | ganv/Node.hpp | 9 | ||||
-rw-r--r-- | ganv/node.h | 3 | ||||
-rw-r--r-- | src/Canvas.cpp | 2 | ||||
-rw-r--r-- | src/node.c | 43 | ||||
-rw-r--r-- | src/port.c | 9 |
5 files changed, 31 insertions, 35 deletions
diff --git a/ganv/Node.hpp b/ganv/Node.hpp index 6bdb96c..3359ac3 100644 --- a/ganv/Node.hpp +++ b/ganv/Node.hpp @@ -73,10 +73,15 @@ public: METHOD0(ganv_node, disconnect); - sigc::signal<void, double, double> signal_moved; + sigc::signal<void, double, double>& signal_moved() { + return _signal_moved; + } + +private: + sigc::signal<void, double, double> _signal_moved; static void on_moved(GanvNode* node, double x, double y) { - Glib::wrap(node)->signal_moved.emit(x, y); + Glib::wrap(node)->_signal_moved.emit(x, y); } }; diff --git a/ganv/node.h b/ganv/node.h index e1f39ac..7c14b53 100644 --- a/ganv/node.h +++ b/ganv/node.h @@ -75,9 +75,6 @@ struct _GanvNodeClass { double* y, double* dx, double* dy); - - gboolean (*on_event)(GanvNode* node, - GdkEvent* event); }; GType ganv_node_get_type(void); diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 9de1a43..ca7a9ad 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -1366,7 +1366,7 @@ Canvas::Canvas(double width, double height) { g_object_set_qdata(G_OBJECT(impl()->_gcanvas), wrapper_key(), this); - g_signal_connect_after(gobj(), "event", + g_signal_connect_after(impl()->root(), "event", G_CALLBACK(on_event_after), this); g_signal_connect(gobj(), "connect", G_CALLBACK(on_connect), this); @@ -45,12 +45,6 @@ enum { PROP_DRAGGABLE }; -static gboolean -on_event(GanvNode* node, GdkEvent* event) -{ - return GANV_NODE_GET_CLASS(node)->on_event(node, event); -} - static void ganv_node_init(GanvNode* node) { @@ -71,9 +65,6 @@ ganv_node_init(GanvNode* node) impl->selected = FALSE; impl->highlighted = FALSE; impl->draggable = FALSE; - - g_signal_connect(G_OBJECT(node), - "event", G_CALLBACK(on_event), node); } static void @@ -120,9 +111,9 @@ ganv_node_set_property(GObject* object, g_return_if_fail(object != NULL); g_return_if_fail(GANV_IS_NODE(object)); - GanvNode* node = GANV_NODE(object); - GanvNodeImpl* impl = node->impl; - GanvItem* item = GANV_ITEM(object); + GanvNode* node = GANV_NODE(object); + GanvNodeImpl* impl = node->impl; + GanvItem* item = GANV_ITEM(object); switch (prop_id) { SET_CASE(PARTNER, object, impl->partner); @@ -164,9 +155,9 @@ ganv_node_get_property(GObject* object, g_return_if_fail(object != NULL); g_return_if_fail(GANV_IS_NODE(object)); - GanvNode* node = GANV_NODE(object); - GanvNodeImpl* impl = node->impl; - GanvItem* item = GANV_ITEM(object); + GanvNode* node = GANV_NODE(object); + GanvNodeImpl* impl = node->impl; + GanvItem* item = GANV_ITEM(object); typedef char* gstring; @@ -329,9 +320,10 @@ ganv_node_default_move_to(GanvNode* node, } static gboolean -ganv_node_default_on_event(GanvNode* node, - GdkEvent* event) +ganv_node_default_event(GanvItem* item, + GdkEvent* event) { + GanvNode* node = GANV_NODE(item); GanvCanvas* canvas = GANV_CANVAS(GANV_ITEM(node)->canvas); // FIXME: put these somewhere better @@ -580,15 +572,16 @@ ganv_node_class_init(GanvNodeClass* class) object_class->destroy = ganv_node_destroy; item_class->realize = ganv_node_realize; - - class->disconnect = ganv_node_default_disconnect; - class->move = ganv_node_default_move; - class->move_to = ganv_node_default_move_to; - class->tick = ganv_node_default_tick; - class->tail_vector = ganv_node_default_tail_vector; - class->head_vector = ganv_node_default_head_vector; - class->on_event = ganv_node_default_on_event; + item_class->event = ganv_node_default_event; + + class->disconnect = ganv_node_default_disconnect; + class->move = ganv_node_default_move; + class->move_to = ganv_node_default_move_to; + class->tick = ganv_node_default_tick; + class->tail_vector = ganv_node_default_tail_vector; + class->head_vector = ganv_node_default_head_vector; } + gboolean ganv_node_can_tail(const GanvNode* self) { @@ -203,12 +203,11 @@ ganv_port_set_height(GanvBox* box, } static gboolean -on_event(GanvNode* node, GdkEvent* event) +event(GanvItem* item, GdkEvent* event) { - GanvItem* item = GANV_ITEM(node); GanvCanvas* canvas = GANV_CANVAS(item->canvas); - return ganv_canvas_port_event(canvas, GANV_PORT(node), event); + return ganv_canvas_port_event(canvas, GANV_PORT(item), event); } static void @@ -216,6 +215,7 @@ ganv_port_class_init(GanvPortClass* class) { GObjectClass* gobject_class = (GObjectClass*)class; GtkObjectClass* object_class = (GtkObjectClass*)class; + GanvItemClass* item_class = (GanvItemClass*)class; GanvNodeClass* node_class = (GanvNodeClass*)class; GanvBoxClass* box_class = (GanvBoxClass*)class; @@ -236,7 +236,8 @@ ganv_port_class_init(GanvPortClass* class) object_class->destroy = ganv_port_destroy; - node_class->on_event = on_event; + item_class->event = event; + node_class->tail_vector = ganv_port_tail_vector; node_class->head_vector = ganv_port_head_vector; node_class->resize = ganv_port_resize; |