[aseprite] 26/51: Don't trim background layer cels automatically (fix #1166)

Tobias Hansen thansen at moszumanska.debian.org
Mon Jul 11 21:35:17 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 9897256d26c8d21b99f1beecf04673d18bb68698
Author: David Capello <davidcapello at gmail.com>
Date:   Fri Jul 1 11:14:50 2016 -0300

    Don't trim background layer cels automatically (fix #1166)
---
 src/app/commands/cmd_flip.cpp         |  3 ++-
 src/app/ui/document_view.cpp          |  3 ++-
 src/app/ui/editor/pixels_movement.cpp |  3 ++-
 src/app/util/clipboard.cpp            |  3 ++-
 src/app/util/expand_cel_canvas.cpp    | 23 +++++++++++++++++------
 src/doc/layer.h                       | 13 +++++++------
 6 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/src/app/commands/cmd_flip.cpp b/src/app/commands/cmd_flip.cpp
index c506d20..0898468 100644
--- a/src/app/commands/cmd_flip.cpp
+++ b/src/app/commands/cmd_flip.cpp
@@ -117,7 +117,8 @@ void FlipCommand::onExecute(Context* context)
           else
             api.flipImage(image, flipBounds, m_flipType);
 
-          transaction.execute(new cmd::TrimCel(cel));
+          if (cel->layer()->isTransparent())
+            transaction.execute(new cmd::TrimCel(cel));
         }
         // When the mask is bigger than the cel bounds, we have to
         // expand the cel, make the flip, and shrink it again.
diff --git a/src/app/ui/document_view.cpp b/src/app/ui/document_view.cpp
index 267ac24..e3ae916 100644
--- a/src/app/ui/document_view.cpp
+++ b/src/app/ui/document_view.cpp
@@ -523,7 +523,8 @@ bool DocumentView::onClear(Context* ctx)
     transaction.execute(new cmd::ClearMask(writer.cel()));
 
     // If the cel wasn't deleted by cmd::ClearMask, we trim it.
-    if (writer.cel())
+    if (writer.cel() &&
+        writer.cel()->layer()->isTransparent())
       transaction.execute(new cmd::TrimCel(writer.cel()));
 
     if (visibleMask &&
diff --git a/src/app/ui/editor/pixels_movement.cpp b/src/app/ui/editor/pixels_movement.cpp
index 1b587ca..81e6134 100644
--- a/src/app/ui/editor/pixels_movement.cpp
+++ b/src/app/ui/editor/pixels_movement.cpp
@@ -182,7 +182,8 @@ void PixelsMovement::cutMask()
       m_transaction.execute(new cmd::ClearMask(writer.cel()));
 
       ASSERT(writer.cel());
-      if (writer.cel())
+      if (writer.cel() &&
+          writer.cel()->layer()->isTransparent())
         m_transaction.execute(new cmd::TrimCel(writer.cel()));
     }
   }
diff --git a/src/app/util/clipboard.cpp b/src/app/util/clipboard.cpp
index 96cb5f4..7e80afe 100644
--- a/src/app/util/clipboard.cpp
+++ b/src/app/util/clipboard.cpp
@@ -225,7 +225,8 @@ void cut(ContextWriter& writer)
       transaction.execute(new cmd::ClearMask(writer.cel()));
 
       ASSERT(writer.cel());
-      if (writer.cel())
+      if (writer.cel() &&
+          writer.cel()->layer()->isTransparent())
         transaction.execute(new cmd::TrimCel(writer.cel()));
 
       transaction.execute(new cmd::DeselectMask(writer.document()));
diff --git a/src/app/util/expand_cel_canvas.cpp b/src/app/util/expand_cel_canvas.cpp
index 2d325f7..6bf2458 100644
--- a/src/app/util/expand_cel_canvas.cpp
+++ b/src/app/util/expand_cel_canvas.cpp
@@ -14,6 +14,7 @@
 #include "app/app.h"
 #include "app/cmd/add_cel.h"
 #include "app/cmd/clear_cel.h"
+#include "app/cmd/copy_region.h"
 #include "app/cmd/patch_cel.h"
 #include "app/context.h"
 #include "app/document.h"
@@ -198,12 +199,22 @@ void ExpandCelCanvas::commit()
       regionToPatch = &reduced;
     }
 
-    m_transaction.execute(
-      new cmd::PatchCel(
-        m_cel,
-        m_dstImage.get(),
-        *regionToPatch,
-        m_bounds.origin()));
+    if (m_layer->isBackground()) {
+      m_transaction.execute(
+        new cmd::CopyRegion(
+          m_cel->image(),
+          m_dstImage.get(),
+          *regionToPatch,
+          m_bounds.origin()));
+    }
+    else {
+      m_transaction.execute(
+        new cmd::PatchCel(
+          m_cel,
+          m_dstImage.get(),
+          *regionToPatch,
+          m_bounds.origin()));
+    }
   }
   else {
     ASSERT(false);
diff --git a/src/doc/layer.h b/src/doc/layer.h
index 95cf3d0..a278965 100644
--- a/src/doc/layer.h
+++ b/src/doc/layer.h
@@ -1,5 +1,5 @@
 // Aseprite Document Library
-// Copyright (c) 2001-2015 David Capello
+// Copyright (c) 2001-2016 David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -62,11 +62,12 @@ namespace doc {
     bool isImage() const { return type() == ObjectType::LayerImage; }
     bool isFolder() const { return type() == ObjectType::LayerFolder; }
 
-    bool isBackground() const { return hasFlags(LayerFlags::Background); }
-    bool isVisible() const    { return hasFlags(LayerFlags::Visible); }
-    bool isEditable() const   { return hasFlags(LayerFlags::Editable); }
-    bool isMovable() const    { return !hasFlags(LayerFlags::LockMove); }
-    bool isContinuous() const { return hasFlags(LayerFlags::Continuous); }
+    bool isBackground() const  { return hasFlags(LayerFlags::Background); }
+    bool isTransparent() const { return !hasFlags(LayerFlags::Background); }
+    bool isVisible() const     { return hasFlags(LayerFlags::Visible); }
+    bool isEditable() const    { return hasFlags(LayerFlags::Editable); }
+    bool isMovable() const     { return !hasFlags(LayerFlags::LockMove); }
+    bool isContinuous() const  { return hasFlags(LayerFlags::Continuous); }
 
     void setBackground(bool state) { switchFlags(LayerFlags::Background, state); }
     void setVisible   (bool state) { switchFlags(LayerFlags::Visible, state); }

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