Commit 442be726 authored by Ell's avatar Ell

app: port relevant transform tools to GimpGenericTransformTool

Derive GimpUnifiedTransformTool, GimpPerspectiveTool, and
GimpHandleTransformTool from GimpGenericTransformTool, eliminating
their common logic.

Remove gimp_transform_matrix_handles(), which is no longer used.
parent 0334595c
......@@ -424,100 +424,6 @@ mod_gauss (gdouble matrix[],
return TRUE;
}
void
gimp_transform_matrix_handles (GimpMatrix3 *matrix,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gdouble x3,
gdouble y3,
gdouble x4,
gdouble y4,
gdouble t_x1,
gdouble t_y1,
gdouble t_x2,
gdouble t_y2,
gdouble t_x3,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4)
{
GimpMatrix3 trafo;
gdouble opos_x[4];
gdouble opos_y[4];
gdouble pos_x[4];
gdouble pos_y[4];
gdouble coeff[8 * 9];
gdouble sol[8];
gint i;
g_return_if_fail (matrix != NULL);
opos_x[0] = x1;
opos_y[0] = y1;
opos_x[1] = x2;
opos_y[1] = y2;
opos_x[2] = x3;
opos_y[2] = y3;
opos_x[3] = x4;
opos_y[3] = y4;
pos_x[0] = t_x1;
pos_y[0] = t_y1;
pos_x[1] = t_x2;
pos_y[1] = t_y2;
pos_x[2] = t_x3;
pos_y[2] = t_y3;
pos_x[3] = t_x4;
pos_y[3] = t_y4;
for (i = 0; i < 4; i++)
{
coeff[i * 9 + 0] = opos_x[i];
coeff[i * 9 + 1] = opos_y[i];
coeff[i * 9 + 2] = 1;
coeff[i * 9 + 3] = 0;
coeff[i * 9 + 4] = 0;
coeff[i * 9 + 5] = 0;
coeff[i * 9 + 6] = -opos_x[i] * pos_x[i];
coeff[i * 9 + 7] = -opos_y[i] * pos_x[i];
coeff[i * 9 + 8] = pos_x[i];
coeff[(i + 4) * 9 + 0] = 0;
coeff[(i + 4) * 9 + 1] = 0;
coeff[(i + 4) * 9 + 2] = 0;
coeff[(i + 4) * 9 + 3] = opos_x[i];
coeff[(i + 4) * 9 + 4] = opos_y[i];
coeff[(i + 4) * 9 + 5] = 1;
coeff[(i + 4) * 9 + 6] = -opos_x[i] * pos_y[i];
coeff[(i + 4) * 9 + 7] = -opos_y[i] * pos_y[i];
coeff[(i + 4) * 9 + 8] = pos_y[i];
}
if (mod_gauss (coeff, sol, 8))
{
trafo.coeff[0][0] = sol[0];
trafo.coeff[0][1] = sol[1];
trafo.coeff[0][2] = sol[2];
trafo.coeff[1][0] = sol[3];
trafo.coeff[1][1] = sol[4];
trafo.coeff[1][2] = sol[5];
trafo.coeff[2][0] = sol[6];
trafo.coeff[2][1] = sol[7];
trafo.coeff[2][2] = 1;
}
else
{
/* this should not happen reset the matrix so the user sees that
* something went wrong
*/
gimp_matrix3_identity (&trafo);
}
gimp_matrix3_mult (&trafo, matrix);
}
gboolean
gimp_transform_matrix_generic (GimpMatrix3 *matrix,
const GimpVector2 *input_points,
......
......@@ -85,23 +85,6 @@ void gimp_transform_matrix_perspective (GimpMatrix3 *matrix,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4);
void gimp_transform_matrix_handles (GimpMatrix3 *matrix,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gdouble x3,
gdouble y3,
gdouble x4,
gdouble y4,
gdouble t_x1,
gdouble t_y1,
gdouble t_x2,
gdouble t_y2,
gdouble t_x3,
gdouble t_y3,
gdouble t_x4,
gdouble t_y4);
gboolean gimp_transform_matrix_generic (GimpMatrix3 *matrix,
const GimpVector2 *input_points,
const GimpVector2 *output_points);
......
......@@ -25,8 +25,6 @@
#include "tools-types.h"
#include "core/gimp-transform-utils.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpwidgets-utils.h"
......@@ -79,27 +77,28 @@ 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 void gimp_handle_transform_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool);
static GimpToolWidget *
gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar *gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar *gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
GimpToolWidget *widget);
static void gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
G_DEFINE_TYPE (GimpHandleTransformTool, gimp_handle_transform_tool,
GIMP_TYPE_TRANSFORM_TOOL)
GIMP_TYPE_GENERIC_TRANSFORM_TOOL)
#define parent_class gimp_handle_transform_tool_parent_class
......@@ -125,17 +124,18 @@ gimp_handle_transform_tool_register (GimpToolRegisterCallback callback,
static void
gimp_handle_transform_tool_class_init (GimpHandleTransformToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
trans_class->dialog = gimp_handle_transform_tool_dialog;
trans_class->dialog_update = gimp_handle_transform_tool_dialog_update;
trans_class->prepare = gimp_handle_transform_tool_prepare;
trans_class->get_widget = gimp_handle_transform_tool_get_widget;
trans_class->recalc_matrix = gimp_handle_transform_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_handle_transform_tool_get_undo_desc;
trans_class->prepare = gimp_handle_transform_tool_prepare;
trans_class->get_widget = gimp_handle_transform_tool_get_widget;
trans_class->recalc_matrix = gimp_handle_transform_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_handle_transform_tool_get_undo_desc;
generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
}
static void
......@@ -202,65 +202,11 @@ gimp_handle_transform_tool_modifier_key (GimpTool *tool,
state, display);
}
static void
gimp_handle_transform_tool_dialog (GimpTransformTool *tr_tool)
{
GimpHandleTransformTool *ht_tool = GIMP_HANDLE_TRANSFORM_TOOL (tr_tool);
GtkWidget *frame;
GtkWidget *table;
gint x, y;
frame = gimp_frame_new (_("Transformation Matrix"));
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
{
GtkWidget *label = gtk_label_new (" ");
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_width_chars (GTK_LABEL (label), 12);
gtk_table_attach (GTK_TABLE (table), label,
x, x + 1, y, y + 1, GTK_EXPAND, GTK_FILL, 0, 0);
gtk_widget_show (label);
ht_tool->label[y][x] = label;
}
}
}
static void
gimp_handle_transform_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpHandleTransformTool *ht_tool = GIMP_HANDLE_TRANSFORM_TOOL (tr_tool);
gint x, y;
for (y = 0; y < 3; y++)
{
for (x = 0; x < 3; x++)
{
gchar buf[32];
g_snprintf (buf, sizeof (buf),
"%10.5f", tr_tool->transform.coeff[y][x]);
gtk_label_set_text (GTK_LABEL (ht_tool->label[y][x]), buf);
}
}
}
static void
gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool)
{
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->prepare (tr_tool);
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
......@@ -332,45 +278,29 @@ static void
gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget)
{
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_handles (&tr_tool->transform,
tr_tool->trans_info[OX0],
tr_tool->trans_info[OY0],
tr_tool->trans_info[OX1],
tr_tool->trans_info[OY1],
tr_tool->trans_info[OX2],
tr_tool->trans_info[OY2],
tr_tool->trans_info[OX3],
tr_tool->trans_info[OY3],
tr_tool->trans_info[X0],
tr_tool->trans_info[Y0],
tr_tool->trans_info[X1],
tr_tool->trans_info[Y1],
tr_tool->trans_info[X2],
tr_tool->trans_info[Y2],
tr_tool->trans_info[X3],
tr_tool->trans_info[Y3]);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
if (widget)
g_object_set (widget,
"transform", &tr_tool->transform,
"n-handles", (gint) tr_tool->trans_info[N_HANDLES],
"orig-x1", tr_tool->trans_info[OX0],
"orig-y1", tr_tool->trans_info[OY0],
"orig-x2", tr_tool->trans_info[OX1],
"orig-y2", tr_tool->trans_info[OY1],
"orig-x3", tr_tool->trans_info[OX2],
"orig-y3", tr_tool->trans_info[OY2],
"orig-x4", tr_tool->trans_info[OX3],
"orig-y4", tr_tool->trans_info[OY3],
"trans-x1", tr_tool->trans_info[X0],
"trans-y1", tr_tool->trans_info[Y0],
"trans-x2", tr_tool->trans_info[X1],
"trans-y2", tr_tool->trans_info[Y1],
"trans-x3", tr_tool->trans_info[X2],
"trans-y3", tr_tool->trans_info[Y2],
"trans-x4", tr_tool->trans_info[X3],
"trans-y4", tr_tool->trans_info[Y3],
"transform", &tr_tool->transform,
"show-guides", tr_tool->transform_valid,
"n-handles", (gint) tr_tool->trans_info[N_HANDLES],
"orig-x1", tr_tool->trans_info[OX0],
"orig-y1", tr_tool->trans_info[OY0],
"orig-x2", tr_tool->trans_info[OX1],
"orig-y2", tr_tool->trans_info[OY1],
"orig-x3", tr_tool->trans_info[OX2],
"orig-y3", tr_tool->trans_info[OY2],
"orig-x4", tr_tool->trans_info[OX3],
"orig-y4", tr_tool->trans_info[OY3],
"trans-x1", tr_tool->trans_info[X0],
"trans-y1", tr_tool->trans_info[Y0],
"trans-x2", tr_tool->trans_info[X1],
"trans-y2", tr_tool->trans_info[Y1],
"trans-x3", tr_tool->trans_info[X2],
"trans-y3", tr_tool->trans_info[Y2],
"trans-x4", tr_tool->trans_info[X3],
"trans-y4", tr_tool->trans_info[Y3],
NULL);
}
......@@ -380,6 +310,31 @@ gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
return g_strdup (C_("undo-type", "Handle transform"));
}
static void
gimp_handle_transform_tool_recalc_points (GimpGenericTransformTool *generic,
GimpToolWidget *widget)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (generic);
generic->input_points[0] = (GimpVector2) {tr_tool->trans_info[OX0],
tr_tool->trans_info[OY0]};
generic->input_points[1] = (GimpVector2) {tr_tool->trans_info[OX1],
tr_tool->trans_info[OY1]};
generic->input_points[2] = (GimpVector2) {tr_tool->trans_info[OX2],
tr_tool->trans_info[OY2]};
generic->input_points[3] = (GimpVector2) {tr_tool->trans_info[OX3],
tr_tool->trans_info[OY3]};
generic->output_points[0] = (GimpVector2) {tr_tool->trans_info[X0],
tr_tool->trans_info[Y0]};
generic->output_points[1] = (GimpVector2) {tr_tool->trans_info[X1],
tr_tool->trans_info[Y1]};
generic->output_points[2] = (GimpVector2) {tr_tool->trans_info[X2],
tr_tool->trans_info[Y2]};
generic->output_points[3] = (GimpVector2) {tr_tool->trans_info[X3],
tr_tool->trans_info[Y3]};
}
static void
gimp_handle_transform_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool)
......
......@@ -19,7 +19,7 @@
#define __GIMP_HANDLE_TRANSFORM_TOOL_H__
#include "gimptransformtool.h"
#include "gimpgenerictransformtool.h"
#define GIMP_TYPE_HANDLE_TRANSFORM_TOOL (gimp_handle_transform_tool_get_type ())
......@@ -37,16 +37,14 @@ typedef struct _GimpHandleTransformToolClass GimpHandleTransformToolClass;
struct _GimpHandleTransformTool
{
GimpTransformTool parent_instance;
GimpGenericTransformTool parent_instance;
GtkWidget *label[3][3];
GimpTransformHandleMode saved_handle_mode;
GimpTransformHandleMode saved_handle_mode;
};
struct _GimpHandleTransformToolClass
{
GimpTransformToolClass parent_class;
GimpGenericTransformToolClass parent_class;
};
......
......@@ -25,9 +25,6 @@
#include "tools-types.h"
#include "core/gimp-transform-utils.h"
#include "core/gimpimage.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
......@@ -57,20 +54,23 @@ enum
/* local function prototypes */
static void gimp_perspective_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool);
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar * gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool);
static GimpToolWidget * gimp_perspective_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar * gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
GimpToolWidget *widget);
static void gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
static void gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
G_DEFINE_TYPE (GimpPerspectiveTool, gimp_perspective_tool,
GIMP_TYPE_TRANSFORM_TOOL)
GIMP_TYPE_GENERIC_TRANSFORM_TOOL)
#define parent_class gimp_perspective_tool_parent_class
void
......@@ -94,14 +94,15 @@ gimp_perspective_tool_register (GimpToolRegisterCallback callback,
static void
gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
{
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
trans_class->dialog = gimp_perspective_tool_dialog;
trans_class->dialog_update = gimp_perspective_tool_dialog_update;
trans_class->prepare = gimp_perspective_tool_prepare;
trans_class->get_widget = gimp_perspective_tool_get_widget;
trans_class->recalc_matrix = gimp_perspective_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_perspective_tool_get_undo_desc;
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
trans_class->prepare = gimp_perspective_tool_prepare;
trans_class->get_widget = gimp_perspective_tool_get_widget;
trans_class->recalc_matrix = gimp_perspective_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_perspective_tool_get_undo_desc;
generic_class->recalc_points = gimp_perspective_tool_recalc_points;
}
static void
......@@ -116,61 +117,11 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
tr_tool->progress_text = _("Perspective transformation");
}
static void
gimp_perspective_tool_dialog (GimpTransformTool *tr_tool)
{
GimpPerspectiveTool *perspective = GIMP_PERSPECTIVE_TOOL (tr_tool);
GtkWidget *frame;
GtkWidget *table;
gint x, y;
frame = gimp_frame_new (_("Transformation Matrix"));
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++)
{
GtkWidget *label = gtk_label_new (" ");
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_width_chars (GTK_LABEL (label), 12);
gtk_table_attach (GTK_TABLE (table), label,
x, x + 1, y, y + 1, GTK_EXPAND, GTK_FILL, 0, 0);
gtk_widget_show (label);
perspective->label[y][x] = label;
}
}
static void
gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpPerspectiveTool *perspective = GIMP_PERSPECTIVE_TOOL (tr_tool);
gint x, y;
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++)
{
gchar buf[32];
g_snprintf (buf, sizeof (buf),
"%10.5f", tr_tool->transform.coeff[y][x]);
gtk_label_set_text (GTK_LABEL (perspective->label[y][x]), buf);
}
}
static void
gimp_perspective_tool_prepare (GimpTransformTool *tr_tool)
{
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->prepare (tr_tool);
tr_tool->trans_info[X0] = (gdouble) tr_tool->x1;
tr_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
tr_tool->trans_info[X1] = (gdouble) tr_tool->x2;
......@@ -213,20 +164,7 @@ static void
gimp_perspective_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget)
{
gimp_matrix3_identity (&tr_tool->transform);
gimp_transform_matrix_perspective (&tr_tool->transform,
tr_tool->x1,
tr_tool->y1,
tr_tool->x2 - tr_tool->x1,
tr_tool->y2 - tr_tool->y1,
tr_tool->trans_info[X0],
tr_tool->trans_info[Y0],
tr_tool->trans_info[X1],
tr_tool->trans_info[Y1],
tr_tool->trans_info[X2],
tr_tool->trans_info[Y2],
tr_tool->trans_info[X3],
tr_tool->trans_info[Y3]);
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
if (widget)
g_object_set (widget,
......@@ -244,6 +182,27 @@ gimp_perspective_tool_get_undo_desc (GimpTransformTool *tr_tool)
return g_strdup (C_("undo-type", "Perspective"));
}
static void
gimp_perspective_tool_recalc_points (GimpGenericTransformTool *generic,
GimpToolWidget *widget)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_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) {tr_tool->trans_info[X0],
tr_tool->trans_info[Y0]};
generic->output_points[1] = (GimpVector2) {tr_tool->trans_info[X1],
tr_tool->trans_info[Y1]};
generic->output_points[2] = (GimpVector2) {tr_tool->trans_info[X2],
tr_tool->trans_info[Y2]};
generic->output_points[3] = (GimpVector2) {tr_tool->trans_info[X3],
tr_tool->trans_info[Y3]};
}
static void
gimp_perspective_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool)
......
......@@ -19,7 +19,7 @@
#define __GIMP_PERSPECTIVE_TOOL_H__
#include "gimptransformtool.h"
#include "gimpgenerictransformtool.h"
#define GIMP_TYPE_PERSPECTIVE_TOOL (gimp_perspective_tool_get_type ())
......@@ -35,14 +35,12 @@ typedef struct _GimpPerspectiveToolClass GimpPerspectiveToolClass;
struct _GimpPerspectiveTool
{
GimpTransformTool parent_instance;
GtkWidget *label[3][3];
GimpGenericTransformTool parent_instance;
};
struct _GimpPerspectiveToolClass
{
GimpTransformToolClass parent_class;
GimpGenericTransformToolClass parent_class;
};
......
......@@ -25,8 +25,6 @@
#include "tools-types.h"
#include "core/gimp-transform-utils.h"
#include "widgets/gimphelp-ids.h"
#include "display/gimpdisplay.h"
......@@ -58,20 +56,23 @@ enum
/* local function prototypes */
static void gimp_unified_transform_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_prepare (GimpTransformTool *tr_tool);
static GimpToolWidget * gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar * gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_prepare (GimpTransformTool *tr_tool);
static GimpToolWidget * gimp_unified_transform_tool_get_widget (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
static gchar * gimp_unified_transform_tool_get_undo_desc (GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_recalc_points (GimpGenericTransformTool *generic,
GimpToolWidget *widget);
static void gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
static void gimp_unified_transform_tool_widget_changed (GimpToolWidget *widget,
GimpTransformTool *tr_tool);
G_DEFINE_TYPE (GimpUnifiedTransformTool, gimp_unified_transform_tool,
GIMP_TYPE_TRANSFORM_TOOL)
GIMP_TYPE_GENERIC_TRANSFORM_TOOL)
#define parent_class gimp_unified_transform_tool_parent_class
void
......@@ -95,14 +96,15 @@ gimp_unified_transform_tool_register (GimpToolRegisterCallback callback,
static void
gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
{
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
trans_class->dialog = gimp_unified_transform_tool_dialog;
trans_class->dialog_update = gimp_unified_transform_tool_dialog_update;
trans_class->prepare = gimp_unified_transform_tool_prepare;
trans_class->get_widget = gimp_unified_transform_tool_get_widget;
trans_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_unified_transform_tool_get_undo_desc;
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
trans_class->prepare = gimp_unified_transform_tool_prepare;
trans_class->get_widget = gimp_unified_transform_tool_get_widget;
trans_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
trans_class->get_undo_desc = gimp_unified_transform_tool_get_undo_desc;
generic_class->recalc_points = gimp_unified_transform_tool_recalc_points;
}
static void
......@@ -113,61 +115,11 @@ gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
tr_tool->progress_text = _("Unified transform");
}
static void
gimp_unified_transform_tool_dialog (GimpTransformTool *tr_tool)
{
GimpUnifiedTransformTool *unified = GIMP_UNIFIED_TRANSFORM_TOOL (tr_tool);
GtkWidget *frame;
GtkWidget *table;
gint x, y;
frame = gimp_frame_new (_("Transform Matrix"));
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
table = gtk_table_new (3, 3, FALSE);
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
gtk_container_add (GTK_CONTAINER (frame), table);
gtk_widget_show (table);
for (y = 0; y < 3; y++)
for (x = 0; x < 3; x++)
{
GtkWidget *label = gtk_label_new (" ");
gtk_label_set_xalign (GTK_LABEL (label), 1.0);
gtk_label_set_width_chars (GTK_LABEL (label), 12);
gtk_table_attach (GTK_TABLE (table), label,
x, x + 1, y, y + 1, GTK_EXPAND, GTK_FILL, 0, 0);
gtk_widget_show (label);
unified->label[y][x] = label;
}
}
static void
gimp_unified_transform_tool_dialog_update (GimpTransformTool *tr_tool)