From 1caf689797bc427be12fbc7babaaa6b53ba2a4c0 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 12 Oct 2021 02:52:02 -0400 Subject: [PATCH] Scroll rack if dragging near the edge of the screen only for certain widgets. --- src/app/RackScrollWidget.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/RackScrollWidget.cpp b/src/app/RackScrollWidget.cpp index 38ba09ef..1696e2c9 100644 --- a/src/app/RackScrollWidget.cpp +++ b/src/app/RackScrollWidget.cpp @@ -1,5 +1,8 @@ #include #include +#include +#include +#include #include #include #include @@ -95,11 +98,12 @@ void RackScrollWidget::step() { zoomWidget->box = scrollBox; rackWidget->box.pos = scrollBox.pos.div(zoom).neg(); - // Scroll rack if dragging cable near the edge of the screen + // Scroll rack if dragging certain widgets near the edge of the screen math::Vec pos = APP->scene->mousePos; math::Rect viewport = getViewport(box.zeroPos()); - widget::Widget* draggedWidget = APP->event->getDraggedWidget(); - if (draggedWidget && draggedWidget->isDescendantOf(container) && APP->event->dragButton == GLFW_MOUSE_BUTTON_LEFT) { + widget::Widget* dw = APP->event->getDraggedWidget(); + if (dw && APP->event->dragButton == GLFW_MOUSE_BUTTON_LEFT && + (dynamic_cast(dw) || dynamic_cast(dw) || dynamic_cast(dw))) { float margin = 20.0; float speed = 15.0; if (pos.x <= viewport.pos.x + margin)