diff --git a/source/gui/slider/two_value_rotary_slider/two_value_ratary_slider.cpp b/source/gui/slider/two_value_rotary_slider/two_value_ratary_slider.cpp index e8aa2449..a5c07666 100644 --- a/source/gui/slider/two_value_rotary_slider/two_value_ratary_slider.cpp +++ b/source/gui/slider/two_value_rotary_slider/two_value_ratary_slider.cpp @@ -142,6 +142,11 @@ namespace zlInterface { } else { slider2.mouseDown(event); } + const auto currentShiftPressed = event.mods.isShiftDown(); + if (currentShiftPressed != isShiftPressed) { + isShiftPressed = currentShiftPressed; + updateDragDistance(); + } } void TwoValueRotarySlider::mouseDrag(const juce::MouseEvent &event) { diff --git a/source/gui/slider/two_value_rotary_slider/two_value_rotary_slider.hpp b/source/gui/slider/two_value_rotary_slider/two_value_rotary_slider.hpp index 5b1228c0..476cde9c 100644 --- a/source/gui/slider/two_value_rotary_slider/two_value_rotary_slider.hpp +++ b/source/gui/slider/two_value_rotary_slider/two_value_rotary_slider.hpp @@ -21,7 +21,7 @@ namespace zlInterface { class TwoValueRotarySlider final : public juce::Component, - private juce::Label::Listener, private juce::Slider::Listener { + private juce::Label::Listener, private juce::Slider::Listener { public: explicit TwoValueRotarySlider(const juce::String &labelText, UIBase &base); @@ -66,6 +66,11 @@ namespace zlInterface { inline bool getEditable() const { return editable.load(); } + void setMouseDragSensitivity(const int x) { + dragDistance = x; + updateDragDistance(); + } + private: UIBase &uiBase; @@ -85,6 +90,9 @@ namespace zlInterface { friz::Animator animator; static constexpr int animationId = 1; + int dragDistance {10}; + bool isShiftPressed {false}; + static juce::String getDisplayValue(juce::Slider &s); void labelTextChanged(juce::Label *labelThatHasChanged) override; @@ -94,6 +102,19 @@ namespace zlInterface { void editorHidden(juce::Label *l, juce::TextEditor &editor) override; void sliderValueChanged(juce::Slider *slider) override; + + void updateDragDistance() { + int actualDragDistance; + if (isShiftPressed) { + actualDragDistance = juce::roundToInt( + static_cast(dragDistance) / uiBase.getSensitivity(sensitivityIdx::mouseDragFine)); + } else { + actualDragDistance = juce::roundToInt( + static_cast(dragDistance) / uiBase.getSensitivity(sensitivityIdx::mouseDrag)); + } + slider1.setMouseDragSensitivity(actualDragDistance); + slider2.setMouseDragSensitivity(actualDragDistance); + } }; } diff --git a/source/panel/control_panel/left_control_panel/left_control_panel.cpp b/source/panel/control_panel/left_control_panel/left_control_panel.cpp index fee2c5b1..70024d04 100644 --- a/source/panel/control_panel/left_control_panel/left_control_panel.cpp +++ b/source/panel/control_panel/left_control_panel/left_control_panel.cpp @@ -92,14 +92,6 @@ namespace zlPanel { void LeftControlPanel::paint(juce::Graphics &g) { const auto bound = getLocalBounds().toFloat(); uiBase.fillRoundedShadowRectangle(g, bound, 0.5f * uiBase.getFontSize(), {.blurRadius = 0.25f}); - const auto style = uiBase.getRotaryStyle(); - const auto sensitivity = juce::roundToInt(uiBase.getRotaryDragSensitivity() * uiBase.getFontSize()); - for (auto &c: {&freqC, &gainC, &qC}) { - c->getSlider1().setSliderStyle(style); - c->getSlider1().setMouseDragSensitivity(sensitivity); - c->getSlider2().setSliderStyle(style); - c->getSlider2().setMouseDragSensitivity(sensitivity); - } } void LeftControlPanel::resized() { @@ -139,6 +131,11 @@ namespace zlPanel { bound.getTopRight().getY(), 1.25f * uiBase.getFontSize(), 1.25f * uiBase.getFontSize()); resetComponent.setBounds(resetBound.toNearestInt()); + updateMouseDragSensitivity(); + } + + void LeftControlPanel::lookAndFeelChanged() { + updateMouseDragSensitivity(); } void LeftControlPanel::attachGroup(const size_t idx) { @@ -240,4 +237,14 @@ namespace zlPanel { qC.setShowSlider2(qS2Editable.load()); repaint(); } + + void LeftControlPanel::updateMouseDragSensitivity() { + const auto style = uiBase.getRotaryStyle(); + const auto sensitivity = juce::roundToInt(uiBase.getRotaryDragSensitivity() * uiBase.getFontSize()); + for (auto &c: {&freqC, &gainC, &qC}) { + c->getSlider1().setSliderStyle(style); + c->getSlider2().setSliderStyle(style); + c->setMouseDragSensitivity(sensitivity); + } + } } diff --git a/source/panel/control_panel/left_control_panel/left_control_panel.hpp b/source/panel/control_panel/left_control_panel/left_control_panel.hpp index 1f7d7b9b..97b61058 100644 --- a/source/panel/control_panel/left_control_panel/left_control_panel.hpp +++ b/source/panel/control_panel/left_control_panel/left_control_panel.hpp @@ -31,6 +31,8 @@ namespace zlPanel { void resized() override; + void lookAndFeelChanged() override; + void attachGroup(size_t idx); private: @@ -59,6 +61,8 @@ namespace zlPanel { void parameterChanged(const juce::String ¶meterID, float newValue) override; void handleAsyncUpdate() override; + + void updateMouseDragSensitivity(); }; } diff --git a/source/panel/control_panel/right_control_panel/right_control_panel.cpp b/source/panel/control_panel/right_control_panel/right_control_panel.cpp index 27c2a620..5e468bac 100644 --- a/source/panel/control_panel/right_control_panel/right_control_panel.cpp +++ b/source/panel/control_panel/right_control_panel/right_control_panel.cpp @@ -68,6 +68,7 @@ namespace zlPanel { for (auto &c: {&thresC, &kneeC, &attackC, &releaseC}) { addAndMakeVisible(c); } + lookAndFeelChanged(); } RightControlPanel::~RightControlPanel() { @@ -80,14 +81,6 @@ namespace zlPanel { void RightControlPanel::paint(juce::Graphics &g) { const auto bound = getLocalBounds().toFloat(); uiBase.fillRoundedShadowRectangle(g, bound, 0.5f * uiBase.getFontSize(), {.blurRadius = 0.25f}); - const auto style = uiBase.getRotaryStyle(); - const auto sensitivity = juce::roundToInt(uiBase.getRotaryDragSensitivity() * uiBase.getFontSize()); - for (auto &c: {&sideFreqC, &sideQC}) { - c->getSlider1().setSliderStyle(style); - c->getSlider1().setMouseDragSensitivity(sensitivity); - c->getSlider2().setSliderStyle(style); - c->getSlider2().setMouseDragSensitivity(sensitivity); - } } void RightControlPanel::resized() { @@ -124,6 +117,11 @@ namespace zlPanel { auto bound = getLocalBounds().toFloat(); bound = uiBase.getRoundedShadowRectangleArea(bound, 0.5f * uiBase.getFontSize(), {}); grid.performLayout(bound.toNearestInt()); + updateMouseDragSensitivity(); + } + + void RightControlPanel::lookAndFeelChanged() { + updateMouseDragSensitivity(); } void RightControlPanel::attachGroup(size_t idx) { @@ -184,4 +182,14 @@ namespace zlPanel { dynRelativeC.repaint(); repaint(); } + + void RightControlPanel::updateMouseDragSensitivity() { + const auto style = uiBase.getRotaryStyle(); + const auto sensitivity = juce::roundToInt(uiBase.getRotaryDragSensitivity() * uiBase.getFontSize()); + for (auto &c: {&sideFreqC, &sideQC}) { + c->getSlider1().setSliderStyle(style); + c->getSlider2().setSliderStyle(style); + c->setMouseDragSensitivity(sensitivity); + } + } } diff --git a/source/panel/control_panel/right_control_panel/right_control_panel.hpp b/source/panel/control_panel/right_control_panel/right_control_panel.hpp index 902bd649..c5df53c3 100644 --- a/source/panel/control_panel/right_control_panel/right_control_panel.hpp +++ b/source/panel/control_panel/right_control_panel/right_control_panel.hpp @@ -28,6 +28,8 @@ namespace zlPanel { void resized() override; + void lookAndFeelChanged() override; + void attachGroup(size_t idx); private: @@ -48,6 +50,8 @@ namespace zlPanel { void parameterChanged(const juce::String ¶meterID, float newValue) override; void handleAsyncUpdate() override; + + void updateMouseDragSensitivity(); }; } diff --git a/source/state/state_definitions.hpp b/source/state/state_definitions.hpp index 30a76b5f..817f0f6d 100644 --- a/source/state/state_definitions.hpp +++ b/source/state/state_definitions.hpp @@ -242,7 +242,7 @@ namespace zlState { public: auto static constexpr ID = "wheel_fine_sensitivity"; auto static constexpr name = ""; - inline auto static const range = juce::NormalisableRange(0.f, 1.f, 0.01f); + inline auto static const range = juce::NormalisableRange(0.01f, 1.f, 0.01f); auto static constexpr defaultV = .12f; }; @@ -258,7 +258,7 @@ namespace zlState { public: auto static constexpr ID = "drag_fine_sensitivity"; auto static constexpr name = ""; - inline auto static const range = juce::NormalisableRange(0.f, 1.f, 0.01f); + inline auto static const range = juce::NormalisableRange(0.01f, 1.f, 0.01f); auto static constexpr defaultV = .25f; };