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.

34 lines
626B

  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. // Automatically set the frame as this SVG file.
  10. // This allows us to wrap() the widget after calling
  11. if (!sw->svg)
  12. sw->svg = svg;
  13. }
  14. void SVGSwitch::step() {
  15. FramebufferWidget::step();
  16. }
  17. void SVGSwitch::onChange() {
  18. int index = roundf(rescalef(value, minValue, maxValue, 0, frames.size() - 1));
  19. if (0 <= index && index < (int)frames.size())
  20. sw->svg = frames[index];
  21. dirty = true;
  22. ParamWidget::onChange();
  23. }
  24. } // namespace rack