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

  1. #include "app/SVGSwitch.hpp"
  2. namespace rack {
  3. SVGSwitch::SVGSwitch() {
  4. fb = new FramebufferWidget;
  5. addChild(fb);
  6. sw = new SVGWidget;
  7. fb->addChild(sw);
  8. }
  9. void SVGSwitch::addFrame(std::shared_ptr<SVG> svg) {
  10. frames.push_back(svg);
  11. // If this is our first frame, automatically set SVG and size
  12. if (!sw->svg) {
  13. sw->setSVG(svg);
  14. box.size = sw->box.size;
  15. fb->box.size = sw->box.size;
  16. }
  17. }
  18. void SVGSwitch::onChange(const event::Change &e) {
  19. if (!frames.empty() && paramQuantity) {
  20. int index = (int) paramQuantity->getValue();
  21. index = math::clamp(index, 0, (int) frames.size() - 1);
  22. sw->setSVG(frames[index]);
  23. fb->dirty = true;
  24. }
  25. ParamWidget::onChange(e);
  26. }
  27. } // namespace rack