From f7a9f44cec65d07ed2f27616d32fe9e71e0fffb9 Mon Sep 17 00:00:00 2001 From: Gaspar Capello Date: Thu, 24 Oct 2024 17:07:34 -0300 Subject: [PATCH] Fix Magic Wand doesn't work correctly in Tiled Mode (fix #4659) --- src/app/tools/tool_loop.h | 3 ++- src/app/tools/tool_loop_manager.cpp | 5 ++--- src/app/ui/editor/tool_loop_impl.cpp | 9 +++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/tools/tool_loop.h b/src/app/tools/tool_loop.h index 377515400..36f07e081 100644 --- a/src/app/tools/tool_loop.h +++ b/src/app/tools/tool_loop.h @@ -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.) diff --git a/src/app/tools/tool_loop_manager.cpp b/src/app/tools/tool_loop_manager.cpp index ae266772d..314f4aeef 100644 --- a/src/app/tools/tool_loop_manager.cpp +++ b/src/app/tools/tool_loop_manager.cpp @@ -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; diff --git a/src/app/ui/editor/tool_loop_impl.cpp b/src/app/ui/editor/tool_loop_impl.cpp index 866f554b6..e44974d24 100644 --- a/src/app/ui/editor/tool_loop_impl.cpp +++ b/src/app/ui/editor/tool_loop_impl.cpp @@ -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; }