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.

33 lines
865B

  1. #pragma once
  2. #include <app/common.hpp>
  3. #include <app/ParamWidget.hpp>
  4. namespace rack {
  5. namespace app {
  6. /** A ParamWidget that represents an integer.
  7. Increases by 1 each time it is clicked.
  8. When maxValue is reached, the next click resets to minValue.
  9. In momentary mode, the value is instead set to maxValue when the mouse is held and minValue when released.
  10. */
  11. struct Switch : ParamWidget {
  12. /** Return to original position when released */
  13. bool momentary = false;
  14. /** Hysteresis state for momentary switch */
  15. bool momentaryPressed = false;
  16. bool momentaryReleased = false;
  17. void step() override;
  18. void onDoubleClick(const event::DoubleClick &e) override;
  19. void onDragStart(const event::DragStart &e) override;
  20. void onDragEnd(const event::DragEnd &e) override;
  21. void reset() override;
  22. void randomize() override;
  23. };
  24. } // namespace app
  25. } // namespace rack