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"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
|
|
|
#include "floating_sel.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "gdisplay.h"
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gdisplay_ops.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "gimpprogress.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
#include "undo.h"
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gimpsheartool.h"
|
|
|
|
#include "tool_manager.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
#include "tool_options.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"
|
|
|
|
|
2001-05-14 08:04:29 +08:00
|
|
|
#define WANT_SHEAR_BITS
|
|
|
|
#include "icons.h"
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
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);
|
|
|
|
static void gimp_shear_tool_init (GimpShearTool *shear_tool);
|
|
|
|
|
|
|
|
static void gimp_shear_tool_destroy (GtkObject *object);
|
|
|
|
|
|
|
|
static TileManager * gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GDisplay *gdisp,
|
|
|
|
TransformState state);
|
|
|
|
|
|
|
|
static void shear_tool_recalc (GimpTool *tool,
|
|
|
|
GDisplay *gdisp);
|
|
|
|
static void shear_tool_motion (GimpTool *tool,
|
|
|
|
GDisplay *gdisp);
|
|
|
|
static void shear_info_update (GimpTool *tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-04-25 02:43:31 +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-29 04:14:32 +08:00
|
|
|
static TransformOptions *shear_options = NULL;
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
|
|
|
|
/* Public functions */
|
|
|
|
|
|
|
|
void
|
2001-07-07 20:17:23 +08:00
|
|
|
gimp_shear_tool_register (Gimp *gimp)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
2001-07-07 20:17:23 +08:00
|
|
|
tool_manager_register_tool (gimp,
|
|
|
|
GIMP_TYPE_SHEAR_TOOL,
|
2001-04-25 02:43:31 +08:00
|
|
|
FALSE,
|
|
|
|
"gimp:shear_tool",
|
|
|
|
_("Shear Tool"),
|
|
|
|
_("Shear the layer or selection"),
|
|
|
|
N_("/Tools/Transform Tools/Shear"), "<shift>F",
|
|
|
|
NULL, "tools/shear.html",
|
|
|
|
(const gchar **) shear_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkType
|
|
|
|
gimp_shear_tool_get_type (void)
|
|
|
|
{
|
|
|
|
static GtkType tool_type = 0;
|
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
|
|
|
GtkTypeInfo tool_info =
|
|
|
|
{
|
|
|
|
"GimpShearTool",
|
|
|
|
sizeof (GimpShearTool),
|
|
|
|
sizeof (GimpShearToolClass),
|
|
|
|
(GtkClassInitFunc) gimp_shear_tool_class_init,
|
|
|
|
(GtkObjectInitFunc) gimp_shear_tool_init,
|
|
|
|
/* reserved_1 */ NULL,
|
|
|
|
/* reserved_2 */ NULL,
|
|
|
|
(GtkClassInitFunc) NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
tool_type = gtk_type_unique (GIMP_TYPE_TRANSFORM_TOOL, &tool_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
gimp_shear_tool_shear (GimpImage *gimage,
|
|
|
|
GimpDrawable *drawable,
|
|
|
|
GDisplay *gdisp,
|
|
|
|
TileManager *float_tiles,
|
|
|
|
gboolean interpolation,
|
|
|
|
GimpMatrix3 matrix)
|
|
|
|
{
|
|
|
|
GimpProgress *progress;
|
|
|
|
TileManager *ret;
|
|
|
|
|
|
|
|
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
|
|
|
|
|
|
|
ret = gimp_transform_tool_do (gimage, drawable, float_tiles,
|
|
|
|
interpolation, matrix,
|
|
|
|
progress ? progress_update_and_flush :
|
|
|
|
(GimpProgressFunc) NULL,
|
|
|
|
progress);
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
progress_end (progress);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_class_init (GimpShearToolClass *klass)
|
|
|
|
{
|
|
|
|
GtkObjectClass *object_class;
|
|
|
|
GimpTransformToolClass *trans_class;
|
|
|
|
|
|
|
|
object_class = (GtkObjectClass *) klass;
|
|
|
|
trans_class = (GimpTransformToolClass *) klass;
|
|
|
|
|
|
|
|
parent_class = gtk_type_class (GIMP_TYPE_TRANSFORM_TOOL);
|
|
|
|
|
|
|
|
object_class->destroy = gimp_shear_tool_destroy;
|
|
|
|
|
|
|
|
trans_class->transform = gimp_shear_tool_transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_init (GimpShearTool *shear_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *tr_tool;
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (shear_tool);
|
|
|
|
tr_tool = GIMP_TRANSFORM_TOOL (shear_tool);
|
|
|
|
|
2001-04-29 04:14:32 +08:00
|
|
|
if (! shear_options)
|
|
|
|
{
|
|
|
|
shear_options = transform_options_new (GIMP_TYPE_SHEAR_TOOL,
|
|
|
|
transform_options_reset);
|
|
|
|
|
|
|
|
tool_manager_register_tool_options (GIMP_TYPE_SHEAR_TOOL,
|
2001-07-18 04:50:01 +08:00
|
|
|
(GimpToolOptions *) shear_options);
|
2001-04-29 04:14:32 +08:00
|
|
|
}
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
tool->tool_cursor = GIMP_SHEAR_TOOL_CURSOR;
|
|
|
|
|
|
|
|
/* assemble the transformation matrix */
|
|
|
|
gimp_matrix3_identity (tr_tool->transform);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_destroy (GtkObject *object)
|
|
|
|
{
|
|
|
|
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
|
|
|
GTK_OBJECT_CLASS (parent_class)->destroy (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static TileManager *
|
|
|
|
gimp_shear_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GDisplay *gdisp,
|
|
|
|
TransformState state)
|
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
tool = GIMP_TOOL (transform_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_INIT:
|
1997-11-25 06:05:25 +08:00
|
|
|
if (!transform_info)
|
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
transform_info = info_dialog_new (_("Shear Information"),
|
2000-01-05 19:18:38 +08:00
|
|
|
gimp_standard_help_func,
|
|
|
|
"tools/transform_shear.html");
|
1999-04-03 06:27:05 +08:00
|
|
|
|
|
|
|
info_dialog_add_spinbutton (transform_info,
|
|
|
|
_("Shear Magnitude X:"),
|
|
|
|
&xshear_val,
|
|
|
|
-65536, 65536, 1, 15, 1, 1, 0,
|
|
|
|
shear_x_mag_changed, tool);
|
|
|
|
|
|
|
|
info_dialog_add_spinbutton (transform_info,
|
|
|
|
_("Y:"),
|
|
|
|
&yshear_val,
|
|
|
|
-65536, 65536, 1, 15, 1, 1, 0,
|
|
|
|
shear_y_mag_changed, tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
2001-04-25 02:43:31 +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
|
|
|
|
|
|
|
return NULL;
|
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_MOTION:
|
2000-12-31 12:07:42 +08:00
|
|
|
shear_tool_motion (tool, gdisp);
|
|
|
|
shear_tool_recalc (tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_RECALC:
|
2000-12-31 12:07:42 +08:00
|
|
|
shear_tool_recalc (tool, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
case TRANSFORM_FINISH:
|
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
Bit of a large checkin this - it's basically three things:
1 - GimpModules using gmodules to dynamically load and
initialise modules at gimp start of day.
2 - Color selectors now register themselves with a color
notebook.
3 - progress bars have been cleaned up a bit, so now have
progress indictations on all transform tool and gradient
fill operations. Not done bucket fill, but that seems to
be the next candidate.
New directories:
* modules/: new directory for dynamically loadable modules.
New files:
* modules/.cvsignore
* modules/Makefile.am
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
color selector the gimp can use.
* app/gimpprogress.[ch]: progress bars within gimp core, either as
popups, or in the status bar. This is mainly code moved out
of plug-in.c
* app/color_notebook.[ch]: color selector notebook, implementing
very similar interface to color_select.h so it can be used as
a drop-in replacement for it.
* libgimp/color_selector.h: API color selectors need to implement
to become a page in the color_notebook.
* libgimp/gimpmodule.h: API gimp modules need to implement to be
initialised by gimp at start of day.
Modified files:
* Makefile.am: add modules/ to SUBDIRS
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
* app/gimprc.[ch]: recognise module-path variable.
* gimprc.in: set module-path variable to something sensible
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
* app/Makefile.am: build color notebook and gimpprogress
* app/app_procs.c: register internal GIMP color selector with
color notebook.
* app/asupsample.c: call progress function less frequently for
better performance.
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
* app/blend.c: make callbacks to a progress function
* app/color_area.c: use a color notebook rather than a color selector
* app/color_panel.c: ditto
* app/color_select.c: export color selector interface for notebook
* app/color_select.h: color_select_init() prototype
* app/flip_tool.c: flip the image every time, rather than every
second click.
* app/interface.c: move progress bar stuff out to
gimpprogress.c. Make the code actually work while we're at it.
* app/interface.h: move prototypes for progress functions out to
gimpprogress.h
* app/plug_in.c: load and initialise modules (if possible). Move
progress bar handling code out to gimpprogress.c
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
a whole bunch of GtkWidgets.
* app/scale_tool.c
* app/rotate_tool.c
* app/shear_tool.c
* app/perspective_tool.c: progress bar during operation.
De-sensitise the dialog to discourage the user from running
two transforms in parallel.
* app/transform_core.c: recalculate grid coords when bounding box
changes. Only initialise the action area of the dialog once,
to avoid multiple "ok" / "reset" buttons appearing. Undraw
transform tool with correct matrix to get rid of handle
remains on screen. Call a progress function as we apply the
transform matrix. A few new i18n markups. Invalidate
floating selection marching ants after applying matrix.
* app/transform_core.h: transform_core_do() takes an optional
progress callback argument (and data).
* plug-ins/oilify/oilify.c: send progress bar updates after every
pixel region, not only if they processed a multiple of 5
pixels (which was quite unlikely, and therefore gave a jerky
progress indication).
1999-01-11 08:57:33 +08:00
|
|
|
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
2001-04-25 02:43:31 +08:00
|
|
|
return gimp_shear_tool_shear (gdisp->gimage,
|
|
|
|
gimp_image_active_drawable (gdisp->gimage),
|
|
|
|
gdisp,
|
|
|
|
transform_tool->original,
|
|
|
|
gimp_transform_tool_smoothing (),
|
|
|
|
transform_tool->transform);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-04-25 02:43:31 +08:00
|
|
|
shear_info_update (GimpTool *tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTransformTool *transform_tool;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (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
|
|
|
|
|
|
|
info_dialog_update (transform_info);
|
|
|
|
info_dialog_popup (transform_info);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gint value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
tool = (GimpTool *) data;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
|
|
|
if (tool)
|
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
value = GTK_ADJUSTMENT (widget)->value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
if (value != transform_tool->trans_info[XSHEAR])
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_draw_tool_pause (draw_tool);
|
|
|
|
transform_tool->trans_info[XSHEAR] = value;
|
2000-12-31 12:07:42 +08:00
|
|
|
shear_tool_recalc (tool, tool->gdisp);
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_draw_tool_resume (draw_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;
|
|
|
|
GimpDrawTool *draw_tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gint value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
tool = (GimpTool *) data;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
|
|
|
if (tool)
|
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
value = GTK_ADJUSTMENT (widget)->value;
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
if (value != transform_tool->trans_info[YSHEAR])
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_draw_tool_pause (draw_tool);
|
|
|
|
transform_tool->trans_info[YSHEAR] = value;
|
2000-12-31 12:07:42 +08:00
|
|
|
shear_tool_recalc (tool, tool->gdisp);
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_draw_tool_resume (draw_tool);
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-04-25 02:43:31 +08:00
|
|
|
shear_tool_motion (GimpTool *tool,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gint diffx, diffy;
|
|
|
|
gint dir;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
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-04-25 02:43:31 +08:00
|
|
|
shear_tool_recalc (GimpTool *tool,
|
2000-12-31 12:07:42 +08:00
|
|
|
GDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-04-25 02:43:31 +08:00
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gfloat width, height;
|
|
|
|
gfloat cx, cy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
cx = (transform_tool->x1 + transform_tool->x2) / 2.0;
|
|
|
|
cy = (transform_tool->y1 + transform_tool->y2) / 2.0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
width = transform_tool->x2 - transform_tool->x1;
|
|
|
|
height = transform_tool->y2 - transform_tool->y1;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (width == 0)
|
|
|
|
width = 1;
|
|
|
|
if (height == 0)
|
|
|
|
height = 1;
|
|
|
|
|
|
|
|
/* assemble the transformation matrix */
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_matrix3_identity (transform_tool->transform);
|
|
|
|
gimp_matrix3_translate (transform_tool->transform, -cx, -cy);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* shear matrix */
|
2001-04-25 02:43:31 +08:00
|
|
|
if (transform_tool->trans_info[HORZ_OR_VERT] == ORIENTATION_HORIZONTAL)
|
|
|
|
gimp_matrix3_xshear (transform_tool->transform,
|
|
|
|
(float) transform_tool->trans_info [XSHEAR] / height);
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_matrix3_yshear (transform_tool->transform,
|
|
|
|
(float) transform_tool->trans_info [YSHEAR] / width);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
gimp_matrix3_translate (transform_tool->transform, +cx, +cy);
|
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 */
|
|
|
|
shear_info_update (tool);
|
|
|
|
}
|