From 3dded8a655b6cad1925f160cb1012b8334e00c3e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 31 Dec 2009 18:27:20 +0000 Subject: Various fixes related to port values and metadata (fix ticket #459 among other things). Fix jitterey behaviour of port controls (on module) while dragging. Update value in status bar while dragging port slider (on module). Update plugin data (e.g. port control range) if the plugin is sent to the client after nodes that are instances of it (i.e. more robust plugin state tracking via merging like with objects). Correctly save and restore port values (ticket #459). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2327 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientStore.cpp | 29 ++++++++++++++++------------- src/client/NodeModel.hpp | 1 + src/client/ObjectModel.cpp | 2 +- src/client/PluginModel.cpp | 20 ++++++++++++++++++++ src/client/PluginModel.hpp | 9 ++++++++- 5 files changed, 46 insertions(+), 15 deletions(-) (limited to 'src/client') diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 74a0faad..64e84494 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -184,11 +184,13 @@ ClientStore::resource(const URI& uri) void ClientStore::add_plugin(SharedPtr pm) { - // FIXME: dupes? merge, like with objects? - - (*_plugins)[pm->uri()] = pm; - signal_new_plugin(pm); - //cerr << "Plugin: " << pm->uri() << ", # plugins: " << _plugins->size() << endl; + SharedPtr existing = this->plugin(pm->uri()); + if (existing) { + existing->set(pm); + } else { + _plugins->insert(make_pair(pm->uri(), pm)); + signal_new_plugin(pm); + } } @@ -300,15 +302,16 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) const Resource::Properties::const_iterator p = properties.find("rdf:instanceOf"); SharedPtr plug; if (p->second.is_valid() && p->second.type() == Atom::URI) { - if ((plug = plugin(p->second.get_uri()))) { - SharedPtr n(new NodeModel(plug, path)); - n->set_properties(properties); - add_object(n); - } else { - SharedPtr n(new NodeModel(p->second.get_uri(), path)); - n->set_properties(properties); - add_object(n); + if (!(plug = plugin(p->second.get_uri()))) { + cout << "WARNING: Unable to find plugin " << p->second.get_uri() << endl; + plug = SharedPtr( + new PluginModel(p->second.get_uri(), "ingen:nil", Resource::Properties())); + add_plugin(plug); } + + SharedPtr n(new NodeModel(plug, path)); + n->set_properties(properties); + add_object(n); } else { cerr << "ERROR: Plugin with no type" << endl; } diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index b5af737e..57d2f09c 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -57,6 +57,7 @@ public: const Raul::URI& plugin_uri() const { return _plugin_uri; } const Shared::Plugin* plugin() const { return _plugin.get(); } + Shared::Plugin* plugin() { return _plugin.get(); } uint32_t num_ports() const { return _ports.size(); } const Ports& ports() const { return _ports; } diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index e41be6c9..6c64735d 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -83,7 +83,7 @@ ObjectModel::polyphonic() const /** Merge the data of @a model with self, as much as possible. * * This will merge the two models, but with any conflict take the value in - * @a model as correct. The paths of the two models MUST be equal. + * @a o as correct. The paths of the two models MUST be equal. */ void ObjectModel::set(SharedPtr o) diff --git a/src/client/PluginModel.cpp b/src/client/PluginModel.cpp index 4f1a4626..c40bb7ef 100644 --- a/src/client/PluginModel.cpp +++ b/src/client/PluginModel.cpp @@ -128,6 +128,26 @@ PluginModel::get_property(const URI& key) const } +void +PluginModel::set(SharedPtr p) +{ + _type = p->_type; + _icon_path = p->_icon_path; + +#ifdef HAVE_SLV2 + if (p->_slv2_plugin) + _slv2_plugin = p->_slv2_plugin; +#endif + + for (Properties::const_iterator v = p->properties().begin(); v != p->properties().end(); ++v) { + ResourceImpl::set_property(v->first, v->second); + signal_property.emit(v->first, v->second); + } + + signal_changed.emit(); +} + + Symbol PluginModel::default_node_symbol() { diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index 90440efe..b9407334 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -89,8 +89,15 @@ public: static Redland::World* rdf_world() { return _rdf_world; } + // Signals + sigc::signal signal_changed; + +protected: + friend class ClientStore; + void set(SharedPtr p); + private: - const Type _type; + Type _type; #ifdef HAVE_SLV2 static SLV2World _slv2_world; -- cgit v1.2.1