From 2be10b0b6f2c0f01870208e9d18e5db87e5dfb88 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 24 Sep 2011 02:27:45 +0000 Subject: Only store patch canvas coordinates in containing patch. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3483 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/PatchCanvas.cpp | 17 +++++++++++------ src/gui/PatchCanvas.hpp | 2 +- src/gui/SubpatchModule.cpp | 37 ++++++++++++++++++++++++++++++++++--- src/gui/SubpatchModule.hpp | 2 ++ 4 files changed, 48 insertions(+), 10 deletions(-) (limited to 'src/gui') 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& ancestors); - GraphObject::Properties get_initial_data(); + GraphObject::Properties get_initial_data(Resource::Graph ctx=Resource::DEFAULT); FlowCanvas::Port* get_port_view(SharedPtr 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 +#include + #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(property_x())); + const Atom y(static_cast(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(); -- cgit v1.2.1