Skip to content

Commit

Permalink
APVTS: Fixed a bug setting the SliderAttachment text for unchanged de…
Browse files Browse the repository at this point in the history
…fault values
  • Loading branch information
tpoole committed Oct 30, 2018
1 parent 9b4ba78 commit 61e2e80
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -535,6 +535,13 @@ struct AudioProcessorValueTreeState::SliderAttachment::Pimpl : private Attached
{
NormalisableRange<float> range (state.getParameterRange (paramID));

if (auto* param = state.getParameterAdapter (paramID))
{
slider.valueFromTextFunction = [param](const String& text) { return (double) param->getDenormalisedValueForText (text); };
slider.textFromValueFunction = [param](double value) { return param->getTextForDenormalisedValue ((float) value); };
slider.setDoubleClickReturnValue (true, range.convertFrom0to1 (param->getParameter().getDefaultValue()));
}

if (range.interval != 0.0f || range.skew != 1.0f)
{
slider.setRange (range.start, range.end, range.interval);
Expand Down Expand Up @@ -576,13 +583,6 @@ struct AudioProcessorValueTreeState::SliderAttachment::Pimpl : private Attached
snapToLegalValueFunction });
}

if (auto* param = state.getParameterAdapter (paramID))
{
slider.valueFromTextFunction = [param](const String& text) { return (double) param->getDenormalisedValueForText (text); };
slider.textFromValueFunction = [param](double value) { return param->getTextForDenormalisedValue ((float) value); };
slider.setDoubleClickReturnValue (true, range.convertFrom0to1 (param->getParameter().getDefaultValue()));
}

sendInitialUpdate();
slider.addListener (this);
}
Expand Down

0 comments on commit 61e2e80

Please sign in to comment.