From bb309fb72e05b2ae8bd594bb6ac7074facaa7519 Mon Sep 17 00:00:00 2001 From: David Capello Date: Mon, 25 Aug 2014 23:30:27 -0300 Subject: [PATCH] Improve Editor::autoScroll() scroll Avoid a bad user experience when he/she tries to put back the mouse position into the editor viewport. --- src/app/ui/editor/editor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp index 5e78b579b..f6a6cf630 100644 --- a/src/app/ui/editor/editor.cpp +++ b/src/app/ui/editor/editor.cpp @@ -712,8 +712,18 @@ gfx::Point Editor::autoScroll(MouseMessage* msg) gfx::Point mousePos = msg->position(); if (!vp.contains(mousePos)) { + gfx::Point delta = (mousePos - m_oldPos); + + if (!((mousePos.x < vp.x && delta.x < 0) || + (mousePos.x >= vp.x+vp.w && delta.x > 0))) + delta.x = 0; + + if (!((mousePos.y < vp.y && delta.y < 0) || + (mousePos.y >= vp.y+vp.h && delta.y > 0))) + delta.y = 0; + gfx::Point scroll = view->getViewScroll(); - scroll += (mousePos - m_oldPos); + scroll += delta; setEditorScroll(scroll.x, scroll.y, true); m_oldPos = mousePos;