Commit 82438728 authored by Jehan's avatar Jehan

Issue #288: Point snapping to guides does not work outside the canvas.

This commit also makes snap to grid and snap to vectors work off-canvas.
Since we now have off-canvas viewing, it just makes sense that snapping
would work there too.

Note that I disable snap to grid when "Show All" is OFF. I am actually
unsure this is right (as "Show All" is a view action, and we usually
don't change behavior based on view actions; for instance snap to guides
are not disabled if guides are hidden). Yet I noticed we do this in
various other features when off-canvas. We kind of use this view flag as
a switch for features working off-canvas (for instance, color picking
works off-canvas only when "Show All" is ON). So let's keep the same
logics for now at least.

Snap to guide or snap to vectors will always work though, because guides
and vectors are always visible off-canvas (even when "Show All" is OFF).
They always have been (visible, not snappable off-canvas; now they are
parent b134da1f
Pipeline #256456 passed with stages
in 48 minutes and 14 seconds
......@@ -221,7 +221,8 @@ gimp_image_snap_point (GimpImage *image,
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas,
gboolean snap_to_vectors)
gboolean snap_to_vectors,
gboolean show_all)
gdouble mindist_x = G_MAXDOUBLE;
gdouble mindist_y = G_MAXDOUBLE;
......@@ -241,10 +242,15 @@ gimp_image_snap_point (GimpImage *image,
if (! (snap_to_guides || snap_to_grid || snap_to_canvas || snap_to_vectors))
return FALSE;
if (x < -epsilon_x || x >= (gimp_image_get_width (image) + epsilon_x) ||
y < -epsilon_y || y >= (gimp_image_get_height (image) + epsilon_y))
if (! show_all &&
(x < -epsilon_x || x >= (gimp_image_get_width (image) + epsilon_x) ||
y < -epsilon_y || y >= (gimp_image_get_height (image) + epsilon_y)))
return FALSE;
/* Off-canvas grid is invisible unless "show all" option is
* enabled. So let's not snap to the invisible grid.
snap_to_grid = FALSE;
snap_to_canvas = FALSE;
if (snap_to_guides)
......@@ -43,7 +43,8 @@ gboolean gimp_image_snap_point (GimpImage *image,
gboolean snap_to_guides,
gboolean snap_to_grid,
gboolean snap_to_canvas,
gboolean snap_to_vectors);
gboolean snap_to_vectors,
gboolean show_all);
gboolean gimp_image_snap_rectangle (GimpImage *image,
gdouble x1,
gdouble y1,
......@@ -1655,7 +1655,8 @@ gimp_display_shell_snap_coords (GimpDisplayShell *shell,
if (snapped)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment