Browse Source

Add port name and "Duplicate/create new cable" to port context menu.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
08e1f9a954
3 changed files with 24 additions and 4 deletions
  1. +2
    -0
      include/engine/PortInfo.hpp
  2. +13
    -4
      src/app/PortWidget.cpp
  3. +9
    -0
      src/engine/PortInfo.cpp

+ 2
- 0
include/engine/PortInfo.hpp View File

@@ -28,6 +28,8 @@ struct PortInfo {

virtual ~PortInfo() {}
virtual std::string getName();
/** Returns name with "input" or "output" appended. */
std::string getFullName();
virtual std::string getDescription();
};



+ 13
- 4
src/app/PortWidget.cpp View File

@@ -20,9 +20,7 @@ struct PortTooltip : ui::Tooltip {
engine::Port* port = portWidget->getPort();
engine::PortInfo* portInfo = portWidget->getPortInfo();
// Label
text = portInfo->getName();
text += " ";
text += (portWidget->type == engine::Port::INPUT) ? "input" : "output";
text = portInfo->getFullName();
// Description
std::string description = portInfo->getDescription();
if (description != "") {
@@ -130,8 +128,11 @@ void PortWidget::createContextMenu() {
ui::Menu* menu = createMenu();
WeakPtr<PortWidget> weakThis = this;

CableWidget* cw = APP->scene->rack->getTopCable(this);
engine::PortInfo* portInfo = getPortInfo();
assert(portInfo);
menu->addChild(createMenuLabel(portInfo->getFullName()));

CableWidget* cw = APP->scene->rack->getTopCable(this);
menu->addChild(createMenuItem("Delete top cable", RACK_MOD_SHIFT_NAME "+click",
[=]() {
if (!weakThis)
@@ -141,6 +142,14 @@ void PortWidget::createContextMenu() {
!cw
));

// TODO
if (type == engine::Port::INPUT) {
menu->addChild(createMenuItem("Duplicate cable", RACK_MOD_CTRL_NAME "+drag", NULL, true));
}
else {
menu->addChild(createMenuItem("Create new cable", RACK_MOD_CTRL_NAME "+drag", NULL, true));
}

// TODO
}



+ 9
- 0
src/engine/PortInfo.cpp View File

@@ -12,6 +12,15 @@ std::string PortInfo::getName() {
return name;
}


std::string PortInfo::getFullName() {
std::string name = getName();
name += " ";
name += (type == Port::INPUT) ? "input" : "output";
return name;
}


std::string PortInfo::getDescription() {
return description;
}


Loading…
Cancel
Save