mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 10:20:48 +00:00
Merge branch 'main' into beta
This commit is contained in:
commit
9be9b4d5e5
@ -106,6 +106,12 @@ void DrawingState::notifyToolLoopModifiersChange(Editor* editor)
|
||||
m_toolLoopManager->notifyToolLoopModifiersChange();
|
||||
}
|
||||
|
||||
void DrawingState::onBeforePopState(Editor* editor)
|
||||
{
|
||||
m_beforeCmdConn.disconnect();
|
||||
StandbyState::onBeforePopState(editor);
|
||||
}
|
||||
|
||||
bool DrawingState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
// Drawing loop
|
||||
@ -247,8 +253,11 @@ bool DrawingState::onKeyDown(Editor* editor, KeyMessage* msg)
|
||||
Params params;
|
||||
if (KeyboardShortcuts::instance()
|
||||
->getCommandFromKeyMessage(msg, &command, ¶ms)) {
|
||||
// We accept zoom commands.
|
||||
if (command->id() == CommandId::Zoom()) {
|
||||
// We accept some commands...
|
||||
if (command->id() == CommandId::Zoom() ||
|
||||
command->id() == CommandId::Undo() ||
|
||||
command->id() == CommandId::Redo() ||
|
||||
command->id() == CommandId::Cancel()) {
|
||||
UIContext::instance()->executeCommandFromMenuOrShortcut(command, params);
|
||||
return true;
|
||||
}
|
||||
@ -338,9 +347,22 @@ bool DrawingState::canExecuteCommands()
|
||||
!m_mousePressedReceived);
|
||||
}
|
||||
|
||||
void DrawingState::onBeforeCommandExecution(CommandExecutionEvent& cmd)
|
||||
void DrawingState::onBeforeCommandExecution(CommandExecutionEvent& ev)
|
||||
{
|
||||
if (canExecuteCommands() && m_toolLoop) {
|
||||
if (!m_toolLoop)
|
||||
return;
|
||||
|
||||
if (canExecuteCommands() ||
|
||||
// Undo/Redo/Cancel will cancel the ToolLoop
|
||||
ev.command()->id() == CommandId::Undo() ||
|
||||
ev.command()->id() == CommandId::Redo() ||
|
||||
ev.command()->id() == CommandId::Cancel()) {
|
||||
if (!canExecuteCommands()) {
|
||||
// Cancel the execution of Undo/Redo/Cancel because we've
|
||||
// simulated it here
|
||||
ev.cancel();
|
||||
}
|
||||
|
||||
m_toolLoopManager->cancel();
|
||||
destroyLoopIfCanceled(m_editor);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -29,6 +29,7 @@ namespace app {
|
||||
tools::ToolLoop* loop,
|
||||
const DrawingType type);
|
||||
virtual ~DrawingState();
|
||||
virtual void onBeforePopState(Editor* editor) override;
|
||||
virtual bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
|
||||
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
|
||||
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
|
||||
@ -57,7 +58,7 @@ namespace app {
|
||||
private:
|
||||
void handleMouseMovement(const tools::Pointer& pointer);
|
||||
bool canExecuteCommands();
|
||||
void onBeforeCommandExecution(CommandExecutionEvent& cmd);
|
||||
void onBeforeCommandExecution(CommandExecutionEvent& ev);
|
||||
void destroyLoopIfCanceled(Editor* editor);
|
||||
void destroyLoop(Editor* editor);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -13,6 +13,7 @@
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/cmd/set_cel_bounds.h"
|
||||
#include "app/commands/command.h"
|
||||
#include "app/context_access.h"
|
||||
#include "app/doc_api.h"
|
||||
#include "app/doc_range.h"
|
||||
@ -88,6 +89,7 @@ MovingCelState::MovingCelState(Editor* editor,
|
||||
, m_hasReference(false)
|
||||
, m_scaled(false)
|
||||
, m_handle(handle)
|
||||
, m_editor(editor)
|
||||
{
|
||||
ContextWriter writer(m_reader);
|
||||
Doc* document = editor->document();
|
||||
@ -112,6 +114,11 @@ MovingCelState::MovingCelState(Editor* editor,
|
||||
}
|
||||
}
|
||||
|
||||
// Hook BeforeCommandExecution signal so we know if the user wants
|
||||
// to execute other command, so we can drop pixels.
|
||||
m_ctxConn = UIContext::instance()->BeforeCommandExecution.connect(
|
||||
&MovingCelState::onBeforeCommandExecution, this);
|
||||
|
||||
m_cursorStart = editor->screenToEditorF(msg->position());
|
||||
editor->captureMouse();
|
||||
|
||||
@ -123,30 +130,16 @@ MovingCelState::MovingCelState(Editor* editor,
|
||||
}
|
||||
}
|
||||
|
||||
void MovingCelState::onBeforePopState(Editor* editor)
|
||||
{
|
||||
m_ctxConn.disconnect();
|
||||
StandbyState::onBeforePopState(editor);
|
||||
}
|
||||
|
||||
bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
Doc* document = editor->document();
|
||||
bool modified = false;
|
||||
|
||||
// Here we put back all cels into their original coordinates (so we
|
||||
// can add the undo information from the start position).
|
||||
for (size_t i=0; i<m_celList.size(); ++i) {
|
||||
Cel* cel = m_celList[i];
|
||||
const gfx::RectF& celStart = m_celStarts[i];
|
||||
|
||||
if (cel->layer()->isReference()) {
|
||||
if (cel->boundsF() != celStart) {
|
||||
cel->setBoundsF(celStart);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (cel->bounds() != gfx::Rect(celStart)) {
|
||||
cel->setBounds(gfx::Rect(celStart));
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool modified = restoreCelStartPosition();
|
||||
|
||||
if (modified) {
|
||||
{
|
||||
@ -326,4 +319,49 @@ gfx::Point MovingCelState::intCelOffset() const
|
||||
int(std::round(m_celOffset.y)));
|
||||
}
|
||||
|
||||
bool MovingCelState::restoreCelStartPosition() const
|
||||
{
|
||||
bool modified = false;
|
||||
|
||||
// Here we put back all cels into their original coordinates (so we
|
||||
// can add the undo information from the start position).
|
||||
for (size_t i=0; i<m_celList.size(); ++i) {
|
||||
Cel* cel = m_celList[i];
|
||||
const gfx::RectF& celStart = m_celStarts[i];
|
||||
|
||||
if (cel->layer()->isReference()) {
|
||||
if (cel->boundsF() != celStart) {
|
||||
cel->setBoundsF(celStart);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (cel->bounds() != gfx::Rect(celStart)) {
|
||||
cel->setBounds(gfx::Rect(celStart));
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
void MovingCelState::onBeforeCommandExecution(CommandExecutionEvent& ev)
|
||||
{
|
||||
if (ev.command()->id() == CommandId::Undo() ||
|
||||
ev.command()->id() == CommandId::Redo() ||
|
||||
ev.command()->id() == CommandId::Cancel()) {
|
||||
restoreCelStartPosition();
|
||||
Doc* document = m_editor->document();
|
||||
// Restore the mask visibility.
|
||||
if (m_maskVisible) {
|
||||
document->setMaskVisible(m_maskVisible);
|
||||
document->generateMaskBoundaries();
|
||||
}
|
||||
m_editor->backToPreviousState();
|
||||
m_editor->releaseMouse();
|
||||
m_editor->invalidate();
|
||||
}
|
||||
ev.cancel();
|
||||
}
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -44,6 +45,7 @@ namespace app {
|
||||
const HandleType handle,
|
||||
const MovingCelCollect& collect);
|
||||
|
||||
virtual void onBeforePopState(Editor* editor) override;
|
||||
virtual bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
|
||||
virtual bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
|
||||
virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
|
||||
@ -53,6 +55,9 @@ namespace app {
|
||||
|
||||
private:
|
||||
gfx::Point intCelOffset() const;
|
||||
bool restoreCelStartPosition() const;
|
||||
// ContextObserver
|
||||
void onBeforeCommandExecution(CommandExecutionEvent& ev);
|
||||
|
||||
ContextReader m_reader;
|
||||
Cel* m_cel;
|
||||
@ -66,6 +71,9 @@ namespace app {
|
||||
bool m_hasReference;
|
||||
bool m_scaled;
|
||||
HandleType m_handle;
|
||||
Editor* m_editor;
|
||||
|
||||
obs::scoped_connection m_ctxConn;
|
||||
};
|
||||
|
||||
} // namespace app
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -109,6 +109,12 @@ EditorState::LeaveAction PlayState::onLeaveState(Editor* editor, EditorState* ne
|
||||
return KeepState;
|
||||
}
|
||||
|
||||
void PlayState::onBeforePopState(Editor* editor)
|
||||
{
|
||||
m_ctxConn.disconnect();
|
||||
StateWithWheelBehavior::onBeforePopState(editor);
|
||||
}
|
||||
|
||||
bool PlayState::onMouseDown(Editor* editor, MouseMessage* msg)
|
||||
{
|
||||
if (editor->hasCapture())
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2020-2021 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2017 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -32,6 +32,7 @@ namespace app {
|
||||
|
||||
void onEnterState(Editor* editor) override;
|
||||
LeaveAction onLeaveState(Editor* editor, EditorState* newState) override;
|
||||
void onBeforePopState(Editor* editor) override;
|
||||
bool onMouseDown(Editor* editor, ui::MouseMessage* msg) override;
|
||||
bool onMouseUp(Editor* editor, ui::MouseMessage* msg) override;
|
||||
bool onMouseMove(Editor* editor, ui::MouseMessage* msg) override;
|
||||
|
2
src/clip
2
src/clip
@ -1 +1 @@
|
||||
Subproject commit f13c9656d51482c1908c9a551ce76f9450b7bd55
|
||||
Subproject commit 1e262be75e448e575581e267904a8ec78bbc6991
|
@ -1 +1 @@
|
||||
Subproject commit af94c4a2317839ce629eb26ce47b80e810cbdaec
|
||||
Subproject commit bddbeed8b94d2639fa945bdf14a90d7afbd58506
|
Loading…
x
Reference in New Issue
Block a user