Oscillator octave lock using shift and mouse
This commit is contained in:
parent
67115a1bf6
commit
b9b885c148
2 changed files with 31 additions and 0 deletions
|
@ -94,6 +94,19 @@ public:
|
|||
}
|
||||
Slider::mouseDown(event);
|
||||
}
|
||||
|
||||
void mouseDrag(const MouseEvent& event) override
|
||||
{
|
||||
Slider::mouseDrag(event);
|
||||
if (event.mods.isShiftDown())
|
||||
{
|
||||
if (shiftDragCallback)
|
||||
{
|
||||
setValue(shiftDragCallback(getValue()), sendNotificationAsync);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
|
||||
public:
|
||||
class KnobAttachment : public juce::AudioProcessorValueTreeState::SliderAttachment
|
||||
|
@ -147,6 +160,8 @@ public:
|
|||
shouldResetOnShiftClick = value;
|
||||
resetActionMessage = identifier;
|
||||
}
|
||||
|
||||
std::function<double(double)> shiftDragCallback;
|
||||
private:
|
||||
Image kni;
|
||||
int fh, numFr;
|
||||
|
|
|
@ -210,6 +210,14 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
|||
}
|
||||
if (name == "osc1PitchKnob"){
|
||||
osc1PitchKnob = addKnob (x, y, d, ownerFilter, OSC1P, "Osc1Pitch", 0);
|
||||
osc1PitchKnob->shiftDragCallback = [](double value)
|
||||
{
|
||||
if (value < 0.125) return 0.0;
|
||||
if (value < 0.375) return 0.25;
|
||||
if (value < 0.625) return 0.5;
|
||||
if (value < 0.875) return 0.75;
|
||||
return 1.0;
|
||||
};
|
||||
mappingComps["osc1PitchKnob"] = osc1PitchKnob;
|
||||
}
|
||||
if (name == "pulseWidthKnob"){
|
||||
|
@ -218,6 +226,14 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
|||
}
|
||||
if (name == "osc2PitchKnob"){
|
||||
osc2PitchKnob = addKnob (x, y, d, ownerFilter, OSC2P, "Osc2Pitch", 0);
|
||||
osc2PitchKnob->shiftDragCallback = [](double value)
|
||||
{
|
||||
if (value < 0.125) return 0.0;
|
||||
if (value < 0.375) return 0.25;
|
||||
if (value < 0.625) return 0.5;
|
||||
if (value < 0.875) return 0.75;
|
||||
return 1.0;
|
||||
};
|
||||
mappingComps["osc2PitchKnob"] = osc2PitchKnob;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue