From d56959ceeabd8d40ad5281e29e2851028ea5bf24 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 12 Aug 2021 19:52:47 -0400 Subject: [PATCH] Some small lasso fixes (#4837) 1. Shift mode works (but see #4835). Closes #4830 2. Lasso on Control Points works. Closes #4832 --- src/gui/overlays/MSEGEditor.cpp | 53 ++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/src/gui/overlays/MSEGEditor.cpp b/src/gui/overlays/MSEGEditor.cpp index a6347c6aac7..f1d282f2b0c 100644 --- a/src/gui/overlays/MSEGEditor.cpp +++ b/src/gui/overlays/MSEGEditor.cpp @@ -425,8 +425,29 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp case DRAW: break; case SHIFT: - Surge::MSEG::adjustDurationShiftingSubsequent(this->ms, prior, dx, ms->hSnap, - longestMSEG); + if (lassoSelector) + { + bool isLast{true}; + for (auto si : lassoSelector->items) + { + isLast = isLast && si <= prior + 1; + } + if (isLast) + { + Surge::MSEG::adjustDurationShiftingSubsequent(this->ms, prior, dx, + ms->hSnap, longestMSEG); + } + else + { + Surge::MSEG::adjustDurationConstantTotalDuration(this->ms, prior, dx, + ms->hSnap); + } + } + else + { + Surge::MSEG::adjustDurationShiftingSubsequent(this->ms, prior, dx, + ms->hSnap, longestMSEG); + } break; case SINGLE: Surge::MSEG::adjustDurationConstantTotalDuration(this->ms, prior, dx, @@ -1475,7 +1496,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp for (auto &h : hotzones) { if (h.rect.contains(e.position.toFloat()) && h.type == hotzone::MOUSABLE_NODE && - h.zoneSubType == hotzone::SEGMENT_ENDPOINT && + (h.zoneSubType == hotzone::SEGMENT_ENDPOINT || + h.zoneSubType == hotzone::SEGMENT_CONTROL) && lassoSelector->contains(h.associatedSegment)) clearLasso = false; } @@ -1823,12 +1845,15 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp bool foundDrag = false; auto where = event.position.toInt(); std::set modifyIndices; + auto draggingType = hotzone::SEGMENT_ENDPOINT; for (auto &h : hotzones) - { + if (h.dragging) + draggingType = h.zoneSubType; - if (h.dragging || - (lassoSelector && lassoSelector->contains(h.associatedSegment) && - h.type == hotzone::MOUSABLE_NODE && h.zoneSubType == hotzone::SEGMENT_ENDPOINT)) + for (auto &h : hotzones) + { + if (h.dragging || (lassoSelector && lassoSelector->contains(h.associatedSegment) && + h.type == hotzone::MOUSABLE_NODE && h.zoneSubType == draggingType)) { modifyIndices.insert(idx); foundDrag = true; @@ -1851,6 +1876,7 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp dragY *= 0.2; } bool sep = false; + holdOffOnModelChanged = true; for (auto idx : modifyIndices) { hotzones[idx].onDrag(dragX, dragY, juce::Point(where.getX(), where.getY())); @@ -1860,7 +1886,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp sep = hotzones[idx].specialEndpoint; } } - modelChanged(hoveredSegment, sep, false); // HACK FIXME + holdOffOnModelChanged = false; + modelChanged(hoveredSegment, sep, false); mouseDownOrigin = where; } @@ -2347,8 +2374,12 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp } } + bool holdOffOnModelChanged{false}; void modelChanged(int activeSegment = -1, bool specialEndpoint = false, bool rchz = true) { + if (holdOffOnModelChanged) + return; + Surge::MSEG::rebuildCache(ms); applyZoomPanConstraints(activeSegment, specialEndpoint); if (rchz) @@ -2922,11 +2953,11 @@ MSEGEditor::MSEGEditor(SurgeStorage *storage, LFOStorage *lfodata, MSEGStorage * canvas = std::make_unique(storage, lfodata, ms, eds, skin, bmp); controls = std::make_unique(nullptr, storage, lfodata, ms, eds, skin, bmp); - addAndMakeVisible(*controls); - addAndMakeVisible(*canvas); - canvas->controlregion = controls.get(); controls->canvas = canvas.get(); + + addAndMakeVisible(*controls); + addAndMakeVisible(*canvas); } MSEGEditor::~MSEGEditor() = default;