diff options
author | David Robillard <d@drobilla.net> | 2009-05-11 18:05:24 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2009-05-11 18:05:24 +0000 |
commit | 698c38587bd4f0133a132dc363098ff8298ec47b (patch) | |
tree | abcab2ab196d995fbcc52a4e62c4f5d496b6a754 /src/gui | |
parent | 9ea901df533b0326e715ced10b9e9970239da515 (diff) | |
download | ingen-698c38587bd4f0133a132dc363098ff8298ec47b.tar.gz ingen-698c38587bd4f0133a132dc363098ff8298ec47b.tar.bz2 ingen-698c38587bd4f0133a132dc363098ff8298ec47b.zip |
* New ontology.
* Display human names on patch ports on creation, if enabled.
* Fix copy/paste of subpatches.
* Split properties into "properties" (class properties) and "variables" (instance properties).
* Names are kind of a legacy leftover...
* Remove special set poly / enable / etc events in favour of just setting properties (less API, extensible, RDF compatible).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1973 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
30 files changed, 260 insertions, 169 deletions
diff --git a/src/gui/ControlPanel.cpp b/src/gui/ControlPanel.cpp index 87167b3f..0d7feafd 100644 --- a/src/gui/ControlPanel.cpp +++ b/src/gui/ControlPanel.cpp @@ -74,12 +74,12 @@ ControlPanel::init(SharedPtr<NodeModel> node, uint32_t poly) add_port(*i); } - node->signal_property.connect(bind( - sigc::mem_fun(this, &ControlPanel::property_changed), false)); + node->signal_property.connect( + sigc::mem_fun(this, &ControlPanel::variable_changed)); if (node->parent()) { - node->signal_property.connect(bind( - sigc::mem_fun(this, &ControlPanel::property_changed), true)); + node->signal_property.connect( + sigc::mem_fun(this, &ControlPanel::parent_property_changed)); } else { cerr << "[ControlPanel] No parent, polyphonic controls disabled" << endl; } @@ -251,15 +251,21 @@ ControlPanel::specific_voice_selected() void -ControlPanel::property_changed(const std::string& predicate, const Raul::Atom& value, bool parent) +ControlPanel::parent_property_changed(const std::string& predicate, const Raul::Atom& value) { - if (!parent && predicate == "ingen:polyphonic" && value.type() == Atom::BOOL) { + if (predicate == "ingen:polyphony" && value.type() == Atom::INT) + _voice_spinbutton->set_range(0, value.get_int32() - 1); +} + + +void +ControlPanel::variable_changed(const std::string& predicate, const Raul::Atom& value) +{ + if (predicate == "ingen:polyphonic" && value.type() == Atom::BOOL) { if (value.get_bool()) _voice_control_box->show(); else _voice_control_box->hide(); - } else if (parent && predicate == "ingen:polyphony" && value.type() == Atom::INT) { - _voice_spinbutton->set_range(0, value.get_int32() - 1); } } diff --git a/src/gui/ControlPanel.hpp b/src/gui/ControlPanel.hpp index c43d59ac..ef73ea16 100644 --- a/src/gui/ControlPanel.hpp +++ b/src/gui/ControlPanel.hpp @@ -72,7 +72,8 @@ private: void all_voices_selected(); void specific_voice_selected(); - void property_changed(const std::string& predicate, const Raul::Atom& value, bool parent); + void variable_changed(const std::string& predicate, const Raul::Atom& value); + void parent_property_changed(const std::string& predicate, const Raul::Atom& value); bool _callback_enabled; diff --git a/src/gui/LoadPatchWindow.cpp b/src/gui/LoadPatchWindow.cpp index 0373ee80..573c6311 100644 --- a/src/gui/LoadPatchWindow.cpp +++ b/src/gui/LoadPatchWindow.cpp @@ -76,7 +76,7 @@ LoadPatchWindow::LoadPatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gno void -LoadPatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Variables data) +LoadPatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Properties data) { set_patch(patch); _initial_data = data; diff --git a/src/gui/LoadPatchWindow.hpp b/src/gui/LoadPatchWindow.hpp index a946275f..2cd9ef9e 100644 --- a/src/gui/LoadPatchWindow.hpp +++ b/src/gui/LoadPatchWindow.hpp @@ -54,7 +54,7 @@ public: void set_replace() { _replace = true; } void set_merge() { _replace = false; } - void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); + void present(SharedPtr<PatchModel> patch, GraphObject::Properties data); protected: void on_show(); @@ -65,7 +65,7 @@ private: void ok_clicked(); void cancel_clicked(); - GraphObject::Variables _initial_data; + GraphObject::Properties _initial_data; SharedPtr<PatchModel> _patch; bool _replace; diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index d8944d28..c0188ba5 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -102,7 +102,7 @@ LoadPluginWindow::LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr<G void -LoadPluginWindow::present(SharedPtr<PatchModel> patch, GraphObject::Variables data) +LoadPluginWindow::present(SharedPtr<PatchModel> patch, GraphObject::Properties data) { set_patch(patch); _initial_data = data; @@ -334,8 +334,8 @@ LoadPluginWindow::add_clicked() } else { Path path = _patch->path().base() + Path::nameify(name); App::instance().engine()->new_node(path, plugin->uri()); - App::instance().engine()->set_property(path, "ingen:polyphonic", polyphonic); - for (GraphObject::Variables::const_iterator i = _initial_data.begin(); + App::instance().engine()->set_variable(path, "ingen:polyphonic", bool(polyphonic)); + for (GraphObject::Properties::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) App::instance().engine()->set_variable(path, i->first, i->second); _node_name_entry->set_text(generate_module_name(++_plugin_name_offset)); diff --git a/src/gui/LoadPluginWindow.hpp b/src/gui/LoadPluginWindow.hpp index e9be576a..6ed76ded 100644 --- a/src/gui/LoadPluginWindow.hpp +++ b/src/gui/LoadPluginWindow.hpp @@ -98,7 +98,7 @@ public: void add_plugin(SharedPtr<PluginModel> plugin); - void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); + void present(SharedPtr<PatchModel> patch, GraphObject::Properties data); protected: void on_show(); @@ -121,7 +121,7 @@ private: void plugin_selection_changed(); string generate_module_name(int offset = 0); - GraphObject::Variables _initial_data; + GraphObject::Properties _initial_data; SharedPtr<PatchModel> _patch; diff --git a/src/gui/LoadRemotePatchWindow.cpp b/src/gui/LoadRemotePatchWindow.cpp index dab1cd0e..e70c6d3b 100644 --- a/src/gui/LoadRemotePatchWindow.cpp +++ b/src/gui/LoadRemotePatchWindow.cpp @@ -61,7 +61,7 @@ LoadRemotePatchWindow::LoadRemotePatchWindow(BaseObjectType* cobject, const Glib void -LoadRemotePatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Variables data) +LoadRemotePatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Properties data) { _liststore->clear(); diff --git a/src/gui/LoadRemotePatchWindow.hpp b/src/gui/LoadRemotePatchWindow.hpp index d6d26725..211924d5 100644 --- a/src/gui/LoadRemotePatchWindow.hpp +++ b/src/gui/LoadRemotePatchWindow.hpp @@ -64,7 +64,7 @@ public: void set_replace() { _replace = true; } void set_merge() { _replace = false; } - void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); + void present(SharedPtr<PatchModel> patch, GraphObject::Properties data); private: void patch_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* col); @@ -73,7 +73,7 @@ private: void open_clicked(); void cancel_clicked(); - GraphObject::Variables _initial_data; + GraphObject::Properties _initial_data; SharedPtr<PatchModel> _patch; bool _replace; diff --git a/src/gui/LoadSubpatchWindow.cpp b/src/gui/LoadSubpatchWindow.cpp index f6ec41d2..3b935f68 100644 --- a/src/gui/LoadSubpatchWindow.cpp +++ b/src/gui/LoadSubpatchWindow.cpp @@ -74,7 +74,7 @@ LoadSubpatchWindow::LoadSubpatchWindow(BaseObjectType* cobject, const Glib::RefP void -LoadSubpatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Variables data) +LoadSubpatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Properties data) { set_patch(patch); _initial_data = data; diff --git a/src/gui/LoadSubpatchWindow.hpp b/src/gui/LoadSubpatchWindow.hpp index 559df05c..9e4fda0d 100644 --- a/src/gui/LoadSubpatchWindow.hpp +++ b/src/gui/LoadSubpatchWindow.hpp @@ -45,7 +45,7 @@ public: void set_patch(SharedPtr<PatchModel> patch); - void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); + void present(SharedPtr<PatchModel> patch, GraphObject::Properties data); protected: void on_show(); @@ -59,7 +59,7 @@ private: void ok_clicked(); void cancel_clicked(); - GraphObject::Variables _initial_data; + GraphObject::Properties _initial_data; SharedPtr<PatchModel> _patch; diff --git a/src/gui/NewSubpatchWindow.cpp b/src/gui/NewSubpatchWindow.cpp index a8a13508..6fa2a430 100644 --- a/src/gui/NewSubpatchWindow.cpp +++ b/src/gui/NewSubpatchWindow.cpp @@ -43,7 +43,7 @@ NewSubpatchWindow::NewSubpatchWindow(BaseObjectType* cobject, const Glib::RefPtr } void -NewSubpatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Variables data) +NewSubpatchWindow::present(SharedPtr<PatchModel> patch, GraphObject::Properties data) { set_patch(patch); _initial_data = data; @@ -92,10 +92,10 @@ NewSubpatchWindow::ok_clicked() const uint32_t poly = _poly_spinbutton->get_value_as_int(); App::instance().engine()->new_patch(path, poly); - for (GraphObject::Variables::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) + for (GraphObject::Properties::const_iterator i = _initial_data.begin(); i != _initial_data.end(); ++i) App::instance().engine()->set_variable(path, i->first, i->second); - App::instance().engine()->set_property(path, "ingen:enabled", (bool)true); + App::instance().engine()->set_variable(path, "ingen:enabled", (bool)true); hide(); } diff --git a/src/gui/NewSubpatchWindow.hpp b/src/gui/NewSubpatchWindow.hpp index 3c685d3f..186e0953 100644 --- a/src/gui/NewSubpatchWindow.hpp +++ b/src/gui/NewSubpatchWindow.hpp @@ -45,14 +45,14 @@ public: void set_patch(SharedPtr<PatchModel> patch); - void present(SharedPtr<PatchModel> patch, GraphObject::Variables data); + void present(SharedPtr<PatchModel> patch, GraphObject::Properties data); private: void name_changed(); void ok_clicked(); void cancel_clicked(); - GraphObject::Variables _initial_data; + GraphObject::Properties _initial_data; SharedPtr<PatchModel> _patch; Gtk::Entry* _name_entry; diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index d2d2fe24..b137ebc1 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -52,7 +52,6 @@ NodeModule::NodeModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeMode node->signal_new_port.connect(sigc::bind(sigc::mem_fun(this, &NodeModule::add_port), true)); node->signal_removed_port.connect(sigc::hide_return(sigc::mem_fun(this, &NodeModule::remove_port))); node->signal_variable.connect(sigc::mem_fun(this, &NodeModule::set_variable)); - node->signal_property.connect(sigc::mem_fun(this, &NodeModule::set_property)); node->signal_renamed.connect(sigc::mem_fun(this, &NodeModule::rename)); } @@ -92,18 +91,19 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n else ret = boost::shared_ptr<NodeModule>(new NodeModule(canvas, node)); - for (GraphObject::Variables::const_iterator m = node->variables().begin(); m != node->variables().end(); ++m) + for (GraphObject::Properties::const_iterator m = node->variables().begin(); m != node->variables().end(); ++m) ret->set_variable(m->first, m->second); for (NodeModel::Ports::const_iterator p = node->ports().begin(); p != node->ports().end(); ++p) { ret->add_port(*p, false); } + + ret->set_stacked_border(node->polyphonic()); if (human) ret->show_human_names(human); // FIXME: double port iteration - - ret->resize(); - ret->set_stacked_border(node->polyphonic()); + else + ret->resize(); return ret; } @@ -372,17 +372,11 @@ NodeModule::store_location() void NodeModule::set_variable(const string& key, const Atom& value) { - if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) { move_to(value.get_float(), property_y()); - else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) + } else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) { move_to(property_x(), value.get_float()); -} - - -void -NodeModule::set_property(const string& key, const Atom& value) -{ - if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) { + } else if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) { set_stacked_border(value.get_bool()); } else if (key == "ingen:selected" && value.type() == Atom::BOOL) { if (value.get_bool() != selected()) { @@ -401,7 +395,7 @@ NodeModule::set_selected(bool b) if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_property(_node->path(), "ingen:selected", b); + App::instance().engine()->set_variable(_node->path(), "ingen:selected", b); } } diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index d5c9ff79..35691dcc 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -77,8 +77,7 @@ protected: void set_selected(bool b); void rename(); - void set_variable(const std::string& key, const Raul::Atom& value); - void set_property(const std::string& predicate, const Raul::Atom& value); + void set_variable(const std::string& predicate, const Raul::Atom& value); void add_port(SharedPtr<PortModel> port, bool resize=true); diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index becbf964..801561e3 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -68,7 +68,7 @@ ObjectMenu::init(SharedPtr<ObjectModel> object) _properties_menuitem->signal_activate().connect( sigc::mem_fun(this, &ObjectMenu::on_menu_properties)); - object->signal_property.connect(sigc::mem_fun(this, &ObjectMenu::property_changed)); + object->signal_variable.connect(sigc::mem_fun(this, &ObjectMenu::variable_changed)); _enable_signal = true; } @@ -78,13 +78,13 @@ void ObjectMenu::on_menu_polyphonic() { if (_enable_signal) - App::instance().engine()->set_property( - _object->path(), "ingen:polyphonic", _polyphonic_menuitem->get_active()); + App::instance().engine()->set_variable( + _object->path(), "ingen:polyphonic", bool(_polyphonic_menuitem->get_active())); } void -ObjectMenu::property_changed(const std::string& predicate, const Raul::Atom& value) +ObjectMenu::variable_changed(const std::string& predicate, const Raul::Atom& value) { _enable_signal = false; if (predicate == "ingen:polyphonic" && value.type() == Atom::BOOL) diff --git a/src/gui/ObjectMenu.hpp b/src/gui/ObjectMenu.hpp index d1f6b5fe..edd25353 100644 --- a/src/gui/ObjectMenu.hpp +++ b/src/gui/ObjectMenu.hpp @@ -50,7 +50,7 @@ protected: void on_menu_destroy(); void on_menu_properties(); - void property_changed(const std::string& predicate, const Raul::Atom& value); + void variable_changed(const std::string& predicate, const Raul::Atom& value); bool _enable_signal; SharedPtr<ObjectModel> _object; diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index e5a92206..ef91e38e 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -85,22 +85,22 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) // Add port menu items _menu_add_audio_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "audio_input", "lv2:AudioPort", false)); + "audio_in", "Audio In", "lv2:AudioPort", false)); _menu_add_audio_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "audio_output", "lv2:AudioPort", true)); + "audio_out", "Audio Out", "lv2:AudioPort", true)); _menu_add_control_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "control_input", "lv2:ControlPort", false)); + "control_in", "Control In", "lv2:ControlPort", false)); _menu_add_control_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "control_output", "lv2:ControlPort", true)); + "control_out", "Control Out", "lv2:ControlPort", true)); _menu_add_event_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "event_input", "lv2ev:EventPort", false)); + "event_in", "Event In", "lv2ev:EventPort", false)); _menu_add_event_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "event_output", "lv2ev:EventPort", true)); + "event_out", "Event Out", "lv2ev:EventPort", true)); // Add control menu items /*_menu_add_number_control->signal_activate().connect( @@ -284,6 +284,10 @@ PatchCanvas::show_human_names(bool b) boost::shared_ptr<NodeModule> mod = boost::dynamic_pointer_cast<NodeModule>(*m); if (mod) mod->show_human_names(b); + + boost::shared_ptr<PatchPortModule> pmod = boost::dynamic_pointer_cast<PatchPortModule>(*m); + if (pmod) + pmod->show_human_names(b); } } @@ -381,7 +385,7 @@ PatchCanvas::add_port(SharedPtr<PortModel> pm) boost::shared_ptr<PatchCanvas> shared_this = boost::dynamic_pointer_cast<PatchCanvas>(shared_from_this()); - SharedPtr<PatchPortModule> view = PatchPortModule::create(shared_this, pm); + SharedPtr<PatchPortModule> view = PatchPortModule::create(shared_this, pm, _human_names); _views.insert(std::make_pair(pm, view)); add_item(view); view->show(); @@ -690,18 +694,18 @@ PatchCanvas::paste() //cout << "Skipping root" << endl; continue; } - GraphObject::Variables::iterator x = i->second->variables().find("ingenuity:canvas-x"); + GraphObject::Properties::iterator x = i->second->variables().find("ingenuity:canvas-x"); if (x != i->second->variables().end()) x->second = x->second.get_float() + (20.0f * _paste_count); - GraphObject::Variables::iterator y = i->second->variables().find("ingenuity:canvas-y"); + GraphObject::Properties::iterator y = i->second->variables().find("ingenuity:canvas-y"); if (y != i->second->variables().end()) y->second = y->second.get_float() + (20.0f * _paste_count); if (i->first.parent() == "/") { - GraphObject::Properties::iterator s = i->second->properties().find("ingen:selected"); - if (s != i->second->properties().end()) + GraphObject::Properties::iterator s = i->second->variables().find("ingen:selected"); + if (s != i->second->variables().end()) s->second = true; else - i->second->properties().insert(make_pair("ingen:selected", true)); + i->second->variables().insert(make_pair("ingen:selected", true)); } builder.build(i->second); } @@ -723,23 +727,27 @@ PatchCanvas::paste() } -string -PatchCanvas::generate_port_name(const string& base) +void +PatchCanvas::generate_port_name( + const string& sym_base, string& symbol, + const string& name_base, string& name) { - string name = base; + symbol = sym_base; + name = name_base; char num_buf[5]; - for (uint i=1; i < 9999; ++i) { + uint32_t i = 1; + for ( ; i < 9999; ++i) { snprintf(num_buf, 5, "%u", i); - name = base + "_"; - name += num_buf; - if (!_patch->get_port(name)) + symbol = sym_base + "_"; + symbol += num_buf; + if (!_patch->get_port(symbol)) break; } - assert(Path::is_valid(string("/") + name)); + assert(Path::is_valid(string("/") + symbol)); - return name; + name.append(" ").append(num_buf); } void @@ -747,7 +755,7 @@ PatchCanvas::menu_add_control(ControlType type) { // FIXME: bundleify - GraphObject::Variables data = get_initial_data(); + GraphObject::Properties data = get_initial_data(); float x = data["ingenuity:canvas-x"].get_float(); float y = data["ingenuity:canvas-y"].get_float(); @@ -758,14 +766,18 @@ PatchCanvas::menu_add_control(ControlType type) } void -PatchCanvas::menu_add_port(const string& name, const string& type, bool is_output) +PatchCanvas::menu_add_port(const string& sym_base, const string& name_base, + const string& type, bool is_output) { - const Path& path = _patch->path().base() + generate_port_name(name); + string sym, name; + generate_port_name(sym_base, sym, name_base, name); + const Path& path = _patch->path().base() + sym; App::instance().engine()->bundle_begin(); App::instance().engine()->new_port(path, type, _patch->num_ports(), is_output); - GraphObject::Variables data = get_initial_data(); - for (GraphObject::Variables::const_iterator i = data.begin(); i != data.end(); ++i) - App::instance().engine()->set_variable(path, i->first, i->second); + GraphObject::Properties data = get_initial_data(); + App::instance().engine()->set_property(path, "lv2:name", Atom(name.c_str())); + for (GraphObject::Properties::const_iterator i = data.begin(); i != data.end(); ++i) + App::instance().engine()->set_property(path, i->first, i->second); App::instance().engine()->bundle_end(); } @@ -788,8 +800,8 @@ PatchCanvas::load_plugin(WeakPtr<PluginModel> weak_plugin) const Path path = _patch->path().base() + name; // FIXME: polyphony? App::instance().engine()->new_node(path, plugin->uri()); - GraphObject::Variables data = get_initial_data(); - for (GraphObject::Variables::const_iterator i = data.begin(); i != data.end(); ++i) + GraphObject::Properties data = get_initial_data(); + for (GraphObject::Properties::const_iterator i = data.begin(); i != data.end(); ++i) App::instance().engine()->set_variable(path, i->first, i->second); } @@ -807,10 +819,10 @@ PatchCanvas::get_new_module_location(double& x, double& y) } -GraphObject::Variables +GraphObject::Properties PatchCanvas::get_initial_data() { - GraphObject::Variables result; + GraphObject::Properties result; result["ingenuity:canvas-x"] = Atom((float)_last_click_x); result["ingenuity:canvas-y"] = Atom((float)_last_click_y); diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index d215817e..b67c4937 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -89,8 +89,13 @@ private: enum ControlType { NUMBER, BUTTON }; void menu_add_control(ControlType type); - string generate_port_name(const string& base); - void menu_add_port(const string& name, const string& type, bool is_output); + void generate_port_name( + const string& sym_base, string& sym, + const string& name_base, string& name); + + void menu_add_port( + const string& sym_base, const string& name_base, + const string& type, bool is_output); void menu_load_plugin(); void menu_new_patch(); @@ -110,7 +115,7 @@ private: SLV2PluginClasses classes); #endif - GraphObject::Variables get_initial_data(); + GraphObject::Properties get_initial_data(); bool canvas_event(GdkEvent* event); diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index ff482fb7..200ce12f 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -16,6 +16,7 @@ */ #include <cassert> +#include <iostream> #include "PatchPortModule.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" @@ -33,40 +34,45 @@ namespace Ingen { namespace GUI { -PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port) - : FlowCanvas::Module(canvas, port->path().name(), 0, 0, false) // FIXME: coords? - , _port(port) +PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> model) + : FlowCanvas::Module(canvas, model->path().name(), 0, 0, false) // FIXME: coords? + , _model(model) + , _human_name_visible(false) { assert(canvas); - assert(port); + assert(model); - assert(PtrCast<PatchModel>(port->parent())); + assert(PtrCast<PatchModel>(model->parent())); - set_stacked_border(port->polyphonic()); + set_stacked_border(model->polyphonic()); - port->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_variable)); - port->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); + model->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_variable)); + model->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); } boost::shared_ptr<PatchPortModule> -PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port) +PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> model, bool human) { - boost::shared_ptr<PatchPortModule> ret = boost::shared_ptr<PatchPortModule>( - new PatchPortModule(canvas, port)); - assert(ret); + boost::shared_ptr<PatchPortModule> ret(new PatchPortModule(canvas, model)); + boost::shared_ptr<Port> port(new Port(ret, model, model->symbol(), true)); - boost::shared_ptr<Port> view(new Port(ret, port, port->symbol(), true)); - ret->add_port(view); - ret->set_menu(view->menu()); + ret->add_port(port); + ret->set_port(port); + ret->set_menu(port->menu()); - for (GraphObject::Variables::const_iterator m = port->variables().begin(); m != port->variables().end(); ++m) + for (GraphObject::Properties::const_iterator m = model->variables().begin(); + m != model->variables().end(); ++m) ret->set_variable(m->first, m->second); - for (GraphObject::Properties::const_iterator m = port->properties().begin(); m != port->properties().end(); ++m) + for (GraphObject::Properties::const_iterator m = model->properties().begin(); + m != model->properties().end(); ++m) ret->set_property(m->first, m->second); - - ret->resize(); + + if (human) + ret->show_human_names(human); + else + ret->resize(); return ret; } @@ -77,7 +83,7 @@ PatchPortModule::create_menu() { Glib::RefPtr<Gnome::Glade::Xml> xml = GladeFactory::new_glade_reference(); xml->get_widget_derived("object_menu", _menu); - _menu->init(_port, true); + _menu->init(_model, true); set_menu(_menu); } @@ -89,29 +95,42 @@ PatchPortModule::store_location() const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); - const Atom& existing_x = _port->get_variable("ingenuity:canvas-x"); - const Atom& existing_y = _port->get_variable("ingenuity:canvas-y"); + const Atom& existing_x = _model->get_property("ingenuity:canvas-x"); + const Atom& existing_y = _model->get_property("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_variable(_port->path(), "ingenuity:canvas-x", Atom(x)); - App::instance().engine()->set_variable(_port->path(), "ingenuity:canvas-y", Atom(y)); + App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_property(_model->path(), "ingenuity:canvas-y", Atom(y)); } } void -PatchPortModule::set_variable(const string& key, const Atom& value) +PatchPortModule::show_human_names(bool b) { - if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) - move_to(value.get_float(), property_y()); - else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) - move_to(property_x(), value.get_float()); + using namespace std; + _human_name_visible = b; + const Atom& name = _model->get_property("lv2:name"); + if (b && name.is_valid()) + set_name(name.get_string()); + else + set_name(_model->symbol()); + + resize(); } void -PatchPortModule::set_property(const string& key, const Atom& value) +PatchPortModule::set_name(const std::string& n) +{ + _port->set_name(n); + Module::resize(); +} + + +void +PatchPortModule::set_variable(const string& key, const Atom& value) { if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) { set_stacked_border(value.get_bool()); @@ -127,12 +146,27 @@ PatchPortModule::set_property(const string& key, const Atom& value) void +PatchPortModule::set_property(const string& key, const Atom& value) +{ + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) { + move_to(value.get_float(), property_y()); + } else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) { + move_to(property_x(), value.get_float()); + } else if (key == "lv2:name" && value.type() == Atom::STRING && _human_name_visible) { + set_name(value.get_string()); + } else if (key == "lv2:symbol" && value.type() == Atom::STRING && !_human_name_visible) { + set_name(value.get_string()); + } +} + + +void PatchPortModule::set_selected(bool b) { if (b != selected()) { Module::set_selected(b); if (App::instance().signal()) - App::instance().engine()->set_property(_port->path(), "ingen:selected", b); + App::instance().engine()->set_variable(_model->path(), "ingen:selected", b); } } diff --git a/src/gui/PatchPortModule.hpp b/src/gui/PatchPortModule.hpp index 60a50738..62c968ef 100644 --- a/src/gui/PatchPortModule.hpp +++ b/src/gui/PatchPortModule.hpp @@ -50,23 +50,31 @@ class PatchPortModule : public FlowCanvas::Module { public: static boost::shared_ptr<PatchPortModule> create(boost::shared_ptr<PatchCanvas> canvas, - SharedPtr<PortModel> port); + SharedPtr<PortModel> model, + bool human); virtual void store_location(); + void show_human_names(bool b); + + void set_name(const std::string& n); - SharedPtr<PortModel> port() const { return _port; } + SharedPtr<PortModel> port() const { return _model; } protected: - PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port); + PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> model); void create_menu(); void set_selected(bool b); + + void set_port(SharedPtr<Port> port) { _port = port; } void set_variable(const std::string& predicate, const Raul::Atom& value); void set_property(const std::string& predicate, const Raul::Atom& value); - SharedPtr<PortModel> _port; + SharedPtr<PortModel> _model; + SharedPtr<Port> _port; PortMenu* _menu; + bool _human_name_visible; }; diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp index 15c33550..f3a24920 100644 --- a/src/gui/PatchTreeWindow.cpp +++ b/src/gui/PatchTreeWindow.cpp @@ -110,8 +110,8 @@ PatchTreeWindow::add_patch(SharedPtr<PatchModel> pm) } } - pm->signal_property.connect(sigc::bind( - sigc::mem_fun(this, &PatchTreeWindow::patch_property_changed), + pm->signal_variable.connect(sigc::bind( + sigc::mem_fun(this, &PatchTreeWindow::patch_variable_changed), pm->path())); pm->signal_destroyed.connect(sigc::bind( @@ -198,12 +198,12 @@ PatchTreeWindow::event_patch_enabled_toggled(const Glib::ustring& path_str) assert(pm); if (_enable_signal) - App::instance().engine()->set_property(patch_path, "ingen:enabled", (bool)!pm->enabled()); + App::instance().engine()->set_variable(patch_path, "ingen:enabled", (bool)!pm->enabled()); } void -PatchTreeWindow::patch_property_changed(const string& key, const Raul::Atom& value, const Path& path) +PatchTreeWindow::patch_variable_changed(const string& key, const Raul::Atom& value, const Path& path) { _enable_signal = false; if (key == "ingen:enabled" && value.type() == Atom::BOOL) { diff --git a/src/gui/PatchTreeWindow.hpp b/src/gui/PatchTreeWindow.hpp index 6c8794e7..64e20b7c 100644 --- a/src/gui/PatchTreeWindow.hpp +++ b/src/gui/PatchTreeWindow.hpp @@ -49,7 +49,7 @@ public: void new_object(SharedPtr<Client::ObjectModel> object); - void patch_property_changed(const string& key, const Raul::Atom& value, const Path& path); + void patch_variable_changed(const string& key, const Raul::Atom& value, const Path& path); void patch_renamed(const Path& old_path, const Path& new_path); void add_patch(SharedPtr<Client::PatchModel> pm); diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index c441a64a..911c7c73 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -81,8 +81,13 @@ PatchView::set_patch(SharedPtr<PatchModel> patch) for (GraphObject::Properties::const_iterator i = patch->properties().begin(); i != patch->properties().end(); ++i) property_changed(i->first, i->second); + + for (GraphObject::Properties::const_iterator i = patch->variables().begin(); + i != patch->variables().end(); ++i) + variable_changed(i->first, i->second); // Connect model signals to track state + patch->signal_variable.connect(sigc::mem_fun(this, &PatchView::variable_changed)); patch->signal_property.connect(sigc::mem_fun(this, &PatchView::property_changed)); // Connect widget signals to do things @@ -193,7 +198,7 @@ PatchView::process_toggled() if (!_enable_signal) return; - App::instance().engine()->set_property(_patch->path(), "ingen:enabled", + App::instance().engine()->set_variable(_patch->path(), "ingen:enabled", (bool)_process_but->get_active()); } @@ -223,12 +228,18 @@ PatchView::refresh_clicked() void PatchView::property_changed(const std::string& predicate, const Raul::Atom& value) { +} + + +void +PatchView::variable_changed(const std::string& predicate, const Raul::Atom& value) +{ _enable_signal = false; if (predicate == "ingen:enabled") { if (value.type() == Atom::BOOL) _process_but->set_active(value.get_bool()); else - cerr << "WARNING: Bad type for ingen:enabled property: " << value.type() << endl; + cerr << "WARNING: Bad type for ingen:enabled variable: " << value.type() << endl; } _enable_signal = true; } diff --git a/src/gui/PatchView.hpp b/src/gui/PatchView.hpp index 474060f1..488674e5 100644 --- a/src/gui/PatchView.hpp +++ b/src/gui/PatchView.hpp @@ -85,6 +85,7 @@ private: void canvas_item_left(Gnome::Canvas::Item* item); void property_changed(const std::string& predicate, const Raul::Atom& value); + void variable_changed(const std::string& predicate, const Raul::Atom& value); void zoom_full(); diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index 14aab7d9..e8e2d7e0 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -394,7 +394,7 @@ PatchWindow::event_import_location() void PatchWindow::event_save() { - GraphObject::Variables::const_iterator doc = _patch->variables().find("ingen:document"); + GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document"); if (doc == _patch->variables().end()) { event_save_as(); } else { @@ -410,38 +410,56 @@ PatchWindow::event_save() void PatchWindow::event_save_as() { - Gtk::FileChooserDialog dialog(*this, "Save Patch", Gtk::FILE_CHOOSER_ACTION_SAVE); - - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - Gtk::Button* save_button = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - save_button->property_has_default() = true; - - Gtk::FileFilter filt; - filt.add_pattern("*.ingen.ttl"); - filt.set_name("Ingen patches"); - filt.add_pattern("*.ingen.lv2"); - filt.set_name("Ingen bundles"); - dialog.set_filter(filt); - - // Set current folder to most sensible default - GraphObject::Variables::const_iterator doc = _patch->variables().find("ingen:document"); - if (doc != _patch->variables().end()) - dialog.set_uri(doc->second.get_string()); - else if (App::instance().configuration()->patch_folder().length() > 0) - dialog.set_current_folder(App::instance().configuration()->patch_folder()); - - int result = dialog.run(); - //bool recursive = recursive_checkbutton.get_active(); - - if (result == Gtk::RESPONSE_OK) { + while (true) { + Gtk::FileChooserDialog dialog(*this, "Save Patch", Gtk::FILE_CHOOSER_ACTION_SAVE); + + dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); + Gtk::Button* save_button = dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); + save_button->property_has_default() = true; + + Gtk::FileFilter filt; + filt.add_pattern("*.ingen.ttl"); + filt.set_name("Ingen patches"); + filt.add_pattern("*.ingen.lv2"); + filt.set_name("Ingen bundles"); + dialog.set_filter(filt); + + // Set current folder to most sensible default + GraphObject::Properties::const_iterator doc = _patch->variables().find("ingen:document"); + if (doc != _patch->variables().end()) + dialog.set_uri(doc->second.get_string()); + else if (App::instance().configuration()->patch_folder().length() > 0) + dialog.set_current_folder(App::instance().configuration()->patch_folder()); + + if (dialog.run() != Gtk::RESPONSE_OK) + break; + string filename = dialog.get_filename(); + + string base = filename.substr(0, filename.find(".")); + if (base.find("/") != string::npos) + base = base.substr(base.find_last_of("/") + 1); + + if (!Symbol::is_valid(base)) { + Gtk::MessageDialog error_dialog(*this, + "<b>Ingen patch file names must be valid symbols</b>", true, + Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true); + error_dialog.set_secondary_text( + "The first character must be _, a-z, or A-Z, and " + "subsequent characters must be _, a-z, A-Z, or 0-9."); + error_dialog.run(); + continue; + } + const bool is_bundle = filename.find(".ingen.lv2") != string::npos; const bool is_patch = filename.find(".ingen.ttl") != string::npos; - + // Save a bundle by default if (!is_bundle && !is_patch) filename += ".ingen.ttl"; + _patch->set_property("lv2:symbol", Atom(base.c_str())); + bool confirm = true; std::fstream fin; fin.open(filename.c_str(), std::ios::in); @@ -449,11 +467,11 @@ PatchWindow::event_save_as() string msg = "File already exists! Are you sure you want to overwrite "; msg += filename + "?"; Gtk::MessageDialog confirm_dialog(*this, - msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); + msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); confirm = (confirm_dialog.run() == Gtk::RESPONSE_YES); } fin.close(); - + if (confirm) { const Glib::ustring uri = Glib::filename_to_uri(filename); App::instance().loader()->save_patch(_patch, uri); @@ -462,8 +480,10 @@ PatchWindow::event_save_as() (boost::format("Wrote %1% to %2%") % _patch->path() % uri).str(), STATUS_CONTEXT_PATCH); } + + App::instance().configuration()->set_patch_folder(dialog.get_current_folder()); + break; } - App::instance().configuration()->set_patch_folder(dialog.get_current_folder()); } diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index cf9265db..64a77d0a 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -86,7 +86,7 @@ ThreadedLoader::load_patch(bool merge, optional<Path> data_path, optional<Path> engine_parent, optional<Symbol> engine_symbol, - optional<GraphObject::Variables> engine_data) + optional<GraphObject::Properties> engine_data) { _mutex.lock(); diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index c0e30a63..ffe7a482 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -61,7 +61,7 @@ public: optional<Path> data_path, optional<Path> engine_parent, optional<Symbol> engine_symbol, - optional<GraphObject::Variables> engine_data); + optional<GraphObject::Properties> engine_data); void save_patch(SharedPtr<PatchModel> model, const string& filename); diff --git a/src/gui/UploadPatchWindow.cpp b/src/gui/UploadPatchWindow.cpp index 874a4b43..96594924 100644 --- a/src/gui/UploadPatchWindow.cpp +++ b/src/gui/UploadPatchWindow.cpp @@ -75,7 +75,7 @@ UploadPatchWindow::on_show() { Gtk::Dialog::on_show(); - Raul::Atom atom = _patch->get_variable("lv2:symbol"); + Raul::Atom atom = _patch->get_property("lv2:symbol"); if (atom.is_valid()) _symbol_entry->set_text(atom.get_string()); @@ -238,7 +238,7 @@ UploadPatchWindow::upload_clicked() Glib::ustring symbol = _symbol_entry->get_text(); Glib::ustring short_name = _short_name_entry->get_text(); - GraphObject::Variables extra_rdf; + GraphObject::Properties extra_rdf; extra_rdf["lv2:symbol"] = Atom(Atom::STRING, symbol); extra_rdf["doap:name"] = Atom(Atom::STRING, short_name); diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 1e7bf14c..5d05c853 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -256,7 +256,7 @@ WindowFactory::remove_control_window(NodeControlWindow* win, GdkEventAny* ignore void -WindowFactory::present_load_plugin(SharedPtr<PatchModel> patch, GraphObject::Variables data) +WindowFactory::present_load_plugin(SharedPtr<PatchModel> patch, GraphObject::Properties data) { PatchWindowMap::iterator w = _patch_windows.find(patch->path()); @@ -269,7 +269,7 @@ WindowFactory::present_load_plugin(SharedPtr<PatchModel> patch, GraphObject::Var void -WindowFactory::present_load_patch(SharedPtr<PatchModel> patch, GraphObject::Variables data) +WindowFactory::present_load_patch(SharedPtr<PatchModel> patch, GraphObject::Properties data) { PatchWindowMap::iterator w = _patch_windows.find(patch->path()); @@ -283,7 +283,7 @@ WindowFactory::present_load_patch(SharedPtr<PatchModel> patch, GraphObject::Vari void -WindowFactory::present_load_remote_patch(SharedPtr<PatchModel> patch, GraphObject::Variables data) +WindowFactory::present_load_remote_patch(SharedPtr<PatchModel> patch, GraphObject::Properties data) { PatchWindowMap::iterator w = _patch_windows.find(patch->path()); @@ -310,7 +310,7 @@ WindowFactory::present_upload_patch(SharedPtr<PatchModel> patch) } void -WindowFactory::present_new_subpatch(SharedPtr<PatchModel> patch, GraphObject::Variables data) +WindowFactory::present_new_subpatch(SharedPtr<PatchModel> patch, GraphObject::Properties data) { PatchWindowMap::iterator w = _patch_windows.find(patch->path()); @@ -322,7 +322,7 @@ WindowFactory::present_new_subpatch(SharedPtr<PatchModel> patch, GraphObject::Va void -WindowFactory::present_load_subpatch(SharedPtr<PatchModel> patch, GraphObject::Variables data) +WindowFactory::present_load_subpatch(SharedPtr<PatchModel> patch, GraphObject::Properties data) { PatchWindowMap::iterator w = _patch_windows.find(patch->path()); diff --git a/src/gui/WindowFactory.hpp b/src/gui/WindowFactory.hpp index 79da3902..60f195f2 100644 --- a/src/gui/WindowFactory.hpp +++ b/src/gui/WindowFactory.hpp @@ -73,12 +73,12 @@ public: void present_controls(SharedPtr<NodeModel> node); - void present_load_plugin(SharedPtr<PatchModel> patch, GraphObject::Variables data=GraphObject::Variables()); - void present_load_patch(SharedPtr<PatchModel> patch, GraphObject::Variables data=GraphObject::Variables()); - void present_load_remote_patch(SharedPtr<PatchModel> patch, GraphObject::Variables data=GraphObject::Variables()); + void present_load_plugin(SharedPtr<PatchModel> patch, GraphObject::Properties data=GraphObject::Properties()); + void present_load_patch(SharedPtr<PatchModel> patch, GraphObject::Properties data=GraphObject::Properties()); + void present_load_remote_patch(SharedPtr<PatchModel> patch, GraphObject::Properties data=GraphObject::Properties()); void present_upload_patch(SharedPtr<PatchModel> patch); - void present_new_subpatch(SharedPtr<PatchModel> patch, GraphObject::Variables data=GraphObject::Variables()); - void present_load_subpatch(SharedPtr<PatchModel> patch, GraphObject::Variables data=GraphObject::Variables()); + void present_new_subpatch(SharedPtr<PatchModel> patch, GraphObject::Properties data=GraphObject::Properties()); + void present_load_subpatch(SharedPtr<PatchModel> patch, GraphObject::Properties data=GraphObject::Properties()); void present_rename(SharedPtr<ObjectModel> object); void present_properties(SharedPtr<ObjectModel> object); |