diff options
author | David Robillard <d@drobilla.net> | 2011-11-25 04:02:49 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-11-25 04:02:49 +0000 |
commit | 572adb6873294bf2f26062cf297660aa449eb675 (patch) | |
tree | a1073ae1d3f50474a6c0983e11d418b88b309d62 /src/PatchageCanvas.cpp | |
parent | b5f4e302523971c305fbc4a815705913ac565d6a (diff) | |
download | patchage-572adb6873294bf2f26062cf297660aa449eb675.tar.gz patchage-572adb6873294bf2f26062cf297660aa449eb675.tar.bz2 patchage-572adb6873294bf2f26062cf297660aa449eb675.zip |
Make it possible to remove connections by middle-clicking on their handle, or
selecting them and pressing delete (implement #616).
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3626 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchageCanvas.cpp')
-rw-r--r-- | src/PatchageCanvas.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index adb1b7a..175d837 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -260,6 +260,55 @@ PatchageCanvas::add_module(const std::string& name, PatchageModule* module) } bool +PatchageCanvas::on_connection_event(FlowCanvas::Connection* c, GdkEvent* ev) +{ + if (ev->type == GDK_BUTTON_PRESS) { + switch (ev->button.button) { + case 1: + if (!(ev->button.state & GDK_CONTROL_MASK) + && !(ev->button.state & GDK_SHIFT_MASK)) { + clear_selection(); + } + select_connection(c); + return true; + case 2: + disconnect(c->source(), c->dest()); + return true; + } + } + return false; +} + +bool +PatchageCanvas::on_event(GdkEvent* ev) +{ + if (ev->type == GDK_KEY_PRESS && ev->key.keyval == GDK_Delete) { + Connections cs = selected_connections(); + clear_selection(); + + for (Connections::const_iterator i = cs.begin(); i != cs.end(); ++i) { + disconnect((*i)->source(), (*i)->dest()); + } + } + + return false; +} + +bool +PatchageCanvas::add_connection(FlowCanvas::Connectable* tail, + FlowCanvas::Connectable* head, + uint32_t color) +{ + FlowCanvas::Connection* c = new FlowCanvas::Connection( + *this, tail, head, color); + c->show_handle(true); + c->signal_event.connect( + sigc::bind<0>(sigc::mem_fun(*this, &PatchageCanvas::on_connection_event), + c)); + return FlowCanvas::Canvas::add_connection(c); +} + +bool PatchageCanvas::remove_item(FlowCanvas::Item* i) { // Remove item from canvas |