You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.1KB

  1. #pragma once
  2. #include <app/common.hpp>
  3. #include <app/ParamWidget.hpp>
  4. #include <context.hpp>
  5. namespace rack {
  6. namespace app {
  7. /** Implements vertical dragging behavior for ParamWidgets */
  8. struct Knob : ParamWidget {
  9. struct Internal;
  10. Internal* internal;
  11. /** Drag horizontally instead of vertically. */
  12. bool horizontal = false;
  13. /** Enables per-sample value smoothing while dragging. */
  14. bool smooth = true;
  15. /** DEPRECATED. Use `ParamQuantity::snapEnabled`. */
  16. bool snap = false;
  17. /** Multiplier for mouse movement to adjust knob value */
  18. float speed = 1.f;
  19. /** Force dragging to linear, e.g. for sliders. */
  20. bool forceLinear = false;
  21. /** Angles in radians. */
  22. float minAngle = -M_PI;
  23. float maxAngle = M_PI;
  24. Knob();
  25. ~Knob();
  26. void initParamQuantity() override;
  27. void onHover(const event::Hover& e) override;
  28. void onButton(const event::Button& e) override;
  29. void onDragStart(const event::DragStart& e) override;
  30. void onDragEnd(const event::DragEnd& e) override;
  31. void onDragMove(const event::DragMove& e) override;
  32. void onDragLeave(const event::DragLeave& e) override;
  33. };
  34. } // namespace app
  35. } // namespace rack