From 00537843b44f74b0ae44df64982129e23b3f1ffa Mon Sep 17 00:00:00 2001 From: jatin Date: Fri, 31 May 2024 21:37:10 -0700 Subject: [PATCH] Attachments: don't create an undo action if sliders don't move --- .../Frontend/chowdsp_SliderAttachment.cpp | 6 ++++-- .../Frontend/chowdsp_SliderChoiceAttachment.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderAttachment.cpp b/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderAttachment.cpp index 6aa8c68a4..c7006e1b6 100644 --- a/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderAttachment.cpp +++ b/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderAttachment.cpp @@ -104,14 +104,16 @@ void SliderAttachment::sliderDragStarted (juce::Slider*) void SliderAttachment::sliderDragEnded (juce::Slider*) { - if (um != nullptr) + const auto valueAtEndOfGesture = attachment.param->get(); + if (um != nullptr && ! juce::approximatelyEqual (valueAtStartOfGesture, valueAtEndOfGesture)) { um->beginNewTransaction(); um->perform ( new ParameterAttachmentHelpers::ParameterChangeAction ( *attachment.param, valueAtStartOfGesture, - attachment.param->get())); + valueAtEndOfGesture, + attachment.pluginState == nullptr ? nullptr : attachment.pluginState->processor)); } attachment.endGesture(); diff --git a/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderChoiceAttachment.cpp b/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderChoiceAttachment.cpp index 83cbb8698..6cff93397 100644 --- a/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderChoiceAttachment.cpp +++ b/modules/plugin/chowdsp_plugin_state/Frontend/chowdsp_SliderChoiceAttachment.cpp @@ -5,6 +5,7 @@ SliderChoiceAttachment::SliderChoiceAttachment (ChoiceParameter& param, juce::Slider& paramSlider) : SliderChoiceAttachment (param, pluginState.getParameterListeners(), paramSlider, pluginState.undoManager) { + attachment.pluginState = &pluginState; } SliderChoiceAttachment::SliderChoiceAttachment (ChoiceParameter& param, @@ -63,14 +64,16 @@ void SliderChoiceAttachment::sliderDragStarted (juce::Slider*) void SliderChoiceAttachment::sliderDragEnded (juce::Slider*) { - if (um != nullptr) + const auto valueAtEndOfGesture = attachment.param->getIndex(); + if (um != nullptr && valueAtEndOfGesture != valueAtStartOfGesture) { um->beginNewTransaction(); um->perform ( new ParameterAttachmentHelpers::ParameterChangeAction ( *attachment.param, valueAtStartOfGesture, - attachment.param->getIndex())); + valueAtEndOfGesture, + attachment.pluginState == nullptr ? nullptr : attachment.pluginState->processor)); } attachment.endGesture();