[gimp] app: bring back the live transformed path in GimpTransformTool
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: bring back the live transformed path in GimpTransformTool
- Date: Mon, 19 Jun 2017 20:14:35 +0000 (UTC)
commit 8ab11e7c1806f2d363f32c0749c4b389aa9eea6c
Author: Michael Natterer <mitch gimp org>
Date: Mon Jun 19 22:13:50 2017 +0200
app: bring back the live transformed path in GimpTransformTool
app/tools/gimptransformtool.c | 61 +++++++++++++++++++++++-----------------
app/tools/gimptransformtool.h | 1 +
2 files changed, 36 insertions(+), 26 deletions(-)
---
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 3793921..8dc7d24 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -232,6 +232,8 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
tr_tool->progress_text = _("Transforming");
gimp_matrix3_identity (&tr_tool->transform);
+
+ tr_tool->strokes = g_ptr_array_new ();
}
static void
@@ -245,6 +247,12 @@ gimp_transform_tool_finalize (GObject *object)
tr_tool->gui = NULL;
}
+ if (tr_tool->strokes)
+ {
+ g_ptr_array_unref (tr_tool->strokes);
+ tr_tool->strokes = NULL;
+ }
+
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -788,16 +796,14 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
GimpImage *image = gimp_display_get_image (tool->display);
GimpMatrix3 matrix = tr_tool->transform;
+ GimpCanvasItem *item;
if (options->direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&matrix);
if (tr_tool->widget)
{
- GimpCanvasItem *item;
- gboolean show_preview;
-
- show_preview = gimp_transform_options_show_preview (options);
+ gboolean show_preview = gimp_transform_options_show_preview (options);
tr_tool->preview =
gimp_draw_tool_add_transform_preview (draw_tool,
@@ -855,16 +861,12 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
}
else if (options->type == GIMP_TRANSFORM_TYPE_PATH)
{
- GimpVectors *vectors;
- GimpStroke *stroke = NULL;
-
- /* FIXME */
- return;
-
- vectors = gimp_image_get_active_vectors (image);
+ GimpVectors *vectors = gimp_image_get_active_vectors (image);
if (vectors)
{
+ GimpStroke *stroke = NULL;
+
while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
{
GArray *coords;
@@ -874,21 +876,16 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
if (coords && coords->len)
{
- gint i;
-
- for (i = 0; i < coords->len; i++)
- {
- GimpCoords *curr = &g_array_index (coords, GimpCoords, i);
-
- gimp_matrix3_transform_point (&matrix,
- curr->x, curr->y,
- &curr->x, &curr->y);
- }
-
- gimp_draw_tool_add_strokes (draw_tool,
- &g_array_index (coords,
- GimpCoords, 0),
- coords->len, NULL, FALSE);
+ item =
+ gimp_draw_tool_add_strokes (draw_tool,
+ &g_array_index (coords,
+ GimpCoords, 0),
+ coords->len, &matrix, FALSE);
+
+ g_ptr_array_add (tr_tool->strokes, item);
+ g_object_weak_ref (G_OBJECT (item),
+ (GWeakNotify) g_ptr_array_remove,
+ tr_tool->strokes);
}
if (coords)
@@ -1127,6 +1124,7 @@ gimp_transform_tool_widget_changed (GimpToolWidget *widget,
{
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
GimpMatrix3 matrix = tr_tool->transform;
+ gint i;
if (options->direction == GIMP_TRANSFORM_BACKWARD)
gimp_matrix3_invert (&matrix);
@@ -1157,6 +1155,17 @@ gimp_transform_tool_widget_changed (GimpToolWidget *widget,
NULL);
gimp_canvas_item_end_change (tr_tool->boundary_out);
}
+
+ for (i = 0; i < tr_tool->strokes->len; i++)
+ {
+ GimpCanvasItem *item = g_ptr_array_index (tr_tool->strokes, i);
+
+ gimp_canvas_item_begin_change (item);
+ g_object_set (item,
+ "transform", &matrix,
+ NULL);
+ gimp_canvas_item_end_change (item);
+ }
}
static void
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 205f4cb..fb85de0 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -72,6 +72,7 @@ struct _GimpTransformTool
GimpCanvasItem *preview;
GimpCanvasItem *boundary_in;
GimpCanvasItem *boundary_out;
+ GPtrArray *strokes;
const gchar *progress_text;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]