| @@ -16,6 +16,7 @@ namespace rack { | |||||
| RackWidget::RackWidget() { | RackWidget::RackWidget() { | ||||
| rails = new FramebufferWidget(); | rails = new FramebufferWidget(); | ||||
| rails->box.size = Vec(); | |||||
| { | { | ||||
| RackRail *rail = new RackRail(); | RackRail *rail = new RackRail(); | ||||
| rail->box.size = Vec(); | rail->box.size = Vec(); | ||||
| @@ -342,17 +343,20 @@ void RackWidget::step() { | |||||
| // Adjust size and position of rails | // Adjust size and position of rails | ||||
| Widget *rail = rails->children.front(); | Widget *rail = rails->children.front(); | ||||
| Rect bound = getViewport(Rect(Vec(), box.size)); | Rect bound = getViewport(Rect(Vec(), box.size)); | ||||
| // bound.pos = bound.pos.plus(Vec(100, 100)); | |||||
| // bound.size = bound.size.minus(Vec(200, 200)); | |||||
| rails->box = bound; | |||||
| 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); | |||||
| if (!bound.isEqual(rail->box)) { | |||||
| 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; | rails->dirty = true; | ||||
| } | } | ||||
| rail->box = bound; | |||||
| // Autosave every 15 seconds | // Autosave every 15 seconds | ||||
| if (gGuiFrame % (60*15) == 0) { | if (gGuiFrame % (60*15) == 0) { | ||||