diff --git a/.gitignore b/.gitignore index 33ec4075..8e77f61a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ *.vcv /patches /design +.DS_Store diff --git a/include/widgets.hpp b/include/widgets.hpp index df978b3e..17150936 100644 --- a/include/widgets.hpp +++ b/include/widgets.hpp @@ -230,6 +230,10 @@ Events are not passed to the underlying scene. struct FramebufferWidget : virtual Widget { /** Set this to true to re-render the children to the framebuffer the next time it is drawn */ bool dirty = true; + /** A margin in pixels around the children in the framebuffer + This prevents cutting the rendered SVG off on the box edges. + */ + float oversample; /** The root object in the framebuffer scene The FramebufferWidget owns the pointer */ diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 95a95545..4b90ac5c 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -15,14 +15,15 @@ namespace rack { RackWidget::RackWidget() { - rails = new FramebufferWidget(); - rails->box.size = Vec(); - { - RackRail *rail = new RackRail(); - rail->box.size = Vec(); - rails->addChild(rail); - } - addChild(rails); + // rails = new FramebufferWidget(); + // rails->box.size = Vec(); + // rails->oversample = 1.0; + // { + // RackRail *rail = new RackRail(); + // rail->box.size = Vec(); + // rails->addChild(rail); + // } + // addChild(rails); moduleContainer = new Widget(); addChild(moduleContainer); @@ -340,23 +341,23 @@ void RackWidget::step() { // We assume that the size is reset by a parent before calling step(). Otherwise it will grow unbounded. box.size = box.size.max(moduleSize); - // Adjust size and position of rails - Widget *rail = rails->children.front(); - Rect bound = getViewport(Rect(Vec(), box.size)); - if (!rails->box.contains(bound)) { - // Add a margin around the otherwise tight bound, so that scrolling slightly will not require a re-render of rails. - Vec margin = Vec(100, 100); - bound.pos = bound.pos.minus(margin); - bound.size = bound.size.plus(margin.mult(2)); - rails->box = bound; - // Compute offset of rail within rails framebuffer - Vec grid = Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT); - Vec gridPos = bound.pos.div(grid).floor().mult(grid); - bound.pos = gridPos.minus(bound.pos); - bound.size = bound.size.minus(bound.pos); - rail->box = bound; - rails->dirty = true; - } + // // Adjust size and position of rails + // Widget *rail = rails->children.front(); + // Rect bound = getViewport(Rect(Vec(), box.size)); + // if (!rails->box.contains(bound)) { + // // Add a margin around the otherwise tight bound, so that scrolling slightly will not require a re-render of rails. + // Vec margin = Vec(100, 100); + // bound.pos = bound.pos.minus(margin); + // bound.size = bound.size.plus(margin.mult(2)); + // rails->box = bound; + // // Compute offset of rail within rails framebuffer + // Vec grid = Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT); + // Vec gridPos = bound.pos.div(grid).floor().mult(grid); + // bound.pos = gridPos.minus(bound.pos); + // bound.size = bound.size.minus(bound.pos); + // rail->box = bound; + // rails->dirty = true; + // } // Autosave every 15 seconds if (gGuiFrame % (60*15) == 0) { @@ -525,7 +526,7 @@ void RackWidget::onMouseDownOpaque(int button) { } void RackWidget::onZoom() { - rails->box.size = Vec(); + // rails->box.size = Vec(); Widget::onZoom(); } diff --git a/src/gui.cpp b/src/gui.cpp index e8c260c5..a9be0f76 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -358,7 +358,7 @@ void guiRun() { std::this_thread::sleep_for(std::chrono::duration(minTime - frameTime)); } endTime = glfwGetTime(); - // printf("%lf fps\n", 1.0 / (endTime - startTime)); + printf("%lf fps\n", 1.0 / (endTime - startTime)); } } diff --git a/src/widgets/FramebufferWidget.cpp b/src/widgets/FramebufferWidget.cpp index 9792635a..703fb65e 100644 --- a/src/widgets/FramebufferWidget.cpp +++ b/src/widgets/FramebufferWidget.cpp @@ -9,12 +9,6 @@ namespace rack { -/** A margin in pixels around the children in the framebuffer -This prevents cutting the rendered SVG off on the box edges. -*/ -static const float oversample = 2.0; - - struct FramebufferWidget::Internal { NVGLUframebuffer *fb = NULL; Rect box; @@ -32,6 +26,7 @@ struct FramebufferWidget::Internal { FramebufferWidget::FramebufferWidget() { internal = new Internal(); + oversample = 1.0; } FramebufferWidget::~FramebufferWidget() { @@ -65,6 +60,7 @@ void FramebufferWidget::draw(NVGcontext *vg) { if (fbSize.x <= 0.0 || fbSize.y <= 0.0) return; + printf("rendering framebuffer %f %f\n", fbSize.x, fbSize.y); // Delete old one first to free up GPU memory internal->setFramebuffer(NULL); // Create a framebuffer from the main nanovg context. We will draw to this in the secondary nanovg context.