Browse Source

Fix autoscrolling when dragging near edge of rack

tags/v0.5.0
Andrew Belt 7 years ago
parent
commit
a094a0cd7d
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      src/app/RackScrollWidget.cpp

+ 6
- 5
src/app/RackScrollWidget.cpp View File

@@ -6,18 +6,19 @@ namespace rack {


void RackScrollWidget::step() {
Vec pos = gRackWidget->lastMousePos;
Vec pos = gMousePos;
Rect viewport = getViewport(box.zeroPos());
// Scroll rack if dragging cable near the edge of the screen
if (gRackWidget->wireContainer->activeWire) {
float margin = 20.0;
float speed = 15.0;
if (pos.x <= margin)
if (pos.x <= viewport.pos.x + margin)
offset.x -= speed;
if (pos.x >= box.size.x - margin)
if (pos.x >= viewport.pos.x + viewport.size.x - margin)
offset.x += speed;
if (pos.y <= margin)
if (pos.y <= viewport.pos.y + margin)
offset.y -= speed;
if (pos.y >= box.size.y - margin)
if (pos.y >= viewport.pos.y + viewport.size.y - margin)
offset.y += speed;
}
ScrollWidget::step();


Loading…
Cancel
Save