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.

Switch.hpp 848B

12345678910111213141516171819202122232425262728293031323334
  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. struct Internal;
  13. Internal* internal;
  14. /** Instead of incrementing values on each click, sets maxValue on press and minValue on release.
  15. */
  16. bool momentary = false;
  17. Switch();
  18. ~Switch();
  19. void initParamQuantity() override;
  20. void step() override;
  21. void onDoubleClick(const DoubleClickEvent& e) override;
  22. void onDragStart(const DragStartEvent& e) override;
  23. void onDragEnd(const DragEndEvent& e) override;
  24. };
  25. } // namespace app
  26. } // namespace rack