From 254b434f0a79fea54bd963e8ff2e845a5b0cd3a6 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 19 Mar 2012 20:16:46 +0000 Subject: Partially functioning communication between Ingen LV2 plugin and UI. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4078 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/App.cpp | 4 +-- src/gui/App.hpp | 5 +-- src/gui/Configuration.cpp | 2 +- src/gui/Controls.cpp | 23 ++++++------- src/gui/LoadPluginWindow.cpp | 8 ++--- src/gui/NodeModule.cpp | 31 +++++++---------- src/gui/ObjectMenu.cpp | 2 +- src/gui/PatchBox.cpp | 10 +++--- src/gui/PatchCanvas.cpp | 43 +++++++++++++----------- src/gui/PatchPortModule.cpp | 12 +++---- src/gui/PatchTreeWindow.cpp | 2 +- src/gui/PatchView.cpp | 11 +++--- src/gui/PatchWindow.cpp | 1 + src/gui/Port.cpp | 8 ++--- src/gui/PortMenu.cpp | 2 +- src/gui/PortPropertiesWindow.cpp | 2 +- src/gui/PropertiesWindow.cpp | 72 +++++++++++++++++++++++++--------------- src/gui/PropertiesWindow.hpp | 6 ++-- src/gui/RenameWindow.cpp | 2 +- src/gui/WindowFactory.cpp | 8 +++-- src/gui/ingen_gui_lv2.cpp | 18 ++++++++-- 21 files changed, 152 insertions(+), 120 deletions(-) (limited to 'src/gui') diff --git a/src/gui/App.cpp b/src/gui/App.cpp index ad70a7f9..431b144c 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -225,8 +225,8 @@ App::property_change(const Raul::URI& subject, const Raul::Atom& value) { if (subject == uris().ingen_engine && key == uris().ingen_sampleRate) { - if (value.type() == Atom::INT) { - LOG(info) << "Sample rate: " << value << std::endl; + if (value.type() == forge().Int) { + LOG(info) << "Sample rate: " << uris().forge.str(value) << std::endl; _sample_rate = value.get_int32(); } else { error << "Engine sample rate property is not an integer" << std::endl; diff --git a/src/gui/App.hpp b/src/gui/App.hpp index 7b45a6e8..7f66c629 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -25,8 +25,9 @@ #include -#include "raul/SharedPtr.hpp" #include "raul/Deletable.hpp" +#include "raul/SharedPtr.hpp" +#include "raul/URI.hpp" #include "ingen/Status.hpp" #include "ingen/shared/World.hpp" @@ -101,7 +102,7 @@ public: Glib::RefPtr icon_from_path(const std::string& path, int size); - Raul::Forge& forge() const { return _world->forge(); } + Ingen::Forge& forge() const { return _world->forge(); } SharedPtr engine() const { return _world->engine(); } SharedPtr client() const { return _client; } SharedPtr store() const { return _store; } diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp index 2d8cf2e6..b85a997c 100644 --- a/src/gui/Configuration.cpp +++ b/src/gui/Configuration.cpp @@ -91,7 +91,7 @@ Configuration::get_port_color(const PortModel* p) return _string_port_color; } else if (_app.can_control(p)) { return _control_port_color; - } else if (p->is_a(uris.ev_EventPort) || p->is_a(uris.atom_MessagePort)) { + } else if (p->is_a(uris.atom_MessagePort)) { return _event_port_color; } diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index c3fe2658..87903f8e 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -218,9 +218,9 @@ SliderControl::port_property_changed(const URI& key, const Atom& value) _enable_signal = false; const Shared::URIs& uris = _app->uris(); - if (key == uris.lv2_minimum && value.type() == Atom::FLOAT) + if (key == uris.lv2_minimum && value.type() == uris.forge.Float) set_range(value.get_float(), _slider->get_adjustment()->get_upper()); - else if (key == uris.lv2_maximum && value.type() == Atom::FLOAT) + else if (key == uris.lv2_maximum && value.type() == uris.forge.Float) set_range(_slider->get_adjustment()->get_lower(), value.get_float()); _enable_signal = true; @@ -320,18 +320,15 @@ ToggleControl::init(App& app, ControlPanel* panel, SharedPtr pm void ToggleControl::set_value(const Atom& val) { - bool enable = false; - switch (val.type()) { - case Atom::FLOAT: + const Shared::URIs& uris = _app->uris(); + bool enable = false; + if (val.type() == uris.forge.Float) { enable = (val.get_float() != 0.0f); - break; - case Atom::INT: + } else if (val.type() == uris.forge.Int) { enable = (val.get_int32() != 0); - break; - case Atom::BOOL: + } else if (val.type() == uris.forge.Bool) { enable = (val.get_bool()); - break; - default: + } else { error << "Unsupported value type for toggle control" << endl; } @@ -380,7 +377,7 @@ void StringControl::set_value(const Atom& val) { _enable_signal = false; - if (val.type() == Atom::STRING) + if (val.type() == _app->forge().String) _entry->set_text(val.get_string()); else error << "Non-string value for string port " << _port_model->path() << endl; @@ -393,7 +390,7 @@ StringControl::activated() if (_enable_signal) _control_panel->value_changed_atom( _port_model, - _app->forge().make(_entry->get_text().c_str())); + _app->forge().alloc(_entry->get_text().c_str())); } } // namespace GUI diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index 95bbc0b6..3b8b1c44 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -226,7 +226,7 @@ LoadPluginWindow::set_row(Gtk::TreeModel::Row& row, { const URIs& uris = _app->uris(); const Atom& name = plugin->get_property(uris.doap_name); - if (name.is_valid() && name.type() == Atom::STRING) + if (name.is_valid() && name.type() == uris.forge.String) row[_plugins_columns._col_name] = name.get_string(); switch (plugin->type()) { @@ -344,7 +344,7 @@ LoadPluginWindow::load_plugin(const Gtk::TreeModel::iterator& iter) Path path = _patch->path().base() + Path::nameify(name); Resource::Properties props = _initial_data; props.insert(make_pair(uris.rdf_type, uris.ingen_Node)); - props.insert(make_pair(uris.rdf_instanceOf, plugin->uri())); + props.insert(make_pair(uris.rdf_instanceOf, _app->forge().alloc_uri(plugin->uri().str()))); props.insert(make_pair(uris.ingen_polyphonic, _app->forge().make(polyphonic))); _app->engine()->put(path, props); @@ -395,7 +395,7 @@ LoadPluginWindow::filter_changed() switch (criteria) { case CriteriaColumns::NAME: - if (name.is_valid() && name.type() == Atom::STRING) + if (name.is_valid() && name.type() == uris.forge.String) field = name.get_string(); break; case CriteriaColumns::TYPE: @@ -441,7 +441,7 @@ LoadPluginWindow::plugin_property_changed(const URI& plugin, const URIs& uris = _app->uris(); if (predicate == uris.doap_name) { Rows::const_iterator i = _rows.find(plugin); - if (i != _rows.end() && value.type() == Atom::STRING) + if (i != _rows.end() && value.type() == uris.forge.String) (*i->second)[_plugins_columns._col_name] = value.get_string(); } } diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 697961db..7ab0be5f 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -138,7 +138,7 @@ 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) + if (name_property.type() == uris.forge.String) set_label(name_property.get_string()); else set_label(node()->plugin_model()->human_name().c_str()); @@ -152,7 +152,7 @@ NodeModule::show_human_names(bool b) Glib::ustring label(port->model()->symbol().c_str()); if (b) { const Raul::Atom& name_property = port->model()->get_property(uris.lv2_name); - if (name_property.type() == Atom::STRING) { + if (name_property.type() == uris.forge.String) { label = name_property.get_string(); } else { Glib::ustring hn = node()->plugin_model()->port_human_name( @@ -171,18 +171,15 @@ NodeModule::value_changed(uint32_t index, const Atom& value) if (!_plugin_ui) return; - float float_val = 0.0f; + float float_val = 0.0f; + const URIs& uris = app().uris(); - switch (value.type()) { - case Atom::FLOAT: + if (value.type() == uris.forge.Float) { float_val = value.get_float(); _plugin_ui->port_event(index, 4, 0, &float_val); - break; - case Atom::STRING: - _plugin_ui->port_event(index, strlen(value.get_string()), 0, value.get_string()); - break; - default: - break; + } else if (value.type() == uris.forge.String) { + _plugin_ui->port_event( + index, strlen(value.get_string()), 0, value.get_string()); } } @@ -397,15 +394,13 @@ void NodeModule::property_changed(const URI& key, const Atom& value) { const Shared::URIs& uris = app().uris(); - switch (value.type()) { - case Atom::FLOAT: + if (value.type() == uris.forge.Float) { if (key == uris.ingen_canvasX) { move_to(value.get_float(), get_y()); } else if (key == uris.ingen_canvasY) { move_to(get_x(), value.get_float()); } - break; - case Atom::BOOL: + } else if (value.type() == uris.forge.Bool) { if (key == uris.ingen_polyphonic) { set_stacked(value.get_bool()); } else if (key == uris.ingen_selected) { @@ -413,13 +408,11 @@ NodeModule::property_changed(const URI& key, const Atom& value) set_selected(value.get_bool()); } } - break; - case Atom::STRING: + } else if (value.type() == uris.forge.String) { if (key == uris.lv2_name - && app().configuration()->name_style() == Configuration::HUMAN) { + && app().configuration()->name_style() == Configuration::HUMAN) { set_label(value.get_string()); } - default: break; } } diff --git a/src/gui/ObjectMenu.cpp b/src/gui/ObjectMenu.cpp index 76607559..a5ffa845 100644 --- a/src/gui/ObjectMenu.cpp +++ b/src/gui/ObjectMenu.cpp @@ -124,7 +124,7 @@ ObjectMenu::property_changed(const URI& predicate, const Atom& value) { const URIs& uris = _app->uris(); _enable_signal = false; - if (predicate == uris.ingen_polyphonic && value.type() == Atom::BOOL) + if (predicate == uris.ingen_polyphonic && value.type() == uris.forge.Bool) _polyphonic_menuitem->set_active(value.get_bool()); _enable_signal = true; } diff --git a/src/gui/PatchBox.cpp b/src/gui/PatchBox.cpp index 127da746..1a38e027 100644 --- a/src/gui/PatchBox.cpp +++ b/src/gui/PatchBox.cpp @@ -22,8 +22,6 @@ #include #include -#include "raul/AtomRDF.hpp" - #include "ingen/Interface.hpp" #include "ingen/client/ClientStore.hpp" #include "ingen/client/PatchModel.hpp" @@ -359,7 +357,7 @@ PatchBox::show_port_status(const PortModel* port, const Raul::Atom& value) } if (value.is_valid()) { - msg << " = " << value; + msg << " = " << _app->forge().str(value); } _status_bar->pop(STATUS_CONTEXT_HOVER); @@ -421,7 +419,7 @@ void PatchBox::event_save() { const Raul::Atom& document = _patch->get_property(_app->uris().ingen_document); - if (!document.is_valid() || document.type() != Raul::Atom::URI) { + if (!document.is_valid() || document.type() != _app->uris().forge.URI) { event_save_as(); } else { _app->loader()->save_patch(_patch, document.get_uri()); @@ -467,7 +465,7 @@ PatchBox::event_save_as() // Set current folder to most sensible default const Raul::Atom& document = _patch->get_property(uris.ingen_document); - if (document.type() == Raul::Atom::URI) + if (document.type() == uris.forge.URI) dialog.set_uri(document.get_uri()); else if (_app->configuration()->patch_folder().length() > 0) dialog.set_current_folder(_app->configuration()->patch_folder()); @@ -536,7 +534,7 @@ PatchBox::event_save_as() _app->loader()->save_patch(_patch, uri); const_cast(_patch.get())->set_property( uris.ingen_document, - _app->forge().alloc(Atom::URI, uri.c_str()), + _app->forge().alloc_uri(uri.c_str()), Resource::EXTERNAL); _status_bar->push( (boost::format("Saved %1% to %2%") % _patch->path().chop_scheme() diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index 64c7df66..070a1da2 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -18,33 +18,37 @@ #include #include #include + #include -#include "raul/log.hpp" + #include "ganv/Canvas.hpp" #include "ganv/Circle.hpp" #include "ingen/Interface.hpp" -#include "ingen/shared/LV2URIMap.hpp" +#include "ingen/client/ClientStore.hpp" +#include "ingen/client/NodeModel.hpp" +#include "ingen/client/PatchModel.hpp" +#include "ingen/client/PluginModel.hpp" +#include "ingen/serialisation/Serialiser.hpp" #include "ingen/shared/Builder.hpp" #include "ingen/shared/ClashAvoider.hpp" -#include "ingen/serialisation/Serialiser.hpp" -#include "ingen/client/PluginModel.hpp" -#include "ingen/client/PatchModel.hpp" -#include "ingen/client/NodeModel.hpp" -#include "ingen/client/ClientStore.hpp" +#include "ingen/shared/LV2URIMap.hpp" #include "ingen/shared/World.hpp" +#include "lv2/lv2plug.in/ns/ext/atom/atom.h" +#include "raul/log.hpp" + #include "App.hpp" -#include "PatchCanvas.hpp" -#include "PatchWindow.hpp" -#include "PatchPortModule.hpp" +#include "Connection.hpp" #include "LoadPluginWindow.hpp" #include "NewSubpatchWindow.hpp" -#include "Port.hpp" -#include "Connection.hpp" #include "NodeModule.hpp" +#include "PatchCanvas.hpp" +#include "PatchPortModule.hpp" +#include "PatchWindow.hpp" +#include "Port.hpp" #include "SubpatchModule.hpp" +#include "ThreadedLoader.hpp" #include "WidgetFactory.hpp" #include "WindowFactory.hpp" -#include "ThreadedLoader.hpp" #define LOG(s) s << "[PatchCanvas] " @@ -108,10 +112,10 @@ PatchCanvas::PatchCanvas(App& app, "control_out", "Control Out", LV2_CORE__ControlPort, true)); _menu_add_event_input->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "event_in", "Event In", "http://lv2plug.in/ns/ext/event#EventPort", false)); + "event_in", "Event In", LV2_ATOM__MessagePort, false)); _menu_add_event_output->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &PatchCanvas::menu_add_port), - "event_out", "Event Out", "http://lv2plug.in/ns/ext/event#EventPort", true)); + "event_out", "Event Out", LV2_ATOM__MessagePort, true)); signal_event.connect( sigc::mem_fun(this, &PatchCanvas::on_event)); @@ -792,13 +796,13 @@ PatchCanvas::menu_add_port(const string& sym_base, const string& name_base, Resource::Properties props = get_initial_data(); props.insert(make_pair(uris.rdf_type, - type)); + _app.forge().alloc_uri(type.str()))); props.insert(make_pair(uris.rdf_type, is_output ? uris.lv2_OutputPort : uris.lv2_InputPort)); props.insert(make_pair(uris.lv2_index, _app.forge().make(int32_t(_patch->num_ports())))); props.insert(make_pair(uris.lv2_name, - _app.forge().make(name.c_str()))); + _app.forge().alloc(name.c_str()))); _app.engine()->put(path, props); } @@ -818,12 +822,13 @@ PatchCanvas::load_plugin(WeakPtr weak_plugin) } const URIs& uris = _app.uris(); + const Path path = _patch->path().child(symbol); - const Path path = _patch->path().child(symbol); // FIXME: polyphony? GraphObject::Properties props = get_initial_data(); props.insert(make_pair(uris.rdf_type, uris.ingen_Node)); - props.insert(make_pair(uris.rdf_instanceOf, plugin->uri())); + props.insert(make_pair(uris.rdf_instanceOf, + uris.forge.alloc_uri(plugin->uri().str()))); _app.engine()->put(path, props); } diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 1e5b1d5a..9ad1fe9a 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -114,7 +114,7 @@ PatchPortModule::show_human_names(bool b) { const URIs& uris = app().uris(); const Atom& name = _model->get_property(uris.lv2_name); - if (b && name.type() == Atom::STRING) + if (b && name.type() == uris.forge.String) set_name(name.get_string()); else set_name(_model->symbol().c_str()); @@ -131,15 +131,13 @@ void PatchPortModule::property_changed(const URI& key, const Atom& value) { const URIs& uris = app().uris(); - switch (value.type()) { - case Atom::FLOAT: + if (value.type() == uris.forge.Float) { if (key == uris.ingen_canvasX) { move_to(value.get_float(), get_y()); } else if (key == uris.ingen_canvasY) { move_to(get_x(), value.get_float()); } - break; - case Atom::STRING: + } else if (value.type() == uris.forge.String) { if (key == uris.lv2_name && app().configuration()->name_style() == Configuration::HUMAN) { set_name(value.get_string()); @@ -147,8 +145,7 @@ PatchPortModule::property_changed(const URI& key, const Atom& value) && app().configuration()->name_style() == Configuration::PATH) { set_name(value.get_string()); } - break; - case Atom::BOOL: + } else if (value.type() == uris.forge.Bool) { if (key == uris.ingen_polyphonic) { set_stacked(value.get_bool()); } else if (key == uris.ingen_selected) { @@ -156,7 +153,6 @@ PatchPortModule::property_changed(const URI& key, const Atom& value) set_selected(value.get_bool()); } } - default: break; } } diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp index 41d82899..486107ce 100644 --- a/src/gui/PatchTreeWindow.cpp +++ b/src/gui/PatchTreeWindow.cpp @@ -198,7 +198,7 @@ PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, { const URIs& uris = _app->uris(); _enable_signal = false; - if (key == uris.ingen_enabled && value.type() == Atom::BOOL) { + if (key == uris.ingen_enabled && value.type() == uris.forge.Bool) { Gtk::TreeModel::iterator i = find_patch(_patch_treestore->children(), patch); if (i != _patch_treestore->children().end()) { Gtk::TreeModel::Row row = *i; diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index 4506a651..a5932a23 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -207,6 +207,8 @@ void PatchView::refresh_clicked() { _app->engine()->get(_patch->path()); + Raul::warn << "Refresh plugins" << std::endl; + _app->engine()->get("ingen:plugins"); } void @@ -214,10 +216,11 @@ PatchView::property_changed(const Raul::URI& predicate, const Raul::Atom& value) { _enable_signal = false; if (predicate == _app->uris().ingen_enabled) { - if (value.type() == Atom::BOOL) - _process_but->set_active(value.get_bool()); - else - warn << "Bad type for ingen:enabled variable: " << value.type() << endl; + if (value.type() == _app->uris().forge.Bool) { + _process_but->set_active(value.get_bool()); + } else { + warn << "Bad type for ingen:enabled variable: " << value.type() << endl; + } } _enable_signal = true; } diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index f555ff37..6d29d532 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -53,6 +53,7 @@ PatchWindow::init_window(App& app) { Window::init_window(app); _box->init_box(app); + _box->set_window(this); } void diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index aa3786e3..d61724d6 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -50,7 +50,7 @@ Port::create(App& app, Glib::ustring label(human_name ? "" : pm->path().symbol()); if (human_name) { const Raul::Atom& name = pm->get_property(app.uris().lv2_name); - if (name.type() == Raul::Atom::STRING) { + if (name.type() == app.forge().String) { label = name.get_string(); } else { const SharedPtr parent(PtrCast(pm->parent())); @@ -163,7 +163,7 @@ Port::on_value_changed(const Glib::VariantBase& value) void Port::value_changed(const Atom& value) { - if (!_pressed && value.type() == Atom::FLOAT) { + if (!_pressed && value.type() == _app.forge().Float) { Ganv::Port::set_control_value(value.get_float()); } } @@ -278,7 +278,7 @@ void Port::property_changed(const URI& key, const Atom& value) { const URIs& uris = _app.uris(); - if (value.type() == Atom::FLOAT) { + if (value.type() == uris.forge.Float) { float val = value.get_float(); if (key == uris.ingen_value && !_pressed) { Ganv::Port::set_control_value(val); @@ -299,7 +299,7 @@ Port::property_changed(const URI& key, const Atom& value) } 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 + if (value.type() == uris.forge.String && _app.configuration()->name_style() == Configuration::HUMAN) { set_label(value.get_string()); } diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp index 60d419f6..dbd5890f 100644 --- a/src/gui/PortMenu.cpp +++ b/src/gui/PortMenu.cpp @@ -63,7 +63,7 @@ PortMenu::init(App& app, SharedPtr port, bool patch_port) _destroy_menuitem->set_sensitive(false); } - if (port->is_a(uris.ev_EventPort)) + if (port->is_a(uris.atom_MessagePort)) _polyphonic_menuitem->hide(); const bool is_control = app.can_control(port.get()) diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp index dd138b12..8c4530de 100644 --- a/src/gui/PortPropertiesWindow.cpp +++ b/src/gui/PortPropertiesWindow.cpp @@ -98,7 +98,7 @@ PortPropertiesWindow::property_changed(const URI& key, const Atom& value) { const Shared::URIs& uris = _app->uris(); - if (value.type() == Atom::FLOAT) { + if (value.type() == uris.forge.Float) { if (key == uris.lv2_minimum) _min_spinner->set_value(value.get_float()); else if (key == uris.lv2_maximum) diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp index 1543398b..42ff5e8b 100644 --- a/src/gui/PropertiesWindow.cpp +++ b/src/gui/PropertiesWindow.cpp @@ -35,6 +35,7 @@ namespace GUI { PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, const Glib::RefPtr& xml) : Window(cobject) + , _initialised(false) { xml->get_widget("properties_vbox", _vbox); xml->get_widget("properties_scrolledwindow", _scrolledwindow); @@ -43,15 +44,6 @@ PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, xml->get_widget("properties_apply_button", _apply_button); xml->get_widget("properties_ok_button", _ok_button); - _type_choices = Gtk::ListStore::create(_type_cols); - for (int i = Raul::Atom::INT; i <= Raul::Atom::BLOB; ++i) { - Gtk::TreeModel::Row row = *_type_choices->append(); - row[_type_cols.type] = static_cast(i); - ostringstream ss; - ss << static_cast(i); - row[_type_cols.choice] = ss.str(); - } - _cancel_button->signal_clicked().connect( sigc::mem_fun(this, &PropertiesWindow::cancel_clicked)); @@ -62,6 +54,33 @@ PropertiesWindow::PropertiesWindow(BaseObjectType* cobject, sigc::mem_fun(this, &PropertiesWindow::ok_clicked)); } +void +PropertiesWindow::init() +{ + Forge& forge = _app->forge(); + Gtk::TreeModel::Row row = *_type_choices->append(); + row[_type_cols.type] = forge.Int; + row[_type_cols.choice] = "Int"; + + row = *_type_choices->append(); + row[_type_cols.type] = forge.Float; + row[_type_cols.choice] = "Float"; + + row = *_type_choices->append(); + row[_type_cols.type] = forge.Bool; + row[_type_cols.choice] = "Bool"; + + row = *_type_choices->append(); + row[_type_cols.type] = forge.URI; + row[_type_cols.choice] = "URI"; + + row = *_type_choices->append(); + row[_type_cols.type] = forge.String; + row[_type_cols.choice] = "String"; + + _initialised = true; +} + void PropertiesWindow::reset() { @@ -137,7 +156,8 @@ PropertiesWindow::set_object(SharedPtr model) Gtk::Widget* PropertiesWindow::create_value_widget(const Raul::URI& uri, const Raul::Atom& value) { - if (value.type() == Atom::INT) { + Ingen::Forge& forge = _app->forge(); + if (value.type() == forge.Int) { Gtk::SpinButton* widget = manage(new Gtk::SpinButton(0.0, 0)); widget->property_numeric() = true; widget->set_value(value.get_int32()); @@ -148,7 +168,7 @@ PropertiesWindow::create_value_widget(const Raul::URI& uri, const Raul::Atom& va sigc::mem_fun(this, &PropertiesWindow::value_edited), uri)); return widget; - } else if (value.type() == Atom::FLOAT) { + } else if (value.type() == forge.Float) { Gtk::SpinButton* widget = manage(new Gtk::SpinButton(0.0, 4)); widget->property_numeric() = true; widget->set_snap_to_ticks(false); @@ -159,21 +179,21 @@ PropertiesWindow::create_value_widget(const Raul::URI& uri, const Raul::Atom& va sigc::mem_fun(this, &PropertiesWindow::value_edited), uri)); return widget; - } else if (value.type() == Atom::BOOL) { + } else if (value.type() == forge.Bool) { Gtk::CheckButton* widget = manage(new Gtk::CheckButton()); widget->set_active(value.get_bool()); widget->signal_toggled().connect(sigc::bind( sigc::mem_fun(this, &PropertiesWindow::value_edited), uri)); return widget; - } else if (value.type() == Atom::URI) { + } else if (value.type() == forge.URI) { Gtk::Entry* widget = manage(new Gtk::Entry()); widget->set_text(value.get_uri()); widget->signal_changed().connect(sigc::bind( sigc::mem_fun(this, &PropertiesWindow::value_edited), uri)); return widget; - } else if (value.type() == Atom::STRING) { + } else if (value.type() == forge.String) { Gtk::Entry* widget = manage(new Gtk::Entry()); widget->set_text(value.get_string()); widget->signal_changed().connect(sigc::bind( @@ -182,7 +202,7 @@ PropertiesWindow::create_value_widget(const Raul::URI& uri, const Raul::Atom& va return widget; } - LOG(error) << "Unable to create widget for value " << value << endl; + LOG(error) << "Unable to create widget for value " << forge.str(value) << endl; return NULL; } @@ -242,28 +262,29 @@ PropertiesWindow::value_edited(const Raul::URI& predicate) return; } - Record& record = r->second; - Raul::Atom::Type type = (*record.type_widget->get_active())[_type_cols.type]; - if (type == Atom::INT) { + Forge& forge = _app->forge(); + Record& record = r->second; + Raul::Atom::TypeID type = (*record.type_widget->get_active())[_type_cols.type]; + if (type == forge.Int) { Gtk::SpinButton* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; record.value = _app->forge().make(widget->get_value_as_int()); - } else if (type == Atom::FLOAT) { + } else if (type == forge.Float) { Gtk::SpinButton* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; record.value = _app->forge().make(static_cast(widget->get_value())); - } else if (type == Atom::BOOL) { + } else if (type == forge.Bool) { Gtk::CheckButton* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; record.value = _app->forge().make(widget->get_active()); - } else if (type == Atom::URI) { + } else if (type == forge.URI) { Gtk::Entry* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; - record.value = _app->forge().alloc(Atom::URI, widget->get_text()); - } else if (type == Atom::STRING) { + record.value = _app->forge().alloc_uri(widget->get_text()); + } else if (type == forge.String) { Gtk::Entry* widget = dynamic_cast(record.value_widget->get_child()); if (!widget) goto bad_type; - record.value = _app->forge().alloc(Atom::URI, widget->get_text()); + record.value = _app->forge().alloc_uri(widget->get_text()); } return; @@ -290,8 +311,7 @@ PropertiesWindow::apply_clicked() const Record& record = r->second; if (!_model->has_property(uri, record.value)) { LOG(debug) << "\t" << uri - << " = " << record.value - << " :: " << record.value.type() << endl; + << " = " << _app->forge().str(record.value) << endl; properties.insert(make_pair(uri, record.value)); } } diff --git a/src/gui/PropertiesWindow.hpp b/src/gui/PropertiesWindow.hpp index 43ed4023..58c4c8a0 100644 --- a/src/gui/PropertiesWindow.hpp +++ b/src/gui/PropertiesWindow.hpp @@ -63,12 +63,13 @@ private: public: TypeColumns() { add(type); add(choice); } - Gtk::TreeModelColumn type; - Gtk::TreeModelColumn choice; + Gtk::TreeModelColumn type; + Gtk::TreeModelColumn choice; }; Gtk::Widget* create_value_widget(const Raul::URI& uri, const Raul::Atom& value); + void init(); void reset(); void on_show(); @@ -94,6 +95,7 @@ private: Gtk::Button* _cancel_button; Gtk::Button* _apply_button; Gtk::Button* _ok_button; + bool _initialised : 1; }; } // namespace GUI diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp index 49323c4e..18c1e236 100644 --- a/src/gui/RenameWindow.cpp +++ b/src/gui/RenameWindow.cpp @@ -65,7 +65,7 @@ RenameWindow::set_object(SharedPtr object) _symbol_entry->set_text(object->path().symbol()); const Atom& name_atom = object->get_property("http://lv2plug.in/ns/lv2core#name"); _label_entry->set_text( - (name_atom.type() == Atom::STRING) ? name_atom.get_string() : ""); + (name_atom.type() == _app->forge().String) ? name_atom.get_string() : ""); } void diff --git a/src/gui/WindowFactory.cpp b/src/gui/WindowFactory.cpp index 811e697e..abbc4357 100644 --- a/src/gui/WindowFactory.cpp +++ b/src/gui/WindowFactory.cpp @@ -259,9 +259,11 @@ WindowFactory::present_load_plugin(SharedPtr patch, _load_plugin_win->set_modal(false); _load_plugin_win->set_type_hint(Gdk::WINDOW_TYPE_HINT_DIALOG); - int width, height; - w->second->get_size(width, height); - _load_plugin_win->set_default_size(width - width / 8, height / 2); + if (w->second) { + int width, height; + w->second->get_size(width, height); + _load_plugin_win->set_default_size(width - width / 8, height / 2); + } _load_plugin_win->set_title( string("Load Plugin - ") + patch->path().chop_scheme() + " - Ingen"); _load_plugin_win->present(patch, data); diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp index 9898005e..0004b935 100644 --- a/src/gui/ingen_gui_lv2.cpp +++ b/src/gui/ingen_gui_lv2.cpp @@ -18,6 +18,7 @@ #include "ingen/client/ClientStore.hpp" #include "ingen/client/PatchModel.hpp" #include "ingen/client/SigClientInterface.hpp" +#include "ingen/shared/AtomReader.hpp" #include "ingen/shared/AtomSink.hpp" #include "ingen/shared/AtomWriter.hpp" #include "ingen/shared/Configuration.hpp" @@ -55,20 +56,21 @@ struct IngenLV2AtomSink : public Ingen::Shared::AtomSink { struct IngenLV2UI { IngenLV2UI() - : conf(&forge) + : conf() , sink(NULL) { } int argc; char** argv; - Raul::Forge forge; + Ingen::Forge* forge; Ingen::Shared::Configuration conf; Ingen::Shared::World* world; IngenLV2AtomSink* sink; SharedPtr app; SharedPtr view; SharedPtr engine; + SharedPtr reader; SharedPtr client; }; @@ -98,6 +100,8 @@ instantiate(const LV2UI_Descriptor* descriptor, ui->world = new Ingen::Shared::World( &ui->conf, ui->argc, ui->argv, map, unmap); + ui->forge = new Ingen::Forge(*ui->world->lv2_uri_map().get()); + if (!ui->world->load_module("client")) { delete ui; return NULL; @@ -120,6 +124,13 @@ instantiate(const LV2UI_Descriptor* descriptor, new Ingen::Client::SigClientInterface()); ui->app->attach(ui->client); + ui->reader = SharedPtr( + new Ingen::Shared::AtomReader(*ui->world->lv2_uri_map().get(), + *ui->world->uris().get(), + ui->world->forge(), + *ui->client.get())); + + // Create empty root patch model Ingen::Resource::Properties props; props.insert(std::make_pair(ui->app->uris().rdf_type, @@ -150,6 +161,9 @@ port_event(LV2UI_Handle handle, uint32_t format, const void* buffer) { + IngenLV2UI* ui = (IngenLV2UI*)handle; + LV2_Atom* atom = (LV2_Atom*)buffer; + ui->reader->write(atom); } const void* -- cgit v1.2.1