diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/LoadPatchWindow.cpp | 15 | ||||
-rw-r--r-- | src/gui/LoadRemotePatchWindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/LoadSubpatchWindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/PatchCanvas.cpp | 46 | ||||
-rw-r--r-- | src/gui/PatchCanvas.hpp | 1 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.cpp | 27 | ||||
-rw-r--r-- | src/gui/ThreadedLoader.hpp | 14 |
7 files changed, 67 insertions, 45 deletions
diff --git a/src/gui/LoadPatchWindow.cpp b/src/gui/LoadPatchWindow.cpp index 5da4b459..0373ee80 100644 --- a/src/gui/LoadPatchWindow.cpp +++ b/src/gui/LoadPatchWindow.cpp @@ -137,15 +137,16 @@ LoadPatchWindow::ok_clicked() if (_replace) App::instance().engine()->clear_patch(_patch->path()); - //if (_patch->path() != "/") - // parent = _patch->path().parent(); - parent = _patch->path(); - + if (_patch->path() != "/") { + parent = _patch->path().parent(); + symbol = _patch->symbol(); + } + _patch.reset(); hide(); - - App::instance().loader()->load_patch(true, get_uri(), "/", - _initial_data, parent, symbol); + + App::instance().loader()->load_patch(true, get_uri(), Path("/"), + parent, symbol, _initial_data); } diff --git a/src/gui/LoadRemotePatchWindow.cpp b/src/gui/LoadRemotePatchWindow.cpp index c2979e80..dab1cd0e 100644 --- a/src/gui/LoadRemotePatchWindow.cpp +++ b/src/gui/LoadRemotePatchWindow.cpp @@ -134,8 +134,6 @@ LoadRemotePatchWindow::open_clicked() { Glib::ustring uri = _uri_entry->get_text(); - cerr << "OPEN URI: " << uri << endl; - // If unset load_patch will load values optional<Path> parent; optional<Symbol> symbol; @@ -146,8 +144,8 @@ LoadRemotePatchWindow::open_clicked() if (_patch->path() != "/") parent = _patch->path().parent(); - App::instance().loader()->load_patch(true, uri, "/", - _initial_data, parent, symbol); + App::instance().loader()->load_patch(true, uri, Path("/"), + parent, symbol, _initial_data); hide(); } diff --git a/src/gui/LoadSubpatchWindow.cpp b/src/gui/LoadSubpatchWindow.cpp index 5bdd8ea6..f6ec41d2 100644 --- a/src/gui/LoadSubpatchWindow.cpp +++ b/src/gui/LoadSubpatchWindow.cpp @@ -169,7 +169,8 @@ LoadSubpatchWindow::ok_clicked() Atom& y = _initial_data["ingenuity:canvas-y"]; y = Atom(y.get_float() + 20.0f); - App::instance().loader()->load_patch(false, *i, "/", _initial_data, _patch->path(), symbol); + App::instance().loader()->load_patch(false, *i, Path("/"), + _patch->path(), symbol, _initial_data); } hide(); diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 852aca5e..8a580b88 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -58,6 +58,7 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height) , _patch(patch) , _last_click_x(0) , _last_click_y(0) + , _paste_count(0) , _refresh_menu(false) , _human_names(true) , _show_port_names(true) @@ -632,6 +633,7 @@ PatchCanvas::copy_selection() } string result = serialiser.finish(); + _paste_count = 0; Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get(); clipboard->set_text(result); @@ -649,30 +651,51 @@ PatchCanvas::paste() } clear_selection(); + ++_paste_count; Builder builder(*App::instance().engine()); ClientStore clipboard; clipboard.set_plugins(App::instance().store()->plugins()); + + // mkdir -p + string to_create = _patch->path().substr(1); + string created = "/"; clipboard.new_patch("/", _patch->poly()); + size_t first_slash; + while (to_create != "/" && to_create != "" + && (first_slash = to_create.find("/")) != string::npos) { + created += to_create.substr(0, first_slash); + assert(Path::is_valid(created)); + clipboard.new_patch(created, _patch->poly()); + to_create = to_create.substr(first_slash + 1); + } + + if (_patch->path() != "/") + clipboard.new_patch(_patch->path(), _patch->poly()); - ClashAvoider avoider(*App::instance().store().get(), _patch->path(), clipboard, &clipboard); - parser->parse_string(App::instance().world(), &avoider, str, "/", _patch->path()); + boost::optional<Raul::Path> data_path; + boost::optional<Raul::Path> parent; + boost::optional<Raul::Symbol> symbol; + + if (_patch->path() != "/") { + parent = _patch->path(); + } + + ClashAvoider avoider(*App::instance().store().get(), clipboard, &clipboard); + parser->parse_string(App::instance().world(), &avoider, str, "", data_path, + parent, symbol); for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) { - //cout << "************ OBJECT: " << i->first << endl; if (_patch->path() == "/" && i->first == "/") { - //cout << "SKIPPING ROOT " << _patch->path() << " :: " << i->first << endl; - continue; - } else if (i->first.parent() != "/") { - //cout << "SKIPPING NON ROOTED OBJECT " << i->first << endl; + //cout << "Skipping root" << endl; continue; } GraphObject::Variables::iterator x = i->second->variables().find("ingenuity:canvas-x"); if (x != i->second->variables().end()) - x->second = x->second.get_float() + 20.0f; + x->second = x->second.get_float() + (20.0f * _paste_count); GraphObject::Variables::iterator y = i->second->variables().find("ingenuity:canvas-y"); if (y != i->second->variables().end()) - y->second = y->second.get_float() + 20.0f; + 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()) @@ -680,11 +703,11 @@ PatchCanvas::paste() else i->second->properties().insert(make_pair("ingen:selected", true)); } - builder.build(_patch->path(), i->second); + builder.build(i->second); } // Successful connections - SharedPtr<PatchModel> root = PtrCast<PatchModel>(clipboard.object("/")); + SharedPtr<PatchModel> root = PtrCast<PatchModel>(clipboard.object(_patch->path())); assert(root); for (Patch::Connections::const_iterator i = root->connections().begin(); i != root->connections().end(); ++i) { @@ -694,6 +717,7 @@ PatchCanvas::paste() // Orphan connections (just in case...) for (ClientStore::ConnectionRecords::const_iterator i = clipboard.connection_records().begin(); i != clipboard.connection_records().end(); ++i) { + cout << "WARNING: Orphan connection paste: " << i->first << " -> " << i->second << endl; App::instance().engine()->connect(i->first, i->second); } } diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index 67553284..f257da4e 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -128,6 +128,7 @@ private: int _last_click_x; int _last_click_y; + int _paste_count; typedef std::multimap<const std::string, Gtk::Menu*> ClassMenus; ClassMenus _class_menus; diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index d2bfec76..ec39abf3 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -81,12 +81,12 @@ ThreadedLoader::_whipped() } void -ThreadedLoader::load_patch(bool merge, - const Glib::ustring& data_base_uri, - const Path& data_path, - GraphObject::Variables engine_data, - optional<Path> engine_parent, - optional<Symbol> engine_symbol) +ThreadedLoader::load_patch(bool merge, + const Glib::ustring& document_uri, + optional<Path> data_path, + optional<Path> engine_parent, + optional<Symbol> engine_symbol, + optional<GraphObject::Variables> engine_data) { _mutex.lock(); @@ -99,26 +99,23 @@ ThreadedLoader::load_patch(bool merge, } // Filthy hack to load deprecated patches based on file extension - if (data_base_uri.substr(data_base_uri.length()-3) == ".om") { + if (document_uri.substr(document_uri.length()-3) == ".om") { _events.push_back(sigc::hide_return(sigc::bind( sigc::mem_fun(_deprecated_loader, &DeprecatedLoader::load_patch), - data_base_uri, + document_uri, merge, engine_parent, engine_symbol, - engine_data, + *engine_data, false))); } else { - if (merge && (!engine_parent || engine_parent.get() == "/")) - engine_base = engine_base.substr(0, engine_base.find_last_of("/")); - _events.push_back(sigc::hide_return(sigc::bind( sigc::mem_fun(_parser.get(), &Ingen::Serialisation::Parser::parse_document), App::instance().world(), App::instance().world()->engine.get(), - data_base_uri, // document - data_base_uri + data_path.substr(1), // object URI document - engine_base, + document_uri, + data_path, + engine_parent, engine_symbol, engine_data))); } diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index fee298d8..50e5deb1 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -57,13 +57,13 @@ class ThreadedLoader : public Raul::Slave public: ThreadedLoader(SharedPtr<EngineInterface> engine); - void load_patch(bool merge, - const Glib::ustring& data_base_uri, - const Path& data_path, - GraphObject::Variables engine_data, - optional<Path> engine_parent = optional<Path>(), - optional<Symbol> engine_symbol = optional<Symbol>()); - + void load_patch(bool merge, + const Glib::ustring& document_uri, + optional<Path> data_path, + optional<Path> engine_parent, + optional<Symbol> engine_symbol, + optional<GraphObject::Variables> engine_data); + void save_patch(SharedPtr<PatchModel> model, const string& filename); SharedPtr<Parser> parser(); |