mirror of https://github.com/GNOME/gimp.git
app: properly "auto straighten" in measure tool.
In particular, this tool should not make huge rotation where the top ends up in the bottom and it should not depend on whether we started the measure tool from the left, right, bottom or top. This is fixed by using atan() instead of atan2(). Also make a proper tooltip text. Help id is unneeded most likely though. Finally do some cleaning and alignment.
This commit is contained in:
parent
9baf2b62cd
commit
ba1d937dfb
|
@ -130,7 +130,9 @@ gimp_measure_options_gui (GimpToolOptions *tool_options)
|
||||||
button = gtk_button_new_with_label (_("Auto straighten"));
|
button = gtk_button_new_with_label (_("Auto straighten"));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
// gimp_help_set_help_data (button, NULL, GIMP_HELP_PATH_STROKE);
|
gimp_help_set_help_data (button,
|
||||||
|
_("Rotate the active layer using the measurement line as horizon"),
|
||||||
|
NULL);
|
||||||
gtk_widget_show (button);
|
gtk_widget_show (button);
|
||||||
|
|
||||||
GIMP_MEASURE_OPTIONS (tool_options)->auto_straighten = button;
|
GIMP_MEASURE_OPTIONS (tool_options)->auto_straighten = button;
|
||||||
|
|
|
@ -110,7 +110,7 @@ static GimpToolGui * gimp_measure_tool_dialog_new (GimpMeasureTool *measur
|
||||||
static void gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
static void gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
||||||
GimpDisplay *display);
|
GimpDisplay *display);
|
||||||
|
|
||||||
static void rotate_active_layer (GtkWidget *button,
|
static void gimp_measure_tool_rotate_active_layer (GtkWidget *button,
|
||||||
GimpMeasureTool *measure);
|
GimpMeasureTool *measure);
|
||||||
|
|
||||||
G_DEFINE_TYPE (GimpMeasureTool, gimp_measure_tool, GIMP_TYPE_DRAW_TOOL)
|
G_DEFINE_TYPE (GimpMeasureTool, gimp_measure_tool, GIMP_TYPE_DRAW_TOOL)
|
||||||
|
@ -281,6 +281,7 @@ gimp_measure_tool_compass_changed (GimpToolWidget *widget,
|
||||||
GimpMeasureTool *measure)
|
GimpMeasureTool *measure)
|
||||||
{
|
{
|
||||||
GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (measure);
|
GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (measure);
|
||||||
|
|
||||||
g_object_get (widget,
|
g_object_get (widget,
|
||||||
"n-points", &measure->n_points,
|
"n-points", &measure->n_points,
|
||||||
"x1", &measure->x[0],
|
"x1", &measure->x[0],
|
||||||
|
@ -398,7 +399,7 @@ gimp_measure_tool_start (GimpMeasureTool *measure,
|
||||||
G_CALLBACK (gimp_measure_tool_compass_create_guides),
|
G_CALLBACK (gimp_measure_tool_compass_create_guides),
|
||||||
measure);
|
measure);
|
||||||
g_signal_connect (options->auto_straighten, "clicked",
|
g_signal_connect (options->auto_straighten, "clicked",
|
||||||
G_CALLBACK (rotate_active_layer),
|
G_CALLBACK (gimp_measure_tool_rotate_active_layer),
|
||||||
measure);
|
measure);
|
||||||
|
|
||||||
tool->display = display;
|
tool->display = display;
|
||||||
|
@ -421,7 +422,7 @@ gimp_measure_tool_halt (GimpMeasureTool *measure)
|
||||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (measure));
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (measure));
|
||||||
|
|
||||||
g_signal_handlers_disconnect_by_func (options->auto_straighten,
|
g_signal_handlers_disconnect_by_func (options->auto_straighten,
|
||||||
G_CALLBACK (rotate_active_layer),
|
G_CALLBACK (gimp_measure_tool_rotate_active_layer),
|
||||||
measure);
|
measure);
|
||||||
|
|
||||||
gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), NULL);
|
gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), NULL);
|
||||||
|
@ -803,7 +804,7 @@ gimp_measure_tool_dialog_new (GimpMeasureTool *measure)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
rotate_active_layer (GtkWidget *button,
|
gimp_measure_tool_rotate_active_layer (GtkWidget *button,
|
||||||
GimpMeasureTool *measure)
|
GimpMeasureTool *measure)
|
||||||
{
|
{
|
||||||
GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (measure);
|
GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (measure);
|
||||||
|
@ -813,7 +814,7 @@ rotate_active_layer (GtkWidget *button,
|
||||||
gdouble ax = measure->x[1] - measure->x[0];
|
gdouble ax = measure->x[1] - measure->x[0];
|
||||||
gdouble ay = measure->y[1] - measure->y[0];
|
gdouble ay = measure->y[1] - measure->y[0];
|
||||||
GimpLayer *item = gimp_image_get_active_layer (image);
|
GimpLayer *item = gimp_image_get_active_layer (image);
|
||||||
gdouble angle = atan2 (ay, ax);
|
gdouble angle = atan (ay / ax);
|
||||||
GimpMatrix3 matrix;
|
GimpMatrix3 matrix;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue