Commit 1dbe7659 authored by Ell's avatar Ell

app: add GimpTransformGridTool; derive most transform tools from it

While most of our transform tools use an interactive transform
grid, and have similar behavior, the flip tool is an odd one out.
The new "auto straighten" function of the measure tool introduces
another tool that performs transformations, while not behaving like
the rest of the transform tools.

Factor out the parts of GimpTransformTool that handle user
interaction into GimpTransformGridTool (with corresponding
GimpTransformGridOptions, and GimpTransformGridToolUndo), and only
leave the basic transform functionality and options in
GimpTransformTool (and GimpTransformOptions).

Derive all the transform tools (and transform-tool base classes)
that previously derived from GimpTransformTool, from
GimpTransformGridTool.  The one exception is GimpFlipTool, which
still derives from GimpTransformTool directly.  The next commit
will derive GimpMeasureTool from GimpTransformTool as well.
parent 8d6f023b
......@@ -848,7 +848,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_VECTORS_REMOVE, "GIMP_UNDO_VECTORS_REMOVE", "vectors-remove" },
{ GIMP_UNDO_VECTORS_MOD, "GIMP_UNDO_VECTORS_MOD", "vectors-mod" },
{ GIMP_UNDO_FS_TO_LAYER, "GIMP_UNDO_FS_TO_LAYER", "fs-to-layer" },
{ GIMP_UNDO_TRANSFORM, "GIMP_UNDO_TRANSFORM", "transform" },
{ GIMP_UNDO_TRANSFORM_GRID, "GIMP_UNDO_TRANSFORM_GRID", "transform-grid" },
{ GIMP_UNDO_PAINT, "GIMP_UNDO_PAINT", "paint" },
{ GIMP_UNDO_INK, "GIMP_UNDO_INK", "ink" },
{ GIMP_UNDO_FOREGROUND_SELECT, "GIMP_UNDO_FOREGROUND_SELECT", "foreground-select" },
......@@ -946,7 +946,7 @@ gimp_undo_type_get_type (void)
{ GIMP_UNDO_VECTORS_REMOVE, NC_("undo-type", "Delete path"), NULL },
{ GIMP_UNDO_VECTORS_MOD, NC_("undo-type", "Path modification"), NULL },
{ GIMP_UNDO_FS_TO_LAYER, NC_("undo-type", "Floating selection to layer"), NULL },
{ GIMP_UNDO_TRANSFORM, NC_("undo-type", "Transform"), NULL },
{ GIMP_UNDO_TRANSFORM_GRID, NC_("undo-type", "Transform grid"), NULL },
{ GIMP_UNDO_PAINT, NC_("undo-type", "Paint"), NULL },
{ GIMP_UNDO_INK, NC_("undo-type", "Ink"), NULL },
{ GIMP_UNDO_FOREGROUND_SELECT, NC_("undo-type", "Select foreground"), NULL },
......
......@@ -444,7 +444,7 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_VECTORS_REMOVE, /*< desc="Delete path" >*/
GIMP_UNDO_VECTORS_MOD, /*< desc="Path modification" >*/
GIMP_UNDO_FS_TO_LAYER, /*< desc="Floating selection to layer" >*/
GIMP_UNDO_TRANSFORM, /*< desc="Transform" >*/
GIMP_UNDO_TRANSFORM_GRID, /*< desc="Transform grid" >*/
GIMP_UNDO_PAINT, /*< desc="Paint" >*/
GIMP_UNDO_INK, /*< desc="Ink" >*/
GIMP_UNDO_FOREGROUND_SELECT, /*< desc="Select foreground" >*/
......
......@@ -206,12 +206,16 @@ libapptools_a_sources = \
gimptoolcontrol.h \
gimptooloptions-gui.c \
gimptooloptions-gui.h \
gimptransformgridoptions.c \
gimptransformgridoptions.h \
gimptransformgridtool.c \
gimptransformgridtool.h \
gimptransformgridtoolundo.c \
gimptransformgridtoolundo.h \
gimptransformoptions.c \
gimptransformoptions.h \
gimptransformtool.c \
gimptransformtool.h \
gimptransformtoolundo.c \
gimptransformtoolundo.h \
gimpunifiedtransformtool.c \
gimpunifiedtransformtool.h \
gimpvectoroptions.c \
......
......@@ -28,7 +28,6 @@
#include "widgets/gimpwidgets-utils.h"
#include "gimpflipoptions.h"
#include "gimptooloptions-gui.h"
#include "gimp-intl.h"
......@@ -120,29 +119,16 @@ gimp_flip_options_gui (GimpToolOptions *tool_options)
GObject *config = G_OBJECT (tool_options);
GimpFlipOptions *options = GIMP_FLIP_OPTIONS (tool_options);
GimpTransformOptions *tr_options = GIMP_TRANSFORM_OPTIONS (tool_options);
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *hbox;
GtkWidget *box;
GtkWidget *label;
GtkWidget *vbox;
GtkWidget *frame;
GtkWidget *combo;
gchar *str;
GtkListStore *clip_model;
GdkModifierType toggle_mask;
toggle_mask = gimp_get_toggle_behavior_mask ();
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
vbox = gimp_transform_options_gui (tool_options, FALSE, FALSE, FALSE);
label = gtk_label_new (_("Transform:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
gtk_widget_show (label);
box = gimp_prop_enum_icon_box_new (config, "type", "gimp", 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), box, FALSE, FALSE, 0);
gtk_widget_show (box);
toggle_mask = gimp_get_toggle_behavior_mask ();
/* tool toggle */
str = g_strdup_printf (_("Direction (%s)"),
......
......@@ -54,37 +54,38 @@
/* local function prototypes */
static GimpDisplay * gimp_flip_tool_has_image (GimpTool *tool,
GimpImage *image);
static gboolean gimp_flip_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error);
static void gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_flip_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool);
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tool);
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *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);
static void gimp_flip_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display);
static void gimp_flip_tool_modifier_key (GimpTool *tool,
GdkModifierType key,
gboolean press,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_oper_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
gboolean proximity,
GimpDisplay *display);
static void gimp_flip_tool_cursor_update (GimpTool *tool,
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool);
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool);
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tr_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);
static GimpOrientationType gimp_flip_tool_get_flip_type (GimpFlipTool *flip);
......@@ -117,20 +118,19 @@ gimp_flip_tool_class_init (GimpFlipToolClass *klass)
{
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
tool_class->has_image = gimp_flip_tool_has_image;
tool_class->initialize = gimp_flip_tool_initialize;
tool_class->modifier_key = gimp_flip_tool_modifier_key;
tool_class->oper_update = gimp_flip_tool_oper_update;
tool_class->cursor_update = gimp_flip_tool_cursor_update;
tool_class->button_press = gimp_flip_tool_button_press;
tool_class->modifier_key = gimp_flip_tool_modifier_key;
tool_class->oper_update = gimp_flip_tool_oper_update;
tool_class->cursor_update = gimp_flip_tool_cursor_update;
draw_tool_class->draw = gimp_flip_tool_draw;
draw_tool_class->draw = gimp_flip_tool_draw;
trans_class->get_undo_desc = gimp_flip_tool_get_undo_desc;
trans_class->transform = gimp_flip_tool_transform;
tr_class->get_undo_desc = gimp_flip_tool_get_undo_desc;
tr_class->transform = gimp_flip_tool_transform;
trans_class->ok_button_label = _("_Flip");
tr_class->progress_text = _("Flipping");
}
static void
......@@ -151,26 +151,17 @@ gimp_flip_tool_init (GimpFlipTool *flip_tool)
flip_tool->guide = NULL;
}
static GimpDisplay *
gimp_flip_tool_has_image (GimpTool *tool,
GimpImage *image)
{
/* avoid committing, and hence flipping, when changing tools */
return NULL;
}
static gboolean
gimp_flip_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
static void
gimp_flip_tool_button_press (GimpTool *tool,
const GimpCoords *coords,
guint32 time,
GdkModifierType state,
GimpButtonPressType press_type,
GimpDisplay *display)
{
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
/* let GimpTransformTool take control over the draw tool while it's active */
if (gimp_draw_tool_is_active (draw_tool))
gimp_draw_tool_stop (draw_tool);
return GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
gimp_transform_tool_transform (tr_tool, display);
}
static void
......@@ -258,7 +249,17 @@ gimp_flip_tool_cursor_update (GimpTool *tool,
GdkModifierType state,
GimpDisplay *display)
{
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
if (! gimp_transform_tool_get_active_item (tr_tool, display, TRUE, NULL))
{
gimp_tool_set_cursor (tool, display,
gimp_tool_control_get_cursor (tool->control),
gimp_tool_control_get_tool_cursor (tool->control),
GIMP_CURSOR_MODIFIER_BAD);
return;
}
gimp_tool_control_set_toggled (tool->control,
gimp_flip_tool_get_flip_type (flip) ==
......@@ -309,7 +310,7 @@ gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool)
}
static GeglBuffer *
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
gimp_flip_tool_transform (GimpTransformTool *tr_tool,
GimpItem *active_item,
GeglBuffer *orig_buffer,
gint orig_offset_x,
......@@ -318,9 +319,9 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
gint *new_offset_x,
gint *new_offset_y)
{
GimpFlipTool *flip = GIMP_FLIP_TOOL (trans_tool);
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (trans_tool);
GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (trans_tool);
GimpFlipTool *flip = GIMP_FLIP_TOOL (tr_tool);
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tr_tool);
GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
GimpContext *context = GIMP_CONTEXT (options);
GimpOrientationType flip_type = GIMP_ORIENTATION_UNKNOWN;
gdouble axis = 0.0;
......@@ -338,13 +339,13 @@ gimp_flip_tool_transform (GimpTransformTool *trans_tool,
switch (flip_type)
{
case GIMP_ORIENTATION_HORIZONTAL:
axis = ((gdouble) trans_tool->x1 +
(gdouble) (trans_tool->x2 - trans_tool->x1) / 2.0);
axis = ((gdouble) tr_tool->x1 +
(gdouble) (tr_tool->x2 - tr_tool->x1) / 2.0);
break;
case GIMP_ORIENTATION_VERTICAL:
axis = ((gdouble) trans_tool->y1 +
(gdouble) (trans_tool->y2 - trans_tool->y1) / 2.0);
axis = ((gdouble) tr_tool->y1 +
(gdouble) (tr_tool->y2 - tr_tool->y1) / 2.0);
break;
default:
......
......@@ -35,33 +35,33 @@
#include "gimpgenerictransformtool.h"
#include "gimptoolcontrol.h"
#include "gimptransformoptions.h"
#include "gimptransformgridoptions.h"
#include "gimp-intl.h"
/* local function prototypes */
static void gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool);
static void gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget);
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_TOOL)
GIMP_TYPE_TRANSFORM_GRID_TOOL)
static void
gimp_generic_transform_tool_class_init (GimpGenericTransformToolClass *klass)
{
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
trans_class->dialog = gimp_generic_transform_tool_dialog;
trans_class->dialog_update = gimp_generic_transform_tool_dialog_update;
trans_class->prepare = gimp_generic_transform_tool_prepare;
trans_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
......@@ -70,9 +70,9 @@ gimp_generic_transform_tool_init (GimpGenericTransformTool *unified_tool)
}
static void
gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
gimp_generic_transform_tool_dialog (GimpTransformGridTool *tg_tool)
{
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *grid;
......@@ -81,7 +81,7 @@ gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
gint x, y;
frame = gimp_frame_new (_("Transform Matrix"));
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)), frame,
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), frame,
FALSE, FALSE, 0);
gtk_widget_show (frame);
......@@ -121,9 +121,10 @@ gimp_generic_transform_tool_dialog (GimpTransformTool *tr_tool)
}
static void
gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool)
gimp_generic_transform_tool_dialog_update (GimpTransformGridTool *tg_tool)
{
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
if (tr_tool->transform_valid)
{
......@@ -153,9 +154,10 @@ gimp_generic_transform_tool_dialog_update (GimpTransformTool *tr_tool)
}
static void
gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool)
gimp_generic_transform_tool_prepare (GimpTransformGridTool *tg_tool)
{
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tg_tool);
generic->input_points[0] = (GimpVector2) {tr_tool->x1, tr_tool->y1};
generic->input_points[1] = (GimpVector2) {tr_tool->x2, tr_tool->y1};
......@@ -167,10 +169,11 @@ gimp_generic_transform_tool_prepare (GimpTransformTool *tr_tool)
}
static void
gimp_generic_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget)
gimp_generic_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
GimpToolWidget *widget)
{
GimpGenericTransformTool *generic = GIMP_GENERIC_TRANSFORM_TOOL (tr_tool);
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)
{
......
......@@ -19,7 +19,7 @@
#define __GIMP_GENERIC_TRANSFORM_TOOL_H__
#include "gimptransformtool.h"
#include "gimptransformgridtool.h"
#define GIMP_TYPE_GENERIC_TRANSFORM_TOOL (gimp_generic_transform_tool_get_type ())
......@@ -34,19 +34,19 @@ typedef struct _GimpGenericTransformToolClass GimpGenericTransformToolClass;
struct _GimpGenericTransformTool
{
GimpTransformTool parent_instance;
GimpTransformGridTool parent_instance;
GimpVector2 input_points[4];
GimpVector2 output_points[4];
GimpVector2 input_points[4];
GimpVector2 output_points[4];
GtkWidget *matrix_grid;
GtkWidget *matrix_labels[3][3];
GtkWidget *invalid_label;
GtkWidget *matrix_grid;
GtkWidget *matrix_labels[3][3];
GtkWidget *invalid_label;
};
struct _GimpGenericTransformToolClass
{
GimpTransformToolClass parent_class;
GimpTransformGridToolClass parent_class;
/* virtual functions */
void (* recalc_points) (GimpGenericTransformTool *generic,
......
......@@ -55,7 +55,7 @@ static void gimp_handle_transform_options_get_property (GObject *objec
G_DEFINE_TYPE (GimpHandleTransformOptions, gimp_handle_transform_options,
GIMP_TYPE_TRANSFORM_OPTIONS)
GIMP_TYPE_TRANSFORM_GRID_OPTIONS)
#define parent_class gimp_handle_transform_options_parent_class
......@@ -134,7 +134,7 @@ GtkWidget *
gimp_handle_transform_options_gui (GimpToolOptions *tool_options)
{
GObject *config = G_OBJECT (tool_options);
GtkWidget *vbox = gimp_transform_options_gui (tool_options);
GtkWidget *vbox = gimp_transform_grid_options_gui (tool_options);
GtkWidget *frame;
GtkWidget *button;
gint i;
......
......@@ -19,7 +19,7 @@
#define __GIMP_HANDLE_TRANSFORM_OPTIONS_H__
#include "gimptransformoptions.h"
#include "gimptransformgridoptions.h"
#define GIMP_TYPE_HANDLE_TRANSFORM_OPTIONS (gimp_handle_transform_options_get_type ())
......@@ -35,14 +35,14 @@ typedef struct _GimpHandleTransformOptionsClass GimpHandleTransformOptionsClass;
struct _GimpHandleTransformOptions
{
GimpTransformOptions parent_instance;
GimpTransformGridOptions parent_instance;
GimpTransformHandleMode handle_mode;
};
struct _GimpHandleTransformOptionsClass
{
GimpTransformOptionsClass parent_class;
GimpTransformGridOptionsClass parent_class;
};
......
......@@ -83,18 +83,19 @@ static void gimp_handle_transform_tool_modifier_key (GimpTool
GdkModifierType state,
GimpDisplay *display);
static void gimp_handle_transform_tool_prepare (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 (GimpTransformTool *tr_tool);
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool);
static void gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_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);
GimpTransformGridTool *tg_tool);
G_DEFINE_TYPE (GimpHandleTransformTool, gimp_handle_transform_tool,
......@@ -125,26 +126,26 @@ 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);
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
GimpGenericTransformToolClass *generic_class = GIMP_GENERIC_TRANSFORM_TOOL_CLASS (klass);
tool_class->modifier_key = gimp_handle_transform_tool_modifier_key;
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;
tr_class->get_undo_desc = gimp_handle_transform_tool_get_undo_desc;
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;
generic_class->recalc_points = gimp_handle_transform_tool_recalc_points;
tr_class->progress_text = _("Handle transformation");
}
static void
gimp_handle_transform_tool_init (GimpHandleTransformTool *ht_tool)
{
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (ht_tool);
tr_tool->progress_text = _("Handle transformation");
ht_tool->saved_handle_mode = GIMP_HANDLE_MODE_ADD_TRANSFORM;
}
......@@ -202,39 +203,48 @@ gimp_handle_transform_tool_modifier_key (GimpTool *tool,
state, display);
}
static gchar *
gimp_handle_transform_tool_get_undo_desc (GimpTransformTool *tr_tool)
{
return g_strdup (C_("undo-type", "Handle transform"));
}
static void
gimp_handle_transform_tool_prepare (GimpTransformTool *tr_tool)
gimp_handle_transform_tool_prepare (GimpTransformGridTool *tg_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;
tr_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
tr_tool->trans_info[X2] = (gdouble) tr_tool->x1;
tr_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
tr_tool->trans_info[X3] = (gdouble) tr_tool->x2;
tr_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
tr_tool->trans_info[OX0] = (gdouble) tr_tool->x1;
tr_tool->trans_info[OY0] = (gdouble) tr_tool->y1;
tr_tool->trans_info[OX1] = (gdouble) tr_tool->x2;
tr_tool->trans_info[OY1] = (gdouble) tr_tool->y1;
tr_tool->trans_info[OX2] = (gdouble) tr_tool->x1;
tr_tool->trans_info[OY2] = (gdouble) tr_tool->y2;
tr_tool->trans_info[OX3] = (gdouble) tr_tool->x2;
tr_tool->trans_info[OY3] = (gdouble) tr_tool->y2;
tr_tool->trans_info[N_HANDLES] = 0;
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->prepare (tg_tool);
tg_tool->trans_info[X0] = (gdouble) tr_tool->x1;
tg_tool->trans_info[Y0] = (gdouble) tr_tool->y1;
tg_tool->trans_info[X1] = (gdouble) tr_tool->x2;
tg_tool->trans_info[Y1] = (gdouble) tr_tool->y1;
tg_tool->trans_info[X2] = (gdouble) tr_tool->x1;
tg_tool->trans_info[Y2] = (gdouble) tr_tool->y2;
tg_tool->trans_info[X3] = (gdouble) tr_tool->x2;
tg_tool->trans_info[Y3] = (gdouble) tr_tool->y2;
tg_tool->trans_info[OX0] = (gdouble) tr_tool->x1;
tg_tool->trans_info[OY0] = (gdouble) tr_tool->y1;
tg_tool->trans_info[OX1] = (gdouble) tr_tool->x2;
tg_tool->trans_info[OY1] = (gdouble) tr_tool->y1;
tg_tool->trans_info[OX2] = (gdouble) tr_tool->x1;
tg_tool->trans_info[OY2] = (gdouble) tr_tool->y2;
tg_tool->trans_info[OX3] = (gdouble) tr_tool->x2;
tg_tool->trans_info[OY3] = (gdouble) tr_tool->y2;
tg_tool->trans_info[N_HANDLES] = 0;
}
static GimpToolWidget *
gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
gimp_handle_transform_tool_get_widget (GimpTransformGridTool *tg_tool)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
GimpTool *tool = GIMP_TOOL (tg_tool);
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
GimpHandleTransformOptions *options;
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
GimpToolWidget *widget;
options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
options = GIMP_HANDLE_TRANSFORM_TOOL_GET_OPTIONS (tg_tool);
widget = gimp_tool_handle_grid_new (shell,
tr_tool->x1,
......@@ -243,23 +253,23 @@ gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
tr_tool->y2);
g_object_set (widget,
"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],
"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);
g_object_bind_property (G_OBJECT (options), "handle-mode",
......@@ -269,99 +279,95 @@ gimp_handle_transform_tool_get_widget (GimpTransformTool *tr_tool)
g_signal_connect (widget, "changed",
G_CALLBACK (gimp_handle_transform_tool_widget_changed),
tr_tool);
tg_tool);
return widget;
}
static void
gimp_handle_transform_tool_recalc_matrix (GimpTransformTool *tr_tool,
GimpToolWidget *widget)
gimp_handle_transform_tool_recalc_matrix (GimpTransformGridTool *tg_tool,
GimpToolWidget *widget)
{
GIMP_TRANSFORM_TOOL_CLASS (parent_class)->recalc_matrix (tr_tool, widget);
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) 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],
"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],