mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-03 23:41:56 +00:00
Improve Editor::autoScroll() scroll
Avoid a bad user experience when he/she tries to put back the mouse position into the editor viewport.
This commit is contained in:
parent
58b3e09d86
commit
bb309fb72e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user