From 9393c08013974c53d398678f0c1b683a67ca1135 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 3 Dec 2011 21:45:57 +0000 Subject: Don't expose canvas data structures. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3775 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/NodeModule.cpp | 16 +++++------ src/gui/PatchCanvas.cpp | 67 +++++++++++++++++++++++++++------------------ src/gui/PatchCanvas.hpp | 3 +- src/gui/PatchPortModule.cpp | 6 ++-- src/gui/PatchWindow.cpp | 2 +- src/gui/Port.cpp | 12 ++++---- 6 files changed, 60 insertions(+), 46 deletions(-) (limited to 'src/gui') diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 108cc2e4..b478e419 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -123,7 +123,7 @@ NodeModule::create(PatchCanvas& canvas, p != node->ports().end(); ++p) ret->new_port_view(*p); - ret->set_stacked_border(node->polyphonic()); + ret->set_stacked(node->polyphonic()); if (human) ret->show_human_names(human); // FIXME: double port iteration @@ -145,12 +145,12 @@ NodeModule::show_human_names(bool b) if (b && node()->plugin()) { const Raul::Atom& name_property = node()->get_property(uris.lv2_name); if (name_property.type() == Atom::STRING) - set_name(name_property.get_string()); + set_label(name_property.get_string()); else - set_name(node()->plugin_model()->human_name()); + set_label(node()->plugin_model()->human_name().c_str()); } else { b = false; - set_name(node()->symbol().c_str()); + set_label(node()->symbol().c_str()); } for (Ports::const_iterator i = ports().begin(); i != ports().end(); ++i) { @@ -167,7 +167,7 @@ NodeModule::show_human_names(bool b) label = hn; } } - (*i)->set_name(label); + (*i)->set_label(label.c_str()); } } @@ -258,7 +258,7 @@ void NodeModule::rename() { if (app().configuration()->name_style() == Configuration::PATH) { - set_name(_node->path().symbol()); + set_label(_node->path().symbol()); } } @@ -403,7 +403,7 @@ NodeModule::property_changed(const URI& key, const Atom& value) break; case Atom::BOOL: if (key == uris.ingen_polyphonic) { - set_stacked_border(value.get_bool()); + set_stacked(value.get_bool()); } else if (key == uris.ingen_selected) { if (value.get_bool() != get_selected()) { if (value.get_bool()) @@ -416,7 +416,7 @@ NodeModule::property_changed(const URI& key, const Atom& value) case Atom::STRING: if (key == uris.lv2_name && app().configuration()->name_style() == Configuration::HUMAN) { - set_name(value.get_string()); + set_label(value.get_string()); } default: break; } diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 82a72bd5..25df6d61 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -304,30 +304,40 @@ PatchCanvas::build() } } -void -PatchCanvas::show_human_names(bool b) +static void +show_module_human_names(FlowCanvasNode* node, void* data) { - _human_names = b; - FOREACH_ITEM(m, items()) { - NodeModule* mod = dynamic_cast(*m); - if (mod) - mod->show_human_names(b); + bool b = *(bool*)data; + if (FLOW_CANVAS_IS_MODULE(node)) { + FlowCanvas::Module* module = Glib::wrap(FLOW_CANVAS_MODULE(node)); + NodeModule* nmod = dynamic_cast(module); + if (nmod) + nmod->show_human_names(b); - PatchPortModule* pmod = dynamic_cast(*m); + PatchPortModule* pmod = dynamic_cast(module); if (pmod) pmod->show_human_names(b); } } +void +PatchCanvas::show_human_names(bool b) +{ + _human_names = b; + for_each_node(show_module_human_names, &b); +} void PatchCanvas::show_port_names(bool b) { + std::cerr << "FIXME: show port names" << std::endl; + #if 0 _show_port_names = b; FOREACH_ITEM(i, items()) { FlowCanvas::Module* m = dynamic_cast(*i); if (m) m->set_show_port_labels(b); } + #endif } void @@ -544,7 +554,7 @@ PatchCanvas::auto_menu_position(int& x, int& y, bool& push_in) } bool -PatchCanvas::canvas_event(GdkEvent* event) +PatchCanvas::on_event(GdkEvent* event) { assert(event); @@ -585,7 +595,7 @@ PatchCanvas::canvas_event(GdkEvent* event) default: break; } - return (ret ? true : Canvas::canvas_event(event)); + return (ret ? true : Canvas::on_event(event)); } void @@ -599,34 +609,38 @@ PatchCanvas::clear_selection() FlowCanvas::Canvas::clear_selection(); } -void -PatchCanvas::destroy_selection() +static void +destroy_module(FlowCanvasNode* node, void* data) { - FOREACH_ITEM(m, selected_items()) { - NodeModule* module = dynamic_cast(*m); - if (module) { - _app.engine()->del(module->node()->path()); - } else { - PatchPortModule* port_module = dynamic_cast(*m); - if (port_module) - _app.engine()->del(port_module->port()->path()); + if (!FLOW_CANVAS_IS_MODULE(node)) { + return; + } + + App* app = (App*)data; + FlowCanvas::Module* module = Glib::wrap(FLOW_CANVAS_MODULE(node)); + NodeModule* node_module = dynamic_cast(module); + + if (node_module) { + app->engine()->del(node_module->node()->path()); + } else { + PatchPortModule* port_module = dynamic_cast(module); + if (port_module) { + app->engine()->del(port_module->port()->path()); } } } void -PatchCanvas::select_all() +PatchCanvas::destroy_selection() { - unselect_ports(); - FOREACH_ITEM(m, items()) - if (dynamic_cast(*m)) - if (!(*m)->get_selected()) - select_item(*m); + for_each_selected_node(destroy_module, &_app); } void PatchCanvas::copy_selection() { + std::cerr << "FIXME: copy" << std::endl; + #if 0 static const char* base_uri = ""; Serialiser serialiser(*_app.world(), _app.store()); serialiser.start_to_string(_patch->path(), base_uri); @@ -657,6 +671,7 @@ PatchCanvas::copy_selection() Glib::RefPtr clipboard = Gtk::Clipboard::get(); clipboard->set_text(result); + #endif } void diff --git a/src/gui/PatchCanvas.hpp b/src/gui/PatchCanvas.hpp index c0dfe8d8..6da98b85 100644 --- a/src/gui/PatchCanvas.hpp +++ b/src/gui/PatchCanvas.hpp @@ -88,11 +88,10 @@ public: void destroy_selection(); void copy_selection(); void paste(); - void select_all(); void show_menu(bool position, unsigned button, uint32_t time); - bool canvas_event(GdkEvent* event); + bool on_event(GdkEvent* event); private: enum ControlType { NUMBER, BUTTON }; diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 98326402..2083b929 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -47,7 +47,7 @@ PatchPortModule::PatchPortModule(PatchCanvas& canvas, assert(PtrCast(model->parent())); - set_stacked_border(model->polyphonic()); + set_stacked(model->polyphonic()); model->signal_property().connect( sigc::mem_fun(this, &PatchPortModule::property_changed)); @@ -123,7 +123,7 @@ PatchPortModule::show_human_names(bool b) void PatchPortModule::set_name(const std::string& n) { - _port->set_name(n); + _port->set_label(n.c_str()); _must_resize = true; } @@ -150,7 +150,7 @@ PatchPortModule::property_changed(const URI& key, const Atom& value) break; case Atom::BOOL: if (key == uris.ingen_polyphonic) { - set_stacked_border(value.get_bool()); + set_stacked(value.get_bool()); } else if (key == uris.ingen_selected) { if (value.get_bool() != get_selected()) { if (value.get_bool()) { diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index eb388ca5..cd4b4ab7 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -635,7 +635,7 @@ bool PatchWindow::on_event(GdkEvent* event) { if ((event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE) - && _view->canvas()->canvas_event(event)) { + && _view->canvas()->on_event(event)) { return true; } else { return Gtk::Window::on_event(event); diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 5d6d7f39..293f3a22 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -85,7 +85,7 @@ Port::Port(App& app, pm->signal_moved().connect(sigc::mem_fun(this, &Port::moved)); if (app.can_control(pm.get())) { - set_toggled(pm->is_toggle()); + set_control_is_toggle(pm->is_toggle()); show_control(); pm->signal_property().connect( sigc::mem_fun(this, &Port::property_changed)); @@ -135,7 +135,7 @@ void Port::moved() { if (_app.configuration()->name_style() == Configuration::PATH) - set_name(model()->symbol().c_str()); + set_label(model()->symbol().c_str()); } void @@ -144,7 +144,7 @@ Port::value_changed(const Atom& value) if (_pressed) return; else if (value.type() == Atom::FLOAT) - FlowCanvas::Port::set_control(value.get_float()); + FlowCanvas::Port::set_control_value(value.get_float()); } bool @@ -249,7 +249,7 @@ Port::set_control(float value, bool signal) pw->show_port_status(model().get(), value); } - FlowCanvas::Port::set_control(value); + FlowCanvas::Port::set_control_value(value); } void @@ -273,13 +273,13 @@ Port::property_changed(const URI& key, const Atom& value) } } else if (key == uris.lv2_portProperty) { if (value == uris.lv2_toggled) - set_toggled(true); + set_control_is_toggle(true); } else if (key == uris.ctx_context) { Raul::info << "TODO: Visual indication of port context?" << std::endl; } else if (key == uris.lv2_name) { if (value.type() == Atom::STRING && _app.configuration()->name_style() == Configuration::HUMAN) { - set_name(value.get_string()); + set_label(value.get_string()); } } } -- cgit v1.2.1