|
@@ -20,7 +20,6 @@ struct PortWidget::Internal { |
|
|
CableWidget* overrideCw = NULL; |
|
|
CableWidget* overrideCw = NULL; |
|
|
CableWidget* overrideCloneCw = NULL; |
|
|
CableWidget* overrideCloneCw = NULL; |
|
|
bool overrideCreateCable = false; |
|
|
bool overrideCreateCable = false; |
|
|
NVGcolor overrideColor = color::BLACK_TRANSPARENT; |
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -153,15 +152,16 @@ struct PortCableItem : ui::ColorDotMenuItem { |
|
|
|
|
|
|
|
|
struct PortCreateCableItem : ui::ColorDotMenuItem { |
|
|
struct PortCreateCableItem : ui::ColorDotMenuItem { |
|
|
PortWidget* pw; |
|
|
PortWidget* pw; |
|
|
|
|
|
size_t colorId; |
|
|
|
|
|
|
|
|
void onButton(const ButtonEvent& e) override { |
|
|
void onButton(const ButtonEvent& e) override { |
|
|
OpaqueWidget::onButton(e); |
|
|
OpaqueWidget::onButton(e); |
|
|
if (disabled) |
|
|
if (disabled) |
|
|
return; |
|
|
return; |
|
|
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == 0) { |
|
|
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_LEFT && (e.mods & RACK_MOD_MASK) == 0) { |
|
|
|
|
|
APP->scene->rack->setNextCableColorId(colorId); |
|
|
// Set PortWidget::onDragStart overrides |
|
|
// Set PortWidget::onDragStart overrides |
|
|
pw->internal->overrideCreateCable = true; |
|
|
pw->internal->overrideCreateCable = true; |
|
|
pw->internal->overrideColor = color; |
|
|
|
|
|
|
|
|
|
|
|
// Pretend the PortWidget was clicked |
|
|
// Pretend the PortWidget was clicked |
|
|
e.consume(pw); |
|
|
e.consume(pw); |
|
@@ -261,11 +261,13 @@ void PortWidget::createContextMenu() { |
|
|
menu->addChild(new ui::MenuSeparator); |
|
|
menu->addChild(new ui::MenuSeparator); |
|
|
|
|
|
|
|
|
// New cable items |
|
|
// New cable items |
|
|
for (NVGcolor color : settings::cableColors) { |
|
|
|
|
|
|
|
|
for (size_t colorId = 0; colorId < settings::cableColors.size(); colorId++) { |
|
|
|
|
|
NVGcolor color = settings::cableColors[colorId]; |
|
|
// Include extra leading spaces for the color circle |
|
|
// Include extra leading spaces for the color circle |
|
|
PortCreateCableItem* item = createMenuItem<PortCreateCableItem>("New cable", "Click+drag"); |
|
|
PortCreateCableItem* item = createMenuItem<PortCreateCableItem>("New cable", "Click+drag"); |
|
|
item->pw = this; |
|
|
item->pw = this; |
|
|
item->color = color; |
|
|
item->color = color; |
|
|
|
|
|
item->colorId = colorId; |
|
|
menu->addChild(item); |
|
|
menu->addChild(item); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -360,7 +362,6 @@ void PortWidget::onDragStart(const DragStartEvent& e) { |
|
|
internal->overrideCw = NULL; |
|
|
internal->overrideCw = NULL; |
|
|
internal->overrideCloneCw = NULL; |
|
|
internal->overrideCloneCw = NULL; |
|
|
internal->overrideCreateCable = false; |
|
|
internal->overrideCreateCable = false; |
|
|
internal->overrideColor = color::BLACK_TRANSPARENT; |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
CableWidget* cw = NULL; |
|
|
CableWidget* cw = NULL; |
|
@@ -412,10 +413,7 @@ void PortWidget::onDragStart(const DragStartEvent& e) { |
|
|
cw = new CableWidget; |
|
|
cw = new CableWidget; |
|
|
|
|
|
|
|
|
// Set color |
|
|
// Set color |
|
|
if (internal->overrideCreateCable) |
|
|
|
|
|
cw->color = internal->overrideColor; |
|
|
|
|
|
else |
|
|
|
|
|
cw->color = APP->scene->rack->getNextCableColor(); |
|
|
|
|
|
|
|
|
cw->color = APP->scene->rack->getNextCableColor(); |
|
|
|
|
|
|
|
|
// Set port |
|
|
// Set port |
|
|
if (type == engine::Port::OUTPUT) |
|
|
if (type == engine::Port::OUTPUT) |
|
|