From 3ce44626f2e557494248d746f688f20eed4be197 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 1 Dec 2011 03:40:57 +0000 Subject: Remove menu stuff from FlowCanvas. git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@3717 a436a847-0d15-0410-975c-d299462d15a1 --- src/PatchageModule.cpp | 9 +++++++++ src/PatchageModule.hpp | 4 ++++ src/PatchagePort.hpp | 19 ++++++++++++++++++- 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index 4254015..e9743f5 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -82,6 +82,15 @@ PatchageModule::show_menu(GdkEventButton* ev) return true; } +bool +PatchageModule::on_click(GdkEventButton* ev) +{ + if (ev->button == 3) { + return show_menu(ev); + } + return false; +} + void PatchageModule::load_location() { diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index f87c208..7b8c02d 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -19,6 +19,8 @@ #include +#include + #include "flowcanvas/Module.hpp" #include "flowcanvas/Port.hpp" @@ -46,6 +48,8 @@ public: ModuleType type() const { return _type; } protected: + bool on_click(GdkEventButton* ev); + void add_port(FlowCanvas::Port* port); void remove_port(FlowCanvas::Port* port); diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp index ebd5a71..693091a 100644 --- a/src/PatchagePort.hpp +++ b/src/PatchagePort.hpp @@ -21,6 +21,8 @@ #include +#include + #include "flowcanvas/Port.hpp" #include "flowcanvas/Module.hpp" @@ -41,13 +43,28 @@ public: uint32_t color) : Port(module, name, is_input, color) , _type(type) - {} + { + } virtual ~PatchagePort() {} /** Returns the full name of this port, as "modulename:portname" */ std::string full_name() const { return _module->name() + ":" + _name; } + bool on_click(GdkEventButton* ev) { + if (ev->button != 3) { + return FlowCanvas::Port::on_click(ev); + } + + Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); + menu->items().push_back( + Gtk::Menu_Helpers::MenuElem( + "Disconnect All", sigc::mem_fun(this, &Port::disconnect_all))); + + menu->popup(ev->button, ev->time); + return true; + } + PortType type() const { return _type; } private: -- cgit v1.2.1