Commit c7895c97 authored by Ell's avatar Ell

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 6a3fc6c1)
parent 130ef5ce
......@@ -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);
}
......@@ -49,8 +49,7 @@ struct _GimpGenericTransformToolClass
GimpTransformGridToolClass parent_class;
/* virtual functions */
void (* recalc_points) (GimpGenericTransformTool *generic,
GimpToolWidget *widget);
void (* recalc_points) (GimpGenericTransformTool *generic);
};
......
......@@ -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]};
}
......@@ -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]};
}
......@@ -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);
}
}
......@@ -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"))
......
......@@ -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