Patch port and breadcrumb fixes.

git-svn-id: http://svn.drobilla.net/lad@135 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
dave 2006-09-14 23:14:53 +00:00
parent c87d84b448
commit 83a21401f9
8 changed files with 84 additions and 50 deletions

View File

@ -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;
} else {
// Empty existing breadcrumbs
for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
remove(**i);
_breadcrumbs.clear();
_full_path = path;
_active_path = path;
// Add root
BreadCrumb* but = create_crumb("/", view);
pack_start(*but, false, false, 1);
_breadcrumbs.push_front(but);
but->set_active(but->path() == _active_path);
// Empty existing breadcrumbs
for (std::list<BreadCrumb*>::iterator i = _breadcrumbs.begin(); i != _breadcrumbs.end(); ++i)
remove(**i);
_breadcrumbs.clear();
// Add the others
while (path != "/") {
BreadCrumb* but = create_crumb(path, view);
// 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;
}

View File

@ -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));
@ -134,6 +136,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)
{

View File

@ -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);

View File

@ -117,14 +117,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)
{

View File

@ -57,7 +57,6 @@ public:
}
virtual void store_location();
void move_to(double x, double y);
void on_right_click(GdkEventButton* event);

View File

@ -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

View File

@ -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
};

View File

@ -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;
}