mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-29 01:20:17 +00:00
Add possibility to cancel the DrawingState with Undo/Redo/Cancel commands
To match the new MovingCelState behavior.
This commit is contained in:
parent
768b69113a
commit
a5c36d0b0f
@ -249,8 +249,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;
|
||||
}
|
||||
@ -330,9 +333,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_toolLoop->cancel();
|
||||
destroyLoopIfCanceled(m_editor);
|
||||
}
|
||||
|
@ -56,7 +56,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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user