[aseprite] 66/134: Avoid regenerating Document's extral cel when we're moving pixels (fix #522)

Tobias Hansen thansen at moszumanska.debian.org
Sat Mar 14 17:10:07 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit d0f97260fccad1a9fd6d7e4548a14805fab055bf
Author: David Capello <davidcapello at gmail.com>
Date:   Sat Nov 15 19:57:03 2014 -0300

    Avoid regenerating Document's extral cel when we're moving pixels (fix #522)
    
    As PixelsMovement class uses the extra cel to show the pixels that we're
    moving, we cannot show brush previews of quicktools (as the brush preview
    uses/destroy/regenerate the same extra cel for its own purpose).
---
 src/app/ui/editor/editor.cpp              | 22 ++++++++++++++++++----
 src/app/ui/editor/editor_state.h          | 11 +++++++++++
 src/app/ui/editor/moving_pixels_state.cpp | 10 ++++++++++
 src/app/ui/editor/moving_pixels_state.h   |  2 ++
 4 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index db7991b..0cf9b35 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -1012,15 +1012,29 @@ void Editor::updateQuicktool()
         return;
     }
 
+    tools::Tool* old_quicktool = m_quicktool;
+    tools::Tool* new_quicktool = m_customizationDelegate->getQuickTool(current_tool);
+
+    // Check if the current state accept the given quicktool.
+    if (new_quicktool && !m_state->acceptQuickTool(new_quicktool))
+      return;
+
     // Hide the drawing cursor with the current tool brush size before
     // we change the quicktool. In this way we avoid using the
     // quicktool brush size to clean the current tool cursor.
-    hideDrawingCursor();
+    //
+    // TODO Remove EditorState::regenerateDrawingCursor() creating a
+    // new Document concept of multiple extra cels: we need an extra
+    // cel for the drawing cursor, other for the moving pixels,
+    // etc. In this way we'll not have conflicts between different
+    // uses of the same extra cel.
+    if (m_state->regenerateDrawingCursor())
+      hideDrawingCursor();
 
-    tools::Tool* old_quicktool = m_quicktool;
-    m_quicktool = m_customizationDelegate->getQuickTool(current_tool);
+    m_quicktool = new_quicktool;
 
-    showDrawingCursor();
+    if (m_state->regenerateDrawingCursor())
+      showDrawingCursor();
 
     // If the tool has changed, we must to update the status bar because
     // the new tool can display something different in the status bar (e.g. Eyedropper)
diff --git a/src/app/ui/editor/editor_state.h b/src/app/ui/editor/editor_state.h
index 551d22a..40988e7 100644
--- a/src/app/ui/editor/editor_state.h
+++ b/src/app/ui/editor/editor_state.h
@@ -32,6 +32,10 @@ namespace app {
   class Editor;
   class EditorDecorator;
 
+  namespace tools {
+    class Tool;
+  }
+
   // Represents one state of the sprite's editor (Editor class).  This
   // is a base class, a dummy state that ignores all events from the
   // Editor. Subclasses overrides these methods to customize the
@@ -103,6 +107,13 @@ namespace app {
     // drawing cursor.
     virtual bool requireBrushPreview() { return false; }
 
+    // Returns true if this state accept the given quicktool.
+    virtual bool acceptQuickTool(tools::Tool* tool) { return true; }
+
+    // Returns true if this state supports changing the drawing cursor
+    // extra cel.
+    virtual bool regenerateDrawingCursor() { return true; }
+
   private:
     DISABLE_COPYING(EditorState);
   };
diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp
index ee1b055..9567398 100644
--- a/src/app/ui/editor/moving_pixels_state.cpp
+++ b/src/app/ui/editor/moving_pixels_state.cpp
@@ -413,6 +413,16 @@ bool MovingPixelsState::onUpdateStatusBar(Editor* editor)
   return true;
 }
 
+bool MovingPixelsState::acceptQuickTool(tools::Tool* tool)
+{
+  return
+    (!m_pixelsMovement ||
+     tool->getInk(0)->isSelection() ||
+     tool->getInk(0)->isEyedropper() ||
+     tool->getInk(0)->isScrollMovement() ||
+     tool->getInk(0)->isZoom());
+}
+
 // Before executing any command, we drop the pixels (go back to standby).
 void MovingPixelsState::onBeforeCommandExecution(Command* command)
 {
diff --git a/src/app/ui/editor/moving_pixels_state.h b/src/app/ui/editor/moving_pixels_state.h
index bbaedcd..60597be 100644
--- a/src/app/ui/editor/moving_pixels_state.h
+++ b/src/app/ui/editor/moving_pixels_state.h
@@ -58,6 +58,8 @@ namespace app {
     virtual bool onKeyDown(Editor* editor, ui::KeyMessage* msg) override;
     virtual bool onKeyUp(Editor* editor, ui::KeyMessage* msg) override;
     virtual bool onUpdateStatusBar(Editor* editor) override;
+    virtual bool acceptQuickTool(tools::Tool* tool) override;
+    virtual bool regenerateDrawingCursor() override { return false; }
 
     // EditorObserver
     virtual void onBeforeFrameChanged(Editor* editor) override;

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