diff --git a/src/app/doc.cpp b/src/app/doc.cpp index 56e0d684e..f867f1f55 100644 --- a/src/app/doc.cpp +++ b/src/app/doc.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -403,7 +403,7 @@ void Doc::setTransformation(const Transformation& transform) void Doc::resetTransformation() { - m_transformation = Transformation(gfx::RectF(m_mask->bounds())); + m_transformation = Transformation(gfx::RectF(m_mask->bounds()), m_transformation.cornerThick()); } ////////////////////////////////////////////////////////////////////// diff --git a/src/app/tools/inks.h b/src/app/tools/inks.h index ad6c63efc..abd8853d2 100644 --- a/src/app/tools/inks.h +++ b/src/app/tools/inks.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2018-2020 Igara Studio S.A. +// Copyright (C) 2018-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -13,6 +13,7 @@ #include "app/doc.h" #include "app/doc_undo.h" #include "app/tools/pick_ink.h" +#include "app/transformation.h" #include "doc/mask.h" #include "doc/tile.h" #include "gfx/region.h" @@ -518,8 +519,11 @@ public: m_mask.unfreeze(); loop->setMask(&m_mask); + double cornerThick = (loop->isTilemapMode()) ? + CORNER_THICK_FOR_TILEMAP_MODE : + CORNER_THICK_FOR_PIXELS_MODE; loop->getDocument()->setTransformation( - Transformation(RectF(m_mask.bounds()))); + Transformation(RectF(m_mask.bounds()), cornerThick)); m_mask.clear(); } diff --git a/src/app/tools/tool_loop.h b/src/app/tools/tool_loop.h index 667f4f3e5..d5651eb4d 100644 --- a/src/app/tools/tool_loop.h +++ b/src/app/tools/tool_loop.h @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2019-2020 Igara Studio S.A. +// Copyright (C) 2019-2021 Igara Studio S.A. // Copyright (C) 2001-2017 David Capello // // This program is distributed under the terms of @@ -88,6 +88,9 @@ namespace app { // Returns the layer that will be modified if the tool paints virtual Layer* getLayer() = 0; + // Returns true if the current mode is TileMap (false = Pixels) + virtual bool isTilemapMode() = 0; + // Returns the frame where we're paiting virtual frame_t getFrame() = 0; diff --git a/src/app/transformation.cpp b/src/app/transformation.cpp index 2f2c6532f..f7b6bb6fa 100644 --- a/src/app/transformation.cpp +++ b/src/app/transformation.cpp @@ -1,5 +1,5 @@ // Aseprite -// Copyright (C) 2020 Igara Studio S.A. +// Copyright (C) 2020-2021 Igara Studio S.A. // Copyright (C) 2001-2018 David Capello // // This program is distributed under the terms of @@ -24,8 +24,9 @@ Transformation::Transformation() { } -Transformation::Transformation(const RectF& bounds) +Transformation::Transformation(const RectF& bounds, double cornerThick) : m_bounds(bounds) + , m_cornerThick(cornerThick) { m_pivot.x = bounds.x + bounds.w/2; m_pivot.y = bounds.y + bounds.h/2; @@ -86,7 +87,7 @@ RectF Transformation::transformedBounds() const // Create a union of all corners RectF bounds; for (int i=0; i +#define CORNER_THICK_FOR_TILEMAP_MODE 0.001 +#define CORNER_THICK_FOR_PIXELS_MODE 1.0 + namespace app { // Represents a transformation that can be done by the user in the @@ -56,10 +59,10 @@ public: void rightBottom(const gfx::PointF& pt) { m_corners[RIGHT_BOTTOM] = pt; } void leftBottom(const gfx::PointF& pt) { m_corners[LEFT_BOTTOM] = pt; } - gfx::RectF bounds() const { + gfx::RectF bounds(double cornerThick) const { gfx::RectF bounds; for (int i=0; ibounds()); + double cornerThick = (m_site.tilemapMode() == TilemapMode::Tiles) ? + CORNER_THICK_FOR_TILEMAP_MODE : + CORNER_THICK_FOR_PIXELS_MODE; + Transformation transform(mask->bounds(), cornerThick); set_pivot_from_preferences(transform); m_initialData = transform; @@ -770,7 +773,7 @@ void PixelsMovement::stampImage(bool finalStamp) if (currentCel && currentCel->layer() && currentCel->layer()->isImage() && !currentCel->layer()->isEditableHierarchy()) { - Transformation initialCelPos(gfx::Rect(m_initialMask0->bounds())); + Transformation initialCelPos(gfx::Rect(m_initialMask0->bounds()), m_currentData.cornerThick()); redrawExtraImage(&initialCelPos); stampExtraCelImage(); } @@ -1023,7 +1026,7 @@ void PixelsMovement::drawImage( ASSERT(dst); auto corners = transformation.transformedCorners(); - gfx::Rect bounds = corners.bounds(); + gfx::Rect bounds = corners.bounds(transformation.cornerThick()); if (m_site.tilemapMode() == TilemapMode::Tiles) { dst->setMaskColor(doc::notile); @@ -1071,7 +1074,7 @@ void PixelsMovement::drawImage( void PixelsMovement::drawMask(doc::Mask* mask, bool shrink) { auto corners = m_currentData.transformedCorners(); - gfx::Rect bounds = corners.bounds(); + gfx::Rect bounds = corners.bounds(m_currentData.cornerThick()); if (bounds.isEmpty()) { mask->clear(); diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index 9aa41b10f..02f37a8db 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -282,6 +282,7 @@ public: Doc* getDocument() override { return m_document; } Sprite* sprite() override { return m_sprite; } Layer* getLayer() override { return m_layer; } + bool isTilemapMode() override { return m_tilesMode; }; frame_t getFrame() override { return m_frame; } RgbMap* getRgbMap() override { if (!m_rgbMap) {