1997-11-24 22:05:25 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (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
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-10-26 22:02:44 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 13:58:46 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2001-05-09 22:34:59 +00:00
|
|
|
#include "tools-types.h"
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gui/gui-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-19 18:23:43 +00:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
|
|
|
#include "core/gimpdrawable-transform-utils.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
2001-01-23 13:01:48 +00:00
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
2001-04-28 20:14:32 +00:00
|
|
|
#include "gimpscaletool.h"
|
|
|
|
#include "transform_options.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-14 23:23:52 +00:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
2000-10-26 22:02:44 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
/* local function prototypes */
|
|
|
|
|
|
|
|
static void gimp_scale_tool_class_init (GimpScaleToolClass *klass);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
static void gimp_scale_tool_init (GimpScaleTool *sc_tool);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
static TileManager * gimp_scale_tool_transform (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state);
|
|
|
|
|
|
|
|
static void gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_scale_tool_motion (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void gimp_scale_tool_info_update (GimpTransformTool *tr_tool);
|
|
|
|
|
|
|
|
static void gimp_scale_tool_size_changed (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void gimp_scale_tool_unit_changed (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* storage for information dialog fields */
|
1999-05-31 14:11:10 +00:00
|
|
|
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];
|
1999-04-02 19:46:59 +00:00
|
|
|
|
|
|
|
/* needed for original size unit update */
|
2000-12-31 04:07:42 +00:00
|
|
|
static GtkWidget *sizeentry = NULL;
|
2001-07-07 12:17:23 +00:00
|
|
|
|
2001-03-25 04:08:51 +00:00
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
|
|
|
|
2001-03-31 14:10:22 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2001-03-25 04:08:51 +00:00
|
|
|
void
|
2001-11-20 23:00:47 +00:00
|
|
|
gimp_scale_tool_register (Gimp *gimp,
|
|
|
|
GimpToolRegisterCallback callback)
|
2001-03-25 04:08:51 +00:00
|
|
|
{
|
2001-11-20 23:00:47 +00:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_SCALE_TOOL,
|
|
|
|
transform_options_new,
|
|
|
|
FALSE,
|
|
|
|
"gimp:scale_tool",
|
|
|
|
_("Scale Tool"),
|
|
|
|
_("Scale the layer or selection"),
|
|
|
|
N_("/Tools/Transform Tools/Scale"), "<shift>T",
|
|
|
|
NULL, "tools/transform.html",
|
|
|
|
GIMP_STOCK_TOOL_SCALE);
|
2001-03-31 14:10:22 +00:00
|
|
|
}
|
2001-03-25 04:08:51 +00:00
|
|
|
|
2001-08-05 16:08:19 +00:00
|
|
|
GType
|
2001-03-25 04:08:51 +00:00
|
|
|
gimp_scale_tool_get_type (void)
|
|
|
|
{
|
2001-08-05 16:08:19 +00:00
|
|
|
static GType tool_type = 0;
|
2001-03-25 04:08:51 +00:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-03-25 04:08:51 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpScaleToolClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_scale_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpScaleTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_scale_tool_init,
|
2001-03-25 04:08:51 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
|
|
|
"GimpScaleTool",
|
|
|
|
&tool_info, 0);
|
2001-03-25 04:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-03-25 04:08:51 +00:00
|
|
|
static void
|
|
|
|
gimp_scale_tool_class_init (GimpScaleToolClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GimpToolClass *tool_class;
|
|
|
|
GimpTransformToolClass *transform_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass *) klass;
|
|
|
|
tool_class = (GimpToolClass *) klass;
|
|
|
|
transform_class = (GimpTransformToolClass *) klass;
|
|
|
|
|
2001-08-05 16:08:19 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-03-25 04:08:51 +00:00
|
|
|
|
|
|
|
transform_class->transform = gimp_scale_tool_transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_init (GimpScaleTool *scale_tool)
|
2001-03-25 04:08:51 +00:00
|
|
|
{
|
2001-11-20 23:00:47 +00:00
|
|
|
GimpTool *tool;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
tool = GIMP_TOOL (scale_tool);
|
2001-04-28 20:14:32 +00:00
|
|
|
|
2001-03-31 14:10:22 +00:00
|
|
|
tool->tool_cursor = GIMP_RESIZE_TOOL_CURSOR;
|
2001-03-25 04:08:51 +00:00
|
|
|
}
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2000-12-31 04:07:42 +00:00
|
|
|
static TileManager *
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_INIT:
|
2001-11-19 18:23:43 +00:00
|
|
|
size_vals[0] = transform_tool->x2 - transform_tool->x1;
|
|
|
|
size_vals[1] = transform_tool->y2 - transform_tool->y1;
|
1999-05-31 21:46:43 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
if (! transform_tool->info_dialog)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
transform_tool->info_dialog =
|
|
|
|
info_dialog_new (_("Scaling Information"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"tools/transform_scale.html");
|
1999-04-02 19:46:59 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
gimp_transform_tool_info_dialog_connect (transform_tool,
|
2001-11-22 14:28:39 +00:00
|
|
|
GIMP_STOCK_TOOL_SCALE);
|
2001-11-22 13:01:26 +00:00
|
|
|
|
|
|
|
info_dialog_add_label (transform_tool->info_dialog,
|
|
|
|
_("Original Width:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
orig_width_buf);
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_label (transform_tool->info_dialog,
|
|
|
|
_("Height:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
orig_height_buf);
|
|
|
|
|
1999-04-06 12:13:54 +00:00
|
|
|
spinbutton =
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog,
|
|
|
|
_("Current Width:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
NULL, -1, 1, 1, 10, 1, 1, 2, NULL, NULL);
|
|
|
|
sizeentry =
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_sizeentry (transform_tool->info_dialog,
|
|
|
|
_("Height:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
size_vals, 1,
|
1999-05-22 17:56:35 +00:00
|
|
|
gdisp->gimage->unit, "%a",
|
1999-04-06 12:13:54 +00:00
|
|
|
TRUE, TRUE, FALSE,
|
1999-04-05 12:48:48 +00:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 21:27:11 +00:00
|
|
|
G_CALLBACK (gimp_scale_tool_size_changed),
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 21:27:11 +00:00
|
|
|
g_signal_connect (G_OBJECT (sizeentry), "unit_changed",
|
|
|
|
G_CALLBACK (gimp_scale_tool_unit_changed),
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-04-02 19:46:59 +00:00
|
|
|
|
1999-05-31 21:46:43 +00:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
1999-04-02 19:46:59 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_label (transform_tool->info_dialog,
|
|
|
|
_("Scale Ratio X:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
x_ratio_buf);
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_label (transform_tool->info_dialog,
|
|
|
|
_("Y:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
y_ratio_buf);
|
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
gtk_table_set_row_spacing
|
|
|
|
(GTK_TABLE (transform_tool->info_dialog->info_table), 1, 4);
|
|
|
|
gtk_table_set_row_spacing
|
|
|
|
(GTK_TABLE (transform_tool->info_dialog->info_table), 2, 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
1999-05-31 21:46:43 +00:00
|
|
|
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
|
|
|
gimp_scale_tool_size_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
|
|
|
gimp_scale_tool_unit_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
gdisp->gimage->unit);
|
|
|
|
if (gdisp->dot_for_dot)
|
2000-02-07 20:35:13 +00:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
gdisp->gimage->xresolution, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
gdisp->gimage->yresolution, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
GIMP_MIN_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
1999-05-31 21:46:43 +00:00
|
|
|
0, size_vals[0]);
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
1999-05-31 21:46:43 +00:00
|
|
|
0, size_vals[1]);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
size_vals[0]);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
size_vals[1]);
|
|
|
|
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
|
|
|
gimp_scale_tool_size_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
|
|
|
gimp_scale_tool_unit_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-04-06 12:13:54 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (transform_tool->info_dialog->shell),
|
|
|
|
TRUE);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool->trans_info[X0] = (gdouble) transform_tool->x1;
|
|
|
|
transform_tool->trans_info[Y0] = (gdouble) transform_tool->y1;
|
|
|
|
transform_tool->trans_info[X1] = (gdouble) transform_tool->x2;
|
|
|
|
transform_tool->trans_info[Y1] = (gdouble) transform_tool->y2;
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_MOTION:
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_motion (transform_tool, gdisp);
|
|
|
|
gimp_scale_tool_recalc (transform_tool, gdisp);
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_RECALC:
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_recalc (transform_tool, gdisp);
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_FINISH:
|
2001-11-19 18:23:43 +00:00
|
|
|
return gimp_transform_tool_transform_tiles (transform_tool,
|
|
|
|
_("Scaling..."));
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_info_update (GimpTransformTool *transform_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-03-25 04:08:51 +00:00
|
|
|
GimpTool *tool;
|
|
|
|
gdouble ratio_x, ratio_y;
|
|
|
|
gint x1, y1, x2, y2, x3, y3, x4, y4;
|
|
|
|
GimpUnit unit;
|
|
|
|
gdouble unit_factor;
|
|
|
|
gchar format_buf[16];
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-02-07 20:35:13 +00:00
|
|
|
static GimpUnit label_unit = GIMP_UNIT_PIXEL;
|
1999-04-06 12:13:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
tool = GIMP_TOOL (transform_tool);
|
|
|
|
|
|
|
|
unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (sizeentry));;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Find original sizes */
|
2001-11-19 18:23:43 +00:00
|
|
|
x1 = transform_tool->x1;
|
|
|
|
y1 = transform_tool->y1;
|
|
|
|
x2 = transform_tool->x2;
|
|
|
|
y2 = transform_tool->y2;
|
1999-04-02 19:46:59 +00:00
|
|
|
|
2000-02-07 20:35:13 +00:00
|
|
|
if (unit != GIMP_UNIT_PERCENT)
|
1999-04-06 12:13:54 +00:00
|
|
|
label_unit = unit;
|
|
|
|
|
|
|
|
unit_factor = gimp_unit_get_factor (label_unit);
|
|
|
|
|
2000-02-07 20:35:13 +00:00
|
|
|
if (label_unit) /* unit != GIMP_UNIT_PIXEL */
|
1999-04-02 19:46:59 +00:00
|
|
|
{
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-22 16:21:10 +00:00
|
|
|
g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s",
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_unit_get_digits (label_unit) + 1,
|
|
|
|
gimp_unit_get_symbol (label_unit));
|
1999-04-02 19:46:59 +00:00
|
|
|
g_snprintf (orig_width_buf, MAX_INFO_BUF, format_buf,
|
2000-12-31 04:07:42 +00:00
|
|
|
(x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution);
|
1999-04-02 19:46:59 +00:00
|
|
|
g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf,
|
2000-12-31 04:07:42 +00:00
|
|
|
(y2 - y1) * unit_factor / tool->gdisp->gimage->yresolution);
|
1999-04-02 19:46:59 +00:00
|
|
|
}
|
2000-02-07 20:35:13 +00:00
|
|
|
else /* unit == GIMP_UNIT_PIXEL */
|
1999-04-02 19:46:59 +00:00
|
|
|
{
|
|
|
|
g_snprintf (orig_width_buf, MAX_INFO_BUF, "%d", x2 - x1);
|
|
|
|
g_snprintf (orig_height_buf, MAX_INFO_BUF, "%d", y2 - y1);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* Find current sizes */
|
2001-11-22 14:28:39 +00:00
|
|
|
x3 = (gint) transform_tool->trans_info[X0];
|
|
|
|
y3 = (gint) transform_tool->trans_info[Y0];
|
|
|
|
x4 = (gint) transform_tool->trans_info[X1];
|
|
|
|
y4 = (gint) transform_tool->trans_info[Y1];
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-02 19:46:59 +00:00
|
|
|
size_vals[0] = x4 - x3;
|
|
|
|
size_vals[1] = y4 - y3;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
ratio_x = ratio_y = 0.0;
|
|
|
|
|
|
|
|
if (x2 - x1)
|
|
|
|
ratio_x = (double) (x4 - x3) / (double) (x2 - x1);
|
|
|
|
if (y2 - y1)
|
|
|
|
ratio_y = (double) (y4 - y3) / (double) (y2 - y1);
|
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
g_snprintf (x_ratio_buf, sizeof (x_ratio_buf), "%0.2f", ratio_x);
|
|
|
|
g_snprintf (y_ratio_buf, sizeof (y_ratio_buf), "%0.2f", ratio_y);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_update (transform_tool->info_dialog);
|
|
|
|
info_dialog_popup (transform_tool->info_dialog);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1998-08-15 13:34:54 +00:00
|
|
|
static void
|
2001-03-25 04:08:51 +00:00
|
|
|
gimp_scale_tool_size_changed (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
GimpTransformTool *transform_tool;
|
2001-03-25 04:08:51 +00:00
|
|
|
GimpTool *tool;
|
|
|
|
gint width;
|
|
|
|
gint height;
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
|
|
|
|
width = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0));
|
|
|
|
height = RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1));
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
if ((width != (transform_tool->trans_info[X1] -
|
|
|
|
transform_tool->trans_info[X0])) ||
|
|
|
|
(height != (transform_tool->trans_info[Y1] -
|
|
|
|
transform_tool->trans_info[Y0])))
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool->trans_info[X1] = transform_tool->trans_info[X0] + width;
|
|
|
|
transform_tool->trans_info[Y1] = transform_tool->trans_info[Y0] + height;
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_recalc (transform_tool, tool->gdisp);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 13:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-03-25 04:08:51 +00:00
|
|
|
gimp_scale_tool_unit_changed (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_info_update (GIMP_TRANSFORM_TOOL (data));
|
1998-08-15 13:34:54 +00:00
|
|
|
}
|
|
|
|
|
1998-03-18 22:35:31 +00:00
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_motion (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-29 16:44:51 +00:00
|
|
|
TransformOptions *options;
|
|
|
|
gdouble ratio;
|
|
|
|
gdouble *x1;
|
|
|
|
gdouble *y1;
|
|
|
|
gdouble *x2;
|
|
|
|
gdouble *y2;
|
|
|
|
gint w, h;
|
|
|
|
gint dir_x, dir_y;
|
2002-02-20 09:59:50 +00:00
|
|
|
gdouble diff_x, diff_y;
|
2001-11-29 16:44:51 +00:00
|
|
|
|
|
|
|
options = (TransformOptions *) GIMP_TOOL (transform_tool)->tool_info->tool_options;
|
2001-11-19 18:23:43 +00:00
|
|
|
|
|
|
|
diff_x = transform_tool->curx - transform_tool->lastx;
|
|
|
|
diff_y = transform_tool->cury - transform_tool->lasty;
|
|
|
|
|
|
|
|
switch (transform_tool->function)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_HANDLE_1:
|
2001-11-22 14:28:39 +00:00
|
|
|
x1 = &transform_tool->trans_info[X0];
|
|
|
|
y1 = &transform_tool->trans_info[Y0];
|
|
|
|
x2 = &transform_tool->trans_info[X1];
|
|
|
|
y2 = &transform_tool->trans_info[Y1];
|
1997-11-24 22:05:25 +00:00
|
|
|
dir_x = dir_y = 1;
|
|
|
|
break;
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_HANDLE_2:
|
2001-11-22 14:28:39 +00:00
|
|
|
x1 = &transform_tool->trans_info[X1];
|
|
|
|
y1 = &transform_tool->trans_info[Y0];
|
|
|
|
x2 = &transform_tool->trans_info[X0];
|
|
|
|
y2 = &transform_tool->trans_info[Y1];
|
1997-11-24 22:05:25 +00:00
|
|
|
dir_x = -1;
|
|
|
|
dir_y = 1;
|
|
|
|
break;
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_HANDLE_3:
|
2001-11-22 14:28:39 +00:00
|
|
|
x1 = &transform_tool->trans_info[X0];
|
|
|
|
y1 = &transform_tool->trans_info[Y1];
|
|
|
|
x2 = &transform_tool->trans_info[X1];
|
|
|
|
y2 = &transform_tool->trans_info[Y0];
|
1997-11-24 22:05:25 +00:00
|
|
|
dir_x = 1;
|
|
|
|
dir_y = -1;
|
|
|
|
break;
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_HANDLE_4:
|
2001-11-22 14:28:39 +00:00
|
|
|
x1 = &transform_tool->trans_info[X1];
|
|
|
|
y1 = &transform_tool->trans_info[Y1];
|
|
|
|
x2 = &transform_tool->trans_info[X0];
|
|
|
|
y2 = &transform_tool->trans_info[Y0];
|
1997-11-24 22:05:25 +00:00
|
|
|
dir_x = dir_y = -1;
|
|
|
|
break;
|
2001-03-31 14:10:22 +00:00
|
|
|
case TRANSFORM_HANDLE_CENTER:
|
2001-11-22 14:28:39 +00:00
|
|
|
transform_tool->trans_info[X0] += diff_x;
|
|
|
|
transform_tool->trans_info[Y0] += diff_y;
|
|
|
|
transform_tool->trans_info[X1] += diff_x;
|
|
|
|
transform_tool->trans_info[Y1] += diff_y;
|
|
|
|
transform_tool->trans_info[X2] += diff_x;
|
|
|
|
transform_tool->trans_info[Y2] += diff_y;
|
|
|
|
transform_tool->trans_info[X3] += diff_x;
|
|
|
|
transform_tool->trans_info[Y3] += diff_y;
|
2001-03-31 14:10:22 +00:00
|
|
|
return;
|
|
|
|
default:
|
1997-11-24 22:05:25 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-06-17 20:34:50 +00:00
|
|
|
/* if just the mod1 key is down, affect only the height */
|
2001-11-29 16:44:51 +00:00
|
|
|
if (options->constrain_2 && ! options->constrain_1)
|
|
|
|
{
|
|
|
|
diff_x = 0;
|
|
|
|
}
|
1999-06-17 20:34:50 +00:00
|
|
|
/* if just the control key is down, affect only the width */
|
2001-11-29 16:44:51 +00:00
|
|
|
else if (options->constrain_1 && ! options->constrain_2)
|
|
|
|
{
|
|
|
|
diff_y = 0;
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
*x1 += diff_x;
|
|
|
|
*y1 += diff_y;
|
|
|
|
|
|
|
|
if (dir_x > 0)
|
|
|
|
{
|
|
|
|
if (*x1 >= *x2) *x1 = *x2 - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*x1 <= *x2) *x1 = *x2 + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dir_y > 0)
|
|
|
|
{
|
|
|
|
if (*y1 >= *y2) *y1 = *y2 - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (*y1 <= *y2) *y1 = *y2 + 1;
|
|
|
|
}
|
|
|
|
|
2000-01-05 11:18:38 +00:00
|
|
|
/* if both the control key & mod1 keys are down,
|
|
|
|
* keep the aspect ratio intact
|
|
|
|
*/
|
2001-11-29 16:44:51 +00:00
|
|
|
if (options->constrain_1 && options->constrain_2)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
ratio = ((gdouble) (transform_tool->x2 - transform_tool->x1) /
|
|
|
|
(gdouble) (transform_tool->y2 - transform_tool->y1));
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
w = ABS ((*x2 - *x1));
|
|
|
|
h = ABS ((*y2 - *y1));
|
|
|
|
|
|
|
|
if (w > h * ratio)
|
|
|
|
h = w / ratio;
|
|
|
|
else
|
|
|
|
w = h * ratio;
|
|
|
|
|
|
|
|
*y1 = *y2 - dir_y * h;
|
|
|
|
*x1 = *x2 - dir_x * w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-05 11:18:38 +00:00
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_recalc (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_drawable_transform_matrix_scale (transform_tool->x1,
|
|
|
|
transform_tool->y1,
|
|
|
|
transform_tool->x2,
|
|
|
|
transform_tool->y2,
|
|
|
|
transform_tool->trans_info[X0],
|
|
|
|
transform_tool->trans_info[Y0],
|
|
|
|
transform_tool->trans_info[X1],
|
|
|
|
transform_tool->trans_info[Y1],
|
|
|
|
transform_tool->transform);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* transform the bounding box */
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_transform_tool_transform_bounding_box (transform_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* update the information dialog */
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_scale_tool_info_update (transform_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|