mirror of https://github.com/GNOME/gimp.git
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:
parent
f026a3fc2d
commit
0f03f9e9f5
|
@ -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
|
||||||
|
|
||||||
|
|
||||||
|
@ -444,6 +445,8 @@ gimp_tool_compass_changed (GimpToolWidget *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++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
arc_line_display_length = ARC_RADIUS +
|
||||||
|
(GIMP_CANVAS_HANDLE_SIZE_CROSS >> 1) +
|
||||||
|
ARC_GAP;
|
||||||
|
arc_line_length = arc_line_display_length /
|
||||||
|
hypot (private->radius2.x * shell->scale_x,
|
||||||
|
private->radius2.y * shell->scale_y);
|
||||||
|
|
||||||
|
if (private->n_points > 2)
|
||||||
|
{
|
||||||
|
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,
|
gimp_canvas_line_set (private->line2,
|
||||||
private->x[0],
|
private->x[0],
|
||||||
private->y[0],
|
private->y[0],
|
||||||
private->x[2],
|
private->x[2],
|
||||||
private->y[2]);
|
private->y[2]);
|
||||||
gimp_canvas_item_set_visible (private->line2, private->n_points > 2);
|
gimp_canvas_item_set_visible (private->line2, TRUE);
|
||||||
if (private->n_points > 2 &&
|
}
|
||||||
gimp_canvas_item_transform_distance (private->line2,
|
}
|
||||||
private->x[0],
|
else
|
||||||
private->y[0],
|
|
||||||
private->x[2],
|
|
||||||
private->y[2]) > ARC_RADIUS)
|
|
||||||
{
|
{
|
||||||
draw_arc++;
|
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],
|
||||||
|
|
Loading…
Reference in New Issue