Commit 82fbfdf9 authored by Jehan's avatar Jehan

app: do not stop the measurement when straightening.

Instead just transform the measurement extremities appropriately to
still map to the same points.
To do so, I also added out parameters to gimp_image_resize_to_layers()
so that calling code can get offsets from old origin (as well as new
image dimensions).

(cherry picked from commit d56a8d439e7b799922cab88d502d690453a09630)
parent 554f342d
......@@ -677,7 +677,7 @@ image_resize_to_layers_cmd_callback (GtkAction *action,
gimp_image_resize_to_layers (image,
action_data_get_context (data),
progress);
NULL, NULL, NULL, NULL, progress);
if (progress)
gimp_progress_end (progress);
......
......@@ -254,6 +254,10 @@ gimp_image_resize_with_layers (GimpImage *image,
void
gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
gint *offset_x,
gint *offset_y,
gint *new_width,
gint *new_height,
GimpProgress *progress)
{
GList *list;
......@@ -296,6 +300,14 @@ gimp_image_resize_to_layers (GimpImage *image,
gimp_image_resize (image, context,
width, height, -x, -y,
progress);
if (offset_x)
*offset_x = -x;
if (offset_y)
*offset_y = -y;
if (new_width)
*new_width = width;
if (new_height)
*new_height = height;
}
void
......
......@@ -40,6 +40,10 @@ void gimp_image_resize_with_layers (GimpImage *image,
void gimp_image_resize_to_layers (GimpImage *image,
GimpContext *context,
gint *offset_x,
gint *offset_y,
gint *new_width,
gint *new_height,
GimpProgress *progress);
void gimp_image_resize_to_selection (GimpImage *image,
GimpContext *context,
......
......@@ -90,7 +90,7 @@ image_resize_to_layers_invoker (GimpProcedure *procedure,
if (success)
{
gimp_image_resize_to_layers (image, context, NULL);
gimp_image_resize_to_layers (image, context, NULL, NULL, NULL, NULL, NULL);
}
return gimp_procedure_get_return_values (procedure, success,
......
......@@ -820,6 +820,9 @@ gimp_measure_tool_rotate_active_layer (GtkWidget *button,
gdouble ay = measure->y[1] - measure->y[0];
gdouble angle;
GimpMatrix3 matrix;
gint offset_x;
gint offset_y;
gdouble x0, y0, x1, y1;
if (! item)
return;
......@@ -855,7 +858,27 @@ gimp_measure_tool_rotate_active_layer (GtkWidget *button,
progress);
}
gimp_image_resize_to_layers (image, context, NULL);
gimp_image_resize_to_layers (image, context, &offset_x, &offset_y,
NULL, NULL, progress);
/* Keep and transform the measurement points as well. */
gimp_matrix3_identity (&matrix);
gimp_transform_matrix_rotate_center (&matrix, measure->x[0], measure->y[0], - angle);
gimp_matrix3_translate (&matrix, offset_x, offset_y);
gimp_matrix3_transform_point (&matrix,
measure->x[0],
measure->y[0],
&x0, &y0);
gimp_matrix3_transform_point (&matrix,
measure->x[1],
measure->y[1],
&x1, &y1);
g_object_set (measure->widget,
"x1", (gint) x0,
"y1", (gint) y0,
"x2", (gint) x1,
"y2", (gint) y1,
NULL);
/* push the undo group end */
gimp_image_undo_group_end (image);
......@@ -864,5 +887,4 @@ gimp_measure_tool_rotate_active_layer (GtkWidget *button,
gimp_progress_end (progress);
gimp_image_flush (image);
gimp_tool_control (GIMP_TOOL (measure), GIMP_TOOL_ACTION_HALT, display);
}
......@@ -77,7 +77,7 @@ HELP
headers => [ qw("core/gimpimage-resize.h") ],
code => <<'CODE'
{
gimp_image_resize_to_layers (image, context, NULL);
gimp_image_resize_to_layers (image, context, NULL, NULL, NULL, NULL, NULL);
}
CODE
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment