Skip to content

Commit

Permalink
Attachments: don't create an undo action if sliders don't move
Browse files Browse the repository at this point in the history
  • Loading branch information
jatinchowdhury18 committed Jun 1, 2024
1 parent 776aa52 commit 0053784
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<FloatParameter> (
*attachment.param,
valueAtStartOfGesture,
attachment.param->get()));
valueAtEndOfGesture,
attachment.pluginState == nullptr ? nullptr : attachment.pluginState->processor));
}

attachment.endGesture();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<ChoiceParameter> (
*attachment.param,
valueAtStartOfGesture,
attachment.param->getIndex()));
valueAtEndOfGesture,
attachment.pluginState == nullptr ? nullptr : attachment.pluginState->processor));
}

attachment.endGesture();
Expand Down

0 comments on commit 0053784

Please sign in to comment.