diff --git a/include/app/Knob.hpp b/include/app/Knob.hpp index 2dc10a15..031d2730 100644 --- a/include/app/Knob.hpp +++ b/include/app/Knob.hpp @@ -16,6 +16,8 @@ struct Knob : ParamWidget { /** Enable snapping at integer values */ bool snap = false; float snapValue = NAN; + /** Drag horizontally instead of vertically */ + bool horizontal = false; void onHover(const event::Hover &e) override; void onButton(const event::Button &e) override; diff --git a/include/app/SliderKnob.hpp b/include/app/SliderKnob.hpp index fdffd946..c5ec60e3 100644 --- a/include/app/SliderKnob.hpp +++ b/include/app/SliderKnob.hpp @@ -7,6 +7,7 @@ namespace rack { struct SliderKnob : Knob { + // Bypass Knob's circular hitbox detection void onHover(const event::Hover &e) override { ParamWidget::onHover(e); } diff --git a/src/app/Knob.cpp b/src/app/Knob.cpp index 3b9c1b43..1eb0a036 100644 --- a/src/app/Knob.cpp +++ b/src/app/Knob.cpp @@ -64,7 +64,10 @@ void Knob::onDragMove(const event::DragMove &e) { // Continuous encoders scale as if their limits are +/-1 range = 2.f; } - float delta = KNOB_SENSITIVITY * -e.mouseDelta.y * speed * range; + float delta = (horizontal ? e.mouseDelta.x : -e.mouseDelta.y); + delta *= KNOB_SENSITIVITY; + delta *= speed; + delta *= range; // Drag slower if mod is held int mods = app()->window->getMods();