@@ -121,6 +121,14 @@ struct Panel : TransparentWidget { | |||||
void draw(NVGcontext *vg); | void draw(NVGcontext *vg); | ||||
}; | }; | ||||
struct PanelBorder : TransparentWidget { | |||||
void draw(NVGcontext *vg); | |||||
}; | |||||
struct SVGPanel : FramebufferWidget { | |||||
void addBackground(std::shared_ptr<SVG> svg); | |||||
}; | |||||
//////////////////// | //////////////////// | ||||
// params | // params | ||||
//////////////////// | //////////////////// | ||||
@@ -198,6 +198,7 @@ struct FramebufferWidget : virtual Widget { | |||||
This prevents cutting the rendered SVG off on the box edges. | This prevents cutting the rendered SVG off on the box edges. | ||||
*/ | */ | ||||
Vec padding; | Vec padding; | ||||
float oversample = 2.0; | |||||
/** The root object in the framebuffer scene | /** The root object in the framebuffer scene | ||||
The FramebufferWidget owns the pointer | The FramebufferWidget owns the pointer | ||||
*/ | */ | ||||
@@ -0,0 +1,20 @@ | |||||
#include "app.hpp" | |||||
namespace rack { | |||||
void PanelBorder::draw(NVGcontext *vg) { | |||||
nvgBeginPath(vg); | |||||
nvgRect(vg, 0.0, 0.0, box.size.x, box.size.y); | |||||
NVGcolor borderColor = nvgRGB(0xac, 0xac, 0xac); | |||||
// Border | |||||
nvgBeginPath(vg); | |||||
nvgRect(vg, 0.5, 0.5, box.size.x - 1, box.size.y - 1); | |||||
nvgStrokeColor(vg, borderColor); | |||||
nvgStrokeWidth(vg, 1.0); | |||||
nvgStroke(vg); | |||||
} | |||||
} // namespace rack |
@@ -0,0 +1,19 @@ | |||||
#include "app.hpp" | |||||
namespace rack { | |||||
void SVGPanel::addBackground(std::shared_ptr<SVG> svg) { | |||||
SVGWidget *sw = new SVGWidget(); | |||||
sw->wrap(); | |||||
sw->svg = svg; | |||||
addChild(sw); | |||||
PanelBorder *pb = new PanelBorder(); | |||||
sw->box.size = box.size; | |||||
addChild(pb); | |||||
} | |||||
} // namespace rack |
@@ -39,7 +39,7 @@ void FramebufferWidget::step() { | |||||
if (dirty) { | if (dirty) { | ||||
internal->box.pos = padding.neg(); | internal->box.pos = padding.neg(); | ||||
internal->box.size = box.size.plus(padding.mult(2)); | internal->box.size = box.size.plus(padding.mult(2)); | ||||
Vec fbSize = internal->box.size.mult(gPixelRatio); | |||||
Vec fbSize = internal->box.size.mult(gPixelRatio * oversample); | |||||
// assert(fbSize.isFinite()); | // assert(fbSize.isFinite()); | ||||
internal->setFramebuffer(NULL); | internal->setFramebuffer(NULL); | ||||
@@ -54,7 +54,7 @@ void FramebufferWidget::step() { | |||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); | ||||
nvgBeginFrame(gVg, fbSize.x, fbSize.y, gPixelRatio); | nvgBeginFrame(gVg, fbSize.x, fbSize.y, gPixelRatio); | ||||
nvgScale(gVg, gPixelRatio, gPixelRatio); | |||||
nvgScale(gVg, gPixelRatio * oversample, gPixelRatio * oversample); | |||||
nvgTranslate(gVg, padding.x, padding.y); | nvgTranslate(gVg, padding.x, padding.y); | ||||
Widget::draw(gVg); | Widget::draw(gVg); | ||||