diff options
author | David Robillard <d@drobilla.net> | 2010-12-15 06:11:04 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-15 06:11:04 +0000 |
commit | 9678996bb97e562fde723bc327e600af7d52e0ef (patch) | |
tree | 99d6aaa87655f6e0c8229a60e905f46435d84d19 /src | |
parent | 8edc1165f245d1131dcbeacb20db57722a74f110 (diff) | |
download | patchage-9678996bb97e562fde723bc327e600af7d52e0ef.tar.gz patchage-9678996bb97e562fde723bc327e600af7d52e0ef.tar.bz2 patchage-9678996bb97e562fde723bc327e600af7d52e0ef.zip |
Don't show `split' menu item for modules with only inputs or outputs (ticket #128).
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@2702 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/PatchageModule.cpp | 39 | ||||
-rw-r--r-- | src/PatchageModule.hpp | 5 |
2 files changed, 44 insertions, 0 deletions
diff --git a/src/PatchageModule.cpp b/src/PatchageModule.cpp index 416c2b6..d129e2e 100644 --- a/src/PatchageModule.cpp +++ b/src/PatchageModule.cpp @@ -35,6 +35,30 @@ PatchageModule::~PatchageModule() } void +PatchageModule::update_menu() +{ + if (!_menu) + return; + + if (_type == InputOutput) { + bool has_in = false; + bool has_out = false; + for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p) { + if ((*p)->is_input()) { + has_in = true; + } else { + has_out = true; + } + if (has_in && has_out) { + _menu->items()[0].show(); // Show "Split" menu item + return; + } + } + _menu->items()[0].hide(); // Hide "Split" menu item + } +} + +void PatchageModule::create_menu() { _menu = new Gtk::Menu(); @@ -42,6 +66,7 @@ PatchageModule::create_menu() if (_type == InputOutput) { items.push_back( Gtk::Menu_Helpers::MenuElem("_Split", sigc::mem_fun(this, &PatchageModule::split))); + update_menu(); } else { items.push_back( Gtk::Menu_Helpers::MenuElem("_Join", sigc::mem_fun(this, &PatchageModule::join))); @@ -91,6 +116,20 @@ PatchageModule::join() } void +PatchageModule::add_port(boost::shared_ptr<Port> port) +{ + FlowCanvas::Module::add_port(port); + update_menu(); +} + +void +PatchageModule::remove_port(boost::shared_ptr<Port> port) +{ + FlowCanvas::Module::remove_port(port); + update_menu(); +} + +void PatchageModule::menu_disconnect_all() { for (PortVector::iterator p = _ports.begin(); p != _ports.end(); ++p) diff --git a/src/PatchageModule.hpp b/src/PatchageModule.hpp index fcab207..a2b67ee 100644 --- a/src/PatchageModule.hpp +++ b/src/PatchageModule.hpp @@ -32,10 +32,15 @@ public: PatchageModule(Patchage* app, const std::string& name, ModuleType type, double x=0, double y=0); ~PatchageModule(); + void add_port(boost::shared_ptr<Port> port); + void remove_port(boost::shared_ptr<Port> port); + void split(); void join(); void create_menu(); + void update_menu(); + void load_location(); void menu_disconnect_all(); void show_dialog() {} |