1997-11-25 06:05:25 +08: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 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2001-02-04 12:51:17 +08:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 07:56:18 +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
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "tools-types.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "gui/gui-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
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"
|
|
|
|
#include "core/gimpdrawable-transform-utils.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gimpsheartool.h"
|
2001-04-29 04:14:32 +08:00
|
|
|
#include "transform_options.h"
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* index into trans_info array */
|
2000-01-05 19:18:38 +08:00
|
|
|
#define HORZ_OR_VERT 0
|
|
|
|
#define XSHEAR 1
|
|
|
|
#define YSHEAR 2
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* the minimum movement before direction of shear can be determined (pixels) */
|
2000-01-05 19:18:38 +08:00
|
|
|
#define MIN_MOVE 5
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
/* forward function declarations */
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
static void gimp_shear_tool_class_init (GimpShearToolClass *klass);
|
2001-11-20 02:23:43 +08:00
|
|
|
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static TileManager * gimp_shear_tool_transform (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static void shear_tool_recalc (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void shear_tool_motion (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void shear_info_update (GimpTransformTool *tr_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
static void shear_x_mag_changed (GtkWidget *widget,
|
|
|
|
gpointer data);
|
|
|
|
static void shear_y_mag_changed (GtkWidget *widget,
|
|
|
|
gpointer data);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* variables local to this file */
|
2000-01-05 19:18:38 +08:00
|
|
|
static gdouble xshear_val;
|
|
|
|
static gdouble yshear_val;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
|
|
|
|
/* Public functions */
|
|
|
|
|
|
|
|
void
|
2001-11-21 07:00:47 +08:00
|
|
|
gimp_shear_tool_register (Gimp *gimp,
|
|
|
|
GimpToolRegisterCallback callback)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
2001-11-21 07:00:47 +08:00
|
|
|
(* callback) (gimp,
|
|
|
|
GIMP_TYPE_SHEAR_TOOL,
|
|
|
|
transform_options_new,
|
|
|
|
FALSE,
|
|
|
|
"gimp:shear_tool",
|
|
|
|
_("Shear Tool"),
|
|
|
|
_("Shear the layer or selection"),
|
|
|
|
N_("/Tools/Transform Tools/Shear"), "<shift>F",
|
|
|
|
NULL, "tools/shear.html",
|
|
|
|
GIMP_STOCK_TOOL_SHEAR);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_shear_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
2001-04-25 02:43:31 +08:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpShearToolClass),
|
2001-08-14 22:53:55 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_shear_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpShearTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_shear_tool_init,
|
2001-04-25 02:43:31 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
|
|
|
"GimpShearTool",
|
|
|
|
&tool_info, 0);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_class_init (GimpShearToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpTransformToolClass *trans_class;
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
trans_class->transform = gimp_shear_tool_transform;
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_init (GimpShearTool *shear_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-22 22:28:39 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2001-11-22 22:28:39 +08:00
|
|
|
tool = GIMP_TOOL (shear_tool);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
2001-11-22 22:28:39 +08:00
|
|
|
|
|
|
|
transform_tool->use_center = FALSE;
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static TileManager *
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_INIT:
|
2001-11-22 21:01:26 +08:00
|
|
|
if (! transform_tool->info_dialog)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-22 21:01:26 +08:00
|
|
|
transform_tool->info_dialog =
|
|
|
|
info_dialog_new (_("Shear Information"),
|
|
|
|
gimp_standard_help_func,
|
|
|
|
"tools/transform_shear.html");
|
1999-04-03 06:27:05 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
gimp_transform_tool_info_dialog_connect (transform_tool,
|
2001-11-22 22:28:39 +08:00
|
|
|
GIMP_STOCK_TOOL_SHEAR);
|
2001-11-22 21:01:26 +08:00
|
|
|
|
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog,
|
1999-04-03 06:27:05 +08:00
|
|
|
_("Shear Magnitude X:"),
|
|
|
|
&xshear_val,
|
|
|
|
-65536, 65536, 1, 15, 1, 1, 0,
|
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-25 05:27:11 +08:00
|
|
|
G_CALLBACK (shear_x_mag_changed),
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
1999-04-03 06:27:05 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog,
|
1999-04-03 06:27:05 +08:00
|
|
|
_("Y:"),
|
|
|
|
&yshear_val,
|
|
|
|
-65536, 65536, 1, 15, 1, 1, 0,
|
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-25 05:27:11 +08:00
|
|
|
G_CALLBACK (shear_y_mag_changed),
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (transform_tool->info_dialog->shell),
|
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_UNKNOWN;
|
|
|
|
transform_tool->trans_info[XSHEAR] = 0.0;
|
|
|
|
transform_tool->trans_info[YSHEAR] = 0.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_MOTION:
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_motion (transform_tool, gdisp);
|
|
|
|
shear_tool_recalc (transform_tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_RECALC:
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_recalc (transform_tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_FINISH:
|
2001-11-20 02:23:43 +08:00
|
|
|
return gimp_transform_tool_transform_tiles (transform_tool,
|
|
|
|
_("Shearing..."));
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_info_update (GimpTransformTool *transform_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
xshear_val = transform_tool->trans_info[XSHEAR];
|
|
|
|
yshear_val = transform_tool->trans_info[YSHEAR];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-22 21:01:26 +08:00
|
|
|
info_dialog_update (transform_tool->info_dialog);
|
|
|
|
info_dialog_popup (transform_tool->info_dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2000-01-05 19:18:38 +08:00
|
|
|
shear_x_mag_changed (GtkWidget *widget,
|
1999-04-03 06:27:05 +08:00
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
2002-02-20 17:59:50 +08:00
|
|
|
gdouble value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
value = GTK_ADJUSTMENT (widget)->value;
|
|
|
|
|
|
|
|
if (value != transform_tool->trans_info[XSHEAR])
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->trans_info[XSHEAR] = value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_recalc (transform_tool, tool->gdisp);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-05 19:18:38 +08:00
|
|
|
shear_y_mag_changed (GtkWidget *widget,
|
1999-04-03 06:27:05 +08:00
|
|
|
gpointer data)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
2002-02-20 17:59:50 +08:00
|
|
|
gdouble value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
|
|
|
|
|
|
|
value = GTK_ADJUSTMENT (widget)->value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
if (value != transform_tool->trans_info[YSHEAR])
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
transform_tool->trans_info[YSHEAR] = value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_recalc (transform_tool, tool->gdisp);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_motion (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-02-20 17:59:50 +08:00
|
|
|
gdouble diffx, diffy;
|
|
|
|
gint dir;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
diffx = transform_tool->curx - transform_tool->lastx;
|
|
|
|
diffy = transform_tool->cury - transform_tool->lasty;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If we haven't yet decided on which way to control shearing
|
|
|
|
* decide using the maximum differential
|
|
|
|
*/
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_UNKNOWN)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-05 19:18:38 +08:00
|
|
|
if (abs (diffx) > MIN_MOVE || abs (diffy) > MIN_MOVE)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-05 19:18:38 +08:00
|
|
|
if (abs (diffx) > abs (diffy))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_HORIZONTAL;
|
|
|
|
transform_tool->trans_info[ORIENTATION_VERTICAL] = 0.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[HORZ_OR_VERT] = ORIENTATION_VERTICAL;
|
|
|
|
transform_tool->trans_info[ORIENTATION_HORIZONTAL] = 0.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* set the current coords to the last ones */
|
|
|
|
else
|
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->curx = transform_tool->lastx;
|
|
|
|
transform_tool->cury = transform_tool->lasty;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if the direction is known, keep track of the magnitude */
|
2001-04-25 02:43:31 +08:00
|
|
|
if (transform_tool->trans_info[HORZ_OR_VERT] != ORIENTATION_UNKNOWN)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
dir = transform_tool->trans_info[HORZ_OR_VERT];
|
|
|
|
switch (transform_tool->function)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_HANDLE_1:
|
1999-07-29 07:00:08 +08:00
|
|
|
if (dir == ORIENTATION_HORIZONTAL)
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[XSHEAR] -= diffx;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[YSHEAR] -= diffy;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_HANDLE_2:
|
1999-07-29 07:00:08 +08:00
|
|
|
if (dir == ORIENTATION_HORIZONTAL)
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[XSHEAR] -= diffx;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[YSHEAR] += diffy;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_HANDLE_3:
|
1999-07-29 07:00:08 +08:00
|
|
|
if (dir == ORIENTATION_HORIZONTAL)
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[XSHEAR] += diffx;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[YSHEAR] -= diffy;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_HANDLE_4:
|
1999-07-29 07:00:08 +08:00
|
|
|
if (dir == ORIENTATION_HORIZONTAL)
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[XSHEAR] += diffx;
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool->trans_info[YSHEAR] += diffy;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-01-05 19:18:38 +08:00
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
static void
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_tool_recalc (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-11-20 02:23:43 +08:00
|
|
|
gdouble amount;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
2001-11-20 02:23:43 +08:00
|
|
|
amount = transform_tool->trans_info[XSHEAR];
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-11-20 02:23:43 +08:00
|
|
|
amount = transform_tool->trans_info[YSHEAR];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
gimp_drawable_transform_matrix_shear (transform_tool->x1,
|
|
|
|
transform_tool->y1,
|
|
|
|
transform_tool->x2,
|
|
|
|
transform_tool->y2,
|
|
|
|
transform_tool->trans_info[HORZ_OR_VERT],
|
|
|
|
amount,
|
|
|
|
transform_tool->transform);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* transform the bounding box */
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_transform_tool_transform_bounding_box (transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* update the information dialog */
|
2001-11-20 02:23:43 +08:00
|
|
|
shear_info_update (transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|