app: constrain line angles in display space, not image space

Add an offset_angle parameter to gimp_constrain_line(), which
offsets the radial lines by a given angle.

Add gimpdisplayshell-utils.[ch], with two new functions:

  - gimp_display_shell_get_constrained_line_offset_angle():
    Returns the offset angle to be passed to
    gimp_constrain_line(), in order to constrain line angles in
    display space, according to the shell's rotation angle and
    flip mode.

  - gimp_display_shell_constrain_line():  A convenience function
    which calls gimp_constrain_line() with the said offset angle.

Use the new functions in all instances where we constrain line
angles, so that angles are constrained in display space, rather
than image space.

The only exception is GimpEditSelectionTool, which keeps
constraining angles in image space, since it's not entirely obvious
that we want to constrain angles of dragged layers/selections in
display space.
This commit is contained in:
Ell
2017-12-22 05:56:11 -05:00
parent 59fd0315c2
commit 984ed6cefd
10 changed files with 65 additions and 31 deletions

View File

@ -610,6 +610,7 @@ gimp_utils_point_to_line_distance (const GimpVector2 *point,
* @end_x:
* @end_y:
* @n_snap_lines: Number evenly disributed lines to snap to.
* @offset_angle: The angle by which to offset the lines, in degrees.
*
* Projects a line onto the specified subset of evenly radially
* distributed lines. @n_lines of 2 makes the line snap horizontally
@ -621,7 +622,8 @@ gimp_constrain_line (gdouble start_x,
gdouble start_y,
gdouble *end_x,
gdouble *end_y,
gint n_snap_lines)
gint n_snap_lines,
gdouble offset_angle)
{
GimpVector2 line_point = { start_x, start_y };
GimpVector2 point = { *end_x, *end_y };
@ -634,7 +636,8 @@ gimp_constrain_line (gdouble start_x,
for (i = 0; i < n_snap_lines; i++)
{
angle = i * G_PI / n_snap_lines;
angle = i * G_PI / n_snap_lines;
angle += offset_angle * G_PI / 180.0;
gimp_vector2_set (&line_dir,
cos (angle),