Browse Source

Remember last color selected by the cable context menu's "New cable" item. Don't reset to first color when toggling "Auto-rotate colors".

tags/v2.5.1
Andrew Belt 6 months ago
parent
commit
63c0dec0e5
2 changed files with 6 additions and 9 deletions
  1. +0
    -1
      src/app/MenuBar.cpp
  2. +6
    -8
      src/app/PortWidget.cpp

+ 0
- 1
src/app/MenuBar.cpp View File

@@ -522,7 +522,6 @@ struct ViewButton : MenuButton {
return settings::cableAutoRotate;
},
[=](bool s) {
APP->scene->rack->setNextCableColorId(0);
settings::cableAutoRotate = s;
}
));


+ 6
- 8
src/app/PortWidget.cpp View File

@@ -20,7 +20,6 @@ struct PortWidget::Internal {
CableWidget* overrideCw = NULL;
CableWidget* overrideCloneCw = NULL;
bool overrideCreateCable = false;
NVGcolor overrideColor = color::BLACK_TRANSPARENT;
};


@@ -153,15 +152,16 @@ struct PortCableItem : ui::ColorDotMenuItem {

struct PortCreateCableItem : ui::ColorDotMenuItem {
PortWidget* pw;
size_t colorId;

void onButton(const ButtonEvent& e) override {
OpaqueWidget::onButton(e);
if (disabled)
return;
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
pw->internal->overrideCreateCable = true;
pw->internal->overrideColor = color;

// Pretend the PortWidget was clicked
e.consume(pw);
@@ -261,11 +261,13 @@ void PortWidget::createContextMenu() {
menu->addChild(new ui::MenuSeparator);

// 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
PortCreateCableItem* item = createMenuItem<PortCreateCableItem>("New cable", "Click+drag");
item->pw = this;
item->color = color;
item->colorId = colorId;
menu->addChild(item);
}

@@ -360,7 +362,6 @@ void PortWidget::onDragStart(const DragStartEvent& e) {
internal->overrideCw = NULL;
internal->overrideCloneCw = NULL;
internal->overrideCreateCable = false;
internal->overrideColor = color::BLACK_TRANSPARENT;
});

CableWidget* cw = NULL;
@@ -412,10 +413,7 @@ void PortWidget::onDragStart(const DragStartEvent& e) {
cw = new CableWidget;

// Set color
if (internal->overrideCreateCable)
cw->color = internal->overrideColor;
else
cw->color = APP->scene->rack->getNextCableColor();
cw->color = APP->scene->rack->getNextCableColor();

// Set port
if (type == engine::Port::OUTPUT)


Loading…
Cancel
Save