computerscare-vcv-modules

ComputerScare modules for VCV Rack
Log | Files | Refs

ComputerscareSVGPanel.cpp (947B)


      1 
      2 #include "Computerscare.hpp"
      3 
      4 namespace rack {
      5 namespace app {
      6 
      7 
      8 void PanelBorder::draw(const DrawArgs &ctx) {
      9 	NVGcolor borderColor = nvgRGBAf(0.5, 0.5, 0.5, 0.5);
     10 	nvgBeginPath(ctx.vg);
     11 	nvgRect(ctx.vg, 0.5, 0.5, box.size.x - 1.0, box.size.y - 1.0);
     12 	nvgStrokeColor(ctx.vg, borderColor);
     13 	nvgStrokeWidth(ctx.vg, 1.0);
     14 	//nvgStroke(ctx.vg);
     15 }
     16 
     17 
     18 void ComputerscareSVGPanel::step() {
     19 	if (math::isNear(APP->window->pixelRatio, 1.0)) {
     20 		// Small details draw poorly at low DPI, so oversample when drawing to the framebuffer
     21 		oversample = 2.0;
     22 	}
     23 	widget::FramebufferWidget::step();
     24 }
     25 
     26 void ComputerscareSVGPanel::setBackground(std::shared_ptr<Svg> svg) {
     27 	widget::SvgWidget *sw = new widget::SvgWidget;
     28 	sw->setSvg(svg);
     29 	addChild(sw);
     30 
     31 	// Set size
     32 	box.size = sw->box.size.div(RACK_GRID_SIZE).round().mult(RACK_GRID_SIZE);
     33 
     34 	PanelBorder *pb = new PanelBorder;
     35 	pb->box.size = box.size;
     36 	addChild(pb);
     37 }
     38 
     39 
     40 } // namespace app
     41 } // namespace rack