2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-10-27 06:02:44 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2007-03-09 21:00:01 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2003-09-16 01:41:18 +08:00
|
|
|
#include "core/gimp-transform-utils.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2006-04-03 15:50:06 +08:00
|
|
|
#include "widgets/gimpsizebox.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-27 06:16:59 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2013-06-07 17:52:48 +08:00
|
|
|
#include "display/gimptoolgui.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2001-04-29 04:14:32 +08:00
|
|
|
#include "gimpscaletool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2003-02-09 05:12:03 +08:00
|
|
|
#include "gimptransformoptions.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-10-27 06:02:44 +08:00
|
|
|
|
2011-03-28 06:50:46 +08:00
|
|
|
/* index into trans_info array */
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
X0,
|
|
|
|
Y0,
|
|
|
|
X1,
|
|
|
|
Y1,
|
|
|
|
X2,
|
|
|
|
Y2,
|
|
|
|
X3,
|
|
|
|
Y3
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2011-08-27 14:37:30 +08:00
|
|
|
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);
|
|
|
|
static void gimp_scale_tool_motion (GimpTransformTool *tr_tool);
|
|
|
|
static void gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool);
|
|
|
|
static gchar * gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2011-08-27 14:37:30 +08:00
|
|
|
static void gimp_scale_tool_size_notify (GtkWidget *box,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpTransformTool *tr_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpScaleTool, gimp_scale_tool, GIMP_TYPE_TRANSFORM_TOOL)
|
2001-03-25 12:08:51 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_scale_tool_parent_class
|
2001-03-31 22:10:22 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2001-03-25 12:08:51 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_scale_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-03-25 12:08:51 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_SCALE_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_TRANSFORM_OPTIONS,
|
|
|
|
gimp_transform_options_gui,
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-scale-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Scale"),
|
2006-10-17 17:38:51 +08:00
|
|
|
_("Scale Tool: Scale the layer, selection or path"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Scale"), "<shift>T",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_SCALE,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_SCALE,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-03-31 22:10:22 +08:00
|
|
|
}
|
2001-03-25 12:08:51 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_scale_tool_class_init (GimpScaleToolClass *klass)
|
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2001-03-25 12:08:51 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
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;
|
2011-03-28 05:12:11 +08:00
|
|
|
trans_class->recalc_matrix = gimp_scale_tool_recalc_matrix;
|
2011-08-27 14:37:30 +08:00
|
|
|
trans_class->get_undo_desc = gimp_scale_tool_get_undo_desc;
|
2001-03-25 12:08:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_scale_tool_init (GimpScaleTool *scale_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-10-21 05:27:34 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (scale_tool);
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (scale_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_RESIZE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2015-03-24 06:18:28 +08:00
|
|
|
tr_tool->progress_text = _("Scaling");
|
2006-08-24 06:13:17 +08:00
|
|
|
|
2015-03-24 06:18:28 +08:00
|
|
|
tr_tool->use_grid = TRUE;
|
|
|
|
tr_tool->use_corner_handles = TRUE;
|
|
|
|
tr_tool->use_side_handles = TRUE;
|
|
|
|
tr_tool->use_center_handle = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2002-11-14 19:54:57 +08:00
|
|
|
gimp_scale_tool_dialog (GimpTransformTool *tr_tool)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-08-07 00:27:13 +08:00
|
|
|
static void
|
|
|
|
gimp_scale_tool_dialog_update (GimpTransformTool *tr_tool)
|
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
2006-05-19 18:56:34 +08:00
|
|
|
|
2006-05-20 00:45:38 +08:00
|
|
|
gint width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
|
|
|
gint height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
2004-08-07 00:27:13 +08:00
|
|
|
|
2006-04-03 15:50:06 +08:00
|
|
|
g_object_set (GIMP_SCALE_TOOL (tr_tool)->box,
|
2006-05-19 18:56:34 +08:00
|
|
|
"width", width,
|
|
|
|
"height", height,
|
2012-08-11 20:42:39 +08:00
|
|
|
"keep-aspect", options->constrain_scale,
|
2006-04-03 15:50:06 +08:00
|
|
|
NULL);
|
2004-08-07 00:27:13 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2011-03-28 04:39:31 +08:00
|
|
|
gimp_scale_tool_prepare (GimpTransformTool *tr_tool)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpScaleTool *scale = GIMP_SCALE_TOOL (tr_tool);
|
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
2011-03-28 04:39:31 +08:00
|
|
|
GimpDisplay *display = GIMP_TOOL (tr_tool)->display;
|
2007-12-27 01:33:41 +08:00
|
|
|
gdouble xres;
|
|
|
|
gdouble yres;
|
2004-08-07 00:27:13 +08:00
|
|
|
|
2002-11-14 19:54:57 +08:00
|
|
|
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->y2;
|
2006-04-03 15:50:06 +08:00
|
|
|
|
2009-10-07 01:20:44 +08:00
|
|
|
gimp_image_get_resolution (gimp_display_get_image (display),
|
|
|
|
&xres, &yres);
|
2007-12-27 01:33:41 +08:00
|
|
|
|
2006-05-22 21:29:32 +08:00
|
|
|
if (scale->box)
|
2006-06-05 03:27:21 +08:00
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (scale->box,
|
|
|
|
gimp_scale_tool_size_notify,
|
|
|
|
tr_tool);
|
|
|
|
gtk_widget_destroy (scale->box);
|
|
|
|
}
|
2006-05-22 21:29:32 +08:00
|
|
|
|
|
|
|
/* Need to create a new GimpSizeBox widget because the initial
|
|
|
|
* width and height is what counts as 100%.
|
|
|
|
*/
|
|
|
|
scale->box =
|
|
|
|
g_object_new (GIMP_TYPE_SIZE_BOX,
|
|
|
|
"width", tr_tool->x2 - tr_tool->x1,
|
|
|
|
"height", tr_tool->y2 - tr_tool->y1,
|
2012-08-11 20:42:39 +08:00
|
|
|
"keep-aspect", options->constrain_scale,
|
2009-10-05 01:56:39 +08:00
|
|
|
"unit", gimp_display_get_shell (display)->unit,
|
2007-12-27 01:33:41 +08:00
|
|
|
"xresolution", xres,
|
|
|
|
"yresolution", yres,
|
2006-05-22 21:29:32 +08:00
|
|
|
NULL);
|
|
|
|
|
2013-06-07 17:52:48 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tr_tool->gui)),
|
2009-07-15 22:19:32 +08:00
|
|
|
scale->box, FALSE, FALSE, 0);
|
2006-05-22 21:29:32 +08:00
|
|
|
gtk_widget_show (scale->box);
|
|
|
|
|
|
|
|
g_signal_connect (scale->box, "notify",
|
|
|
|
G_CALLBACK (gimp_scale_tool_size_notify),
|
|
|
|
tr_tool);
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2011-03-28 04:39:31 +08:00
|
|
|
gimp_scale_tool_motion (GimpTransformTool *tr_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
2003-02-05 22:39:40 +08:00
|
|
|
gdouble *x1;
|
|
|
|
gdouble *y1;
|
|
|
|
gdouble *x2;
|
|
|
|
gdouble *y2;
|
2006-06-19 16:15:50 +08:00
|
|
|
gint dir_x;
|
|
|
|
gint dir_y;
|
|
|
|
gdouble diff_x = tr_tool->curx - tr_tool->lastx;
|
|
|
|
gdouble diff_y = tr_tool->cury - tr_tool->lasty;
|
2006-06-19 01:44:06 +08:00
|
|
|
|
2002-11-14 19:54:57 +08:00
|
|
|
switch (tr_tool->function)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-08-24 06:13:17 +08:00
|
|
|
case TRANSFORM_HANDLE_N:
|
|
|
|
diff_x = 0; /* and fall through */
|
2006-06-19 01:44:06 +08:00
|
|
|
case TRANSFORM_HANDLE_NW:
|
2002-11-14 19:54:57 +08:00
|
|
|
x1 = &tr_tool->trans_info[X0];
|
|
|
|
y1 = &tr_tool->trans_info[Y0];
|
|
|
|
x2 = &tr_tool->trans_info[X1];
|
|
|
|
y2 = &tr_tool->trans_info[Y1];
|
1997-11-25 06:05:25 +08:00
|
|
|
dir_x = dir_y = 1;
|
|
|
|
break;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-08-24 06:13:17 +08:00
|
|
|
case TRANSFORM_HANDLE_E:
|
|
|
|
diff_y = 0; /* and fall through */
|
2006-06-19 01:44:06 +08:00
|
|
|
case TRANSFORM_HANDLE_NE:
|
2002-11-14 19:54:57 +08:00
|
|
|
x1 = &tr_tool->trans_info[X1];
|
|
|
|
y1 = &tr_tool->trans_info[Y0];
|
|
|
|
x2 = &tr_tool->trans_info[X0];
|
|
|
|
y2 = &tr_tool->trans_info[Y1];
|
1997-11-25 06:05:25 +08:00
|
|
|
dir_x = -1;
|
|
|
|
dir_y = 1;
|
|
|
|
break;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-08-24 06:13:17 +08:00
|
|
|
case TRANSFORM_HANDLE_W:
|
|
|
|
diff_y = 0; /* and fall through */
|
2006-06-19 01:44:06 +08:00
|
|
|
case TRANSFORM_HANDLE_SW:
|
2002-11-14 19:54:57 +08:00
|
|
|
x1 = &tr_tool->trans_info[X0];
|
|
|
|
y1 = &tr_tool->trans_info[Y1];
|
|
|
|
x2 = &tr_tool->trans_info[X1];
|
|
|
|
y2 = &tr_tool->trans_info[Y0];
|
1997-11-25 06:05:25 +08:00
|
|
|
dir_x = 1;
|
|
|
|
dir_y = -1;
|
|
|
|
break;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-08-24 06:13:17 +08:00
|
|
|
case TRANSFORM_HANDLE_S:
|
|
|
|
diff_x = 0; /* and fall through */
|
2006-06-19 01:44:06 +08:00
|
|
|
case TRANSFORM_HANDLE_SE:
|
2002-11-14 19:54:57 +08:00
|
|
|
x1 = &tr_tool->trans_info[X1];
|
|
|
|
y1 = &tr_tool->trans_info[Y1];
|
|
|
|
x2 = &tr_tool->trans_info[X0];
|
|
|
|
y2 = &tr_tool->trans_info[Y0];
|
1997-11-25 06:05:25 +08:00
|
|
|
dir_x = dir_y = -1;
|
|
|
|
break;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2001-03-31 22:10:22 +08:00
|
|
|
case TRANSFORM_HANDLE_CENTER:
|
2002-11-14 19:54:57 +08:00
|
|
|
tr_tool->trans_info[X0] += diff_x;
|
|
|
|
tr_tool->trans_info[Y0] += diff_y;
|
|
|
|
tr_tool->trans_info[X1] += diff_x;
|
|
|
|
tr_tool->trans_info[Y1] += diff_y;
|
|
|
|
tr_tool->trans_info[X2] += diff_x;
|
|
|
|
tr_tool->trans_info[Y2] += diff_y;
|
|
|
|
tr_tool->trans_info[X3] += diff_x;
|
|
|
|
tr_tool->trans_info[Y3] += diff_y;
|
2001-03-31 22:10:22 +08:00
|
|
|
return;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2001-03-31 22:10:22 +08:00
|
|
|
default:
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-12-30 04:04:34 +08:00
|
|
|
*x1 += diff_x;
|
|
|
|
*y1 += diff_y;
|
|
|
|
|
2006-05-19 18:56:34 +08:00
|
|
|
/* if control is being held, constrain the aspect ratio */
|
2012-08-11 20:42:39 +08:00
|
|
|
if (options->constrain_scale)
|
2004-06-19 07:07:23 +08:00
|
|
|
{
|
2006-12-30 04:04:34 +08:00
|
|
|
/* FIXME: improve this */
|
|
|
|
gdouble h = tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0];
|
2004-06-19 07:07:23 +08:00
|
|
|
|
2006-12-30 04:04:34 +08:00
|
|
|
switch (tr_tool->function)
|
2004-08-05 19:12:58 +08:00
|
|
|
{
|
2006-12-30 04:04:34 +08:00
|
|
|
case TRANSFORM_HANDLE_NW:
|
|
|
|
case TRANSFORM_HANDLE_SW:
|
|
|
|
tr_tool->trans_info[X0] =
|
|
|
|
tr_tool->trans_info[X1] - tr_tool->aspect * h;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TRANSFORM_HANDLE_NE:
|
|
|
|
case TRANSFORM_HANDLE_SE:
|
|
|
|
tr_tool->trans_info[X1] =
|
|
|
|
tr_tool->trans_info[X0] + tr_tool->aspect * h;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2004-08-05 19:12:58 +08:00
|
|
|
}
|
2004-06-19 07:07:23 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (dir_x > 0)
|
|
|
|
{
|
2006-06-19 01:44:06 +08:00
|
|
|
if (*x1 >= *x2)
|
|
|
|
*x1 = *x2 - 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-19 01:44:06 +08:00
|
|
|
if (*x1 <= *x2)
|
|
|
|
*x1 = *x2 + 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (dir_y > 0)
|
|
|
|
{
|
2006-06-19 01:44:06 +08:00
|
|
|
if (*y1 >= *y2)
|
|
|
|
*y1 = *y2 - 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-06-19 01:44:06 +08:00
|
|
|
if (*y1 <= *y2)
|
|
|
|
*y1 = *y2 + 1;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
static void
|
2011-03-28 05:12:11 +08:00
|
|
|
gimp_scale_tool_recalc_matrix (GimpTransformTool *tr_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-03-22 03:10:11 +08:00
|
|
|
gimp_matrix3_identity (&tr_tool->transform);
|
|
|
|
gimp_transform_matrix_scale (&tr_tool->transform,
|
|
|
|
tr_tool->x1,
|
2003-09-16 01:41:18 +08:00
|
|
|
tr_tool->y1,
|
app/core/gimp-transform-utils.[ch]. switch from x1,y1,x2,y2 bounding boxes
2004-10-27 Michael Natterer <mitch@gimp.org>
* app/core/gimp-transform-utils.[ch]. switch from x1,y1,x2,y2
bounding boxes to x,y,width,height ones. Added
gimp_transform_matrix_flip_free(). Renamed some parameters to be
consistent with others. Some internal cleanup.
* app/tools/gimpperspectivetool.c
* app/tools/gimpscaletool.c
* app/tools/gimpsheartool.c
* tools/pdbgen/pdb/drawable_transform.pdb
* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
* tools/pdbgen/pdb/drawable_transform.pdb
* tools/pdbgen/pdb/transform_tools.pdb: guard all transform
wrappers with if(gimp_drawable_mask_intersect(...)), also the
ones which don't need the returned bounding box.
* tools/pdbgen/pdb/drawable_transform.pdb: renamed some parameters
and added gimp_drawable_transform_matrix() which takes the 9
coefficients of a 3x3 matrix for ultimate flexibility ;)
* app/pdb/drawable_transform_cmds.c
* app/pdb/internal_procs.c
* app/pdb/transform_tools_cmds.c
* libgimp/gimpdrawabletransform_pdb.[ch]: regenerated.
2004-10-28 01:56:02 +08:00
|
|
|
tr_tool->x2 - tr_tool->x1,
|
|
|
|
tr_tool->y2 - tr_tool->y1,
|
2003-09-16 01:41:18 +08:00
|
|
|
tr_tool->trans_info[X0],
|
|
|
|
tr_tool->trans_info[Y0],
|
app/core/gimp-transform-utils.[ch]. switch from x1,y1,x2,y2 bounding boxes
2004-10-27 Michael Natterer <mitch@gimp.org>
* app/core/gimp-transform-utils.[ch]. switch from x1,y1,x2,y2
bounding boxes to x,y,width,height ones. Added
gimp_transform_matrix_flip_free(). Renamed some parameters to be
consistent with others. Some internal cleanup.
* app/tools/gimpperspectivetool.c
* app/tools/gimpscaletool.c
* app/tools/gimpsheartool.c
* tools/pdbgen/pdb/drawable_transform.pdb
* tools/pdbgen/pdb/transform_tools.pdb: changed accordingly.
* tools/pdbgen/pdb/drawable_transform.pdb
* tools/pdbgen/pdb/transform_tools.pdb: guard all transform
wrappers with if(gimp_drawable_mask_intersect(...)), also the
ones which don't need the returned bounding box.
* tools/pdbgen/pdb/drawable_transform.pdb: renamed some parameters
and added gimp_drawable_transform_matrix() which takes the 9
coefficients of a 3x3 matrix for ultimate flexibility ;)
* app/pdb/drawable_transform_cmds.c
* app/pdb/internal_procs.c
* app/pdb/transform_tools_cmds.c
* libgimp/gimpdrawabletransform_pdb.[ch]: regenerated.
2004-10-28 01:56:02 +08:00
|
|
|
tr_tool->trans_info[X1] - tr_tool->trans_info[X0],
|
2005-03-22 03:10:11 +08:00
|
|
|
tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
|
2011-08-27 14:37:30 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_scale_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
|
|
|
{
|
|
|
|
gint width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
|
|
|
gint height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
|
|
|
|
|
|
|
return g_strdup_printf (C_("undo-type", "Scale to %d x %d"),
|
|
|
|
width, height);
|
|
|
|
}
|
|
|
|
|
2002-11-14 19:54:57 +08:00
|
|
|
static void
|
2006-04-03 15:50:06 +08:00
|
|
|
gimp_scale_tool_size_notify (GtkWidget *box,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpTransformTool *tr_tool)
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
if (! strcmp (pspec->name, "width") ||
|
|
|
|
! strcmp (pspec->name, "height"))
|
2006-05-19 18:56:34 +08:00
|
|
|
{
|
2006-06-05 03:27:21 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
gint old_width;
|
|
|
|
gint old_height;
|
|
|
|
|
|
|
|
g_object_get (box,
|
|
|
|
"width", &width,
|
|
|
|
"height", &height,
|
2006-05-19 18:56:34 +08:00
|
|
|
NULL);
|
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
old_width = ROUND (tr_tool->trans_info[X1] - tr_tool->trans_info[X0]);
|
|
|
|
old_height = ROUND (tr_tool->trans_info[Y1] - tr_tool->trans_info[Y0]);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
if ((width != old_width) || (height != old_height))
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tr_tool));
|
|
|
|
|
|
|
|
tr_tool->trans_info[X1] = tr_tool->trans_info[X0] + width;
|
|
|
|
tr_tool->trans_info[Y1] = tr_tool->trans_info[Y0] + height;
|
|
|
|
|
2011-08-13 23:42:41 +08:00
|
|
|
gimp_transform_tool_push_internal_undo (tr_tool);
|
|
|
|
|
2011-03-28 05:12:11 +08:00
|
|
|
gimp_transform_tool_recalc_matrix (tr_tool);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tr_tool));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (! strcmp (pspec->name, "keep-aspect"))
|
|
|
|
{
|
|
|
|
gboolean constrain;
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
g_object_get (box,
|
|
|
|
"keep-aspect", &constrain,
|
|
|
|
NULL);
|
2004-06-13 09:37:29 +08:00
|
|
|
|
2012-08-11 20:42:39 +08:00
|
|
|
if (constrain != options->constrain_scale)
|
2006-06-05 03:27:21 +08:00
|
|
|
{
|
2006-12-30 04:48:42 +08:00
|
|
|
gint width;
|
|
|
|
gint height;
|
|
|
|
|
|
|
|
g_object_get (box,
|
|
|
|
"width", &width,
|
|
|
|
"height", &height,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* Take the aspect ratio from the size box when the user
|
|
|
|
* activates the constraint by pressing the chain button.
|
|
|
|
*/
|
|
|
|
tr_tool->aspect = (gdouble) width / (gdouble) height;
|
|
|
|
|
2006-06-05 03:27:21 +08:00
|
|
|
g_object_set (options,
|
2012-08-11 20:42:39 +08:00
|
|
|
"constrain-scale", constrain,
|
2006-06-05 03:27:21 +08:00
|
|
|
NULL);
|
|
|
|
}
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
}
|