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
684B

  1. #include "../include/ColourDragging.hpp"
  2. #include "../include/BaseWidget.hpp"
  3. #include "window.hpp"
  4. using namespace rack;
  5. namespace rack_plugin_rcm {
  6. static const float COLOURDRAG_SENSITIVITY = 0.0015f;
  7. ColourDragging::ColourDragging(BaseWidget* widget) : widget(widget) {
  8. windowCursorLock();
  9. }
  10. ColourDragging::~ColourDragging() {
  11. windowCursorUnlock();
  12. }
  13. void ColourDragging::onDragMove(EventDragMove& e) {
  14. float speed = 1.f;
  15. float range = 1.f;
  16. float delta = COLOURDRAG_SENSITIVITY * e.mouseRel.y * speed * range;
  17. if (windowIsModPressed()) {
  18. delta /= 16.f;
  19. }
  20. widget->backgroundHue = clamp(widget->backgroundHue + delta, 0.f, 1.f);
  21. }
  22. } // namespace rack_plugin_rcm