Browse Source

Add Knob::horizontal

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
21b99196d7
3 changed files with 7 additions and 1 deletions
  1. +2
    -0
      include/app/Knob.hpp
  2. +1
    -0
      include/app/SliderKnob.hpp
  3. +4
    -1
      src/app/Knob.cpp

+ 2
- 0
include/app/Knob.hpp View File

@@ -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;


+ 1
- 0
include/app/SliderKnob.hpp View File

@@ -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);
}


+ 4
- 1
src/app/Knob.cpp View File

@@ -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();


Loading…
Cancel
Save