Commit db821565 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Transform tool cleanup:

2004-08-06  Michael Natterer  <mitch@gimp.org>

	Transform tool cleanup:

	* app/tools/gimptransformtool.[ch]: added new virtual function
	GimpTransformTool::dialog_update().
	Made wrapper for ::recalc() public and function
	transform_bounding_box() private.
	Call ::dialog_update() and transform_bounding_box() from the
	::recalc() wrapper.

	* app/tools/gimpperspectivetool.[ch]
	* app/tools/gimprotatetool.[ch]
	* app/tools/gimpscaletool.[ch]
	* app/tools/gimpsheartool.[ch]: turned all info_dialog update
	functions into GimpTransformTool::dialog_update() implementations
	and don't call them from ::recalc(), also removed calls to
	transform_bounding_box(); both functions are called by the parent
	class now. Call gimp_transform_tool_recalc() when dialog values
	were changed, not the tool's internal function.
	Moved all static variables to the instance structs.
parent 42bc755c
2004-08-06 Michael Natterer <mitch@gimp.org>
Transform tool cleanup:
* app/tools/gimptransformtool.[ch]: added new virtual function
GimpTransformTool::dialog_update().
Made wrapper for ::recalc() public and function
transform_bounding_box() private.
Call ::dialog_update() and transform_bounding_box() from the
::recalc() wrapper.
* app/tools/gimpperspectivetool.[ch]
* app/tools/gimprotatetool.[ch]
* app/tools/gimpscaletool.[ch]
* app/tools/gimpsheartool.[ch]: turned all info_dialog update
functions into GimpTransformTool::dialog_update() implementations
and don't call them from ::recalc(), also removed calls to
transform_bounding_box(); both functions are called by the parent
class now. Call gimp_transform_tool_recalc() when dialog values
were changed, not the tool's internal function.
Moved all static variables to the instance structs.
2004-08-06 Michael Natterer <mitch@gimp.org>
* app/tools/gimpsheartool.[ch]: applied (modified) patch from Ari
......
......@@ -52,19 +52,17 @@
static void gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass);
static void gimp_perspective_tool_init (GimpPerspectiveTool *tool);
static void gimp_perspective_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_perspective_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_perspective_tool_motion (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
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,
GimpDisplay *gdisp);
static void gimp_perspective_tool_motion (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void perspective_info_update (GimpTransformTool *tr_tool);
/* storage for information dialog fields */
static gchar matrix_row_buf [3][MAX_INFO_BUF];
/* private variables */
static GimpTransformToolClass *parent_class = NULL;
......@@ -123,10 +121,11 @@ gimp_perspective_tool_class_init (GimpPerspectiveToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
trans_class->dialog = gimp_perspective_tool_dialog;
trans_class->prepare = gimp_perspective_tool_prepare;
trans_class->motion = gimp_perspective_tool_motion;
trans_class->recalc = gimp_perspective_tool_recalc;
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->motion = gimp_perspective_tool_motion;
trans_class->recalc = gimp_perspective_tool_recalc;
}
static void
......@@ -145,12 +144,37 @@ gimp_perspective_tool_init (GimpPerspectiveTool *perspective_tool)
static void
gimp_perspective_tool_dialog (GimpTransformTool *tr_tool)
{
GimpPerspectiveTool *perspective = GIMP_PERSPECTIVE_TOOL (tr_tool);
info_dialog_add_label (tr_tool->info_dialog, _("Matrix:"),
matrix_row_buf[0]);
perspective->matrix_row_buf[0]);
info_dialog_add_label (tr_tool->info_dialog, "",
matrix_row_buf[1]);
perspective->matrix_row_buf[1]);
info_dialog_add_label (tr_tool->info_dialog, "",
matrix_row_buf[2]);
perspective->matrix_row_buf[2]);
}
static void
gimp_perspective_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpPerspectiveTool *perspective = GIMP_PERSPECTIVE_TOOL (tr_tool);
gint i;
for (i = 0; i < 3; i++)
{
gchar *p = perspective->matrix_row_buf[i];
gint j;
for (j = 0; j < 3; j++)
{
p += g_snprintf (p,
MAX_INFO_BUF - (p - perspective->matrix_row_buf[i]),
"%10.3g", tr_tool->transform.coeff[i][j]);
}
}
info_dialog_update (tr_tool->info_dialog);
info_dialog_show (tr_tool->info_dialog);
}
static void
......@@ -226,31 +250,4 @@ gimp_perspective_tool_recalc (GimpTransformTool *tr_tool,
tr_tool->trans_info[X3],
tr_tool->trans_info[Y3],
&tr_tool->transform);
/* transform the bounding box */
gimp_transform_tool_transform_bounding_box (tr_tool);
/* update the information dialog */
perspective_info_update (tr_tool);
}
static void
perspective_info_update (GimpTransformTool *tr_tool)
{
gint i;
for (i = 0; i < 3; i++)
{
gchar *p = matrix_row_buf[i];
gint j;
for (j = 0; j < 3; j++)
{
p += g_snprintf (p, MAX_INFO_BUF - (p - matrix_row_buf[i]),
"%10.3g", tr_tool->transform.coeff[i][j]);
}
}
info_dialog_update (tr_tool->info_dialog);
info_dialog_show (tr_tool->info_dialog);
}
......@@ -37,6 +37,9 @@ typedef struct _GimpPerspectiveToolClass GimpPerspectiveToolClass;
struct _GimpPerspectiveTool
{
GimpTransformTool parent_instance;
/* perspective dialog */
gchar matrix_row_buf [3][MAX_INFO_BUF];
};
struct _GimpPerspectiveToolClass
......
......@@ -60,31 +60,25 @@
/* local function prototypes */
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
static void gimp_rotate_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_rotate_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_rotate_tool_motion (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_rotate_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_rotate_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_rotate_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_rotate_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_rotate_tool_motion (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_rotate_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void rotate_info_update (GimpTransformTool *tr_tool);
static void rotate_angle_changed (GtkWidget *entry,
GimpTransformTool *tr_tool);
static void rotate_center_changed (GtkWidget *entry,
GimpTransformTool *tr_tool);
static void rotate_angle_changed (GtkWidget *entry,
GimpTransformTool *tr_tool);
static void rotate_center_changed (GtkWidget *entry,
GimpTransformTool *tr_tool);
/* variables local to this file */
static gdouble angle_val;
static gdouble center_vals[2];
/* needed for size update */
static GtkWidget *sizeentry = NULL;
/* private variables */
static GimpTransformToolClass *parent_class = NULL;
......@@ -146,10 +140,11 @@ gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
trans_class->dialog = gimp_rotate_tool_dialog;
trans_class->prepare = gimp_rotate_tool_prepare;
trans_class->motion = gimp_rotate_tool_motion;
trans_class->recalc = gimp_rotate_tool_recalc;
trans_class->dialog = gimp_rotate_tool_dialog;
trans_class->dialog_update = gimp_rotate_tool_dialog_update;
trans_class->prepare = gimp_rotate_tool_prepare;
trans_class->motion = gimp_rotate_tool_motion;
trans_class->recalc = gimp_rotate_tool_recalc;
}
static void
......@@ -167,11 +162,12 @@ gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
static void
gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
{
GtkWidget *widget;
GtkWidget *spinbutton2;
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
GtkWidget *widget;
GtkWidget *spinbutton2;
widget = info_dialog_add_spinbutton (tr_tool->info_dialog, _("Angle:"),
&angle_val,
&rotate->angle_val,
-180, 180, 1, 15, 1, 1, 2,
G_CALLBACK (rotate_angle_changed),
tr_tool);
......@@ -179,7 +175,7 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
/* this looks strange (-180, 181), but it works */
widget = info_dialog_add_scale (tr_tool->info_dialog, "",
&angle_val,
&rotate->angle_val,
-180, 181, 0.01, 0.1, 1, -1,
G_CALLBACK (rotate_angle_changed),
tr_tool);
......@@ -190,15 +186,15 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
NULL,
-1, 1, 1, 10, 1, 1, 2,
NULL, NULL);
sizeentry = info_dialog_add_sizeentry (tr_tool->info_dialog, _("Y:"),
center_vals, 1,
GIMP_UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
G_CALLBACK (rotate_center_changed),
tr_tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
rotate->sizeentry = info_dialog_add_sizeentry (tr_tool->info_dialog, _("Y:"),
rotate->center_vals, 1,
GIMP_UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
G_CALLBACK (rotate_center_changed),
tr_tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (rotate->sizeentry),
GTK_SPIN_BUTTON (spinbutton2), NULL);
gtk_table_set_row_spacing (GTK_TABLE (tr_tool->info_dialog->info_table),
......@@ -207,51 +203,66 @@ gimp_rotate_tool_dialog (GimpTransformTool *tr_tool)
2, 0);
}
static void
gimp_rotate_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
rotate->angle_val = gimp_rad_to_deg (tr_tool->trans_info[ANGLE]);
rotate->center_vals[0] = tr_tool->trans_info[CENTER_X];
rotate->center_vals[1] = tr_tool->trans_info[CENTER_Y];
info_dialog_update (tr_tool->info_dialog);
info_dialog_show (tr_tool->info_dialog);
}
static void
gimp_rotate_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
angle_val = 0.0;
center_vals[0] = tr_tool->cx;
center_vals[1] = tr_tool->cy;
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tr_tool);
g_signal_handlers_block_by_func (sizeentry,
rotate->angle_val = 0.0;
rotate->center_vals[0] = tr_tool->cx;
rotate->center_vals[1] = tr_tool->cy;
g_signal_handlers_block_by_func (rotate->sizeentry,
rotate_center_changed,
tr_tool);
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (rotate->sizeentry),
GIMP_DISPLAY_SHELL (gdisp->shell)->unit);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
gdisp->gimage->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
gdisp->gimage->yresolution, FALSE);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
-65536,
65536 + gdisp->gimage->width);
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
-65536,
65536 + gdisp->gimage->height);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
tr_tool->x1, tr_tool->x2);
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
tr_tool->y1, tr_tool->y2);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
center_vals[0]);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
center_vals[1]);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
rotate->center_vals[0]);
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
rotate->center_vals[1]);
g_signal_handlers_unblock_by_func (sizeentry,
g_signal_handlers_unblock_by_func (rotate->sizeentry,
rotate_center_changed,
tr_tool);
tr_tool->trans_info[ANGLE] = angle_val;
tr_tool->trans_info[REAL_ANGLE] = angle_val;
tr_tool->trans_info[CENTER_X] = center_vals[0];
tr_tool->trans_info[CENTER_Y] = center_vals[1];
tr_tool->trans_info[ANGLE] = rotate->angle_val;
tr_tool->trans_info[REAL_ANGLE] = rotate->angle_val;
tr_tool->trans_info[CENTER_X] = rotate->center_vals[0];
tr_tool->trans_info[CENTER_Y] = rotate->center_vals[1];
}
static void
......@@ -324,44 +335,20 @@ static void
gimp_rotate_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp)
{
gdouble cx, cy;
cx = tr_tool->trans_info[CENTER_X];
cy = tr_tool->trans_info[CENTER_Y];
tr_tool->cx = cx;
tr_tool->cy = cy;
tr_tool->cx = tr_tool->trans_info[CENTER_X];
tr_tool->cy = tr_tool->trans_info[CENTER_Y];
gimp_transform_matrix_rotate_center (tr_tool->cx,
tr_tool->cy,
tr_tool->trans_info[ANGLE],
&tr_tool->transform);
/* transform the bounding box */
gimp_transform_tool_transform_bounding_box (tr_tool);
/* update the information dialog */
rotate_info_update (tr_tool);
}
static void
rotate_info_update (GimpTransformTool *tr_tool)
{
angle_val = gimp_rad_to_deg (tr_tool->trans_info[ANGLE]);
center_vals[0] = tr_tool->trans_info[CENTER_X];
center_vals[1] = tr_tool->trans_info[CENTER_Y];
info_dialog_update (tr_tool->info_dialog);
info_dialog_show (tr_tool->info_dialog);
}
static void
rotate_angle_changed (GtkWidget *widget,
GimpTransformTool *tr_tool)
{
gdouble value;
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
gdouble value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
#define ANGLE_EPSILON 0.0001
......@@ -371,7 +358,7 @@ rotate_angle_changed (GtkWidget *widget,
tr_tool->trans_info[ANGLE] = value;
gimp_rotate_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_expose_preview (tr_tool);
......@@ -385,11 +372,8 @@ static void
rotate_center_changed (GtkWidget *widget,
GimpTransformTool *tr_tool)
{
gdouble cx;
gdouble cy;
cx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
cy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
gdouble cx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
gdouble cy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
if ((cx != tr_tool->trans_info[CENTER_X]) ||
(cy != tr_tool->trans_info[CENTER_Y]))
......@@ -401,7 +385,7 @@ rotate_center_changed (GtkWidget *widget,
tr_tool->cx = cx;
tr_tool->cy = cy;
gimp_rotate_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_recalc (tr_tool, GIMP_TOOL (tr_tool)->gdisp);
gimp_transform_tool_expose_preview (tr_tool);
......
......@@ -37,6 +37,12 @@ typedef struct _GimpRotateToolClass GimpRotateToolClass;
struct _GimpRotateTool
{
GimpTransformTool parent_instance;
/* rotate dialog */
gdouble angle_val;
gdouble center_vals[2];
GtkWidget *sizeentry;
};
struct _GimpRotateToolClass
......
......@@ -56,6 +56,7 @@ static void gimp_scale_tool_class_init (GimpScaleToolClass *klass);
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
static void gimp_scale_tool_dialog (GimpTransformTool *tr_tool);
static void gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool);
static void gimp_scale_tool_prepare (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_scale_tool_motion (GimpTransformTool *tr_tool,
......@@ -63,8 +64,6 @@ static void gimp_scale_tool_motion (GimpTransformTool *tr_tool,
static void gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
GimpDisplay *gdisp);
static void gimp_scale_tool_info_update (GimpTransformTool *tr_tool);
static void gimp_scale_tool_size_changed (GtkWidget *widget,
GimpTransformTool *tr_tool);
static void gimp_scale_tool_unit_changed (GtkWidget *widget,
......@@ -73,15 +72,7 @@ static void gimp_scale_tool_aspect_changed (GtkWidget *widget,
GimpTransformTool *tr_tool);
/* storage for information dialog fields */
static gchar orig_width_buf[MAX_INFO_BUF];
static gchar orig_height_buf[MAX_INFO_BUF];
static gdouble size_vals[2];
static gchar x_ratio_buf[MAX_INFO_BUF];
static gchar y_ratio_buf[MAX_INFO_BUF];
/* needed for original size unit update */
static GtkWidget *sizeentry = NULL;
/* private variables */
static GimpTransformToolClass *parent_class = NULL;
......@@ -143,10 +134,11 @@ gimp_scale_tool_class_init (GimpScaleToolClass *klass)
parent_class = g_type_class_peek_parent (klass);
trans_class->dialog = gimp_scale_tool_dialog;
trans_class->prepare = gimp_scale_tool_prepare;
trans_class->motion = gimp_scale_tool_motion;
trans_class->recalc = gimp_scale_tool_recalc;
trans_class->dialog = gimp_scale_tool_dialog;
trans_class->dialog_update = gimp_scale_tool_dialog_update;
trans_class->prepare = gimp_scale_tool_prepare;
trans_class->motion = gimp_scale_tool_motion;
trans_class->recalc = gimp_scale_tool_recalc;
}
static void
......@@ -164,40 +156,41 @@ gimp_scale_tool_init (GimpScaleTool *scale_tool)
static void
gimp_scale_tool_dialog (GimpTransformTool *tr_tool)
{
GtkWidget *spinbutton;
GimpScaleTool *scale = GIMP_SCALE_TOOL (tr_tool);
GtkWidget *spinbutton;
info_dialog_add_label (tr_tool->info_dialog,
_("Original Width:"),
orig_width_buf);
scale->orig_width_buf);
info_dialog_add_label (tr_tool->info_dialog,
_("Height:"),
orig_height_buf);
scale->orig_height_buf);
spinbutton = info_dialog_add_spinbutton (tr_tool->info_dialog,
_("Current width:"),
NULL, -1, 1, 1, 10, 1, 1, 2,
NULL, NULL);
sizeentry = info_dialog_add_sizeentry (tr_tool->info_dialog,
_("Current height:"),
size_vals, 1,
GIMP_UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
G_CALLBACK (gimp_scale_tool_size_changed),
tr_tool);
g_signal_connect (sizeentry, "unit_changed",
scale->sizeentry = info_dialog_add_sizeentry (tr_tool->info_dialog,
_("Current height:"),
scale->size_vals, 1,
GIMP_UNIT_PIXEL, "%a",
TRUE, TRUE, FALSE,
GIMP_SIZE_ENTRY_UPDATE_SIZE,
G_CALLBACK (gimp_scale_tool_size_changed),
tr_tool);
g_signal_connect (scale->sizeentry, "unit_changed",
G_CALLBACK (gimp_scale_tool_unit_changed),
tr_tool);
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (scale->sizeentry),
GTK_SPIN_BUTTON (spinbutton), NULL);
info_dialog_add_label (tr_tool->info_dialog,
_("Scale ratio X:"),
x_ratio_buf);
scale->x_ratio_buf);
info_dialog_add_label (tr_tool->info_dialog,
_("Scale ratio Y:"),
y_ratio_buf);
scale->y_ratio_buf);
spinbutton = info_dialog_add_spinbutton (tr_tool->info_dialog,
_("Aspect Ratio:"),
......@@ -212,49 +205,140 @@ gimp_scale_tool_dialog (GimpTransformTool *tr_tool)
2, 0);
}
static void
gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool)
{
GimpTool *tool = GIMP_TOOL (tr_tool);
GimpScaleTool *scale = GIMP_SCALE_TOOL (tr_tool);
GimpTransformOptions *options;
Gimp *gimp;
gdouble ratio_x, ratio_y;
gint x1, y1, x2, y2, x3, y3, x4, y4;
GimpUnit unit;
gdouble unit_factor;
gchar format_buf[16];
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
options = GIMP_TRANSFORM_OPTIONS (tool->tool_info->tool_options);
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (scale->sizeentry));
/* Find original sizes */
x1 = tr_tool->x1;
y1 = tr_tool->y1;
x2 = tr_tool->x2;
y2 = tr_tool->y2;
if (unit != GIMP_UNIT_PERCENT)
label_unit = unit;
gimp = tool->tool_info->gimp;
unit_factor = _gimp_unit_get_factor (gimp, label_unit);
if (label_unit) /* unit != GIMP_UNIT_PIXEL */
{
g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s",
_gimp_unit_get_digits (gimp, label_unit) + 1,
_gimp_unit_get_symbol (gimp, label_unit));
g_snprintf (scale->orig_width_buf, MAX_INFO_BUF, format_buf,
(x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution);
g_snprintf (scale->orig_height_buf, MAX_INFO_BUF, format_buf,
(y2 - y1) * unit_factor / tool->gdisp->gimage->yresolution);
}
else /* unit == GIMP_UNIT_PIXEL */
{
g_snprintf (scale->orig_width_buf, MAX_INFO_BUF, "%d", x2 - x1);
g_snprintf (scale->orig_height_buf, MAX_INFO_BUF, "%d", y2 - y1);
}
/* Find current sizes */
x3 = (gint) tr_tool->trans_info[X0];
y3 = (gint) tr_tool->trans_info[Y0];