| 19 | } |
| 20 | |
| 21 | void onDragMove(const event::DragMove& e) override { |
| 22 | ParamQuantity* paramQuantity = getParamQuantity(); |
| 23 | float diff = APP->scene->rack->getMousePos().y - startMouseY; |
| 24 | |
| 25 | // Once the user has dragged the mouse a "threshold" distance, latch |
| 26 | // to disallow further changes of state until the mouse is released. |
| 27 | // We don't just setValue(1) (default/rest state) because this creates a |
| 28 | // jarring UI experience |
| 29 | if (diff < -10 && !latched) { |
| 30 | paramQuantity->setValue(2); |
| 31 | latched = true; |
| 32 | } |
| 33 | if (diff > 10 && !latched) { |
| 34 | paramQuantity->setValue(0); |
| 35 | latched = true; |
| 36 | } |
| 37 | |
| 38 | ParamWidget::onDragMove(e); |
| 39 | } |
| 40 | |
| 41 | void onDragEnd(const event::DragEnd& e) override { |
| 42 | // on release, the switch resets to default/neutral/middle position |