Browse Source

Support moving continuous encoders (knobs with infinite bounds)

tags/v0.6.0
Andrew Belt 7 years ago
parent
commit
82f73d9e3e
2 changed files with 15 additions and 6 deletions
  1. +8
    -4
      src/app/Knob.cpp
  2. +7
    -2
      src/app/SVGKnob.cpp

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

@@ -21,10 +21,14 @@ void Knob::onDragStart(EventDragStart &e) {
}

void Knob::onDragMove(EventDragMove &e) {
float range = maxValue - minValue;
float delta = KNOB_SENSITIVITY * -e.mouseRel.y * speed;
if (isfinite(range))
delta *= range;
float range;
if (isfinite(minValue) && isfinite(maxValue)) {
range = maxValue - minValue;
}
else {
range = 1.0 - (-1.0);
}
float delta = KNOB_SENSITIVITY * -e.mouseRel.y * speed * range;

// Drag slower if Mod is held
if (windowIsModPressed())


+ 7
- 2
src/app/SVGKnob.cpp View File

@@ -28,9 +28,14 @@ void SVGKnob::setSVG(std::shared_ptr<SVG> svg) {
void SVGKnob::step() {
// Re-transform TransformWidget if dirty
if (dirty) {
float angle = 0.0;
if (isfinite(minValue) && isfinite(maxValue))
float angle;
if (isfinite(minValue) && isfinite(maxValue)) {
angle = rescale(value, minValue, maxValue, minAngle, maxAngle);
}
else {
angle = rescale(value, -1.0, 1.0, minAngle, maxAngle);
angle = fmodf(angle, 2*M_PI);
}
tw->identity();
// Rotate SVG
Vec center = sw->box.getCenter();


Loading…
Cancel
Save