Browse Source

Added support for continuous encoders, aka Knob widgets with infinite

min/max values
pull/1639/head
Andrew Belt 6 years ago
parent
commit
9085727425
2 changed files with 8 additions and 2 deletions
  1. +5
    -1
      src/app/Knob.cpp
  2. +3
    -1
      src/app/SVGKnob.cpp

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

@@ -18,7 +18,11 @@ void Knob::onDragStart(EventDragStart &e) {

void Knob::onDragMove(EventDragMove &e) {
// Drag slower if Mod
float delta = KNOB_SENSITIVITY * (maxValue - minValue) * -e.mouseRel.y * speed;
float range = maxValue - minValue;
float delta = KNOB_SENSITIVITY * -e.mouseRel.y * speed;
if (std::isfinite(range))
delta *= range;

if (guiIsModPressed())
delta /= 16.0;
dragValue += delta;


+ 3
- 1
src/app/SVGKnob.cpp View File

@@ -23,7 +23,9 @@ void SVGKnob::step() {
// Re-transform TransformWidget if dirty
if (dirty) {
tw->box.size = box.size;
float angle = rescalef(value, minValue, maxValue, minAngle, maxAngle);
float angle = 0.0;
if (std::isfinite(minValue) && std::isfinite(maxValue))
angle = rescalef(value, minValue, maxValue, minAngle, maxAngle);
tw->identity();
// Scale SVG to box
tw->scale(box.size.div(sw->box.size));


Loading…
Cancel
Save