summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-09-15 04:15:03 +0000
committerDavid Robillard <d@drobilla.net>2008-09-15 04:15:03 +0000
commitfccfce4b1e9c9f80b38d20dd8f0e90fe83a93068 (patch)
treea2c81600ac907662f84912fa5375bfd14450811c /src
parent966b1446fcc3fc5a4cdda778c259bb24ed59539a (diff)
downloadingen-fccfce4b1e9c9f80b38d20dd8f0e90fe83a93068.tar.gz
ingen-fccfce4b1e9c9f80b38d20dd8f0e90fe83a93068.tar.bz2
ingen-fccfce4b1e9c9f80b38d20dd8f0e90fe83a93068.zip
Make view togglable between symbols and human names (just LV2 plugins for now).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1502 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/libs/client/PluginModel.cpp33
-rw-r--r--src/libs/client/PluginModel.hpp4
-rw-r--r--src/libs/gui/LoadPluginWindow.cpp4
-rw-r--r--src/libs/gui/NodeModule.cpp32
-rw-r--r--src/libs/gui/NodeModule.hpp8
-rw-r--r--src/libs/gui/PatchCanvas.cpp20
-rw-r--r--src/libs/gui/PatchCanvas.hpp2
-rw-r--r--src/libs/gui/PatchWindow.cpp10
-rw-r--r--src/libs/gui/PatchWindow.hpp2
-rw-r--r--src/libs/gui/ingen_gui.glade3
10 files changed, 106 insertions, 12 deletions
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
index 6246a69e..32d9fd69 100644
--- a/src/libs/client/PluginModel.cpp
+++ b/src/libs/client/PluginModel.cpp
@@ -36,12 +36,43 @@ Redland::World* PluginModel::_rdf_world = NULL;
string
-PluginModel::default_node_name()
+PluginModel::default_node_symbol()
{
return Raul::Path::nameify(_symbol);
}
+string
+PluginModel::human_name()
+{
+#ifdef HAVE_SLV2
+ if (_slv2_plugin) {
+ SLV2Value name = slv2_plugin_get_name(_slv2_plugin);
+ string ret = slv2_value_as_string(name);
+ slv2_value_free(name);
+ return ret;
+ }
+#endif
+ return default_node_symbol();
+}
+
+
+string
+PluginModel::port_human_name(uint32_t index)
+{
+#ifdef HAVE_SLV2
+ if (_slv2_plugin) {
+ SLV2Port port = slv2_port(index);
+ SLV2Value name = slv2_port_get_name(_slv2_plugin, port);
+ string ret = slv2_value_as_string(name);
+ slv2_value_free(name);
+ return ret;
+ }
+#endif
+ return "";
+}
+
+
#ifdef HAVE_SLV2
bool
PluginModel::has_ui() const
diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp
index f8630e94..e2137e19 100644
--- a/src/libs/client/PluginModel.hpp
+++ b/src/libs/client/PluginModel.hpp
@@ -83,7 +83,9 @@ public:
}
}
- string default_node_name();
+ string default_node_symbol();
+ string human_name();
+ string port_human_name(uint32_t index);
#ifdef HAVE_SLV2
static SLV2World slv2_world() { return _slv2_world; }
diff --git a/src/libs/gui/LoadPluginWindow.cpp b/src/libs/gui/LoadPluginWindow.cpp
index b63de230..28815ba9 100644
--- a/src/libs/gui/LoadPluginWindow.cpp
+++ b/src/libs/gui/LoadPluginWindow.cpp
@@ -289,7 +289,7 @@ LoadPluginWindow::plugin_selection_changed()
Gtk::TreeModel::Row row = *iter;
boost::shared_ptr<PluginModel> p = row.get_value(_plugins_columns._col_plugin_model);
_plugin_name_offset = App::instance().store()->child_name_offset(
- _patch->path(), p->default_node_name());
+ _patch->path(), p->default_node_symbol());
_node_name_entry->set_text(generate_module_name(_plugin_name_offset));
} else {
_plugin_name_offset = 0;
@@ -315,7 +315,7 @@ LoadPluginWindow::generate_module_name(int offset)
Gtk::TreeModel::Row row = *iter;
SharedPtr<PluginModel> plugin = row.get_value(_plugins_columns._col_plugin_model);
std::stringstream ss;
- ss << plugin->default_node_name();
+ ss << plugin->default_node_symbol();
if (offset != 0)
ss << "_" << offset + 1;
name = ss.str();
diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp
index fc6b13de..09df174e 100644
--- a/src/libs/gui/NodeModule.cpp
+++ b/src/libs/gui/NodeModule.cpp
@@ -77,7 +77,7 @@ NodeModule::create_menu()
boost::shared_ptr<NodeModule>
-NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node)
+NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node, bool human)
{
boost::shared_ptr<NodeModule> ret;
@@ -94,12 +94,42 @@ NodeModule::create(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> n
ret->add_port(*p, false);
}
+ if (human)
+ ret->show_human_names(human);
+
ret->resize();
ret->set_stacked_border(node->polyphonic());
return ret;
}
+
+void
+NodeModule::show_human_names(bool b)
+{
+ if (b && node()->plugin())
+ set_name(((PluginModel*)node()->plugin())->human_name());
+ else
+ b = false;
+
+ if (!b)
+ set_name(node()->symbol());
+
+ uint32_t index = 0;
+ for (PortVector::const_iterator i = ports().begin(); i != ports().end(); ++i) {
+ if (b) {
+ string hn = ((PluginModel*)node()->plugin())->port_human_name(index);
+ if (hn != "")
+ (*i)->set_name(hn);
+ } else {
+ (*i)->set_name(node()->port(index)->symbol());
+ }
+ ++index;
+ }
+
+ resize();
+}
+
void
NodeModule::value_changed(uint32_t index, const Atom& value)
diff --git a/src/libs/gui/NodeModule.hpp b/src/libs/gui/NodeModule.hpp
index 2b592446..de9556fd 100644
--- a/src/libs/gui/NodeModule.hpp
+++ b/src/libs/gui/NodeModule.hpp
@@ -48,7 +48,10 @@ class Port;
class NodeModule : public FlowCanvas::Module
{
public:
- static boost::shared_ptr<NodeModule> create (boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node);
+ static boost::shared_ptr<NodeModule> create (
+ boost::shared_ptr<PatchCanvas> canvas,
+ SharedPtr<NodeModel> node,
+ bool human_names);
virtual ~NodeModule();
@@ -58,6 +61,7 @@ public:
}
virtual void store_location();
+ void show_human_names(bool b);
SharedPtr<NodeModel> node() const { return _node; }
@@ -65,7 +69,7 @@ protected:
NodeModule(boost::shared_ptr<PatchCanvas> canvas, SharedPtr<NodeModel> node);
void on_double_click(GdkEventButton* ev);
-
+
void show_control_window();
void embed_gui(bool embed);
bool popup_gui();
diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp
index 5d064124..2aba1ec0 100644
--- a/src/libs/gui/PatchCanvas.cpp
+++ b/src/libs/gui/PatchCanvas.cpp
@@ -58,6 +58,7 @@ PatchCanvas::PatchCanvas(SharedPtr<PatchModel> patch, int width, int height)
, _last_click_x(0)
, _last_click_y(0)
, _refresh_menu(false)
+ , _human_names(true)
, _menu(NULL)
, _internal_menu(NULL)
, _plugin_menu(NULL)
@@ -291,6 +292,18 @@ PatchCanvas::arrange(bool ingen_doesnt_use_length_hints)
(*i)->store_location();
}
+
+void
+PatchCanvas::show_human_names(bool b)
+{
+ _human_names = b;
+ for (ItemList::iterator m = _items.begin(); m != _items.end(); ++m) {
+ boost::shared_ptr<NodeModule> mod = boost::dynamic_pointer_cast<NodeModule>(*m);
+ if (mod)
+ mod->show_human_names(b);
+ }
+}
+
void
PatchCanvas::add_plugin(SharedPtr<PluginModel> pm)
@@ -308,9 +321,9 @@ PatchCanvas::add_node(SharedPtr<NodeModel> nm)
SharedPtr<PatchModel> pm = PtrCast<PatchModel>(nm);
SharedPtr<NodeModule> module;
if (pm) {
- module = SubpatchModule::create(shared_this, pm);
+ module = SubpatchModule::create(shared_this, pm, _human_names);
} else {
- module = NodeModule::create(shared_this, nm);
+ module = NodeModule::create(shared_this, nm, _human_names);
const PluginModel* plugm = dynamic_cast<const PluginModel*>(nm->plugin());
if (plugm && plugm->icon_path() != "")
module->set_icon(App::instance().icon_from_path(plugm->icon_path(), 100));
@@ -537,7 +550,6 @@ PatchCanvas::destroy_selection()
App::instance().engine()->destroy(port_module->port()->path());
}
}
-
}
@@ -677,7 +689,7 @@ PatchCanvas::menu_add_port(const string& name, const string& type, bool is_outpu
void
PatchCanvas::load_plugin(SharedPtr<PluginModel> plugin)
{
- string name = plugin->default_node_name();
+ string name = plugin->default_node_symbol();
unsigned offset = App::instance().store()->child_name_offset(_patch->path(), name);
if (offset != 0) {
std::stringstream ss;
diff --git a/src/libs/gui/PatchCanvas.hpp b/src/libs/gui/PatchCanvas.hpp
index f596c97b..667b65a1 100644
--- a/src/libs/gui/PatchCanvas.hpp
+++ b/src/libs/gui/PatchCanvas.hpp
@@ -66,6 +66,7 @@ public:
void build();
void arrange(bool use_length_hints);
+ void show_human_names(bool show);
void add_plugin(SharedPtr<PluginModel> pm);
void add_node(SharedPtr<NodeModel> nm);
@@ -125,6 +126,7 @@ private:
int _last_click_y;
bool _refresh_menu;
+ bool _human_names;
Gtk::Menu* _menu;
Gtk::Menu* _internal_menu;
Gtk::Menu* _plugin_menu;
diff --git a/src/libs/gui/PatchWindow.cpp b/src/libs/gui/PatchWindow.cpp
index 01f74436..e0dc4b06 100644
--- a/src/libs/gui/PatchWindow.cpp
+++ b/src/libs/gui/PatchWindow.cpp
@@ -73,6 +73,7 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
xml->get_widget("patch_view_engine_window_menuitem", _menu_view_engine_window);
xml->get_widget("patch_properties_menuitem", _menu_view_patch_properties);
xml->get_widget("patch_fullscreen_menuitem", _menu_fullscreen);
+ xml->get_widget("patch_human_names_menuitem", _menu_human_names);
xml->get_widget("patch_arrange_menuitem", _menu_arrange);
xml->get_widget("patch_clear_menuitem", _menu_clear);
xml->get_widget("patch_destroy_menuitem", _menu_destroy_patch);
@@ -106,6 +107,8 @@ PatchWindow::PatchWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glad
sigc::mem_fun(this, &PatchWindow::event_quit));
_menu_fullscreen->signal_activate().connect(
sigc::mem_fun(this, &PatchWindow::event_fullscreen_toggled));
+ _menu_human_names->signal_activate().connect(
+ sigc::mem_fun(this, &PatchWindow::event_human_names_toggled));
_menu_arrange->signal_activate().connect(
sigc::mem_fun(this, &PatchWindow::event_arrange));
_menu_view_engine_window->signal_activate().connect(
@@ -527,5 +530,12 @@ PatchWindow::event_fullscreen_toggled()
}
+void
+PatchWindow::event_human_names_toggled()
+{
+ _view->canvas()->show_human_names(_menu_human_names->get_active());
+}
+
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/libs/gui/PatchWindow.hpp b/src/libs/gui/PatchWindow.hpp
index 2b5a90be..ec3d14e8 100644
--- a/src/libs/gui/PatchWindow.hpp
+++ b/src/libs/gui/PatchWindow.hpp
@@ -95,6 +95,7 @@ private:
void event_destroy();
void event_clear();
void event_fullscreen_toggled();
+ void event_human_names_toggled();
void event_arrange();
void event_show_properties();
void event_show_controls();
@@ -123,6 +124,7 @@ private:
Gtk::MenuItem* _menu_delete;
Gtk::MenuItem* _menu_close;
Gtk::MenuItem* _menu_quit;
+ Gtk::CheckMenuItem* _menu_human_names;
Gtk::MenuItem* _menu_fullscreen;
Gtk::MenuItem* _menu_clear;
Gtk::MenuItem* _menu_destroy_patch;
diff --git a/src/libs/gui/ingen_gui.glade b/src/libs/gui/ingen_gui.glade
index 8bdc9328..e402fb1d 100644
--- a/src/libs/gui/ingen_gui.glade
+++ b/src/libs/gui/ingen_gui.glade
@@ -296,11 +296,12 @@
</widget>
</child>
<child>
- <widget class="GtkCheckMenuItem" id="human_names">
+ <widget class="GtkCheckMenuItem" id="patch_human_names_menuitem">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Show human readable names instead of identifiers</property>
<property name="label" translatable="yes">_Human names</property>
<property name="use_underline">True</property>
+ <property name="active">True</property>
<accelerator key="H" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>