[gimp/gimp-2-10] app: clean up GimpTransformGridTool; adapt subclasses
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: clean up GimpTransformGridTool; adapt subclasses
- Date: Fri, 15 Jun 2018 20:06:37 +0000 (UTC)
commit c7895c9752dd4ea1ca956c5215a2f223e3d1d8ad
Author: Ell <ell_se yahoo com>
Date: Fri Jun 15 15:42:19 2018 -0400
app: clean up GimpTransformGridTool; adapt subclasses
Get rid of GimpTransformGridTool::recalc_matrix() and
gimp_transform_grid_tool_recalc_matrix(), and have
GimpTransformGridTool and its subclasses use
GimpTransformTool::recalc_matrix() and
gimp_transform_tool_recalc_matrix() directly instead.
In order to break the GimpToolWidget::changed/
GimpTransformTool::recalc_matrix() loop, add a
GimpTransformGridTool::update_widget() vfunc, which subclasses
should override to update their tool-widget (instead of doing this
in ::recalc_matrix()), and ::widget_changed(), which is called when
the tool-widget changes (and which subclasses should override
instead of connecting to the tool-widget's "changed" signal
directly.) GimpTransformGridTool calls these functions as
necessary, instead of relying on extra parameters passed to
recalc_matrix().
Adapt all the direct and indirect subclasses of
GimpTransformGridTool to the change.
(cherry picked from commit 6a3fc6c1b932d552443e8fd4ff5c0ca71fdf95ce)
app/tools/gimpgenerictransformtool.c | 47 +++----
app/tools/gimpgenerictransformtool.h | 3 +-
app/tools/gimphandletransformtool.c | 138 ++++++++++-----------
app/tools/gimpperspectivetool.c | 87 ++++++-------
app/tools/gimprotatetool.c | 69 ++++++-----
app/tools/gimpscaletool.c | 78 ++++++------
app/tools/gimpsheartool.c | 109 +++++++++--------
app/tools/gimptransformgridtool.c | 230 ++++++++++++++++++++---------------
app/tools/gimptransformgridtool.h | 30 +++--
app/tools/gimpunifiedtransformtool.c | 91 ++++++--------
10 files changed, 446 insertions(+), 436 deletions(-)
---
diff --git a/app/tools/gimpgenerictransformtool.c b/app/tools/gimpgenerictransformtool.c
index f05a09495c..52a8b1e91e 100644
--- a/app/tools/gimpgenerictransformtool.c
+++ b/app/tools/gimpgenerictransformtool.c
@@ -42,26 +42,30 @@
/* local function prototypes */
+static void gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool);
+
static void gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool);
-static void gimp_generic_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
G_DEFINE_TYPE (GimpGenericTransformTool, gimp_generic_transform_tool,
GIMP_TYPE_TRANSFORM_GRID_TOOL)
+#define parent_class gimp_generic_transform_tool_parent_class
+
static void
gimp_generic_transform_tool_class_init (GimpGenericTransformToolClass *klass)
{
+ GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
+ tr_class->recalc_matrix = gimp_generic_transform_tool_recalc_matrix;
+
tg_class->dialog = gimp_generic_transform_tool_dialog;
tg_class->dialog_update = gimp_generic_transform_tool_dialog_update;
tg_class->prepare = gimp_generic_transform_tool_prepare;
- tg_class->recalc_matrix = gimp_generic_transform_tool_recalc_matrix;
}
static void
@@ -69,6 +73,23 @@ gimp_generic_transform_tool_init (GimpGenericTransformTool *unified_tool)
{
}
+static void
+gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool)
+{
+ GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
+
+ if (GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points)
+ GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points (generic);
+
+ gimp_matrix3_identity (&tr_tool->transform);
+ tr_tool->transform_valid =
+ gimp_transform_matrix_generic (&tr_tool->transform,
+ generic->input_points,
+ generic->output_points);
+
+ GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
+}
+
static void
gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool)
{
@@ -168,23 +189,3 @@ gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool)
memcpy (generic->output_points, generic->input_points,
sizeof (generic->input_points));
}
-
-static void
-gimp_generic_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
-{
- GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
-
- if (GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points)
- {
- GIMP_GENERIC_TRANSFORM_TOOL_GET_CLASS (generic)->recalc_points (generic,
- widget);
- }
-
- gimp_matrix3_identity (&tr_tool->transform);
- tr_tool->transform_valid =
- gimp_transform_matrix_generic (&tr_tool->transform,
- generic->input_points,
- generic->output_points);
-}
diff --git a/app/tools/gimpgenerictransformtool.h b/app/tools/gimpgenerictransformtool.h
index b6937ffa8e..3c1c89af91 100644
--- a/app/tools/gimpgenerictransformtool.h
+++ b/app/tools/gimpgenerictransformtool.h
@@ -49,8 +49,7 @@ struct _GimpGenericTransformToolClass
GimpTransformGridToolClass parent_class;
/* virtual functions */
- void (* recalc_points) (GimpGenericTransformTool *generic,
- GimpToolWidget *widget);
+ void (* recalc_points) (GimpGenericTransformTool *generic);
};
diff --git a/app/tools/gimphandletransformtool.c b/app/tools/gimphandletransformtool.c
index b3491b9d01..5fec5ca6ef 100644
--- a/app/tools/gimphandletransformtool.c
+++ b/app/tools/gimphandletransformtool.c
@@ -77,25 +77,20 @@ enum
/* local function prototypes */
-static void gimp_handle_transform_tool_modifier_key (GimpTool *tool,
- GdkModifierType key,
- gboolean press,
- GdkModifierType state,
- GimpDisplay *display);
+static void gimp_handle_transform_tool_modifier_key (GimpTool *tool,
+ GdkModifierType key,
+ gboolean press,
+ GdkModifierType state,
+ GimpDisplay *display);
-static gchar *gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
+static gchar * gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
-static void gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_tool);
-static GimpToolWidget *
- gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
-
-static void gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget);
+static void gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_tool);
+static GimpToolWidget * gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
+static void gimp_handle_transform_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_handle_transform_tool_widget_changed (GimpTransformGridTool *tg_tool);
-static void gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic);
G_DEFINE_TYPE (GimpHandleTransformTool, gimp_handle_transform_tool,
@@ -136,7 +131,8 @@ gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
tg_class->prepare = gimp_handle_transform_tool_prepare;
tg_class->get_widget = gimp_handle_transform_tool_get_widget;
- tg_class->recalc_matrix = gimp_handle_transform_tool_recalc_matrix;
+ tg_class->update_widget = gimp_handle_transform_tool_update_widget;
+ tg_class->widget_changed = gimp_handle_transform_tool_widget_changed;
generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
@@ -277,77 +273,43 @@ gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
G_BINDING_SYNC_CREATE |
G_BINDING_BIDIRECTIONAL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_handle_transform_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_handle_transform_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "show-guides", tr_tool->transform_valid,
- "n-handles", (gint) tg_tool->trans_info[N_HANDLES],
- "orig-x1", tg_tool->trans_info[OX0],
- "orig-y1", tg_tool->trans_info[OY0],
- "orig-x2", tg_tool->trans_info[OX1],
- "orig-y2", tg_tool->trans_info[OY1],
- "orig-x3", tg_tool->trans_info[OX2],
- "orig-y3", tg_tool->trans_info[OY2],
- "orig-x4", tg_tool->trans_info[OX3],
- "orig-y4", tg_tool->trans_info[OY3],
- "trans-x1", tg_tool->trans_info[X0],
- "trans-y1", tg_tool->trans_info[Y0],
- "trans-x2", tg_tool->trans_info[X1],
- "trans-y2", tg_tool->trans_info[Y1],
- "trans-x3", tg_tool->trans_info[X2],
- "trans-y3", tg_tool->trans_info[Y2],
- "trans-x4", tg_tool->trans_info[X3],
- "trans-y4", tg_tool->trans_info[Y3],
- NULL);
-}
-
-static void
-gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget)
-{
- GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
-
- generic->input_points[0] = (GimpVector2) {tg_tool->trans_info[OX0],
- tg_tool->trans_info[OY0]};
- generic->input_points[1] = (GimpVector2) {tg_tool->trans_info[OX1],
- tg_tool->trans_info[OY1]};
- generic->input_points[2] = (GimpVector2) {tg_tool->trans_info[OX2],
- tg_tool->trans_info[OY2]};
- generic->input_points[3] = (GimpVector2) {tg_tool->trans_info[OX3],
- tg_tool->trans_info[OY3]};
-
- generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
- tg_tool->trans_info[Y0]};
- generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
- tg_tool->trans_info[Y1]};
- generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
- tg_tool->trans_info[Y2]};
- generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
- tg_tool->trans_info[Y3]};
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "show-guides", tr_tool->transform_valid,
+ "n-handles", (gint) tg_tool->trans_info[N_HANDLES],
+ "orig-x1", tg_tool->trans_info[OX0],
+ "orig-y1", tg_tool->trans_info[OY0],
+ "orig-x2", tg_tool->trans_info[OX1],
+ "orig-y2", tg_tool->trans_info[OY1],
+ "orig-x3", tg_tool->trans_info[OX2],
+ "orig-y3", tg_tool->trans_info[OY2],
+ "orig-x4", tg_tool->trans_info[OX3],
+ "orig-y4", tg_tool->trans_info[OY3],
+ "trans-x1", tg_tool->trans_info[X0],
+ "trans-y1", tg_tool->trans_info[Y0],
+ "trans-x2", tg_tool->trans_info[X1],
+ "trans-y2", tg_tool->trans_info[Y1],
+ "trans-x3", tg_tool->trans_info[X2],
+ "trans-y3", tg_tool->trans_info[Y2],
+ "trans-x4", tg_tool->trans_info[X3],
+ "trans-y4", tg_tool->trans_info[Y3],
+ NULL);
}
static void
-gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_handle_transform_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
gint n_handles;
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"n-handles", &n_handles,
"orig-x1", &tg_tool->trans_info[OX0],
"orig-y1", &tg_tool->trans_info[OY0],
@@ -369,5 +331,29 @@ gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
tg_tool->trans_info[N_HANDLES] = n_handles;
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
+}
+
+static void
+gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic)
+{
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
+
+ generic->input_points[0] = (GimpVector2) {tg_tool->trans_info[OX0],
+ tg_tool->trans_info[OY0]};
+ generic->input_points[1] = (GimpVector2) {tg_tool->trans_info[OX1],
+ tg_tool->trans_info[OY1]};
+ generic->input_points[2] = (GimpVector2) {tg_tool->trans_info[OX2],
+ tg_tool->trans_info[OY2]};
+ generic->input_points[3] = (GimpVector2) {tg_tool->trans_info[OX3],
+ tg_tool->trans_info[OY3]};
+
+ generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
+ tg_tool->trans_info[Y0]};
+ generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
+ tg_tool->trans_info[Y1]};
+ generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
+ tg_tool->trans_info[Y2]};
+ generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
+ tg_tool->trans_info[Y3]};
}
diff --git a/app/tools/gimpperspectivetool.c b/app/tools/gimpperspectivetool.c
index f7f238921f..f595dc1d60 100644
--- a/app/tools/gimpperspectivetool.c
+++ b/app/tools/gimpperspectivetool.c
@@ -58,14 +58,10 @@ static gchar * gimp_perspective_tool_get_undo_desc (GimpTransformTool
static void gimp_perspective_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_perspective_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
+static void gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool);
-static void gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget);
-
-static void gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic);
G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool,
@@ -103,7 +99,8 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
tg_class->prepare = gimp_perspective_tool_prepare;
tg_class->get_widget = gimp_perspective_tool_get_widget;
- tg_class->recalc_matrix = gimp_perspective_tool_recalc_matrix;
+ tg_class->update_widget = gimp_perspective_tool_update_widget;
+ tg_class->widget_changed = gimp_perspective_tool_widget_changed;
generic_class->recalc_points = gimp_perspective_tool_recalc_points;
@@ -164,61 +161,30 @@ gimp_perspective_tool_get_widget (GimpTransformGridTool *tg_tool)
"use-center-handle", TRUE,
NULL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_perspective_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_perspective_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_perspective_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "x1", (gdouble) tr_tool->x1,
- "y1", (gdouble) tr_tool->y1,
- "x2", (gdouble) tr_tool->x2,
- "y2", (gdouble) tr_tool->y2,
- NULL);
-}
-
-static void
-gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget)
-{
- GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
- GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
-
- generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
- generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
- generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
- generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
-
- generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
- tg_tool->trans_info[Y0]};
- generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
- tg_tool->trans_info[Y1]};
- generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
- tg_tool->trans_info[Y2]};
- generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
- tg_tool->trans_info[Y3]};
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "x1", (gdouble) tr_tool->x1,
+ "y1", (gdouble) tr_tool->y1,
+ "x2", (gdouble) tr_tool->x2,
+ "y2", (gdouble) tr_tool->y2,
+ NULL);
}
static void
-gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_perspective_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 *transform;
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"transform", &transform,
NULL);
@@ -241,5 +207,26 @@ gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
g_free (transform);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
+}
+
+static void
+gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic)
+{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
+
+ generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
+ generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
+ generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
+ generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
+
+ generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
+ tg_tool->trans_info[Y0]};
+ generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
+ tg_tool->trans_info[Y1]};
+ generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
+ tg_tool->trans_info[Y2]};
+ generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
+ tg_tool->trans_info[Y3]};
}
diff --git a/app/tools/gimprotatetool.c b/app/tools/gimprotatetool.c
index 9a9feca351..98349fb154 100644
--- a/app/tools/gimprotatetool.c
+++ b/app/tools/gimprotatetool.c
@@ -61,17 +61,15 @@ static gboolean gimp_rotate_tool_key_press (GimpTool *
GdkEventKey *kevent,
GimpDisplay *display);
+static void gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_rotate_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
-
-static void gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_rotate_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_rotate_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void rotate_angle_changed (GtkAdjustment *adj,
GimpTransformGridTool *tg_tool);
@@ -110,13 +108,15 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
tool_class->key_press = gimp_rotate_tool_key_press;
+ tr_class->recalc_matrix = gimp_rotate_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
tg_class->dialog = gimp_rotate_tool_dialog;
tg_class->dialog_update = gimp_rotate_tool_dialog_update;
tg_class->prepare = gimp_rotate_tool_prepare;
tg_class->get_widget = gimp_rotate_tool_get_widget;
- tg_class->recalc_matrix = gimp_rotate_tool_recalc_matrix;
+ tg_class->update_widget = gimp_rotate_tool_update_widget;
+ tg_class->widget_changed = gimp_rotate_tool_widget_changed;
tr_class->progress_text = _("Rotating");
tg_class->ok_button_label = _("R_otate");
@@ -168,6 +168,20 @@ gimp_rotate_tool_key_press (GimpTool *tool,
return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
}
+static void
+gimp_rotate_tool_recalc_matrix (GimpTransformTool *tr_tool)
+{
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
+
+ gimp_matrix3_identity (&tr_tool->transform);
+ gimp_transform_matrix_rotate_center (&tr_tool->transform,
+ tg_tool->trans_info[PIVOT_X],
+ tg_tool->trans_info[PIVOT_Y],
+ tg_tool->trans_info[ANGLE]);
+
+ GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
+}
+
static gchar *
gimp_rotate_tool_get_undo_desc (GimpTransformTool *tr_tool)
{
@@ -330,45 +344,32 @@ gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool)
"use-pivot-handle", TRUE,
NULL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_rotate_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_rotate_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_rotate_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- gimp_matrix3_identity (&tr_tool->transform);
- gimp_transform_matrix_rotate_center (&tr_tool->transform,
- tg_tool->trans_info[PIVOT_X],
- tg_tool->trans_info[PIVOT_Y],
- tg_tool->trans_info[ANGLE]);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "angle", tg_tool->trans_info[ANGLE],
- "pivot-x", tg_tool->trans_info[PIVOT_X],
- "pivot-y", tg_tool->trans_info[PIVOT_Y],
- NULL);
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "angle", tg_tool->trans_info[ANGLE],
+ "pivot-x", tg_tool->trans_info[PIVOT_X],
+ "pivot-y", tg_tool->trans_info[PIVOT_Y],
+ NULL);
}
static void
-gimp_rotate_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_rotate_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"angle", &tg_tool->trans_info[ANGLE],
"pivot-x", &tg_tool->trans_info[PIVOT_X],
"pivot-y", &tg_tool->trans_info[PIVOT_Y],
NULL);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
}
static void
@@ -381,11 +382,14 @@ rotate_angle_changed (GtkAdjustment *adj,
if (ABS (value - tg_tool->trans_info[ANGLE]) > ANGLE_EPSILON)
{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+
tg_tool->trans_info[ANGLE] = value;
gimp_transform_grid_tool_push_internal_undo (tg_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
#undef ANGLE_EPSILON
@@ -401,11 +405,14 @@ rotate_center_changed (GtkWidget *widget,
if ((px != tg_tool->trans_info[PIVOT_X]) ||
(py != tg_tool->trans_info[PIVOT_Y]))
{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+
tg_tool->trans_info[PIVOT_X] = px;
tg_tool->trans_info[PIVOT_Y] = py;
gimp_transform_grid_tool_push_internal_undo (tg_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
}
diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c
index 9b75e50585..53ab21b956 100644
--- a/app/tools/gimpscaletool.c
+++ b/app/tools/gimpscaletool.c
@@ -57,17 +57,15 @@ enum
/* local function prototypes */
+static void gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_scale_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_scale_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_scale_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
-
-static void gimp_scale_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_scale_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_scale_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void gimp_scale_tool_size_notify (GtkWidget *box,
GParamSpec *pspec,
@@ -102,13 +100,15 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
+ tr_class->recalc_matrix = gimp_scale_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
tg_class->dialog = gimp_scale_tool_dialog;
tg_class->dialog_update = gimp_scale_tool_dialog_update;
tg_class->prepare = gimp_scale_tool_prepare;
tg_class->get_widget = gimp_scale_tool_get_widget;
- tg_class->recalc_matrix = gimp_scale_tool_recalc_matrix;
+ tg_class->update_widget = gimp_scale_tool_update_widget;
+ tg_class->widget_changed = gimp_scale_tool_widget_changed;
tr_class->progress_text = _("Scaling");
tg_class->ok_button_label = _("_Scale");
@@ -122,6 +122,25 @@ gimp_scale_tool_init (GimpScaleTool *scale_tool)
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE);
}
+static void
+gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool)
+{
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
+
+ gimp_matrix3_identity (&tr_tool->transform);
+ gimp_transform_matrix_scale (&tr_tool->transform,
+ tr_tool->x1,
+ tr_tool->y1,
+ tr_tool->x2 - tr_tool->x1,
+ tr_tool->y2 - tr_tool->y1,
+ tg_tool->trans_info[X0],
+ tg_tool->trans_info[Y0],
+ tg_tool->trans_info[X1] - tg_tool->trans_info[X0],
+ tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
+
+ GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
+}
+
static gchar *
gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool)
{
@@ -231,50 +250,30 @@ gimp_scale_tool_get_widget (GimpTransformGridTool *tg_tool)
"use-center-handle", TRUE,
NULL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_scale_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_scale_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_scale_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- gimp_matrix3_identity (&tr_tool->transform);
- gimp_transform_matrix_scale (&tr_tool->transform,
- tr_tool->x1,
- tr_tool->y1,
- tr_tool->x2 - tr_tool->x1,
- tr_tool->y2 - tr_tool->y1,
- tg_tool->trans_info[X0],
- tg_tool->trans_info[Y0],
- tg_tool->trans_info[X1] - tg_tool->trans_info[X0],
- tg_tool->trans_info[Y1] - tg_tool->trans_info[Y0]);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "x1", (gdouble) tr_tool->x1,
- "y1", (gdouble) tr_tool->y1,
- "x2", (gdouble) tr_tool->x2,
- "y2", (gdouble) tr_tool->y2,
- "pivot-x", (tr_tool->x1 + tr_tool->x2) / 2.0,
- "pivot-y", (tr_tool->y1 + tr_tool->y2) / 2.0,
- NULL);
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "x1", (gdouble) tr_tool->x1,
+ "y1", (gdouble) tr_tool->y1,
+ "x2", (gdouble) tr_tool->x2,
+ "y2", (gdouble) tr_tool->y2,
+ NULL);
}
static void
-gimp_scale_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_scale_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 *transform;
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"transform", &transform,
NULL);
@@ -289,7 +288,7 @@ gimp_scale_tool_widget_changed (GimpToolWidget *widget,
g_free (transform);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
}
static void
@@ -317,12 +316,15 @@ gimp_scale_tool_size_notify (GtkWidget *box,
if ((width != old_width) || (height != old_height))
{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+
tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + width;
tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + height;
gimp_transform_grid_tool_push_internal_undo (tg_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
}
else if (! strcmp (pspec->name, "keep-aspect"))
diff --git a/app/tools/gimpsheartool.c b/app/tools/gimpsheartool.c
index d06b148368..2cf4026a12 100644
--- a/app/tools/gimpsheartool.c
+++ b/app/tools/gimpsheartool.c
@@ -55,17 +55,15 @@ enum
/* local function prototypes */
+static void gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool);
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool);
static void gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool);
static void gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_shear_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
-
-static void gimp_shear_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_shear_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_shear_tool_widget_changed (GimpTransformGridTool *tg_tool);
static void shear_x_mag_changed (GtkAdjustment *adj,
GimpTransformGridTool *tg_tool);
@@ -75,6 +73,8 @@ static void shear_y_mag_changed (GtkAdjustment *a
G_DEFINE_TYPE (GimpShearTool, gimp_shear_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
+#define parent_class gimp_shear_tool_parent_class
+
void
gimp_shear_tool_register (GimpToolRegisterCallback callback,
@@ -99,13 +99,15 @@ gimp_shear_tool_class_init (GimpShearToolClass *klass)
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
+ tr_class->recalc_matrix = gimp_shear_tool_recalc_matrix;
tr_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
tg_class->dialog = gimp_shear_tool_dialog;
tg_class->dialog_update = gimp_shear_tool_dialog_update;
tg_class->prepare = gimp_shear_tool_prepare;
tg_class->get_widget = gimp_shear_tool_get_widget;
- tg_class->recalc_matrix = gimp_shear_tool_recalc_matrix;
+ tg_class->update_widget = gimp_shear_tool_update_widget;
+ tg_class->widget_changed = gimp_shear_tool_widget_changed;
tr_class->progress_text = _("Shearing");
tg_class->ok_button_label = _("_Shear");
@@ -119,6 +121,35 @@ gimp_shear_tool_init (GimpShearTool *shear_tool)
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SHEAR);
}
+static void
+gimp_shear_tool_recalc_matrix (GimpTransformTool *tr_tool)
+{
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
+ gdouble amount;
+
+ if (tg_tool->trans_info[SHEAR_X] == 0.0 &&
+ tg_tool->trans_info[SHEAR_Y] == 0.0)
+ {
+ tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
+ }
+
+ if (tg_tool->trans_info[ORIENTATION] == GIMP_ORIENTATION_HORIZONTAL)
+ amount = tg_tool->trans_info[SHEAR_X];
+ else
+ amount = tg_tool->trans_info[SHEAR_Y];
+
+ gimp_matrix3_identity (&tr_tool->transform);
+ gimp_transform_matrix_shear (&tr_tool->transform,
+ tr_tool->x1,
+ tr_tool->y1,
+ tr_tool->x2 - tr_tool->x1,
+ tr_tool->y2 - tr_tool->y1,
+ tg_tool->trans_info[ORIENTATION],
+ amount);
+
+ GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool);
+}
+
static gchar *
gimp_shear_tool_get_undo_desc (GimpTransformTool *tr_tool)
{
@@ -218,60 +249,32 @@ gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool)
"frompivot-shear", TRUE,
NULL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_shear_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_shear_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_shear_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- gdouble amount;
-
- if (tg_tool->trans_info[SHEAR_X] == 0.0 &&
- tg_tool->trans_info[SHEAR_Y] == 0.0)
- {
- tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
- }
- if (tg_tool->trans_info[ORIENTATION] == GIMP_ORIENTATION_HORIZONTAL)
- amount = tg_tool->trans_info[SHEAR_X];
- else
- amount = tg_tool->trans_info[SHEAR_Y];
-
- gimp_matrix3_identity (&tr_tool->transform);
- gimp_transform_matrix_shear (&tr_tool->transform,
- tr_tool->x1,
- tr_tool->y1,
- tr_tool->x2 - tr_tool->x1,
- tr_tool->y2 - tr_tool->y1,
- tg_tool->trans_info[ORIENTATION],
- amount);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "x1", (gdouble) tr_tool->x1,
- "y1", (gdouble) tr_tool->y1,
- "x2", (gdouble) tr_tool->x2,
- "y2", (gdouble) tr_tool->y2,
- "orientation", (gint) tg_tool->trans_info[ORIENTATION],
- "shear-x", tg_tool->trans_info[SHEAR_X],
- "shear-y", tg_tool->trans_info[SHEAR_Y],
- NULL);
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "x1", (gdouble) tr_tool->x1,
+ "y1", (gdouble) tr_tool->y1,
+ "x2", (gdouble) tr_tool->x2,
+ "y2", (gdouble) tr_tool->y2,
+ "orientation", (gint) tg_tool->trans_info[ORIENTATION],
+ "shear-x", tg_tool->trans_info[SHEAR_X],
+ "shear-y", tg_tool->trans_info[SHEAR_Y],
+ NULL);
}
static void
-gimp_shear_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_shear_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
GimpOrientationType orientation;
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"orientation", &orientation,
"shear-x", &tg_tool->trans_info[SHEAR_X],
"shear-y", &tg_tool->trans_info[SHEAR_Y],
@@ -279,7 +282,7 @@ gimp_shear_tool_widget_changed (GimpToolWidget *widget,
tg_tool->trans_info[ORIENTATION] = orientation;
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
}
static void
@@ -290,6 +293,9 @@ shear_x_mag_changed (GtkAdjustment *adj,
if (value != tg_tool->trans_info[SHEAR_X])
{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_HORIZONTAL;
tg_tool->trans_info[SHEAR_X] = value;
@@ -297,7 +303,7 @@ shear_x_mag_changed (GtkAdjustment *adj,
gimp_transform_grid_tool_push_internal_undo (tg_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
}
@@ -309,6 +315,9 @@ shear_y_mag_changed (GtkAdjustment *adj,
if (value != tg_tool->trans_info[SHEAR_Y])
{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_VERTICAL;
tg_tool->trans_info[SHEAR_Y] = value;
@@ -316,6 +325,6 @@ shear_y_mag_changed (GtkAdjustment *adj,
gimp_transform_grid_tool_push_internal_undo (tg_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
}
diff --git a/app/tools/gimptransformgridtool.c b/app/tools/gimptransformgridtool.c
index ebf98d64dc..830fb36253 100644
--- a/app/tools/gimptransformgridtool.c
+++ b/app/tools/gimptransformgridtool.c
@@ -107,7 +107,7 @@ static void gimp_transform_grid_tool_options_notify (GimpTool
static void gimp_transform_grid_tool_draw (GimpDrawTool *draw_tool);
-static void gimp_transform_grid_tool_transform_recalc_matrix (GimpTransformTool *tr_tool);
+static void gimp_transform_grid_tool_recalc_matrix (GimpTransformTool *tr_tool);
static GeglBuffer * gimp_transform_grid_tool_transform (GimpTransformTool *tr_tool,
GimpItem *item,
GeglBuffer *orig_buffer,
@@ -117,6 +117,7 @@ static GeglBuffer * gimp_transform_grid_tool_transform (GimpTransformTool
gint *new_offset_x,
gint *new_offset_y);
+static void gimp_transform_grid_tool_real_widget_changed (GimpTransformGridTool *tg_tool);
static GeglBuffer * gimp_transform_grid_tool_real_transform (GimpTransformGridTool *tg_tool,
GimpItem *item,
GeglBuffer *orig_buffer,
@@ -140,12 +141,14 @@ static void gimp_transform_grid_tool_dialog_update (GimpTransformGridT
static void gimp_transform_grid_tool_prepare (GimpTransformGridTool *tg_tool,
GimpDisplay *display);
static GimpToolWidget * gimp_transform_grid_tool_get_widget (GimpTransformGridTool *tg_tool);
+static void gimp_transform_grid_tool_update_widget (GimpTransformGridTool *tg_tool);
static void gimp_transform_grid_tool_response (GimpToolGui *gui,
gint response_id,
GimpTransformGridTool *tg_tool);
static void gimp_transform_grid_tool_update_sensitivity (GimpTransformGridTool *tg_tool);
+static void gimp_transform_grid_tool_update_preview (GimpTransformGridTool *tg_tool);
static void gimp_transform_grid_tool_hide_active_item (GimpTransformGridTool *tg_tool,
GimpItem *item);
static void gimp_transform_grid_tool_show_active_item (GimpTransformGridTool *tg_tool);
@@ -184,13 +187,15 @@ gimp_transform_grid_tool_class_init (GimpTransformGridToolClass *klass)
draw_class->draw = gimp_transform_grid_tool_draw;
- tr_class->recalc_matrix = gimp_transform_grid_tool_transform_recalc_matrix;
+ tr_class->recalc_matrix = gimp_transform_grid_tool_recalc_matrix;
tr_class->transform = gimp_transform_grid_tool_transform;
klass->dialog = NULL;
klass->dialog_update = NULL;
klass->prepare = NULL;
- klass->recalc_matrix = NULL;
+ klass->get_widget = NULL;
+ klass->update_widget = NULL;
+ klass->widget_changed = gimp_transform_grid_tool_real_widget_changed;
klass->transform = gimp_transform_grid_tool_real_transform;
klass->ok_button_label = _("_Transform");
@@ -264,8 +269,8 @@ gimp_transform_grid_tool_initialize (GimpTool *tool,
/* Initialize the tool-specific trans_info, and adjust the tool dialog */
gimp_transform_grid_tool_prepare (tg_tool, display);
- /* Recalculate the transform_grid tool */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ /* Recalculate the tool's transformation matrix */
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
/* Get the on-canvas gui */
tg_tool->widget = gimp_transform_grid_tool_get_widget (tg_tool);
@@ -294,6 +299,7 @@ gimp_transform_grid_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display)
{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
switch (action)
@@ -302,7 +308,7 @@ gimp_transform_grid_tool_control (GimpTool *tool,
break;
case GIMP_TOOL_ACTION_RESUME:
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
break;
case GIMP_TOOL_ACTION_HALT:
@@ -350,6 +356,7 @@ gimp_transform_grid_tool_button_release (GimpTool *tool,
GimpButtonReleaseType release_type,
GimpDisplay *display)
{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
gimp_tool_control_halt (tool->control);
@@ -380,7 +387,7 @@ gimp_transform_grid_tool_button_release (GimpTool *tool,
sizeof (TransInfo));
/* recalculate the tool's transformation matrix */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
}
}
@@ -488,6 +495,7 @@ static gboolean
gimp_transform_grid_tool_undo (GimpTool *tool,
GimpDisplay *display)
{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
GList *item;
@@ -506,7 +514,7 @@ gimp_transform_grid_tool_undo (GimpTool *tool,
sizeof (TransInfo));
/* recalculate the tool's transformation matrix */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
return TRUE;
}
@@ -515,6 +523,7 @@ static gboolean
gimp_transform_grid_tool_redo (GimpTool *tool,
GimpDisplay *display)
{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tool);
GList *item;
@@ -533,7 +542,7 @@ gimp_transform_grid_tool_redo (GimpTool *tool,
sizeof (TransInfo));
/* recalculate the tool's transformation matrix */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
return TRUE;
}
@@ -561,7 +570,7 @@ gimp_transform_grid_tool_options_notify (GimpTool *tool,
if (! strcmp (pspec->name, "direction"))
{
/* recalculate the tool's transformation matrix */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
}
else if (! strcmp (pspec->name, "show-preview"))
{
@@ -716,11 +725,17 @@ gimp_transform_grid_tool_draw (GimpDrawTool *draw_tool)
}
static void
-gimp_transform_grid_tool_transform_recalc_matrix (GimpTransformTool *tr_tool)
+gimp_transform_grid_tool_recalc_matrix (GimpTransformTool *tr_tool)
{
GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (tr_tool);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ gimp_transform_grid_tool_dialog_update (tg_tool);
+ gimp_transform_grid_tool_update_sensitivity (tg_tool);
+ gimp_transform_grid_tool_update_widget (tg_tool);
+ gimp_transform_grid_tool_update_preview (tg_tool);
+
+ if (tg_tool->gui)
+ gimp_tool_gui_show (tg_tool->gui);
}
static GeglBuffer *
@@ -760,6 +775,23 @@ gimp_transform_grid_tool_transform (GimpTransformTool *tr_tool,
return new_buffer;
}
+static void
+gimp_transform_grid_tool_real_widget_changed (GimpTransformGridTool *tg_tool)
+{
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+ GimpToolWidget *widget = tg_tool->widget;
+
+ /* supress the call to GimpTransformGridTool::update_widget() when
+ * recalculating the matrix
+ */
+ tg_tool->widget = NULL;
+
+ gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
+
+ tg_tool->widget = widget;
+}
+
static GeglBuffer *
gimp_transform_grid_tool_real_transform (GimpTransformGridTool *tg_tool,
GimpItem *item,
@@ -786,61 +818,8 @@ static void
gimp_transform_grid_tool_widget_changed (GimpToolWidget *widget,
GimpTransformGridTool *tg_tool)
{
- GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
- GimpTransformOptions *tr_options = GIMP_TRANSFORM_OPTIONS (options);
- GimpMatrix3 matrix = tr_tool->transform;
- gint i;
-
- if (tr_options->direction == GIMP_TRANSFORM_BACKWARD)
- gimp_matrix3_invert (&matrix);
-
- if (tg_tool->preview)
- {
- gboolean show_preview = gimp_transform_grid_options_show_preview (options) &&
- tr_tool->transform_valid;
-
- gimp_canvas_item_begin_change (tg_tool->preview);
- gimp_canvas_item_set_visible (tg_tool->preview, show_preview);
- g_object_set (tg_tool->preview,
- "transform", &matrix,
- NULL);
- gimp_canvas_item_end_change (tg_tool->preview);
- }
-
- if (tg_tool->boundary_in)
- {
- gimp_canvas_item_begin_change (tg_tool->boundary_in);
- gimp_canvas_item_set_visible (tg_tool->boundary_in,
- tr_tool->transform_valid);
- g_object_set (tg_tool->boundary_in,
- "transform", &matrix,
- NULL);
- gimp_canvas_item_end_change (tg_tool->boundary_in);
- }
-
- if (tg_tool->boundary_out)
- {
- gimp_canvas_item_begin_change (tg_tool->boundary_out);
- gimp_canvas_item_set_visible (tg_tool->boundary_out,
- tr_tool->transform_valid);
- g_object_set (tg_tool->boundary_out,
- "transform", &matrix,
- NULL);
- gimp_canvas_item_end_change (tg_tool->boundary_out);
- }
-
- for (i = 0; i < tg_tool->strokes->len; i++)
- {
- GimpCanvasItem *item = g_ptr_array_index (tg_tool->strokes, i);
-
- gimp_canvas_item_begin_change (item);
- gimp_canvas_item_set_visible (item, tr_tool->transform_valid);
- g_object_set (item,
- "transform", &matrix,
- NULL);
- gimp_canvas_item_end_change (item);
- }
+ if (GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->widget_changed)
+ GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->widget_changed (tg_tool);
}
static void
@@ -1040,13 +1019,34 @@ gimp_transform_grid_tool_get_widget (GimpTransformGridTool *tg_tool)
return widget;
}
+static void
+gimp_transform_grid_tool_update_widget (GimpTransformGridTool *tg_tool)
+{
+ if (tg_tool->widget &&
+ GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->update_widget)
+ {
+ g_signal_handlers_block_by_func (
+ tg_tool->widget,
+ G_CALLBACK (gimp_transform_grid_tool_widget_changed),
+ tg_tool);
+
+ GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->update_widget (tg_tool);
+
+ g_signal_handlers_unblock_by_func (
+ tg_tool->widget,
+ G_CALLBACK (gimp_transform_grid_tool_widget_changed),
+ tg_tool);
+ }
+}
+
static void
gimp_transform_grid_tool_response (GimpToolGui *gui,
gint response_id,
GimpTransformGridTool *tg_tool)
{
- GimpTool *tool = GIMP_TOOL (tg_tool);
- GimpDisplay *display = tool->display;
+ GimpTool *tool = GIMP_TOOL (tg_tool);
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+ GimpDisplay *display = tool->display;
switch (response_id)
{
@@ -1070,7 +1070,7 @@ gimp_transform_grid_tool_response (GimpToolGui *gui,
sizeof (TransInfo));
/* recalculate the tool's transformtion matrix */
- gimp_transform_grid_tool_recalc_matrix (tg_tool, tg_tool->widget);
+ gimp_transform_tool_recalc_matrix (tr_tool, display);
/* update the undo actions / menu items */
gimp_image_flush (gimp_display_get_image (display));
@@ -1105,6 +1105,68 @@ gimp_transform_grid_tool_update_sensitivity (GimpTransformGridTool *tg_tool)
g_list_next (tg_tool->undo_list) != NULL);
}
+static void
+gimp_transform_grid_tool_update_preview (GimpTransformGridTool *tg_tool)
+{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
+ GimpTransformGridOptions *options = GIMP_TRANSFORM_GRID_TOOL_GET_OPTIONS (tg_tool);
+ GimpTransformOptions *tr_options = GIMP_TRANSFORM_OPTIONS (options);
+ GimpMatrix3 matrix;
+ gint i;
+
+ matrix = tr_tool->transform;
+
+ if (tr_options->direction == GIMP_TRANSFORM_BACKWARD)
+ gimp_matrix3_invert (&matrix);
+
+ if (tg_tool->preview)
+ {
+ gboolean show_preview = gimp_transform_grid_options_show_preview (options) &&
+ tr_tool->transform_valid;
+
+ gimp_canvas_item_begin_change (tg_tool->preview);
+ gimp_canvas_item_set_visible (tg_tool->preview, show_preview);
+ g_object_set (tg_tool->preview,
+ "transform", &matrix,
+ NULL);
+ gimp_canvas_item_end_change (tg_tool->preview);
+ }
+
+ if (tg_tool->boundary_in)
+ {
+ gimp_canvas_item_begin_change (tg_tool->boundary_in);
+ gimp_canvas_item_set_visible (tg_tool->boundary_in,
+ tr_tool->transform_valid);
+ g_object_set (tg_tool->boundary_in,
+ "transform", &matrix,
+ NULL);
+ gimp_canvas_item_end_change (tg_tool->boundary_in);
+ }
+
+ if (tg_tool->boundary_out)
+ {
+ gimp_canvas_item_begin_change (tg_tool->boundary_out);
+ gimp_canvas_item_set_visible (tg_tool->boundary_out,
+ tr_tool->transform_valid);
+ g_object_set (tg_tool->boundary_out,
+ "transform", &matrix,
+ NULL);
+ gimp_canvas_item_end_change (tg_tool->boundary_out);
+ }
+
+ for (i = 0; i < tg_tool->strokes->len; i++)
+ {
+ GimpCanvasItem *item = g_ptr_array_index (tg_tool->strokes, i);
+
+ gimp_canvas_item_begin_change (item);
+ gimp_canvas_item_set_visible (item, tr_tool->transform_valid);
+ g_object_set (item,
+ "transform", &matrix,
+ NULL);
+ gimp_canvas_item_end_change (item);
+ }
+}
+
static void
gimp_transform_grid_tool_hide_active_item (GimpTransformGridTool *tg_tool,
GimpItem *item)
@@ -1156,34 +1218,6 @@ trans_info_free (TransInfo *info)
g_slice_free (TransInfo, info);
}
-void
-gimp_transform_grid_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
-{
- GimpTool *tool;
- GimpTransformTool *tr_tool;
-
- g_return_if_fail (GIMP_IS_TRANSFORM_GRID_TOOL (tg_tool));
- g_return_if_fail (widget == NULL || GIMP_IS_TOOL_WIDGET (widget));
-
- tool = GIMP_TOOL (tg_tool);
- tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
-
- gimp_transform_tool_bounds (tr_tool, tool->display);
-
- if (GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->recalc_matrix)
- {
- GIMP_TRANSFORM_GRID_TOOL_GET_CLASS (tg_tool)->recalc_matrix (tg_tool,
- widget);
- }
-
- gimp_transform_grid_tool_dialog_update (tg_tool);
- gimp_transform_grid_tool_update_sensitivity (tg_tool);
-
- if (tg_tool->gui)
- gimp_tool_gui_show (tg_tool->gui);
-}
-
void
gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool)
{
diff --git a/app/tools/gimptransformgridtool.h b/app/tools/gimptransformgridtool.h
index da383ddeec..eed9c0cf48 100644
--- a/app/tools/gimptransformgridtool.h
+++ b/app/tools/gimptransformgridtool.h
@@ -74,20 +74,20 @@ struct _GimpTransformGridToolClass
GimpTransformToolClass parent_class;
/* virtual functions */
- void (* dialog) (GimpTransformGridTool *tg_tool);
- void (* dialog_update) (GimpTransformGridTool *tg_tool);
- void (* prepare) (GimpTransformGridTool *tg_tool);
- GimpToolWidget * (* get_widget) (GimpTransformGridTool *tg_tool);
- void (* recalc_matrix) (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
- GeglBuffer * (* transform) (GimpTransformGridTool *tg_tool,
- GimpItem *item,
- GeglBuffer *orig_buffer,
- gint orig_offset_x,
- gint orig_offset_y,
- GimpColorProfile **buffer_profile,
- gint *new_offset_x,
- gint *new_offset_y);
+ void (* dialog) (GimpTransformGridTool *tg_tool);
+ void (* dialog_update) (GimpTransformGridTool *tg_tool);
+ void (* prepare) (GimpTransformGridTool *tg_tool);
+ GimpToolWidget * (* get_widget) (GimpTransformGridTool *tg_tool);
+ void (* update_widget) (GimpTransformGridTool *tg_tool);
+ void (* widget_changed) (GimpTransformGridTool *tg_tool);
+ GeglBuffer * (* transform) (GimpTransformGridTool *tg_tool,
+ GimpItem *item,
+ GeglBuffer *orig_buffer,
+ gint orig_offset_x,
+ gint orig_offset_y,
+ GimpColorProfile **buffer_profile,
+ gint *new_offset_x,
+ gint *new_offset_y);
const gchar *ok_button_label;
};
@@ -95,8 +95,6 @@ struct _GimpTransformGridToolClass
GType gimp_transform_grid_tool_get_type (void) G_GNUC_CONST;
-void gimp_transform_grid_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
void gimp_transform_grid_tool_push_internal_undo (GimpTransformGridTool *tg_tool);
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index 2d5bd98cf6..90256e6acf 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -60,14 +60,10 @@ static gchar * gimp_unified_transform_tool_get_undo_desc (GimpTransfor
static void gimp_unified_transform_tool_prepare (GimpTransformGridTool *tg_tool);
static GimpToolWidget * gimp_unified_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
-static void gimp_unified_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget);
+static void gimp_unified_transform_tool_update_widget (GimpTransformGridTool *tg_tool);
+static void gimp_unified_transform_tool_widget_changed (GimpTransformGridTool *tg_tool);
-static void gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget);
-
-static void gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool);
+static void gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic);
G_DEFINE_TYPE (GimpUnifiedTransformTool, gimp_unified_transform_tool,
@@ -105,7 +101,8 @@ gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
tg_class->prepare = gimp_unified_transform_tool_prepare;
tg_class->get_widget = gimp_unified_transform_tool_get_widget;
- tg_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
+ tg_class->update_widget = gimp_unified_transform_tool_update_widget;
+ tg_class->widget_changed = gimp_unified_transform_tool_widget_changed;
generic_class->recalc_points = gimp_unified_transform_tool_recalc_points;
@@ -170,63 +167,32 @@ gimp_unified_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
"use-pivot-handle", TRUE,
NULL);
- g_signal_connect (widget, "changed",
- G_CALLBACK (gimp_unified_transform_tool_widget_changed),
- tg_tool);
-
return widget;
}
static void
-gimp_unified_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
- GimpToolWidget *widget)
+gimp_unified_transform_tool_update_widget (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
- GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->recalc_matrix (tg_tool, widget);
-
- if (widget)
- g_object_set (widget,
- "transform", &tr_tool->transform,
- "x1", (gdouble) tr_tool->x1,
- "y1", (gdouble) tr_tool->y1,
- "x2", (gdouble) tr_tool->x2,
- "y2", (gdouble) tr_tool->y2,
- "pivot-x", tg_tool->trans_info[PIVOT_X],
- "pivot-y", tg_tool->trans_info[PIVOT_Y],
- NULL);
-}
-
-static void
-gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic,
- GimpToolWidget *widget)
-{
- GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
- GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
-
- generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
- generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
- generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
- generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
-
- generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
- tg_tool->trans_info[Y0]};
- generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
- tg_tool->trans_info[Y1]};
- generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
- tg_tool->trans_info[Y2]};
- generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
- tg_tool->trans_info[Y3]};
+ g_object_set (tg_tool->widget,
+ "transform", &tr_tool->transform,
+ "x1", (gdouble) tr_tool->x1,
+ "y1", (gdouble) tr_tool->y1,
+ "x2", (gdouble) tr_tool->x2,
+ "y2", (gdouble) tr_tool->y2,
+ "pivot-x", tg_tool->trans_info[PIVOT_X],
+ "pivot-y", tg_tool->trans_info[PIVOT_Y],
+ NULL);
}
static void
-gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
- GimpTransformGridTool *tg_tool)
+gimp_unified_transform_tool_widget_changed (GimpTransformGridTool *tg_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpMatrix3 *transform;
- g_object_get (widget,
+ g_object_get (tg_tool->widget,
"transform", &transform,
"pivot-x", &tg_tool->trans_info[PIVOT_X],
"pivot-y", &tg_tool->trans_info[PIVOT_Y],
@@ -251,5 +217,26 @@ gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
g_free (transform);
- gimp_transform_grid_tool_recalc_matrix (tg_tool, NULL);
+ GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
+}
+
+static void
+gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic)
+{
+ GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
+ GimpTransformGridTool *tg_tool = GIMP_TRANSFORM_GRID_TOOL (generic);
+
+ generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
+ generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
+ generic->input_points[2] = (GimpVector2) {tr_tool->x1, tr_tool->y2};
+ generic->input_points[3] = (GimpVector2) {tr_tool->x2, tr_tool->y2};
+
+ generic->output_points[0] = (GimpVector2) {tg_tool->trans_info[X0],
+ tg_tool->trans_info[Y0]};
+ generic->output_points[1] = (GimpVector2) {tg_tool->trans_info[X1],
+ tg_tool->trans_info[Y1]};
+ generic->output_points[2] = (GimpVector2) {tg_tool->trans_info[X2],
+ tg_tool->trans_info[Y2]};
+ generic->output_points[3] = (GimpVector2) {tg_tool->trans_info[X3],
+ tg_tool->trans_info[Y3]};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]