app: in GimpToolCompass, add visual distinction between angle lines

When using a GimpToolCompass in 3-point mode, add a small gap after
the angle arc to the line corresponding to the "second" non-origin
point, so that it's visually distinguishable from the line
corresponding to the "first" point.  This has significance for the
measure tool, since it determines the direction of the rotation
when straightening the image (the first point is rotated toward the
second point.)
This commit is contained in:
Ell 2018-07-16 02:13:26 -04:00
parent f026a3fc2d
commit 0f03f9e9f5
1 changed files with 56 additions and 18 deletions

View File

@ -50,6 +50,7 @@
#define ARC_RADIUS 30 #define ARC_RADIUS 30
#define ARC_GAP (ARC_RADIUS / 2)
#define EPSILON 1e-6 #define EPSILON 1e-6
@ -438,12 +439,14 @@ gimp_tool_compass_get_property (GObject *object,
static void static void
gimp_tool_compass_changed (GimpToolWidget *widget) gimp_tool_compass_changed (GimpToolWidget *widget)
{ {
GimpToolCompass *compass = GIMP_TOOL_COMPASS (widget); GimpToolCompass *compass = GIMP_TOOL_COMPASS (widget);
GimpToolCompassPrivate *private = compass->private; GimpToolCompassPrivate *private = compass->private;
GimpDisplayShell *shell = gimp_tool_widget_get_shell (widget); GimpDisplayShell *shell = gimp_tool_widget_get_shell (widget);
gdouble angle1; gdouble angle1;
gdouble angle2; gdouble angle2;
gint draw_arc = 0; gint draw_arc = 0;
gboolean draw_arc_line = FALSE;
gdouble arc_line_display_length;
gdouble arc_line_length; gdouble arc_line_length;
gimp_tool_compass_update_angle (compass, private->orientation, FALSE); gimp_tool_compass_update_angle (compass, private->orientation, FALSE);
@ -468,20 +471,55 @@ gimp_tool_compass_changed (GimpToolWidget *widget)
draw_arc++; draw_arc++;
} }
gimp_canvas_line_set (private->line2,
private->x[0], arc_line_display_length = ARC_RADIUS +
private->y[0], (GIMP_CANVAS_HANDLE_SIZE_CROSS >> 1) +
private->x[2], ARC_GAP;
private->y[2]); arc_line_length = arc_line_display_length /
gimp_canvas_item_set_visible (private->line2, private->n_points > 2); hypot (private->radius2.x * shell->scale_x,
if (private->n_points > 2 && private->radius2.y * shell->scale_y);
gimp_canvas_item_transform_distance (private->line2,
private->x[0], if (private->n_points > 2)
private->y[0],
private->x[2],
private->y[2]) > ARC_RADIUS)
{ {
draw_arc++; gdouble length = gimp_canvas_item_transform_distance (private->line2,
private->x[0],
private->y[0],
private->x[2],
private->y[2]);
if (length > ARC_RADIUS)
{
draw_arc++;
draw_arc_line = TRUE;
if (length > arc_line_display_length)
{
gimp_canvas_line_set (
private->line2,
private->x[0] + private->radius2.x * arc_line_length,
private->y[0] + private->radius2.y * arc_line_length,
private->x[2],
private->y[2]);
gimp_canvas_item_set_visible (private->line2, TRUE);
}
else
{
gimp_canvas_item_set_visible (private->line2, FALSE);
}
}
else
{
gimp_canvas_line_set (private->line2,
private->x[0],
private->y[0],
private->x[2],
private->y[2]);
gimp_canvas_item_set_visible (private->line2, TRUE);
}
}
else
{
gimp_canvas_item_set_visible (private->line2, FALSE);
} }
gimp_canvas_handle_set_position (private->arc, gimp_canvas_handle_set_position (private->arc,
@ -502,7 +540,7 @@ gimp_tool_compass_changed (GimpToolWidget *widget)
private->x[0] + private->radius2.x * arc_line_length, private->x[0] + private->radius2.x * arc_line_length,
private->y[0] + private->radius2.y * arc_line_length); private->y[0] + private->radius2.y * arc_line_length);
gimp_canvas_item_set_visible (private->arc_line, gimp_canvas_item_set_visible (private->arc_line,
private->n_points == 2 && (private->n_points == 2 || draw_arc_line) &&
fabs (angle2) > EPSILON); fabs (angle2) > EPSILON);
gimp_canvas_handle_set_position (private->handles[0], gimp_canvas_handle_set_position (private->handles[0],