diff options
author | David Robillard <d@drobilla.net> | 2011-09-24 02:27:45 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-09-24 02:27:45 +0000 |
commit | 2be10b0b6f2c0f01870208e9d18e5db87e5dfb88 (patch) | |
tree | e5bf3a28b59978c6464bb07eac160a458b01cd0d /src | |
parent | 4cc5c82a87cf2316f425a9ea1de0fb29d0c24c8e (diff) | |
download | ingen-2be10b0b6f2c0f01870208e9d18e5db87e5dfb88.tar.gz ingen-2be10b0b6f2c0f01870208e9d18e5db87e5dfb88.tar.bz2 ingen-2be10b0b6f2c0f01870208e9d18e5db87e5dfb88.zip |
Only store patch canvas coordinates in containing patch.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3483 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/client/ObjectModel.cpp | 5 | ||||
-rw-r--r-- | src/gui/PatchCanvas.cpp | 17 | ||||
-rw-r--r-- | src/gui/PatchCanvas.hpp | 2 | ||||
-rw-r--r-- | src/gui/SubpatchModule.cpp | 37 | ||||
-rw-r--r-- | src/gui/SubpatchModule.hpp | 2 | ||||
-rw-r--r-- | src/server/events/SetMetadata.cpp | 10 | ||||
-rw-r--r-- | src/shared/ResourceImpl.cpp | 12 | ||||
-rw-r--r-- | src/shared/ResourceImpl.hpp | 3 |
8 files changed, 65 insertions, 23 deletions
diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 940bd51e..de783ac2 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -57,9 +57,10 @@ ObjectModel::set_property(const Raul::URI& key, const Raul::Atom& value, } void -ObjectModel::add_property(const Raul::URI& key, const Raul::Atom& value) +ObjectModel::add_property(const Raul::URI& key, const Raul::Atom& value, + Resource::Graph ctx) { - ResourceImpl::add_property(key, value); + ResourceImpl::add_property(key, value, ctx); _signal_property.emit(key, value); } diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 13836154..ded2cbe9 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -822,31 +822,36 @@ PatchCanvas::get_new_module_location(double& x, double& y) } GraphObject::Properties -PatchCanvas::get_initial_data() +PatchCanvas::get_initial_data(Resource::Graph ctx) { GraphObject::Properties result; const LV2URIMap& uris = App::instance().uris(); - result.insert(make_pair(uris.ingenui_canvas_x, Atom((float)_last_click_x))); - result.insert(make_pair(uris.ingenui_canvas_y, Atom((float)_last_click_y))); + result.insert(make_pair(uris.ingenui_canvas_x, + Resource::Property((float)_last_click_x, ctx))); + result.insert(make_pair(uris.ingenui_canvas_y, + Resource::Property((float)_last_click_y, ctx))); return result; } void PatchCanvas::menu_load_plugin() { - App::instance().window_factory()->present_load_plugin(_patch, get_initial_data()); + App::instance().window_factory()->present_load_plugin( + _patch, get_initial_data()); } void PatchCanvas::menu_load_patch() { - App::instance().window_factory()->present_load_subpatch(_patch, get_initial_data()); + App::instance().window_factory()->present_load_subpatch( + _patch, get_initial_data(Resource::EXTERNAL)); } void PatchCanvas::menu_new_patch() { - App::instance().window_factory()->present_new_subpatch(_patch, get_initial_data()); + App::instance().window_factory()->present_new_subpatch( + _patch, get_initial_data(Resource::EXTERNAL)); } void diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index e20aa96b..654b2dca 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -122,7 +122,7 @@ private: const LV2Children& children, std::set<const char*>& ancestors); - GraphObject::Properties get_initial_data(); + GraphObject::Properties get_initial_data(Resource::Graph ctx=Resource::DEFAULT); FlowCanvas::Port* get_port_view(SharedPtr<PortModel> port); diff --git a/src/gui/SubpatchModule.cpp b/src/gui/SubpatchModule.cpp index 8481d185..3cadb506 100644 --- a/src/gui/SubpatchModule.cpp +++ b/src/gui/SubpatchModule.cpp @@ -15,18 +15,25 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "SubpatchModule.hpp" #include <cassert> +#include <utility> + #include "ingen/ServerInterface.hpp" #include "ingen/client/PatchModel.hpp" + #include "App.hpp" -#include "NodeModule.hpp" +#include "LV2URIMap.hpp" #include "NodeControlWindow.hpp" -#include "PatchWindow.hpp" +#include "NodeModule.hpp" #include "PatchCanvas.hpp" +#include "PatchWindow.hpp" #include "Port.hpp" +#include "SubpatchModule.hpp" #include "WindowFactory.hpp" +using namespace std; +using namespace Raul; + namespace Ingen { namespace GUI { @@ -52,6 +59,30 @@ SubpatchModule::on_double_click(GdkEventButton* event) App::instance().window_factory()->present_patch(_patch, preferred); } +void +SubpatchModule::store_location() +{ + const Atom x(static_cast<float>(property_x())); + const Atom y(static_cast<float>(property_y())); + + const LV2URIMap& uris = App::instance().uris(); + + const Atom& existing_x = _node->get_property(uris.ingenui_canvas_x); + const Atom& existing_y = _node->get_property(uris.ingenui_canvas_y); + + if (x != existing_x && y != existing_y) { + Resource::Properties remove; + remove.insert(make_pair(uris.ingenui_canvas_x, uris.wildcard)); + remove.insert(make_pair(uris.ingenui_canvas_y, uris.wildcard)); + Resource::Properties add; + add.insert(make_pair(uris.ingenui_canvas_x, + Resource::Property(x, Resource::EXTERNAL))); + add.insert(make_pair(uris.ingenui_canvas_y, + Resource::Property(y, Resource::EXTERNAL))); + App::instance().engine()->delta(_node->path(), remove, add); + } +} + /** Browse to this patch in current (parent's) window * (unless an existing window is displaying it) */ diff --git a/src/gui/SubpatchModule.hpp b/src/gui/SubpatchModule.hpp index b58c78fa..97a7d85c 100644 --- a/src/gui/SubpatchModule.hpp +++ b/src/gui/SubpatchModule.hpp @@ -53,6 +53,8 @@ public: void on_double_click(GdkEventButton* ev); + void store_location(); + void browse_to_patch(); void menu_remove(); diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index b01e17cb..1a2d6b17 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -174,12 +174,12 @@ SetMetadata::pre_process() } for (Properties::iterator p = _properties.begin(); p != _properties.end(); ++p) { - const Raul::URI& key = p->first; - const Raul::Atom& value = p->second; - SpecialType op = NONE; + const Raul::URI& key = p->first; + const Resource::Property& value = p->second; + SpecialType op = NONE; if (obj) { Resource& resource = *obj; - resource.add_property(key, value); + resource.add_property(key, value, value.context()); PortImpl* port = dynamic_cast<PortImpl*>(_object); if (port) { @@ -231,7 +231,7 @@ SetMetadata::pre_process() if (value.type() == Atom::BOOL) { op = POLYPHONIC; _blocking = true; - obj->set_property(key, value.get_bool()); + obj->set_property(key, value.get_bool(), value.context()); NodeImpl* node = dynamic_cast<NodeImpl*>(obj); if (node) node->set_polyphonic(value.get_bool()); diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 729a8152..e6f4ba70 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -27,16 +27,18 @@ namespace Ingen { namespace Shared { void -ResourceImpl::add_property(const Raul::URI& uri, const Raul::Atom& value) +ResourceImpl::add_property(const Raul::URI& uri, + const Raul::Atom& value, + Graph ctx) { // Ignore duplicate statements typedef Resource::Properties::const_iterator iterator; const std::pair<iterator,iterator> range = _properties.equal_range(uri); for (iterator i = range.first; i != range.second && i != _properties.end(); ++i) - if (i->second == value) + if (i->second == value && i->second.context() == ctx) return; - _properties.insert(make_pair(uri, value)); + _properties.insert(make_pair(uri, Property(value, ctx))); } const Raul::Atom& @@ -165,7 +167,7 @@ void ResourceImpl::set_properties(const Properties& p) { for (Resource::Properties::const_iterator i = p.begin(); i != p.end(); ++i) { - set_property(i->first, i->second); + set_property(i->first, i->second, i->second.context()); } } @@ -174,7 +176,7 @@ ResourceImpl::add_properties(const Properties& p) { typedef Resource::Properties::const_iterator iterator; for (iterator i = p.begin(); i != p.end(); ++i) - add_property(i->first, i->second); + add_property(i->first, i->second, i->second.context()); } void diff --git a/src/shared/ResourceImpl.hpp b/src/shared/ResourceImpl.hpp index 0d96d840..6f5a2ed2 100644 --- a/src/shared/ResourceImpl.hpp +++ b/src/shared/ResourceImpl.hpp @@ -50,7 +50,8 @@ public: Resource::Graph ctx=Resource::DEFAULT); void remove_property(const Raul::URI& uri, const Raul::Atom& value); bool has_property(const Raul::URI& uri, const Raul::Atom& value) const; - void add_property(const Raul::URI& uri, const Raul::Atom& value); + void add_property(const Raul::URI& uri, const Raul::Atom& value, + Graph ctx=DEFAULT); void set_properties(const Properties& p); void add_properties(const Properties& p); void remove_properties(const Properties& p); |