summaryrefslogtreecommitdiffstats
path: root/src/PatchagePort.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-04-06 06:14:04 +0000
committerDavid Robillard <d@drobilla.net>2014-04-06 06:14:04 +0000
commitd1678ff80fe301569215904fcd886f257136b062 (patch)
tree114aecfbd5a9697d76ccd3941103004b5722534a /src/PatchagePort.hpp
parent96442dec20443f41ba75e599fe89eb5dd338919a (diff)
downloadpatchage-d1678ff80fe301569215904fcd886f257136b062.tar.gz
patchage-d1678ff80fe301569215904fcd886f257136b062.tar.bz2
patchage-d1678ff80fe301569215904fcd886f257136b062.zip
Support port pretty names via new Jack metadata API.
git-svn-id: http://svn.drobilla.net/lad/trunk/patchage@5357 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/PatchagePort.hpp')
-rw-r--r--src/PatchagePort.hpp31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/PatchagePort.hpp b/src/PatchagePort.hpp
index 0ddbc6e..29dae48 100644
--- a/src/PatchagePort.hpp
+++ b/src/PatchagePort.hpp
@@ -29,6 +29,7 @@
#include "Configuration.hpp"
#include "PatchageCanvas.hpp"
+#include "PatchageModule.hpp"
#include "PortID.hpp"
#include "patchage_config.h"
@@ -40,10 +41,17 @@ public:
PatchagePort(Ganv::Module& module,
PortType type,
const std::string& name,
+ const std::string& human_name,
bool is_input,
- uint32_t color)
- : Port(module, name, is_input, color)
+ uint32_t color,
+ bool show_human_name)
+ : Port(module,
+ (show_human_name && !human_name.empty()) ? human_name : name,
+ is_input,
+ color)
, _type(type)
+ , _name(name)
+ , _human_name(human_name)
{
signal_event().connect(
sigc::mem_fun(this, &PatchagePort::on_event));
@@ -53,9 +61,18 @@ public:
/** Returns the full name of this port, as "modulename:portname" */
std::string full_name() const {
- return std::string(get_module()->get_label()) + ":" + get_label();
+ PatchageModule* pmod = dynamic_cast<PatchageModule*>(get_module());
+ return std::string(pmod->name()) + ":" + _name;
}
+ void show_human_name(bool human) {
+ if (human && !_human_name.empty()) {
+ set_label(_human_name.c_str());
+ } else {
+ set_label(_name.c_str());
+ }
+ }
+
bool on_event(GdkEvent* ev) {
if (ev->type != GDK_BUTTON_PRESS || ev->button.button != 3) {
return false;
@@ -70,10 +87,14 @@ public:
return true;
}
- PortType type() const { return _type; }
+ PortType type() const { return _type; }
+ const std::string& name() const { return _name; }
+ const std::string& human_name() const { return _human_name; }
private:
- PortType _type;
+ PortType _type;
+ std::string _name;
+ std::string _human_name;
};
#endif // PATCHAGE_PATCHAGEPORT_HPP