[aseprite] 116/196: Add DrawingState::destroyLoopIfCanceled() to avoid duplicated code
Tobias Hansen
thansen at moszumanska.debian.org
Wed Apr 20 18:50:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 799803d582340e0f50b51d6f9a67bbef45bc209a
Author: David Capello <davidcapello at gmail.com>
Date: Sat Mar 26 10:56:20 2016 -0300
Add DrawingState::destroyLoopIfCanceled() to avoid duplicated code
---
src/app/ui/editor/drawing_state.cpp | 37 ++++++++++++++++++-------------------
src/app/ui/editor/drawing_state.h | 3 ++-
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/src/app/ui/editor/drawing_state.cpp b/src/app/ui/editor/drawing_state.cpp
index fe7a34d..b342d59 100644
--- a/src/app/ui/editor/drawing_state.cpp
+++ b/src/app/ui/editor/drawing_state.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -116,15 +116,9 @@ bool DrawingState::onMouseDown(Editor* editor, MouseMessage* msg)
// Notify the mouse button down to the tool loop manager.
m_toolLoopManager->pressButton(pointer_from_msg(editor, msg));
- // Cancel drawing loop
- if (m_toolLoopManager->isCanceled()) {
- destroyLoop(editor);
-
- // Change to standby state
- editor->backToPreviousState();
- editor->releaseMouse();
- }
-
+ // The user might have canceled by the tool loop clicking with the
+ // secondary mouse button.
+ destroyLoopIfCanceled(editor);
return true;
}
@@ -216,15 +210,8 @@ bool DrawingState::onKeyUp(Editor* editor, KeyMessage* msg)
{
m_toolLoopManager->releaseKey(msg->scancode());
- // Cancel drawing loop
- if (m_toolLoopManager->isCanceled()) {
- destroyLoop(editor);
-
- // Change to standby state
- editor->backToPreviousState();
- editor->releaseMouse();
- }
-
+ // The user might have canceled the tool loop pressing the 'Esc' key.
+ destroyLoopIfCanceled(editor);
return true;
}
@@ -241,6 +228,18 @@ void DrawingState::onExposeSpritePixels(const gfx::Region& rgn)
m_toolLoop->validateDstImage(rgn);
}
+void DrawingState::destroyLoopIfCanceled(Editor* editor)
+{
+ // Cancel drawing loop
+ if (m_toolLoopManager->isCanceled()) {
+ destroyLoop(editor);
+
+ // Change to standby state
+ editor->backToPreviousState();
+ editor->releaseMouse();
+ }
+}
+
void DrawingState::destroyLoop(Editor* editor)
{
if (editor) {
diff --git a/src/app/ui/editor/drawing_state.h b/src/app/ui/editor/drawing_state.h
index a7165f8..7339057 100644
--- a/src/app/ui/editor/drawing_state.h
+++ b/src/app/ui/editor/drawing_state.h
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -37,6 +37,7 @@ namespace app {
void initToolLoop(Editor* editor, ui::MouseMessage* msg);
private:
+ void destroyLoopIfCanceled(Editor* editor);
void destroyLoop(Editor* editor);
// The tool-loop.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list