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.

35 lines
595B

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