From 2df7c1a1e805bea3d439d345d37469a8d202a656 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 3 Jul 2006 18:28:10 +0000 Subject: Creating of multiple patch input/output ports git-svn-id: http://svn.drobilla.net/lad/ingen@80 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/events/AddPortEvent.cpp | 7 +++---- src/progs/ingenuity/OmFlowCanvas.cpp | 21 ++++++++++++++++++++- src/progs/ingenuity/OmFlowCanvas.h | 1 + src/progs/ingenuity/ingenuity.glade | 10 +++++----- 4 files changed, 29 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp index 1c96206a..92c9cfb9 100644 --- a/src/libs/engine/events/AddPortEvent.cpp +++ b/src/libs/engine/events/AddPortEvent.cpp @@ -45,8 +45,7 @@ AddPortEvent::AddPortEvent(CountedPtr responder, const string& path, _data_type(DataType::UNKNOWN), _patch(NULL), _patch_port(NULL), - _driver_port(NULL), - _succeeded(true) + _driver_port(NULL) { string type_str; if (type == "CONTROL" || type == "AUDIO") @@ -118,8 +117,8 @@ AddPortEvent::execute(samplecount offset) void AddPortEvent::post_process() { - if (!_succeeded) { - const string msg = string("Could not create port - ").append(_path);// + " already exists."; + if (!_patch_port) { + const string msg = string("Could not create port - ").append(_path); m_responder->respond_error(msg); } else { m_responder->respond_ok(); diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp index 57b66998..fc9ec9ef 100644 --- a/src/progs/ingenuity/OmFlowCanvas.cpp +++ b/src/progs/ingenuity/OmFlowCanvas.cpp @@ -172,10 +172,27 @@ OmFlowCanvas::destroy_selected() } +string +OmFlowCanvas::generate_port_name(const string& base) { + string name = base; + + char num_buf[5]; + for (uint i=1; i < 9999; ++i) { + snprintf(num_buf, 5, "%d", i); + name = base + "_"; + name += num_buf; + if (!m_patch_controller->patch_model()->get_port(name)) + break; + } + + return name; +} + + void OmFlowCanvas::menu_add_port(const string& name, const string& type, bool is_output) { - const Path& path = m_patch_controller->path().base_path() + name; + const Path& path = m_patch_controller->path().base_path() + generate_port_name(name); Controller::instance().create_port(path, type, is_output); char temp_buf[16]; @@ -184,6 +201,8 @@ OmFlowCanvas::menu_add_port(const string& name, const string& type, bool is_outp snprintf(temp_buf, 16, "%d", m_last_click_y); Controller::instance().set_metadata(path, "module-y", temp_buf); } + + /* void OmFlowCanvas::menu_add_audio_input() diff --git a/src/progs/ingenuity/OmFlowCanvas.h b/src/progs/ingenuity/OmFlowCanvas.h index 47cb9b2d..d14c79d3 100644 --- a/src/progs/ingenuity/OmFlowCanvas.h +++ b/src/progs/ingenuity/OmFlowCanvas.h @@ -53,6 +53,7 @@ public: { m_menu->popup(event->button.button, event->button.time); } private: + string generate_port_name(const string& base); void menu_add_port(const string& name, const string& type, bool is_output); /*void menu_add_audio_input(); void menu_add_audio_output(); diff --git a/src/progs/ingenuity/ingenuity.glade b/src/progs/ingenuity/ingenuity.glade index 17736ce2..67286660 100644 --- a/src/progs/ingenuity/ingenuity.glade +++ b/src/progs/ingenuity/ingenuity.glade @@ -3022,14 +3022,14 @@ True - OmGtk + Ingenuity Copyright (C) 2005-2006 Dave Robillard - A client for the Om modular synthesizer + A graphical client for the Ingen audio processor Licensed under the GNU GPL, Version 2. -See COPYING file included with Om, or http://www.gnu.org/licenses/gpl.txt for more information - False - http://om-synth.nongnu.org +See COPYING file included with this distribution, or http://www.gnu.org/licenses/gpl.txt for more information + True + http://codeson.net/software/ingen Author: Dave Robillard <drobilla@connect.carelton.ca> -- cgit v1.2.1