Browse Source

Oversample SVGPanels by 2, everything else by 1

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
99ad658694
7 changed files with 36 additions and 31 deletions
  1. +1
    -0
      include/app.hpp
  2. +27
    -27
      src/app/RackWidget.cpp
  3. +4
    -0
      src/app/SVGPanel.cpp
  4. +1
    -1
      src/app/Toolbar.cpp
  5. +1
    -1
      src/gui.cpp
  6. +1
    -2
      src/widgets/FramebufferWidget.cpp
  7. +1
    -0
      src/widgets/SVGWidget.cpp

+ 1
- 0
include/app.hpp View File

@@ -155,6 +155,7 @@ struct Panel : TransparentWidget {
};

struct SVGPanel : FramebufferWidget {
SVGPanel();
void setBackground(std::shared_ptr<SVG> svg);
};



+ 27
- 27
src/app/RackWidget.cpp View File

@@ -15,15 +15,15 @@ namespace rack {


RackWidget::RackWidget() {
// rails = new FramebufferWidget();
// rails->box.size = Vec();
// rails->oversample = 1.0;
// {
// 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);
@@ -341,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) {
@@ -526,7 +526,7 @@ void RackWidget::onMouseDownOpaque(int button) {
}

void RackWidget::onZoom() {
// rails->box.size = Vec();
rails->box.size = Vec();
Widget::onZoom();
}



+ 4
- 0
src/app/SVGPanel.cpp View File

@@ -16,6 +16,10 @@ struct PanelBorder : TransparentWidget {
};


SVGPanel::SVGPanel() {
oversample = 2.0;
}

void SVGPanel::setBackground(std::shared_ptr<SVG> svg) {
clearChildren();



+ 1
- 1
src/app/Toolbar.cpp View File

@@ -153,7 +153,7 @@ Toolbar::Toolbar() {
zoomSlider->box.size.x = 150;
zoomSlider->label = "Zoom";
zoomSlider->unit = "%";
zoomSlider->setLimits(33.33, 200.0);
zoomSlider->setLimits(50.0, 200.0);
zoomSlider->setDefaultValue(100.0);
addChild(zoomSlider);
xPos += zoomSlider->box.size.x;


+ 1
- 1
src/gui.cpp View File

@@ -358,7 +358,7 @@ void guiRun() {
std::this_thread::sleep_for(std::chrono::duration<double>(minTime - frameTime));
}
endTime = glfwGetTime();
printf("%lf fps\n", 1.0 / (endTime - startTime));
// printf("%lf fps\n", 1.0 / (endTime - startTime));
}
}



+ 1
- 2
src/widgets/FramebufferWidget.cpp View File

@@ -25,8 +25,8 @@ struct FramebufferWidget::Internal {


FramebufferWidget::FramebufferWidget() {
internal = new Internal();
oversample = 1.0;
internal = new Internal();
}

FramebufferWidget::~FramebufferWidget() {
@@ -60,7 +60,6 @@ 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.


+ 1
- 0
src/widgets/SVGWidget.cpp View File

@@ -201,6 +201,7 @@ void SVGWidget::wrap() {

void SVGWidget::draw(NVGcontext *vg) {
if (svg && svg->handle) {
// printf("drawing svg %f %f\n", box.size.x, box.size.y);
drawSVG(vg, svg->handle);
}
}


Loading…
Cancel
Save