diff options
author | David Robillard <d@drobilla.net> | 2008-08-17 04:05:30 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-17 04:05:30 +0000 |
commit | fa067527fe00b66b85d71955e152e9ef9215c9cd (patch) | |
tree | 382a8e9e58259929415e7188992252ac1ca2ea9b /src/libs/gui | |
parent | 3019b09099371b3fe568b7dcc3bb92203d800b1f (diff) | |
download | ingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.tar.gz ingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.tar.bz2 ingen-fa067527fe00b66b85d71955e152e9ef9215c9cd.zip |
Replace imperative polyphony/polyphonic stuff with properties (kill more API).
git-svn-id: http://svn.drobilla.net/lad/ingen@1412 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/gui')
-rw-r--r-- | src/libs/gui/ControlPanel.cpp | 29 | ||||
-rw-r--r-- | src/libs/gui/ControlPanel.hpp | 4 | ||||
-rw-r--r-- | src/libs/gui/LoadPluginWindow.cpp | 3 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.cpp | 10 | ||||
-rw-r--r-- | src/libs/gui/NodeModule.hpp | 1 | ||||
-rw-r--r-- | src/libs/gui/ObjectMenu.cpp | 7 | ||||
-rw-r--r-- | src/libs/gui/ObjectMenu.hpp | 2 | ||||
-rw-r--r-- | src/libs/gui/PatchCanvas.cpp | 2 | ||||
-rw-r--r-- | src/libs/gui/PatchPortModule.cpp | 19 | ||||
-rw-r--r-- | src/libs/gui/PatchPortModule.hpp | 4 |
10 files changed, 51 insertions, 30 deletions
diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp index 0f38d5dd..84f1163a 100644 --- a/src/libs/gui/ControlPanel.cpp +++ b/src/libs/gui/ControlPanel.cpp @@ -73,12 +73,12 @@ ControlPanel::init(SharedPtr<NodeModel> node, uint32_t poly) add_port(*i); } - node->signal_polyphonic.connect( - sigc::mem_fun(this, &ControlPanel::polyphonic_changed)); + node->signal_property.connect(bind( + sigc::mem_fun(this, &ControlPanel::property_changed), false)); if (node->parent()) { - ((PatchModel*)node->parent().get())->signal_polyphony.connect( - sigc::mem_fun(this, &ControlPanel::polyphony_changed)); + node->signal_property.connect(bind( + sigc::mem_fun(this, &ControlPanel::property_changed), true)); } else { cerr << "[ControlPanel] No parent, polyphonic controls disabled" << endl; } @@ -252,19 +252,16 @@ ControlPanel::specific_voice_selected() void -ControlPanel::polyphony_changed(uint32_t poly) +ControlPanel::property_changed(const std::string& predicate, const Raul::Atom& value, bool parent) { - _voice_spinbutton->set_range(0, poly - 1); -} - - -void -ControlPanel::polyphonic_changed(bool poly) -{ - if (poly) - _voice_control_box->show(); - else - _voice_control_box->hide(); + if (!parent && 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/libs/gui/ControlPanel.hpp b/src/libs/gui/ControlPanel.hpp index 9dded79b..8af5a728 100644 --- a/src/libs/gui/ControlPanel.hpp +++ b/src/libs/gui/ControlPanel.hpp @@ -69,8 +69,8 @@ public: private: void all_voices_selected(); void specific_voice_selected(); - void polyphony_changed(uint32_t poly); - void polyphonic_changed(bool poly); + + void property_changed(const std::string& predicate, const Raul::Atom& value, bool parent); bool _callback_enabled; diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp index 5aa07c27..92fcb221 100644 --- a/src/libs/gui/LoadPluginWindow.cpp +++ b/src/libs/gui/LoadPluginWindow.cpp @@ -345,7 +345,8 @@ LoadPluginWindow::add_clicked() dialog.run(); } else { Path path = _patch->path().base() + Path::nameify(name); - App::instance().engine()->new_node(path, plugin->uri(), polyphonic); + 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(); 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/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 9539c226..fe71dd2f 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -47,7 +47,7 @@ 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::mem_fun(this, &NodeModule::remove_port)); node->signal_variable.connect(sigc::mem_fun(this, &NodeModule::set_variable)); - node->signal_polyphonic.connect(sigc::mem_fun(this, &NodeModule::set_stacked_border)); + node->signal_property.connect(sigc::mem_fun(this, &NodeModule::set_property)); node->signal_renamed.connect(sigc::mem_fun(this, &NodeModule::rename)); } @@ -308,5 +308,13 @@ NodeModule::set_variable(const string& key, const Atom& value) } +void +NodeModule::set_property(const string& key, const Atom& value) +{ + if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) + set_stacked_border(value.get_bool()); +} + + } // namespace GUI } // namespace Ingen diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp index 4f877b74..3bf2d3eb 100644 --- a/src/libs/gui/NodeModule.hpp +++ b/src/libs/gui/NodeModule.hpp @@ -73,6 +73,7 @@ protected: void rename(); void set_variable(const std::string& key, const Atom& value); + void set_property(const std::string& predicate, const Raul::Atom& value); void add_port(SharedPtr<PortModel> port, bool resize=true); void remove_port(SharedPtr<PortModel> port); diff --git a/src/libs/gui/ObjectMenu.cpp b/src/libs/gui/ObjectMenu.cpp index 3a208d51..8f7c3869 100644 --- a/src/libs/gui/ObjectMenu.cpp +++ b/src/libs/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_polyphonic.connect(sigc::mem_fun(this, &ObjectMenu::polyphonic_changed)); + object->signal_property.connect(sigc::mem_fun(this, &ObjectMenu::property_changed)); _enable_signal = true; } @@ -83,10 +83,11 @@ ObjectMenu::on_menu_polyphonic() void -ObjectMenu::polyphonic_changed(bool polyphonic) +ObjectMenu::property_changed(const std::string& predicate, const Raul::Atom& value) { _enable_signal = false; - _polyphonic_menuitem->set_active(polyphonic); + if (predicate == "ingen:polyphonic" && value.type() == Atom::BOOL) + _polyphonic_menuitem->set_active(value.get_bool()); _enable_signal = true; } diff --git a/src/libs/gui/ObjectMenu.hpp b/src/libs/gui/ObjectMenu.hpp index 712322e3..b5c5bf49 100644 --- a/src/libs/gui/ObjectMenu.hpp +++ b/src/libs/gui/ObjectMenu.hpp @@ -51,7 +51,7 @@ protected: void on_menu_destroy(); void on_menu_properties(); - void polyphonic_changed(bool polyphonic); + void property_changed(const std::string& predicate, const Raul::Atom& value); bool _enable_signal; SharedPtr<ObjectModel> _object; diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index 77aa64e6..df6ba285 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -627,7 +627,7 @@ PatchCanvas::load_plugin(SharedPtr<PluginModel> plugin) const Path path = _patch->path().base() + name; // FIXME: polyphony? - App::instance().engine()->new_node(path, plugin->uri(), false); + 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) App::instance().engine()->set_variable(path, i->first, i->second); diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp index a6192210..75504a91 100644 --- a/src/libs/gui/PatchPortModule.cpp +++ b/src/libs/gui/PatchPortModule.cpp @@ -58,8 +58,8 @@ PatchPortModule::PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPt set_stacked_border(port->polyphonic()); - port->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::variable_change)); - port->signal_polyphonic.connect(sigc::mem_fun(this, &PatchPortModule::set_stacked_border)); + port->signal_variable.connect(sigc::mem_fun(this, &PatchPortModule::set_variable)); + port->signal_property.connect(sigc::mem_fun(this, &PatchPortModule::set_property)); } @@ -77,7 +77,10 @@ PatchPortModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortMod ret->set_menu(ret->_patch_port->menu()); for (GraphObject::Variables::const_iterator m = port->variables().begin(); m != port->variables().end(); ++m) - ret->variable_change(m->first, m->second); + ret->set_variable(m->first, m->second); + + for (GraphObject::Variables::const_iterator m = port->properties().begin(); m != port->properties().end(); ++m) + ret->set_property(m->first, m->second); ret->resize(); @@ -114,7 +117,7 @@ PatchPortModule::store_location() void -PatchPortModule::variable_change(const string& key, const Atom& value) +PatchPortModule::set_variable(const string& key, const Atom& value) { if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); @@ -123,5 +126,13 @@ PatchPortModule::variable_change(const string& key, const Atom& value) } +void +PatchPortModule::set_property(const string& key, const Atom& value) +{ + if (key == "ingen:polyphonic" && value.type() == Atom::BOOL) + set_stacked_border(value.get_bool()); +} + + } // namespace GUI } // namespace Ingen diff --git a/src/libs/gui/PatchPortModule.hpp b/src/libs/gui/PatchPortModule.hpp index 5e103bbf..bdf9c6d5 100644 --- a/src/libs/gui/PatchPortModule.hpp +++ b/src/libs/gui/PatchPortModule.hpp @@ -61,8 +61,10 @@ public: protected: PatchPortModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<PortModel> port); - void variable_change(const string& key, const Raul::Atom& value); void create_menu(); + + 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; PortMenu* _menu; |