Browse Source

initializing knob sensitivity in the struct delcaration did not work

pull/682/head
Jon Williams 7 years ago
parent
commit
632f5aa65f
2 changed files with 7 additions and 4 deletions
  1. +1
    -2
      include/app.hpp
  2. +6
    -2
      src/app/Knob.cpp

+ 1
- 2
include/app.hpp View File

@@ -23,7 +23,6 @@ struct SVGPanel;
// A 1U module should be 15x380. Thus the width of a module should be a factor of 15.
#define RACK_GRID_WIDTH 15
#define RACK_GRID_HEIGHT 380
#define KNOB_SENSITIVITY 0.0015

static const Vec RACK_GRID_SIZE = Vec(15, 380);

@@ -201,7 +200,7 @@ struct Knob : ParamWidget {
/** Snap to nearest integer while dragging */
bool snap = false;
float dragValue;
float sensitivity = KNOB_SENSITIVITY;
float sensitivity = 0.0;
void onDragStart(EventDragStart &e) override;
void onDragMove(EventDragMove &e) override;
void onDragEnd(EventDragEnd &e) override;


+ 6
- 2
src/app/Knob.cpp View File

@@ -4,9 +4,9 @@
// For GLFW_KEY_LEFT_CONTROL, etc.
#include <GLFW/glfw3.h>


namespace rack {

#define KNOB_SENSITIVITY 0.0015


void Knob::onDragStart(EventDragStart &e) {
@@ -16,8 +16,12 @@ void Knob::onDragStart(EventDragStart &e) {
}

void Knob::onDragMove(EventDragMove &e) {
float sens = sensitivity;
if (sens == 0.f) {
sens = KNOB_SENSITIVITY;
}
// Drag slower if Mod
float delta = sensitivity * (maxValue - minValue) * -e.mouseRel.y;
float delta = sens * (maxValue - minValue) * -e.mouseRel.y;
if (guiIsModPressed())
delta /= 16.0;
dragValue += delta;


Loading…
Cancel
Save