Browse Source

Re-enable plug lights. Re-enable port dimming when dragging cable.

tags/v2.6.0
Andrew Belt 6 months ago
parent
commit
41eddb0890
2 changed files with 17 additions and 20 deletions
  1. +4
    -4
      src/app/CableWidget.cpp
  2. +13
    -16
      src/app/PortWidget.cpp

+ 4
- 4
src/app/CableWidget.cpp View File

@@ -279,15 +279,15 @@ void CableWidget::step() {


// Draw output plug // Draw output plug
outputPlug->setPosition(outputPos); outputPlug->setPosition(outputPos);
// bool outputTop = isComplete() && APP->scene->rack->getTopCable(outputPort) == this;
// outputPlug->setTop(outputTop);
bool outputTop = outputPort && (APP->scene->rack->getTopPlug(outputPort) == outputPlug);
outputPlug->setTop(outputTop);
outputPlug->setAngle(slump.minus(outputPos).arg()); outputPlug->setAngle(slump.minus(outputPos).arg());
outputPlug->setColor(colorOpaque); outputPlug->setColor(colorOpaque);


// Draw input plug // Draw input plug
inputPlug->setPosition(inputPos); inputPlug->setPosition(inputPos);
// bool inputTop = isComplete() && APP->scene->rack->getTopCable(inputPort) == this;
// inputPlug->setTop(inputTop);
bool inputTop = inputPort && (APP->scene->rack->getTopPlug(inputPort) == inputPlug);
inputPlug->setTop(inputTop);
inputPlug->setAngle(slump.minus(inputPos).arg()); inputPlug->setAngle(slump.minus(inputPos).arg());
inputPlug->setColor(colorOpaque); inputPlug->setColor(colorOpaque);




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

@@ -20,6 +20,8 @@ struct PortWidget::Internal {
CableWidget* overrideCw = NULL; CableWidget* overrideCw = NULL;
CableWidget* overrideCloneCw = NULL; CableWidget* overrideCloneCw = NULL;
bool overrideCreateCable = false; bool overrideCreateCable = false;
/** When dragging port, this is the grabbed end type of the cable. */
engine::Port::Type draggedType = engine::Port::INPUT;
}; };




@@ -346,18 +348,11 @@ void PortWidget::step() {
void PortWidget::draw(const DrawArgs& args) { void PortWidget::draw(const DrawArgs& args) {
PortWidget* draggedPw = dynamic_cast<PortWidget*>(APP->event->getDraggedWidget()); PortWidget* draggedPw = dynamic_cast<PortWidget*>(APP->event->getDraggedWidget());
if (draggedPw) { if (draggedPw) {
// TODO
}
// TODO Reimplement this
#if 0
CableWidget* cw = APP->scene->rack->getIncompleteCable();
if (cw) {
// Dim the PortWidget if the active cable cannot plug into this PortWidget
if (type == engine::Port::OUTPUT ? cw->outputPort : cw->inputPort) {
if (draggedPw->internal->draggedType != type) {
// Dim the PortWidget if the active cable cannot plug into this PortWidget
nvgTint(args.vg, nvgRGBf(0.33, 0.33, 0.33)); nvgTint(args.vg, nvgRGBf(0.33, 0.33, 0.33));
} }
} }
#endif
Widget::draw(args); Widget::draw(args);
} }


@@ -421,6 +416,7 @@ void PortWidget::onDragStart(const DragStartEvent& e) {
else else
cw->outputPort = cloneCw->outputPort; cw->outputPort = cloneCw->outputPort;
cw->updateCable(); cw->updateCable();
internal->draggedType = type;
} }
} }
else { else {
@@ -438,6 +434,13 @@ void PortWidget::onDragStart(const DragStartEvent& e) {
// Reuse existing cable // Reuse existing cable
cw->getPort(type) = NULL; cw->getPort(type) = NULL;
cw->updateCable(); cw->updateCable();
internal->draggedType = type;

// Move grabbed plug to top of stack
PlugWidget* plug = cw->getPlug(type);
assert(plug);
APP->scene->rack->getPlugContainer()->removeChild(plug);
APP->scene->rack->getPlugContainer()->addChild(plug);
} }
} }


@@ -451,19 +454,13 @@ void PortWidget::onDragStart(const DragStartEvent& e) {
// Set port // Set port
cw->getPort(type) = this; cw->getPort(type) = this;
cw->updateCable(); cw->updateCable();
internal->draggedType = (type == engine::Port::INPUT) ? engine::Port::OUTPUT : engine::Port::INPUT;
} }


// Add cable to rack if not already added // Add cable to rack if not already added
if (!cw->getParent()) { if (!cw->getParent()) {
APP->scene->rack->addCable(cw); APP->scene->rack->addCable(cw);
} }
else {
// Move grabbed plug to top of stack
PlugWidget* plug = cw->getPlug(type);
assert(plug);
APP->scene->rack->getPlugContainer()->removeChild(plug);
APP->scene->rack->getPlugContainer()->addChild(plug);
}
} }






Loading…
Cancel
Save