app/display: Initialize rectange constraints

Resolves #11897.
The crop tool currently doesn't constrain
to the top-left of the layer when the
"Allow growing" option is turned off and
"Selected layers only" is turned on.
Instead, it always constrains to 0, 0.

When we converted to multi-layer select,
we added a loop to check the boundaries
of all selected layers. In this loop, we use
separate variables to get the offset and
then get the min of it and the current
min_x and min_y. However, those values
are initialized to 0, so they will always be
smaller if the layer is inside the canvas.

To fix this, before the loop we check if
there are any selected layers. If so, we
get the offset of the first layer and set
min_x and min_y to that value rather than
0, 0.
This commit is contained in:
Alx Sa 2024-08-11 19:51:06 +00:00
parent aabfec824d
commit 376bda8e38
1 changed files with 3 additions and 0 deletions

View File

@ -3780,6 +3780,9 @@ gimp_tool_rectangle_get_constraints (GimpToolRectangle *rectangle,
GList *items = gimp_image_get_selected_drawables (image); GList *items = gimp_image_get_selected_drawables (image);
GList *iter; GList *iter;
if (items != NULL)
gimp_item_get_offset (items->data, min_x, min_y);
/* Min and max constraints are respectively the smallest and /* Min and max constraints are respectively the smallest and
* highest drawable coordinates. * highest drawable coordinates.
*/ */