summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-07 19:00:42 +0000
committerDavid Robillard <d@drobilla.net>2011-12-07 19:00:42 +0000
commitd106c0a03d7c2e1b29a461195552e0cb95191bc4 (patch)
tree7ae7c8b6a809f191588ee63eb7ad93fb4000f9ac
parentbbec2793593ff1e06349c7d40c1b5139f6c1bfcd (diff)
downloadganv-d106c0a03d7c2e1b29a461195552e0cb95191bc4.tar.gz
ganv-d106c0a03d7c2e1b29a461195552e0cb95191bc4.tar.bz2
ganv-d106c0a03d7c2e1b29a461195552e0cb95191bc4.zip
Fix event handling.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@3829 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ganv/Canvas.hpp15
-rw-r--r--src/Canvas.cpp25
2 files changed, 21 insertions, 19 deletions
diff --git a/ganv/Canvas.hpp b/ganv/Canvas.hpp
index aa6cb95..139d5ab 100644
--- a/ganv/Canvas.hpp
+++ b/ganv/Canvas.hpp
@@ -121,20 +121,6 @@ public:
/** Return the current flow direction of the canvas. */
FlowDirection direction() const;
- /**
- Called whenever a edge is made.
- This should be overridden by an implementation to do something.
- */
- virtual void connect(Node* /*tail*/,
- Node* /*head*/) {}
-
- /**
- Called whenever a edge is severed.
- This should be overridden by an implementation to do something.
- */
- virtual void disconnect(Node* /*tail*/,
- Node* /*head*/) {}
-
typedef void (*NodeFunction)(GanvNode* node, void* data);
void for_each_node(NodeFunction f, void* data);
@@ -169,6 +155,7 @@ public:
GanvCanvas* gobj();
const GanvCanvas* gobj() const;
+ sigc::signal<bool, GdkEvent*> signal_event;
sigc::signal<void, Node*, Node*> signal_connect;
sigc::signal<void, Node*, Node*> signal_disconnect;
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index 775e9be..601c882 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -742,10 +742,12 @@ GanvCanvasImpl::on_event(GdkEvent* event)
{
static const int scroll_increment = 10;
int scroll_x, scroll_y;
- gnome_canvas_get_scroll_offsets(GNOME_CANVAS(_gcanvas), &scroll_x, &scroll_y);
+ bool handled = false;
switch (event->type) {
case GDK_KEY_PRESS:
+ handled = true;
+ gnome_canvas_get_scroll_offsets(GNOME_CANVAS(_gcanvas), &scroll_x, &scroll_y);
switch (event->key.keyval) {
case GDK_Up:
scroll_y -= scroll_increment;
@@ -764,12 +766,15 @@ GanvCanvasImpl::on_event(GdkEvent* event)
join_selection();
clear_selection();
}
- return true;
+ break;
default:
- return false;
+ handled = false;
}
- gnome_canvas_scroll_to(GNOME_CANVAS(_gcanvas), scroll_x, scroll_y);
- return true;
+ if (handled) {
+ gnome_canvas_scroll_to(GNOME_CANVAS(_gcanvas), scroll_x, scroll_y);
+ return true;
+ }
+ break;
case GDK_SCROLL:
if ((event->scroll.state & GDK_CONTROL_MASK)) {
@@ -1333,6 +1338,14 @@ GanvCanvasImpl::resize(double width, double height)
namespace Ganv {
+static gboolean
+on_event_after(GnomeCanvasItem* canvasitem,
+ GdkEvent* ev,
+ void* canvas)
+{
+ return ((Canvas*)canvas)->signal_event.emit(ev);
+}
+
static void
on_connect(GanvCanvas* canvas, GanvNode* tail, GanvNode* head, void* data)
{
@@ -1352,6 +1365,8 @@ Canvas::Canvas(double width, double height)
{
g_object_set_qdata(G_OBJECT(impl()->_gcanvas), wrapper_key(), this);
+ g_signal_connect_after(gobj(), "event",
+ G_CALLBACK(on_event_after), this);
g_signal_connect(gobj(), "connect",
G_CALLBACK(on_connect), this);
g_signal_connect(gobj(), "disconnect",