Browse Source

Don't smooth snapped knobs

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
0b5e30fcf0
2 changed files with 9 additions and 6 deletions
  1. +1
    -1
      include/app.hpp
  2. +8
    -5
      src/app/Knob.cpp

+ 1
- 1
include/app.hpp View File

@@ -185,7 +185,7 @@ struct ParamWidget : OpaqueWidget, QuantityWidget {
struct Knob : ParamWidget {
/** Snap to nearest integer while dragging */
bool snap = false;
float snapValue;
float dragValue;
void onDragStart();
void onDragMove(Vec mouseRel);
void onDragEnd();


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

@@ -12,7 +12,7 @@ namespace rack {

void Knob::onDragStart() {
guiCursorLock();
snapValue = value;
dragValue = value;
randomizable = false;
}

@@ -20,11 +20,11 @@ void Knob::onDragMove(Vec mouseRel) {
// Drag slower if Mod
if (guiIsModPressed())
mouseRel = mouseRel.mult(1/16.0);
snapValue += KNOB_SENSITIVITY * (maxValue - minValue) * -mouseRel.y;
dragValue += KNOB_SENSITIVITY * (maxValue - minValue) * -mouseRel.y;
if (snap)
setValue(roundf(snapValue));
setValue(roundf(dragValue));
else
setValue(snapValue);
setValue(dragValue);
}

void Knob::onDragEnd() {
@@ -36,7 +36,10 @@ void Knob::onChange() {
if (!module)
return;

engineSetParamSmooth(module, paramId, value);
if (snap)
engineSetParam(module, paramId, value);
else
engineSetParamSmooth(module, paramId, value);
}




Loading…
Cancel
Save