Dragging crop region from top right or top left does not keep aspect ratio if going out of image bounds
Submitted by Iñaki García Etxebarria
Link to original bug (#753408)
Description
Created attachment 308975 2x3 crop region
Assume that you start a crop operation on an image, with a fixed aspect ratio for the crop. (First attached image.)
Now resize the crop region by dragging the top left or top right corners, in such a way that the crop region dimensions exceed the page size. In this case the crop region no longer keeps the original aspect ratio. (Second attached image.)
The culprit is the following code in src/editing_tools/EditingTools.vala:
case BoxLocation.TOP_LEFT:
if (get_constraint_aspect_ratio() == ANY_ASPECT_RATIO) {
top = y;
left = x;
} else {
if (y < eval_radial_line(center_x, center_y, left, top, x)) {
top = y;
float new_width = ((float) (bottom - top)) * get_constraint_aspect_ratio();
left = right - ((int) new_width);
} else {
left = x;
float new_height = ((float) (right - left)) / get_constraint_aspect_ratio();
top = bottom - ((int) new_height);
}
}
break;
and
case BoxLocation.TOP_RIGHT:
if (get_constraint_aspect_ratio() == ANY_ASPECT_RATIO) {
top = y;
right = x;
} else {
if (y < eval_radial_line(center_x, center_y, right, top, x)) {
top = y;
float new_width = ((float) (bottom - top)) * get_constraint_aspect_ratio();
right = left + ((int) new_width);
} else {
right = x;
float new_height = ((float) (right - left)) / get_constraint_aspect_ratio();
top = bottom - ((int) new_height);
}
}
break;
In both cases the condition is switched, it should be if (y >= eval_radial_line(...)).
Resizing from any other edge of the crop box keeps the aspect ratio as it should.
Attachment 308975, "2x3 crop region":
Version: 0.22.x