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.

43 lines
878B

  1. #include "app.hpp"
  2. #include "gui.hpp"
  3. namespace rack {
  4. struct PanelBorder : TransparentWidget {
  5. void draw(NVGcontext *vg) override {
  6. NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5);
  7. nvgBeginPath(vg);
  8. nvgRect(vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0);
  9. nvgStrokeColor(vg, borderColor);
  10. nvgStrokeWidth(vg, 1.0);
  11. nvgStroke(vg);
  12. }
  13. };
  14. void SVGPanel::step() {
  15. if (isNear(gPixelRatio, 1.0)) {
  16. // Small details draw poorly at low DPI, so oversample when drawing to the framebuffer
  17. oversample = 2.0;
  18. }
  19. FramebufferWidget::step();
  20. }
  21. void SVGPanel::setBackground(std::shared_ptr<SVG> svg) {
  22. SVGWidget *sw = new SVGWidget();
  23. sw->setSVG(svg);
  24. addChild(sw);
  25. // Set size
  26. box.size = sw->box.size.div(RACK_GRID_SIZE).round().mult(RACK_GRID_SIZE);
  27. PanelBorder *pb = new PanelBorder();
  28. pb->box.size = box.size;
  29. addChild(pb);
  30. }
  31. } // namespace rack