Created
March 4, 2021 18:02
-
-
Save Xenakios/f15813e53e910e5540ceaa49c9272e48 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DualSliderWithAttachments : public juce::Slider | |
{ | |
public: | |
DualSliderWithAttachments(juce::Slider::SliderStyle style_, juce::RangedAudioParameter* minpar, juce::RangedAudioParameter* maxpar) : | |
minAttach(*minpar, [this](float x) { setMinValue(x, juce::dontSendNotification); }), | |
maxAttach(*maxpar, [this](float x) { setMaxValue(x, juce::dontSendNotification); }) | |
{ | |
setSliderStyle(style_); | |
setRange(minpar->getNormalisableRange().start, maxpar->getNormalisableRange().end); | |
minAttach.sendInitialUpdate(); | |
maxAttach.sendInitialUpdate(); | |
onDragStart = [this]() | |
{ | |
thumbThatWasDragged = getThumbBeingDragged(); | |
if (thumbThatWasDragged == 1) | |
minAttach.beginGesture(); | |
else if (thumbThatWasDragged == 2) | |
maxAttach.beginGesture(); | |
}; | |
onValueChange = [this]() | |
{ | |
if (thumbThatWasDragged == 1) | |
minAttach.setValueAsPartOfGesture(getMinValue()); | |
else if (thumbThatWasDragged == 2) | |
maxAttach.setValueAsPartOfGesture(getMaxValue()); | |
}; | |
onDragEnd = [this]() | |
{ | |
if (thumbThatWasDragged == 1) | |
minAttach.endGesture(); | |
else if (thumbThatWasDragged == 2) | |
maxAttach.endGesture(); | |
}; | |
} | |
private: | |
juce::ParameterAttachment minAttach; | |
juce::ParameterAttachment maxAttach; | |
int thumbThatWasDragged = 0; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment