From 15611d1f9d7a6aba34b70ccaf63f564d565b55f3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 10 Jun 2011 01:45:19 +0000 Subject: Avoid resizing entirely when adding a port and new size/etc is simple to compute. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3382 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/NodeModule.cpp | 8 ++++---- src/gui/NodeModule.hpp | 2 +- src/gui/PatchCanvas.cpp | 19 +++++++++++-------- src/gui/PatchCanvas.hpp | 2 +- src/gui/PatchPortModule.cpp | 6 +++--- src/gui/PatchPortModule.hpp | 6 +++--- src/gui/Port.cpp | 4 ++-- src/gui/Port.hpp | 10 +++++----- 8 files changed, 30 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index e634793c..07d759c5 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -86,18 +86,18 @@ NodeModule::create_menu() set_menu(_menu); } -boost::shared_ptr +NodeModule* NodeModule::create(PatchCanvas& canvas, SharedPtr node, bool human) { - boost::shared_ptr ret; + NodeModule* ret; SharedPtr patch = PtrCast(node); if (patch) - ret = boost::shared_ptr(new SubpatchModule(canvas, patch)); + ret = new SubpatchModule(canvas, patch); else - ret = boost::shared_ptr(new NodeModule(canvas, node)); + ret = new NodeModule(canvas, node); for (GraphObject::Properties::const_iterator m = node->properties().begin(); m != node->properties().end(); ++m) diff --git a/src/gui/NodeModule.hpp b/src/gui/NodeModule.hpp index db6fb274..d275b648 100644 --- a/src/gui/NodeModule.hpp +++ b/src/gui/NodeModule.hpp @@ -49,7 +49,7 @@ class NodeMenu; class NodeModule : public FlowCanvas::Module { public: - static boost::shared_ptr create( + static NodeModule* create( PatchCanvas& canvas, SharedPtr node, bool human_names); diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 0b5d4056..13836154 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -380,7 +380,7 @@ void PatchCanvas::add_node(SharedPtr nm) { SharedPtr pm = PtrCast(nm); - SharedPtr module; + NodeModule* module; if (pm) { module = SubpatchModule::create(*this, pm, _human_names); } else { @@ -400,6 +400,7 @@ PatchCanvas::remove_node(SharedPtr nm) Views::iterator i = _views.find(nm); if (i != _views.end()) { + delete i->second; _views.erase(i); } } @@ -407,7 +408,7 @@ PatchCanvas::remove_node(SharedPtr nm) void PatchCanvas::add_port(SharedPtr pm) { - SharedPtr view = PatchPortModule::create(*this, pm, _human_names); + PatchPortModule* view = PatchPortModule::create(*this, pm, _human_names); _views.insert(std::make_pair(pm, view)); view->show(); } @@ -419,10 +420,11 @@ PatchCanvas::remove_port(SharedPtr pm) // Port on this patch if (i != _views.end()) { + delete i->second; _views.erase(i); } else { - SharedPtr module = PtrCast(_views[pm->parent()]); + NodeModule* module = dynamic_cast(_views[pm->parent()]); module->delete_port_view(pm); } @@ -432,15 +434,16 @@ PatchCanvas::remove_port(SharedPtr pm) FlowCanvas::Port* PatchCanvas::get_port_view(SharedPtr port) { - SharedPtr module = _views[port]; + FlowCanvas::Module* module = _views[port]; // Port on this patch if (module) { - return (dynamic_cast(module.get())) - ? *(dynamic_cast(module.get())->ports().begin()) - : dynamic_cast(module.get()); + PatchPortModule* ppm = dynamic_cast(module); + return ppm + ? *ppm->ports().begin() + : dynamic_cast(module); } else { - module = PtrCast(_views[port->parent()]); + module = dynamic_cast(_views[port->parent()]); if (module) { for (Module::Ports::const_iterator p = module->ports().begin(); p != module->ports().end(); ++p) { diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index 243f76ae..e20aa96b 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -135,7 +135,7 @@ private: SharedPtr _patch; typedef std::map, - SharedPtr + FlowCanvas::Module* > Views; Views _views; diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 49dc4925..08889d8d 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -53,13 +53,13 @@ PatchPortModule::PatchPortModule(PatchCanvas& canvas, sigc::mem_fun(this, &PatchPortModule::property_changed)); } -boost::shared_ptr +PatchPortModule* PatchPortModule::create(PatchCanvas& canvas, SharedPtr model, bool human) { - boost::shared_ptr ret(new PatchPortModule(canvas, model)); - boost::shared_ptr port(Port::create(*ret, model, human, true)); + PatchPortModule* ret = new PatchPortModule(canvas, model); + Port* port = Port::create(*ret, model, human, true); ret->set_port(port); ret->set_menu(port->menu()); diff --git a/src/gui/PatchPortModule.hpp b/src/gui/PatchPortModule.hpp index 9334c48f..42607315 100644 --- a/src/gui/PatchPortModule.hpp +++ b/src/gui/PatchPortModule.hpp @@ -49,7 +49,7 @@ class PortMenu; class PatchPortModule : public FlowCanvas::Module { public: - static boost::shared_ptr create( + static PatchPortModule* create( PatchCanvas& canvas, SharedPtr model, bool human); @@ -68,12 +68,12 @@ protected: void create_menu(); void set_selected(bool b); - void set_port(SharedPtr port) { _port = port; } + void set_port(Port* port) { _port = port; } void property_changed(const Raul::URI& predicate, const Raul::Atom& value); SharedPtr _model; - SharedPtr _port; + Port* _port; PortMenu* _menu; }; diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 72c37b12..bc623950 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -40,7 +40,7 @@ namespace GUI { ArtVpathDash* Port::_dash; -SharedPtr +Port* Port::create(FlowCanvas::Module& module, SharedPtr pm, bool human_name, @@ -57,7 +57,7 @@ Port::create(FlowCanvas::Module& module, label = parent->plugin_model()->port_human_name(pm->index()); } } - return SharedPtr(new Port(module, pm, label, flip)); + return new Port(module, pm, label, flip); } /** @a flip Make an input port appear as an output port, and vice versa. diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 17b1c37b..3bc66cd3 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -40,11 +40,11 @@ namespace GUI { class Port : public FlowCanvas::Port { public: - static SharedPtr create( - FlowCanvas::Module& module, - SharedPtr pm, - bool human_name, - bool flip = false); + static Port* create( + FlowCanvas::Module& module, + SharedPtr pm, + bool human_name, + bool flip = false); ~Port(); -- cgit v1.2.1