summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-09-14 23:14:53 +0000
committerDavid Robillard <d@drobilla.net>2006-09-14 23:14:53 +0000
commitf9f760893e4fa1ff850becf7d98bd4c6af8b8d73 (patch)
tree1cf83435ef5ee08c31bb9ddc11b9dbca96264158 /src/progs
parenta100c20612fc4f7f30372f579e355f782befa7e2 (diff)
downloadingen-f9f760893e4fa1ff850becf7d98bd4c6af8b8d73.tar.gz
ingen-f9f760893e4fa1ff850becf7d98bd4c6af8b8d73.tar.bz2
ingen-f9f760893e4fa1ff850becf7d98bd4c6af8b8d73.zip
Patch port and breadcrumb fixes.
git-svn-id: http://svn.drobilla.net/lad/ingen@135 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/ingenuity/BreadCrumbBox.cpp56
-rw-r--r--src/progs/ingenuity/OmFlowCanvas.cpp20
-rw-r--r--src/progs/ingenuity/OmFlowCanvas.h3
-rw-r--r--src/progs/ingenuity/OmModule.cpp8
-rw-r--r--src/progs/ingenuity/OmModule.h1
-rw-r--r--src/progs/ingenuity/OmPortModule.cpp36
-rw-r--r--src/progs/ingenuity/OmPortModule.h4
-rw-r--r--src/progs/ingenuity/PatchWindow.cpp12
8 files changed, 87 insertions, 53 deletions
diff --git a/src/progs/ingenuity/BreadCrumbBox.cpp b/src/progs/ingenuity/BreadCrumbBox.cpp
index 8dc0b8a0..c4234e8a 100644
--- a/src/progs/ingenuity/BreadCrumbBox.cpp
+++ b/src/progs/ingenuity/BreadCrumbBox.cpp
@@ -53,11 +53,10 @@ BreadCrumbBox::build(Path path, CountedPtr<PatchView> view)
_active_path = path;
_enable_signal = old_enable_signal;
- return;
- }
+
// Moving to a child of the full path, just append crumbs (preserve view cache)
- if (_breadcrumbs.size() > 0 && (path.is_child_of(_full_path))) {
+ } else if (_breadcrumbs.size() > 0 && (path.is_child_of(_full_path))) {
string postfix = path.substr(_full_path.length());
while (postfix.length() > 0) {
const string name = postfix.substr(0, postfix.find("/"));
@@ -66,40 +65,45 @@ BreadCrumbBox::build(Path path, CountedPtr<PatchView> view)
BreadCrumb* but = create_crumb(_full_path, view);
pack_end(*but, false, false, 1);
_breadcrumbs.push_back(but);
+ but->show();
if (postfix.find("/") == string::npos)
break;
else
postfix = postfix.substr(postfix.find("/")+1);
}
- }
+
+ for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
+ (*i)->set_active(false);
+ _breadcrumbs.back()->set_active(true);
+
+ // Rebuild from scratch
// Getting here is bad unless absolutely necessary, since the PatchView cache is lost
-
- // Otherwise rebuild from scratch
- _full_path = path;
- _active_path = path;
-
- // Empty existing breadcrumbs
- for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
- remove(**i);
- _breadcrumbs.clear();
-
- // Add root
- BreadCrumb* but = create_crumb("/", view);
- pack_start(*but, false, false, 1);
- _breadcrumbs.push_front(but);
- but->set_active(but->path() == _active_path);
-
- // Add the others
- while (path != "/") {
- BreadCrumb* but = create_crumb(path, view);
+ } else {
+
+ _full_path = path;
+ _active_path = path;
+
+ // Empty existing breadcrumbs
+ for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
+ remove(**i);
+ _breadcrumbs.clear();
+
+ // Add root
+ BreadCrumb* but = create_crumb("/", view);
pack_start(*but, false, false, 1);
_breadcrumbs.push_front(but);
but->set_active(but->path() == _active_path);
- path = path.parent();
- }
- show_all_children();
+ // Add the others
+ while (path != "/") {
+ BreadCrumb* but = create_crumb(path, view);
+ pack_start(*but, false, false, 1);
+ _breadcrumbs.push_front(but);
+ but->set_active(but->path() == _active_path);
+ path = path.parent();
+ }
+ }
_enable_signal = old_enable_signal;
}
diff --git a/src/progs/ingenuity/OmFlowCanvas.cpp b/src/progs/ingenuity/OmFlowCanvas.cpp
index dfd89f8a..35b5c064 100644
--- a/src/progs/ingenuity/OmFlowCanvas.cpp
+++ b/src/progs/ingenuity/OmFlowCanvas.cpp
@@ -79,6 +79,8 @@ OmFlowCanvas::OmFlowCanvas(CountedPtr<PatchModel> patch, int width, int height)
// Connect to model signals to track state
m_patch->new_node_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::add_node));
m_patch->removed_node_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::remove_node));
+ m_patch->new_port_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::add_port));
+ m_patch->removed_port_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::remove_port));
m_patch->new_connection_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::connection));
m_patch->removed_connection_sig.connect(sigc::mem_fun(this, &OmFlowCanvas::disconnection));
@@ -135,6 +137,24 @@ OmFlowCanvas::remove_node(CountedPtr<NodeModel> nm)
void
+OmFlowCanvas::add_port(CountedPtr<PortModel> pm)
+{
+ cerr << "FIXME: PORT MODULE LEAK!" << endl;
+
+ new OmPortModule(this, pm);
+}
+
+
+void
+OmFlowCanvas::remove_port(CountedPtr<PortModel> pm)
+{
+ cerr << "FIXME: PORT REMOVE" << endl;
+ //LibFlowCanvas::Module* module = get_module(pm->path().name());
+ //delete module;
+}
+
+
+void
OmFlowCanvas::connection(CountedPtr<ConnectionModel> cm)
{
// Deal with port "anonymous nodes" for this patch's own ports...
diff --git a/src/progs/ingenuity/OmFlowCanvas.h b/src/progs/ingenuity/OmFlowCanvas.h
index ae5501c4..ffbaa363 100644
--- a/src/progs/ingenuity/OmFlowCanvas.h
+++ b/src/progs/ingenuity/OmFlowCanvas.h
@@ -31,6 +31,7 @@ using LibFlowCanvas::Port;
using Ingen::Client::ConnectionModel;
using Ingen::Client::PatchModel;
using Ingen::Client::NodeModel;
+using Ingen::Client::PortModel;
using Ingen::Client::MetadataMap;
namespace Ingenuity {
@@ -52,6 +53,8 @@ public:
void add_node(CountedPtr<NodeModel> nm);
void remove_node(CountedPtr<NodeModel> nm);
+ void add_port(CountedPtr<PortModel> pm);
+ void remove_port(CountedPtr<PortModel> pm);
void connection(CountedPtr<ConnectionModel> cm);
void disconnection(const Path& src_port_path, const Path& dst_port_path);
diff --git a/src/progs/ingenuity/OmModule.cpp b/src/progs/ingenuity/OmModule.cpp
index 9e06d910..489b035a 100644
--- a/src/progs/ingenuity/OmModule.cpp
+++ b/src/progs/ingenuity/OmModule.cpp
@@ -118,14 +118,6 @@ OmModule::store_location()
void
-OmModule::move_to(double x, double y)
-{
- Module::move_to(x, y);
- //store_location();
-}
-
-
-void
OmModule::on_right_click(GdkEventButton* event)
{
m_menu.popup(event->button, event->time);
diff --git a/src/progs/ingenuity/OmModule.h b/src/progs/ingenuity/OmModule.h
index 243c31e7..e20391c6 100644
--- a/src/progs/ingenuity/OmModule.h
+++ b/src/progs/ingenuity/OmModule.h
@@ -57,7 +57,6 @@ public:
}
virtual void store_location();
- void move_to(double x, double y);
void on_right_click(GdkEventButton* event);
diff --git a/src/progs/ingenuity/OmPortModule.cpp b/src/progs/ingenuity/OmPortModule.cpp
index aaa26205..7496a6a6 100644
--- a/src/progs/ingenuity/OmPortModule.cpp
+++ b/src/progs/ingenuity/OmPortModule.cpp
@@ -32,7 +32,8 @@ namespace Ingenuity {
OmPortModule::OmPortModule(OmFlowCanvas* canvas, CountedPtr<PortModel> port)
: LibFlowCanvas::Module(canvas, "", 0, 0), // FIXME: coords?
- m_port(port)
+ m_port(port),
+ m_patch_port(NULL)
{
/*if (port_model()->polyphonic() && port_model()->parent() != NULL
&& port_model()->parent_patch()->poly() > 1) {
@@ -62,33 +63,36 @@ OmPortModule::OmPortModule(OmFlowCanvas* canvas, CountedPtr<PortModel> port)
canvas->get_new_module_location(default_x, default_y);
move_to(default_x, default_y);
}
+
+ port->metadata_update_sig.connect(sigc::mem_fun(this, &OmPortModule::metadata_update));
}
void
OmPortModule::store_location()
-{
- char temp_buf[16];
+{
+ const float x = static_cast<float>(property_x());
+ const float y = static_cast<float>(property_y());
- //m_port->x(property_x());
- snprintf(temp_buf, 16, "%f", property_x().get_value());
- //m_port->set_metadata("module-x", temp_buf); // just in case?
- App::instance().engine()->set_metadata(m_port->path(), "module-x", temp_buf);
+ const Atom& existing_x = m_port->get_metadata("module-x");
+ const Atom& existing_y = m_port->get_metadata("module-y");
- //m_port->y(property_y());
- snprintf(temp_buf, 16, "%f", property_y().get_value());
- //m_port->set_metadata("module-y", temp_buf); // just in case?
- App::instance().engine()->set_metadata(m_port->path(), "module-y", temp_buf);
+ if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT
+ || existing_x.get_float() != x || existing_y.get_float() != y) {
+ App::instance().engine()->set_metadata(m_port->path(), "module-x", Atom(x));
+ App::instance().engine()->set_metadata(m_port->path(), "module-y", Atom(y));
+ }
}
void
-OmPortModule::move_to(double x, double y)
+OmPortModule::metadata_update(const string& key, const Atom& value)
{
- Module::move_to(x, y);
- //m_port->x(x);
- //m_port->y(y);
- //store_location();
+ if (key == "module-x" && value.type() == Atom::FLOAT)
+ move_to(value.get_float(), property_y());
+ else if (key == "module-y" && value.type() == Atom::FLOAT)
+ move_to(property_x(), value.get_float());
}
+
} // namespace Ingenuity
diff --git a/src/progs/ingenuity/OmPortModule.h b/src/progs/ingenuity/OmPortModule.h
index 00d20f96..028f3c78 100644
--- a/src/progs/ingenuity/OmPortModule.h
+++ b/src/progs/ingenuity/OmPortModule.h
@@ -20,6 +20,7 @@
#include <string>
#include <libgnomecanvasmm.h>
#include <flowcanvas/Module.h>
+#include "util/Atom.h"
#include "OmPatchPort.h"
using std::string;
@@ -53,7 +54,6 @@ public:
//}
virtual void store_location();
- void move_to(double x, double y);
//void on_right_click(GdkEventButton* event) { m_port->show_menu(event); }
@@ -63,6 +63,8 @@ protected:
//virtual void on_double_click(GdkEventButton* ev) { show_control_window(); }
//virtual void on_middle_click(GdkEventButton* ev) { show_control_window(); }
+ void metadata_update(const string& key, const Atom& value);
+
CountedPtr<PortModel> m_port;
OmPatchPort* m_patch_port; ///< Port on this 'anonymous' module
};
diff --git a/src/progs/ingenuity/PatchWindow.cpp b/src/progs/ingenuity/PatchWindow.cpp
index 07bcb781..d3bfd14b 100644
--- a/src/progs/ingenuity/PatchWindow.cpp
+++ b/src/progs/ingenuity/PatchWindow.cpp
@@ -161,15 +161,23 @@ PatchWindow::set_patch(CountedPtr<PatchModel> patch, CountedPtr<PatchView> view)
m_view = view ? view : PatchView::create(patch);
assert(m_view);
+ // Add view to ourself
+ if (m_view->get_parent())
+ m_view->get_parent()->remove(*m_view);
+
m_viewport->remove();
m_viewport->add(*m_view.get());
+
+ // Add our breadcrumbs to the view
+ if (m_breadcrumb_box->get_parent())
+ m_breadcrumb_box->get_parent()->remove(*m_breadcrumb_box);
+
m_view->breadcrumb_container()->remove();
m_view->breadcrumb_container()->add(*m_breadcrumb_box);
m_breadcrumb_box->build(patch->path(), m_view);
m_breadcrumb_box->show();
- show_all();
//m_menu_view_control_window->property_sensitive() = patch->has_control_inputs();
@@ -190,6 +198,8 @@ PatchWindow::set_patch(CountedPtr<PatchModel> patch, CountedPtr<PatchView> view)
m_patch->destroyed_sig.connect(sigc::mem_fun(this, &PatchWindow::patch_destroyed));
+ show_all();
+
m_enable_signal = true;
}