diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index 6342fd3bf..f256e319a 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020-2021 Igara Studio S.A. +// Copyright (C) 2020-2022 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -80,10 +80,11 @@ MovingCelCollect::MovingCelCollect(Editor* editor, Layer* layer) } MovingCelState::MovingCelState(Editor* editor, - MouseMessage* msg, + const MouseMessage* msg, const HandleType handle, const MovingCelCollect& collect) : m_reader(UIContext::instance(), 500) + , m_delayedMouseMove(this, editor, 5) , m_cel(nullptr) , m_celList(collect.celList()) , m_celOffset(0.0, 0.0) @@ -128,6 +129,8 @@ MovingCelState::MovingCelState(Editor* editor, document->setMaskVisible(false); document->generateMaskBoundaries(); } + + m_delayedMouseMove.onMouseDown(msg); } void MovingCelState::onBeforePopState(Editor* editor) @@ -138,6 +141,8 @@ void MovingCelState::onBeforePopState(Editor* editor) bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) { + m_delayedMouseMove.onMouseUp(msg); + Doc* document = editor->document(); bool modified = restoreCelStartPosition(); @@ -209,9 +214,15 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg) { - const gfx::Point mousePos = editor->autoScroll(msg, AutoScroll::MouseDir); - const gfx::PointF newCursorPos = editor->screenToEditorF(mousePos); + m_delayedMouseMove.onMouseMove(msg); + // Use StandbyState implementation + return StandbyState::onMouseMove(editor, msg); +} + +void MovingCelState::onCommitMouseMove(Editor* editor, + const gfx::PointF& newCursorPos) +{ switch (m_handle) { case MovePixelsHandle: @@ -271,9 +282,6 @@ bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg) // Redraw the new cel position. editor->invalidate(); - - // Use StandbyState implementation - return StandbyState::onMouseMove(editor, msg); } bool MovingCelState::onKeyDown(Editor* editor, KeyMessage* msg) diff --git a/src/app/ui/editor/moving_cel_state.h b/src/app/ui/editor/moving_cel_state.h index aa4a82a87..b3050279f 100644 --- a/src/app/ui/editor/moving_cel_state.h +++ b/src/app/ui/editor/moving_cel_state.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2021 Igara Studio S.A. +// Copyright (C) 2021-2022 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -12,6 +12,7 @@ #include "app/ui/editor/standby_state.h" #include "app/context_access.h" +#include "app/ui/editor/delayed_mouse_move.h" #include "app/ui/editor/handle_type.h" #include "doc/cel_list.h" @@ -38,10 +39,11 @@ namespace app { CelList m_celList; }; - class MovingCelState : public StandbyState { + class MovingCelState : public StandbyState + , DelayedMouseMoveDelegate { public: MovingCelState(Editor* editor, - ui::MouseMessage* msg, + const ui::MouseMessage* msg, const HandleType handle, const MovingCelCollect& collect); @@ -59,7 +61,12 @@ namespace app { // ContextObserver void onBeforeCommandExecution(CommandExecutionEvent& ev); + // DelayedMouseMoveDelegate impl + void onCommitMouseMove(Editor* editor, + const gfx::PointF& spritePos) override; + ContextReader m_reader; + DelayedMouseMove m_delayedMouseMove; Cel* m_cel; CelList m_celList; std::vector m_celStarts;