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.

40 lines
788B

  1. #include "app.hpp"
  2. namespace rack {
  3. SVGSlider::SVGSlider() {
  4. background = new SVGWidget();
  5. addChild(background);
  6. handle = new SVGWidget();
  7. addChild(handle);
  8. speed = 2.0;
  9. }
  10. void SVGSlider::setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG) {
  11. background->setSVG(backgroundSVG);
  12. box.size = background->box.size;
  13. if (handleSVG) {
  14. handle->setSVG(handleSVG);
  15. }
  16. }
  17. void SVGSlider::step() {
  18. if (dirty) {
  19. // Interpolate handle position
  20. handle->box.pos = math::Vec(math::rescale(value, minValue, maxValue, minHandlePos.x, maxHandlePos.x), math::rescale(value, minValue, maxValue, minHandlePos.y, maxHandlePos.y));
  21. }
  22. FramebufferWidget::step();
  23. }
  24. void SVGSlider::onChange(EventChange &e) {
  25. dirty = true;
  26. Knob::onChange(e);
  27. }
  28. } // namespace rack