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.

37 lines
852B

  1. #include "app/ToggleSwitch.hpp"
  2. #include "app.hpp"
  3. #include "app/Scene.hpp"
  4. #include "history.hpp"
  5. namespace rack {
  6. void ToggleSwitch::onDragStart(const event::DragStart &e) {
  7. // Cycle through values
  8. // e.g. a range of [0.0, 3.0] would have modes 0, 1, 2, and 3.
  9. if (paramQuantity) {
  10. float oldValue = paramQuantity->getValue();
  11. if (paramQuantity->isMax()) {
  12. paramQuantity->setMin();
  13. }
  14. else {
  15. paramQuantity->setValue(std::floor(paramQuantity->getValue() + 1));
  16. }
  17. float newValue = paramQuantity->getValue();
  18. if (oldValue != newValue) {
  19. // Push ParamChange history action
  20. history::ParamChange *h = new history::ParamChange;
  21. h->moduleId = paramQuantity->module->id;
  22. h->paramId = paramQuantity->paramId;
  23. h->oldValue = oldValue;
  24. h->newValue = newValue;
  25. app()->history->push(h);
  26. }
  27. }
  28. }
  29. } // namespace rack