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.

32 lines
843B

  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 initParamQuantity() override;
  18. void step() override;
  19. void onDoubleClick(const DoubleClickEvent& e) override;
  20. void onDragStart(const DragStartEvent& e) override;
  21. void onDragEnd(const DragEndEvent& e) override;
  22. };
  23. } // namespace app
  24. } // namespace rack