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.

Knob.hpp 881B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include "app/common.hpp"
  3. #include "app/ParamWidget.hpp"
  4. #include "app.hpp"
  5. namespace rack {
  6. namespace app {
  7. /** Implements vertical dragging behavior for ParamWidgets */
  8. struct Knob : ParamWidget {
  9. /** Multiplier for mouse movement to adjust knob value */
  10. float speed = 1.0;
  11. float oldValue = 0.f;
  12. bool smooth = true;
  13. /** Enable snapping at integer values */
  14. bool snap = false;
  15. float snapValue = NAN;
  16. /** Drag horizontally instead of vertically */
  17. bool horizontal = false;
  18. void onHover(const widget::HoverEvent &e) override;
  19. void onButton(const widget::ButtonEvent &e) override;
  20. void onDragStart(const widget::DragStartEvent &e) override;
  21. void onDragEnd(const widget::DragEndEvent &e) override;
  22. void onDragMove(const widget::DragMoveEvent &e) override;
  23. void reset() override;
  24. void randomize() override;
  25. };
  26. } // namespace app
  27. } // namespace rack