Fix Magic Wand doesn't work correctly in Tiled Mode (fix #4659)

This commit is contained in:
Gaspar Capello 2024-10-24 17:07:34 -03:00 committed by David Capello
parent 77e0944baa
commit f7a9f44cec
3 changed files with 13 additions and 4 deletions

View File

@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2019-2022 Igara Studio S.A.
// Copyright (C) 2019-2024 Igara Studio S.A.
// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
@ -207,6 +207,7 @@ namespace app {
virtual const doc::Grid& getGrid() const = 0;
virtual gfx::Rect getGridBounds() = 0;
virtual bool isPixelConnectivityEightConnected() = 0;
virtual bool isPointInsideCanvas(const gfx::Point& point) = 0;
// Returns true if the figure must be filled when we release the
// mouse (e.g. a filled rectangle, etc.)

View File

@ -154,9 +154,8 @@ bool ToolLoopManager::releaseButton(const Pointer& pointer)
if (m_toolLoop->getController()->isOnePoint() &&
m_toolLoop->getInk()->isSelection() &&
!m_toolLoop->getSrcImage()->bounds().contains(pointer.point())) {
!m_toolLoop->isPointInsideCanvas(pointer.point()))
return false;
}
Stroke::Pt spritePoint = getSpriteStrokePt(pointer);
bool res = m_toolLoop->getController()->releaseButton(m_stroke, spritePoint);
@ -209,7 +208,7 @@ void ToolLoopManager::movement(Pointer pointer)
doLoopStep(false);
}
void ToolLoopManager::disableMouseStabilizer()
void ToolLoopManager::disableMouseStabilizer()
{
// Disable mouse stabilizer for the current ToolLoopManager
m_dynamics.stabilizer = false;

View File

@ -360,6 +360,15 @@ public:
== app::gen::PixelConnectivity::EIGHT_CONNECTED);
}
bool isPointInsideCanvas(const gfx::Point& point) override {
const int a = ((getTiledMode() == TiledMode::X_AXIS ||
getTiledMode() == TiledMode::BOTH) ? 3 : 1);
const int b = ((getTiledMode() == TiledMode::Y_AXIS ||
getTiledMode() == TiledMode::BOTH) ? 3 : 1);
return 0 <= point.x && point.x < a * sprite()->size().w &&
0 <= point.y && point.y < b * sprite()->size().h;
}
const doc::Grid& getGrid() const override { return m_grid; }
gfx::Rect getGridBounds() override { return m_gridBounds; }
gfx::Point getCelOrigin() override { return m_celOrigin; }