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.

44 lines
707B

  1. #include "app.hpp"
  2. namespace rack {
  3. SVGKnob::SVGKnob() {
  4. tw = new TransformWidget();
  5. addChild(tw);
  6. sw = new SVGWidget();
  7. tw->addChild(sw);
  8. }
  9. void SVGKnob::setSVG(std::shared_ptr<SVG> svg) {
  10. sw->svg = svg;
  11. sw->wrap();
  12. tw->box.size = sw->box.size;
  13. box.size = sw->box.size;
  14. }
  15. void SVGKnob::step() {
  16. // Re-transform TransformWidget if dirty
  17. if (dirty) {
  18. float angle = rescalef(value, minValue, maxValue, minAngle, maxAngle);
  19. tw->identity();
  20. // Rotate SVG
  21. Vec center = sw->box.getCenter();
  22. tw->translate(center);
  23. tw->rotate(angle);
  24. tw->translate(center.neg());
  25. }
  26. FramebufferWidget::step();
  27. }
  28. void SVGKnob::onChange() {
  29. dirty = true;
  30. Knob::onChange();
  31. }
  32. } // namespace rack