You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
823B

  1. #include "app/RackScrollWidget.hpp"
  2. #include "app/Scene.hpp"
  3. #include "window.hpp"
  4. #include "app.hpp"
  5. namespace rack {
  6. void RackScrollWidget::step() {
  7. math::Vec pos = app()->window->mousePos;
  8. math::Rect viewport = getViewport(box.zeroPos());
  9. // Scroll rack if dragging cable near the edge of the screen
  10. if (app()->scene->rackWidget->incompleteCable) {
  11. float margin = 20.0;
  12. float speed = 15.0;
  13. if (pos.x <= viewport.pos.x + margin)
  14. offset.x -= speed;
  15. if (pos.x >= viewport.pos.x + viewport.size.x - margin)
  16. offset.x += speed;
  17. if (pos.y <= viewport.pos.y + margin)
  18. offset.y -= speed;
  19. if (pos.y >= viewport.pos.y + viewport.size.y - margin)
  20. offset.y += speed;
  21. }
  22. ScrollWidget::step();
  23. }
  24. void RackScrollWidget::draw(const DrawContext &ctx) {
  25. ScrollWidget::draw(ctx);
  26. }
  27. } // namespace rack