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