Don't trim background layer cels automatically (fix #1166)

This commit is contained in:
David Capello 2016-07-01 11:14:50 -03:00
parent 67ce9473f8
commit 9897256d26
6 changed files with 32 additions and 16 deletions

View File

@ -117,6 +117,7 @@ void FlipCommand::onExecute(Context* context)
else
api.flipImage(image, flipBounds, m_flipType);
if (cel->layer()->isTransparent())
transaction.execute(new cmd::TrimCel(cel));
}
// When the mask is bigger than the cel bounds, we have to

View File

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

View File

@ -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()));
}
}

View File

@ -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()));

View File

@ -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,6 +199,15 @@ void ExpandCelCanvas::commit()
regionToPatch = &reduced;
}
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,
@ -205,6 +215,7 @@ void ExpandCelCanvas::commit()
*regionToPatch,
m_bounds.origin()));
}
}
else {
ASSERT(false);
}

View File

@ -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.
@ -63,6 +63,7 @@ namespace doc {
bool isFolder() const { return type() == ObjectType::LayerFolder; }
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); }