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.

38 lines
755B

  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. }
  9. void SVGSlider::setSVGs(std::shared_ptr<SVG> backgroundSVG, std::shared_ptr<SVG> handleSVG) {
  10. background->setSVG(backgroundSVG);
  11. box.size = background->box.size;
  12. if (handleSVG) {
  13. handle->setSVG(handleSVG);
  14. }
  15. }
  16. void SVGSlider::step() {
  17. if (dirty) {
  18. // Interpolate handle position
  19. handle->box.pos = Vec(rescale(value, minValue, maxValue, minHandlePos.x, maxHandlePos.x), rescale(value, minValue, maxValue, minHandlePos.y, maxHandlePos.y));
  20. }
  21. FramebufferWidget::step();
  22. }
  23. void SVGSlider::onChange(EventChange &e) {
  24. dirty = true;
  25. Knob::onChange(e);
  26. }
  27. } // namespace rack