Browse Source

Add RackWidget::get/setNextCableColorId().

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
e6f5c62968
2 changed files with 18 additions and 1 deletions
  1. +4
    -0
      include/app/RackWidget.hpp
  2. +14
    -1
      src/app/RackWidget.cpp

+ 4
- 0
include/app/RackWidget.hpp View File

@@ -119,6 +119,10 @@ struct RackWidget : widget::OpaqueWidget {
std::vector<CableWidget*> getCompleteCables();
/** Returns all cables attached to port, complete or not. */
std::vector<CableWidget*> getCablesOnPort(PortWidget* port);
/** Returns but does not advance the next cable color. */
int getNextCableColorId();
void setNextCableColorId(int id);
/** Returns and advances the next cable color. */
NVGcolor getNextCableColor();
};



+ 14
- 1
src/app/RackWidget.cpp View File

@@ -1399,12 +1399,25 @@ std::vector<CableWidget*> RackWidget::getCablesOnPort(PortWidget* port) {
}


int RackWidget::getNextCableColorId() {
return internal->nextCableColorId;
}


void RackWidget::setNextCableColorId(int id) {
internal->nextCableColorId = id;
}


NVGcolor RackWidget::getNextCableColor() {
if (settings::cableColors.empty())
return color::WHITE;

int id = internal->nextCableColorId++;
internal->nextCableColorId %= settings::cableColors.size();
if (id >= settings::cableColors.size())
id = 0;
if (internal->nextCableColorId >= settings::cableColors.size())
internal->nextCableColorId = 0;
return settings::cableColors[id];
}



Loading…
Cancel
Save