Bug 492434 - Snap to grid does not work at the edge of the canvas
Summary: Snap to grid does not work at the edge of the canvas
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 5.2.3
Platform: Android Android 14.x
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-31 03:04 UTC by Chris W
Modified: 2024-11-15 14:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
screen recording of trying to use the bezier tool with snap to grid at the edge of the canvas (3.26 MB, video/mp4)
2024-08-31 03:14 UTC, Chris W
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Chris W 2024-08-31 03:04:14 UTC
***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
When snap to grid is on, grid points which lie on the edge of the canvas do not get snapped to. 

STEPS TO REPRODUCE
1. Create a document of 300px x 300px
2. In "Grids and Guides" docker, set up a grid with x and y spacing set to 30px
3. Select the bezier curve tool
4. Try to click on a point where the horizontal and vertical grid lines intersect with the edge of the canvas. Notice how the tool does not snap to any grid points which are on the edge of the canvas. 
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT


SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Chris W 2024-08-31 03:10:03 UTC
Sorry, I didn't see the extra fields!

OBSERVED RESULT
Bezier tool loosely snaps to the edge of the canvas instead of to the grid points that lie on the edge of the canvas. This means that points on the edge of the canvas do not align with the grid. 

EXPECTED RESULT
Tapping a grid point on the edge of the canvas places the next bezier vertex exactly at the grid point. 


SOFTWARE/OS VERSIONS
Windows: n/a
macOS:  n/a
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: n/a
KDE Plasma Version: n/a
KDE Frameworks Version: n/a
Qt Version: n/a

ADDITIONAL INFORMATION
Reproduced on a Samsung Galaxy S8 Tab Ultra (Android)
Comment 2 Chris W 2024-08-31 03:14:12 UTC
Created attachment 173154 [details]
screen recording of trying to use the bezier tool with snap to grid at the edge of the canvas
Comment 3 Reinold Rojas 2024-11-15 01:56:32 UTC
I can confirm that the "snap to grid" doesn't work for the grid points at the edge of the canvas. It does snap edge of the canvas but does not snap to the intersecting points. Seems to be reproducible on any edge of the canvas
Comment 4 Dmitry Kazakov 2024-11-15 14:07:32 UTC
Git commit 4009f8f911f6ec9006c4652eb029d3213df76a06 by Dmitry Kazakov.
Committed on 15/11/2024 at 14:00.
Pushed by dkazakov into branch 'krita/5.2'.

Make sure that point-based snap points have higher priority than line-based ones

Basically, if grid intersection lays near (or on the top of) the guide (or image bounds),
then this intersection should have higher priority than snapping to a "mere" line.

Ideally, we should make some clver resolver that can also find intersections between
the different snap strategies, e.g. inteersection between a guide and a grid line. But it
needs quite a lot of redesing in our snapping code, so we can postpone it now.

M  +1    -1    libs/basicflakes/tools/KoCreatePathTool_p.h
M  +9    -5    libs/flake/KoSnapGuide.cpp
M  +33   -16   libs/flake/KoSnapStrategy.cpp
M  +15   -2    libs/flake/KoSnapStrategy.h
M  +1    -1    libs/ui/canvas/KisSnapPixelStrategy.cpp
M  +1    -1    libs/ui/canvas/KisSnapPointStrategy.cpp
M  +4    -1    libs/ui/canvas/kis_snap_line_strategy.cpp

https://invent.kde.org/graphics/krita/-/commit/4009f8f911f6ec9006c4652eb029d3213df76a06
Comment 5 Dmitry Kazakov 2024-11-15 14:08:03 UTC
Git commit f639df17feea76ff67985e96e4b6c517b969fb1a by Dmitry Kazakov.
Committed on 15/11/2024 at 14:07.
Pushed by dkazakov into branch 'master'.

Make sure that point-based snap points have higher priority than line-based ones

Basically, if grid intersection lays near (or on the top of) the guide (or image bounds),
then this intersection should have higher priority than snapping to a "mere" line.

Ideally, we should make some clver resolver that can also find intersections between
the different snap strategies, e.g. inteersection between a guide and a grid line. But it
needs quite a lot of redesing in our snapping code, so we can postpone it now.

M  +1    -1    libs/basicflakes/tools/KoCreatePathTool_p.h
M  +9    -5    libs/flake/KoSnapGuide.cpp
M  +33   -16   libs/flake/KoSnapStrategy.cpp
M  +15   -2    libs/flake/KoSnapStrategy.h
M  +1    -1    libs/ui/canvas/KisSnapPixelStrategy.cpp
M  +1    -1    libs/ui/canvas/KisSnapPointStrategy.cpp
M  +4    -1    libs/ui/canvas/kis_snap_line_strategy.cpp

https://invent.kde.org/graphics/krita/-/commit/f639df17feea76ff67985e96e4b6c517b969fb1a