Browse Source

Copy cable color when cloning cables with Ctrl+click.

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
9ea49664bb
4 changed files with 12 additions and 4 deletions
  1. +1
    -0
      include/app/CableWidget.hpp
  2. +7
    -4
      src/app/CableWidget.cpp
  3. +2
    -0
      src/app/PortWidget.cpp
  4. +2
    -0
      src/app/RackWidget.cpp

+ 1
- 0
include/app/CableWidget.hpp View File

@@ -22,6 +22,7 @@ struct CableWidget : widget::OpaqueWidget {

CableWidget();
~CableWidget();
void setNextCableColor();
bool isComplete();
/** Based on the input/output ports, re-creates the cable and removes/adds it to the Engine. */
void updateCable();


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

@@ -14,6 +14,13 @@ namespace app {

CableWidget::CableWidget() {
color = color::BLACK_TRANSPARENT;
}

CableWidget::~CableWidget() {
setCable(NULL);
}

void CableWidget::setNextCableColor() {
if (!settings::cableColors.empty()) {
int id = APP->scene->rack->nextCableColorId++;
APP->scene->rack->nextCableColorId %= settings::cableColors.size();
@@ -21,10 +28,6 @@ CableWidget::CableWidget() {
}
}

CableWidget::~CableWidget() {
setCable(NULL);
}

bool CableWidget::isComplete() {
return outputPort && inputPort;
}


+ 2
- 0
src/app/PortWidget.cpp View File

@@ -193,6 +193,7 @@ void PortWidget::onDragStart(const event::DragStart& e) {
CableWidget* topCw = APP->scene->rack->getTopCable(this);
if (topCw) {
cw = new CableWidget;
cw->color = topCw->color;
cw->outputPort = topCw->outputPort;
cw->updateCable();
}
@@ -221,6 +222,7 @@ void PortWidget::onDragStart(const event::DragStart& e) {
if (!cw) {
// Create a new cable
cw = new CableWidget;
cw->setNextCableColor();
if (type == engine::Port::OUTPUT)
cw->outputPort = this;
else


+ 2
- 0
src/app/RackWidget.cpp View File

@@ -279,6 +279,8 @@ void RackWidget::fromJson(json_t* rootJ) {
continue;

CableWidget* cw = new CableWidget;
// Legacy: Before v1, cable colors were not serialized. So we need to initialize the color here.
cw->setNextCableColor();
cw->setCable(cable);
cw->fromJson(cableJ);
addCable(cw);


Loading…
Cancel
Save