Merge branch 'main' into beta

This commit is contained in:
David Capello 2022-01-06 18:43:49 -03:00
commit 8ec2fff447
2 changed files with 25 additions and 10 deletions

View File

@ -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)

View File

@ -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<gfx::RectF> m_celStarts;