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.

40 lines
718B

  1. #include <app/SvgPort.hpp>
  2. namespace rack {
  3. namespace app {
  4. SvgPort::SvgPort() {
  5. fb = new widget::FramebufferWidget;
  6. addChild(fb);
  7. shadow = new CircularShadow;
  8. fb->addChild(shadow);
  9. // Avoid breakage if plugins fail to call setSvg()
  10. // In that case, just disable the shadow.
  11. shadow->box.size = math::Vec();
  12. sw = new widget::SvgWidget;
  13. fb->addChild(sw);
  14. }
  15. void SvgPort::setSvg(std::shared_ptr<window::Svg> svg) {
  16. if (svg == sw->svg)
  17. return;
  18. sw->setSvg(svg);
  19. fb->box.size = sw->box.size;
  20. box.size = sw->box.size;
  21. // Move shadow downward by 10%
  22. shadow->box.size = sw->box.size;
  23. shadow->box.pos = math::Vec(0, sw->box.size.y * 0.10);
  24. fb->setDirty();
  25. }
  26. } // namespace app
  27. } // namespace rack