summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/GraphCanvas.cpp19
-rw-r--r--src/gui/GraphPortModule.cpp5
-rw-r--r--src/gui/GraphPortModule.hpp3
-rw-r--r--src/gui/NodeModule.cpp3
-rw-r--r--src/gui/Port.cpp52
-rw-r--r--src/gui/Port.hpp4
6 files changed, 60 insertions, 26 deletions
diff --git a/src/gui/GraphCanvas.cpp b/src/gui/GraphCanvas.cpp
index b06b47b1..1fe665e7 100644
--- a/src/gui/GraphCanvas.cpp
+++ b/src/gui/GraphCanvas.cpp
@@ -256,13 +256,30 @@ void
GraphCanvas::show_human_names(bool b)
{
_human_names = b;
+ _app.world()->conf().set("human-names", _app.forge().make(b));
+
for_each_node(show_module_human_names, &b);
}
+static void
+ensure_port_labels(GanvNode* node, void* data)
+{
+ if (GANV_IS_MODULE(node)) {
+ Ganv::Module* module = Glib::wrap(GANV_MODULE(node));
+ for (Ganv::Port* p : *module) {
+ Ingen::GUI::Port* port = dynamic_cast<Ingen::GUI::Port*>(p);
+ if (port) {
+ port->ensure_label();
+ }
+ }
+ }
+}
+
void
GraphCanvas::show_port_names(bool b)
{
ganv_canvas_set_direction(gobj(), b ? GANV_DIRECTION_RIGHT : GANV_DIRECTION_DOWN);
+ for_each_node(ensure_port_labels, &b);
}
void
@@ -314,7 +331,7 @@ GraphCanvas::remove_block(SPtr<const BlockModel> bm)
void
GraphCanvas::add_port(SPtr<const PortModel> pm)
{
- GraphPortModule* view = GraphPortModule::create(*this, pm, _human_names);
+ GraphPortModule* view = GraphPortModule::create(*this, pm);
_views.insert(std::make_pair(pm, view));
view->show();
}
diff --git a/src/gui/GraphPortModule.cpp b/src/gui/GraphPortModule.cpp
index dc781a35..99704eaa 100644
--- a/src/gui/GraphPortModule.cpp
+++ b/src/gui/GraphPortModule.cpp
@@ -66,11 +66,10 @@ GraphPortModule::GraphPortModule(GraphCanvas& canvas,
GraphPortModule*
GraphPortModule::create(GraphCanvas& canvas,
- SPtr<const PortModel> model,
- bool human)
+ SPtr<const PortModel> model)
{
GraphPortModule* ret = new GraphPortModule(canvas, model);
- Port* port = Port::create(canvas.app(), *ret, model, human, true);
+ Port* port = Port::create(canvas.app(), *ret, model, true);
ret->set_port(port);
if (model->is_numeric()) {
diff --git a/src/gui/GraphPortModule.hpp b/src/gui/GraphPortModule.hpp
index 5cffa7bc..8dcee1c9 100644
--- a/src/gui/GraphPortModule.hpp
+++ b/src/gui/GraphPortModule.hpp
@@ -48,8 +48,7 @@ class GraphPortModule : public Ganv::Module
public:
static GraphPortModule* create(
GraphCanvas& canvas,
- SPtr<const Client::PortModel> model,
- bool human);
+ SPtr<const Client::PortModel> model);
App& app() const;
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index 40303ad7..c03618cf 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -268,8 +268,7 @@ NodeModule::rename()
void
NodeModule::new_port_view(SPtr<const PortModel> port)
{
- Port::create(app(), *this, port,
- app().world()->conf().option("human-names").get<int32_t>());
+ Port::create(app(), *this, port);
port->signal_value_changed().connect(
sigc::bind<0>(sigc::mem_fun(this, &NodeModule::port_value_changed),
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index f15d067c..07e654db 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -44,25 +44,9 @@ Port*
Port::create(App& app,
Ganv::Module& module,
SPtr<const PortModel> pm,
- bool human_name,
bool flip)
{
- Glib::ustring label;
- if (app.world()->conf().option("port-labels").get<int32_t>()) {
- if (human_name) {
- const Atom& name = pm->get_property(app.uris().lv2_name);
- if (name.type() == app.forge().String) {
- label = name.ptr<char>();
- } else {
- const SPtr<const BlockModel> parent(dynamic_ptr_cast<const BlockModel>(pm->parent()));
- if (parent && parent->plugin_model())
- label = parent->plugin_model()->port_human_name(pm->index());
- }
- } else {
- label = pm->path().symbol();
- }
- }
- return new Port(app, module, pm, label, flip);
+ return new Port(app, module, pm, port_label(app, pm), flip);
}
/** @param flip Make an input port appear as an output port, and vice versa.
@@ -118,6 +102,40 @@ Port::~Port()
_app.activity_port_destroyed(this);
}
+std::string
+Port::port_label(App& app, SPtr<const PortModel> pm)
+{
+ if (!pm) {
+ return "";
+ }
+
+ std::string label;
+ if (app.world()->conf().option("port-labels").get<int32_t>()) {
+ if (app.world()->conf().option("human-names").get<int32_t>()) {
+ const Atom& name = pm->get_property(app.uris().lv2_name);
+ if (name.type() == app.forge().String) {
+ label = name.ptr<char>();
+ } else {
+ const SPtr<const BlockModel> parent(
+ dynamic_ptr_cast<const BlockModel>(pm->parent()));
+ if (parent && parent->plugin_model())
+ label = parent->plugin_model()->port_human_name(pm->index());
+ }
+ } else {
+ label = pm->path().symbol();
+ }
+ }
+ return label;
+}
+
+void
+Port::ensure_label()
+{
+ if (!get_label()) {
+ set_label(port_label(_app, _port_model.lock()).c_str());
+ }
+}
+
void
Port::update_metadata()
{
diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp
index e547fcc4..44703fb4 100644
--- a/src/gui/Port.hpp
+++ b/src/gui/Port.hpp
@@ -50,7 +50,6 @@ public:
App& app,
Ganv::Module& module,
SPtr<const Client::PortModel> pm,
- bool human_name,
bool flip = false);
~Port();
@@ -59,6 +58,7 @@ public:
bool show_menu(GdkEventButton* ev);
void update_metadata();
+ void ensure_label();
void value_changed(const Atom& value);
void activity(const Atom& value);
@@ -73,6 +73,8 @@ private:
const std::string& name,
bool flip = false);
+ static std::string port_label(App& app, SPtr<const Client::PortModel> pm);
+
Gtk::Menu* build_enum_menu();
Gtk::Menu* build_uri_menu();
GraphBox* get_graph_box() const;