diff --git a/src-ui/app/edit-screen/components/mapping-pane/SampleWaveform.cpp b/src-ui/app/edit-screen/components/mapping-pane/SampleWaveform.cpp index 69848511..61237ac1 100644 --- a/src-ui/app/edit-screen/components/mapping-pane/SampleWaveform.cpp +++ b/src-ui/app/edit-screen/components/mapping-pane/SampleWaveform.cpp @@ -327,16 +327,23 @@ void SampleWaveform::mouseDrag(const juce::MouseEvent &e) { case MouseState::HZ_DRAG_SAMPSTART: display->variantView.variants[display->selectedVariation].startSample = - sampleForXPixel(xpos); + std::min(sampleForXPixel(xpos), + display->variantView.variants[display->selectedVariation].endSample); break; case MouseState::HZ_DRAG_SAMPEND: - display->variantView.variants[display->selectedVariation].endSample = sampleForXPixel(xpos); + display->variantView.variants[display->selectedVariation].endSample = + std::max(sampleForXPixel(xpos), + display->variantView.variants[display->selectedVariation].startSample); break; case MouseState::HZ_DRAG_LOOPSTART: - display->variantView.variants[display->selectedVariation].startLoop = sampleForXPixel(xpos); + display->variantView.variants[display->selectedVariation].startLoop = + std::min(sampleForXPixel(xpos), + display->variantView.variants[display->selectedVariation].endLoop); break; case MouseState::HZ_DRAG_LOOPEND: - display->variantView.variants[display->selectedVariation].endLoop = sampleForXPixel(xpos); + display->variantView.variants[display->selectedVariation].endLoop = + std::max(sampleForXPixel(xpos), + display->variantView.variants[display->selectedVariation].startLoop); break; default: break; diff --git a/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp b/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp index e509635f..975cbab1 100644 --- a/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp +++ b/src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp @@ -186,13 +186,26 @@ void VariantDisplay::rebuildForSelectedVariation(size_t sel, bool rebuildTabs) }; attachSamplePoint(startP, "StartS", variantView.variants[selectedVariation].startSample); + sampleAttachments[startP]->precheckGuiAdjust = [this](auto f) { + return std::min(f, this->variantView.variants[this->selectedVariation].endSample); + }; addLabel(startP, "Start"); attachSamplePoint(endP, "EndS", variantView.variants[selectedVariation].endSample); + sampleAttachments[endP]->precheckGuiAdjust = [this](auto f) { + return std::max(f, this->variantView.variants[this->selectedVariation].startSample); + }; addLabel(endP, "End"); attachSamplePoint(startL, "StartL", variantView.variants[selectedVariation].startLoop); + sampleAttachments[startL]->precheckGuiAdjust = [this](auto f) { + return std::min(f, this->variantView.variants[this->selectedVariation].endLoop); + }; + editor->themeApplier.applyVariantLoopTheme(sampleEditors[startL].get()); addLabel(startL, "Start"); attachSamplePoint(endL, "EndL", variantView.variants[selectedVariation].endLoop); + sampleAttachments[endL]->precheckGuiAdjust = [this](auto f) { + return std::max(f, this->variantView.variants[this->selectedVariation].startLoop); + }; editor->themeApplier.applyVariantLoopTheme(sampleEditors[endL].get()); addLabel(endL, "End"); attachSamplePoint(fadeL, "fadeL", variantView.variants[selectedVariation].loopFade); diff --git a/src-ui/connectors/PayloadDataAttachment.h b/src-ui/connectors/PayloadDataAttachment.h index a51eec55..3837032e 100644 --- a/src-ui/connectors/PayloadDataAttachment.h +++ b/src-ui/connectors/PayloadDataAttachment.h @@ -417,6 +417,7 @@ struct SamplePointDataAttachment : sst::jucegui::data::Continuous std::string label; int64_t sampleCount{0}; std::function onGuiChanged{nullptr}; + std::function precheckGuiAdjust{nullptr}; SamplePointDataAttachment(int64_t &v, std::function ogc) @@ -431,8 +432,13 @@ struct SamplePointDataAttachment : sst::jucegui::data::Continuous return ""; return fmt::format("{}", (int64_t)f); } - void setValueFromGUI(const float &f) override + void setValueFromGUI(const float &ff) override { + auto f = ff; + if (precheckGuiAdjust) + { + f = precheckGuiAdjust(ff); + } value = (int64_t)f; if (onGuiChanged) onGuiChanged(*this);