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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2012-03-20 02:57:55 +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
|
|
|
|
2011-04-28 20:23:33 +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-04-25 02:43:31 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2014-05-25 21:44:38 +08:00
|
|
|
#include "widgets/gimpspinscale.h"
|
2003-08-22 09:42:57 +08:00
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2013-06-07 17:52:48 +08:00
|
|
|
#include "display/gimptoolgui.h"
|
2017-06-17 09:02:01 +08:00
|
|
|
#include "display/gimptoolsheargrid.h"
|
2013-06-07 17:52:48 +08:00
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
#include "gimpsheartool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2018-06-10 04:25:03 +08:00
|
|
|
#include "gimptransformgridoptions.h"
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* index into trans_info array */
|
2011-03-28 06:50:46 +08:00
|
|
|
enum
|
|
|
|
{
|
2017-06-17 09:02:01 +08:00
|
|
|
ORIENTATION,
|
|
|
|
SHEAR_X,
|
|
|
|
SHEAR_Y
|
2011-03-28 06:50:46 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
#define SB_WIDTH 10
|
2006-03-31 21:36:34 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2004-08-06 21:56:34 +08:00
|
|
|
/* local function prototypes */
|
2000-12-31 12:07:42 +08:00
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
static gboolean gimp_shear_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
|
|
|
|
GimpMatrix3 *transform);
|
|
|
|
static gchar * gimp_shear_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
|
2018-06-10 04:25:03 +08:00
|
|
|
static void gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool);
|
|
|
|
static void gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool);
|
|
|
|
static void gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool);
|
|
|
|
static GimpToolWidget * gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool);
|
2018-06-16 03:42:19 +08:00
|
|
|
static void gimp_shear_tool_update_widget (GimpTransformGridTool *tg_tool);
|
|
|
|
static void gimp_shear_tool_widget_changed (GimpTransformGridTool *tg_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
static void shear_x_mag_changed (GtkAdjustment *adj,
|
|
|
|
GimpTransformGridTool *tg_tool);
|
|
|
|
static void shear_y_mag_changed (GtkAdjustment *adj,
|
|
|
|
GimpTransformGridTool *tg_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
G_DEFINE_TYPE (GimpShearTool, gimp_shear_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
1998-08-15 21:34:54 +08:00
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
#define parent_class gimp_shear_tool_parent_class
|
|
|
|
|
2001-04-25 02:43:31 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_shear_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-04-25 02:43:31 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_SHEAR_TOOL,
|
2018-06-10 04:25:03 +08:00
|
|
|
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
|
|
|
gimp_transform_grid_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-shear-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Shear"),
|
2006-10-17 17:38:51 +08:00
|
|
|
_("Shear Tool: Shear the layer, selection or path"),
|
2018-01-04 01:02:28 +08:00
|
|
|
N_("S_hear"), "<shift>H",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_SHEAR,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_SHEAR,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-04-25 02:43:31 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_shear_tool_class_init (GimpShearToolClass *klass)
|
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
|
|
|
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
2001-04-25 02:43:31 +08:00
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
tg_class->info_to_matrix = gimp_shear_tool_info_to_matrix;
|
|
|
|
tg_class->get_undo_desc = gimp_shear_tool_get_undo_desc;
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_class->dialog = gimp_shear_tool_dialog;
|
|
|
|
tg_class->dialog_update = gimp_shear_tool_dialog_update;
|
|
|
|
tg_class->prepare = gimp_shear_tool_prepare;
|
|
|
|
tg_class->get_widget = gimp_shear_tool_get_widget;
|
2018-06-16 03:42:19 +08:00
|
|
|
tg_class->update_widget = gimp_shear_tool_update_widget;
|
|
|
|
tg_class->widget_changed = gimp_shear_tool_widget_changed;
|
2018-06-10 04:25:03 +08:00
|
|
|
|
2019-02-04 23:21:31 +08:00
|
|
|
tr_class->progress_text = C_("undo-type", "Shear");
|
2018-06-10 04:25:03 +08:00
|
|
|
tr_class->progress_text = _("Shearing");
|
|
|
|
tg_class->ok_button_label = _("_Shear");
|
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
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (shear_tool);
|
2001-04-29 04:14:32 +08:00
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_SHEAR);
|
2018-06-10 04:25:03 +08:00
|
|
|
}
|
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_shear_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
|
|
|
|
GimpMatrix3 *transform)
|
2018-06-16 03:42:19 +08:00
|
|
|
{
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
gdouble amount;
|
2018-06-16 03:42:19 +08:00
|
|
|
|
|
|
|
if (tg_tool->trans_info[SHEAR_X] == 0.0 &&
|
|
|
|
tg_tool->trans_info[SHEAR_Y] == 0.0)
|
|
|
|
{
|
|
|
|
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tg_tool->trans_info[ORIENTATION] == GIMP_ORIENTATION_HORIZONTAL)
|
|
|
|
amount = tg_tool->trans_info[SHEAR_X];
|
|
|
|
else
|
|
|
|
amount = tg_tool->trans_info[SHEAR_Y];
|
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
gimp_matrix3_identity (transform);
|
|
|
|
gimp_transform_matrix_shear (transform,
|
2018-06-16 03:42:19 +08:00
|
|
|
tr_tool->x1,
|
|
|
|
tr_tool->y1,
|
|
|
|
tr_tool->x2 - tr_tool->x1,
|
|
|
|
tr_tool->y2 - tr_tool->y1,
|
|
|
|
tg_tool->trans_info[ORIENTATION],
|
|
|
|
amount);
|
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
return TRUE;
|
2018-06-16 03:42:19 +08:00
|
|
|
}
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
static gchar *
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
gimp_shear_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
|
2018-06-10 04:25:03 +08:00
|
|
|
{
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
gdouble x = tg_tool->trans_info[SHEAR_X];
|
|
|
|
gdouble y = tg_tool->trans_info[SHEAR_Y];
|
2018-06-10 04:25:03 +08:00
|
|
|
|
|
|
|
switch ((gint) tg_tool->trans_info[ORIENTATION])
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
|
|
|
return g_strdup_printf (C_("undo-type", "Shear horizontally by %-3.3g"),
|
|
|
|
x);
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
|
|
|
return g_strdup_printf (C_("undo-type", "Shear vertically by %-3.3g"),
|
|
|
|
y);
|
2002-06-17 01:13:39 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
default:
|
|
|
|
/* e.g. user entered numbers but no notification callback */
|
|
|
|
return g_strdup_printf (C_("undo-type", "Shear horizontally by %-3.3g, vertically by %-3.3g"),
|
|
|
|
x, y);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_shear_tool_dialog (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpShearTool *shear = GIMP_SHEAR_TOOL (tg_tool);
|
2014-05-25 21:44:38 +08:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *scale;
|
2006-03-31 21:36:34 +08:00
|
|
|
|
2014-05-25 21:44:38 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2018-06-10 04:25:03 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), vbox,
|
2013-06-07 17:52:48 +08:00
|
|
|
FALSE, FALSE, 0);
|
2014-05-25 21:44:38 +08:00
|
|
|
gtk_widget_show (vbox);
|
2006-03-31 21:36:34 +08:00
|
|
|
|
2010-10-19 19:01:44 +08:00
|
|
|
shear->x_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
2014-05-25 21:44:38 +08:00
|
|
|
scale = gimp_spin_scale_new (shear->x_adj, _("Shear magnitude _X"), 0);
|
|
|
|
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (scale);
|
2006-03-31 21:36:34 +08:00
|
|
|
|
|
|
|
g_signal_connect (shear->x_adj, "value-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_CALLBACK (shear_x_mag_changed),
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool);
|
2006-03-31 21:36:34 +08:00
|
|
|
|
2010-10-19 19:01:44 +08:00
|
|
|
shear->y_adj = gtk_adjustment_new (0, -65536, 65536, 1, 10, 0);
|
2014-05-25 21:44:38 +08:00
|
|
|
scale = gimp_spin_scale_new (shear->y_adj, _("Shear magnitude _Y"), 0);
|
|
|
|
gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (scale), -1000, 1000);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), scale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (scale);
|
2006-03-31 21:36:34 +08:00
|
|
|
|
|
|
|
g_signal_connect (shear->y_adj, "value-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_CALLBACK (shear_y_mag_changed),
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool);
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
|
|
|
|
2004-08-07 00:27:13 +08:00
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_shear_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
2004-08-07 00:27:13 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpShearTool *shear = GIMP_SHEAR_TOOL (tg_tool);
|
2004-08-07 00:27:13 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
gtk_adjustment_set_value (shear->x_adj, tg_tool->trans_info[SHEAR_X]);
|
|
|
|
gtk_adjustment_set_value (shear->y_adj, tg_tool->trans_info[SHEAR_Y]);
|
2004-08-07 00:27:13 +08:00
|
|
|
}
|
|
|
|
|
1998-08-15 21:34:54 +08:00
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_shear_tool_prepare (GimpTransformGridTool *tg_tool)
|
1998-08-15 21:34:54 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_UNKNOWN;
|
|
|
|
tg_tool->trans_info[SHEAR_X] = 0.0;
|
|
|
|
tg_tool->trans_info[SHEAR_Y] = 0.0;
|
1998-08-15 21:34:54 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
static GimpToolWidget *
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_shear_tool_get_widget (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (tool->display);
|
|
|
|
GimpToolWidget *widget;
|
2017-06-17 09:02:01 +08:00
|
|
|
|
|
|
|
widget = gimp_tool_shear_grid_new (shell,
|
|
|
|
tr_tool->x1,
|
|
|
|
tr_tool->y1,
|
|
|
|
tr_tool->x2,
|
|
|
|
tr_tool->y2,
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[ORIENTATION],
|
|
|
|
tg_tool->trans_info[SHEAR_X],
|
|
|
|
tg_tool->trans_info[SHEAR_Y]);
|
2017-06-17 09:02:01 +08:00
|
|
|
|
|
|
|
g_object_set (widget,
|
2017-06-20 05:29:01 +08:00
|
|
|
"inside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
|
|
|
"outside-function", GIMP_TRANSFORM_FUNCTION_SHEAR,
|
|
|
|
"frompivot-shear", TRUE,
|
2017-06-17 09:02:01 +08:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
return widget;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-01-05 19:18:38 +08:00
|
|
|
static void
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_shear_tool_update_widget (GimpTransformGridTool *tg_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
2004-08-06 21:56:34 +08:00
|
|
|
|
app: in GimpTransformGridTool, allow simultaneous forward and backward transforms
In GimpTransformGridTool, allow performing simultaneous forward
(normal) and backward (corrective) transforms, by having each
transform direction operate on an independent set of parameters.
In other words, whereas the transform-grid tools previously had a
single transform, which could be applied either normally or
correctively using the "direction" tool-option, they now have two
independent transforms, one applied normally and the other
applied correctively, which are toggled using the "direction"
option. The overall transform is the combination of the backward
transform, followed by the forward transform.
Another way to think about it, is that the tool transforms a source
shape into a destination shape. The source shape is defined by the
backward transform, and the destination shape is defined by the
forward transform. Wherewas previously only one of these shapes
could be controlled (the other shape always being the item bounds),
it's now possible to control both shapes in a single transform.
The next commit will allow modifying both shapes simultaneously,
making this even more useful.
Note that since both transforms start off as the identity, using
only one of the transform directions has the same behavior as
before.
2019-02-04 23:30:18 +08:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
|
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
g_object_set (tg_tool->widget,
|
|
|
|
"x1", (gdouble) tr_tool->x1,
|
|
|
|
"y1", (gdouble) tr_tool->y1,
|
|
|
|
"x2", (gdouble) tr_tool->x2,
|
|
|
|
"y2", (gdouble) tr_tool->y2,
|
|
|
|
"orientation", (gint) tg_tool->trans_info[ORIENTATION],
|
|
|
|
"shear-x", tg_tool->trans_info[SHEAR_X],
|
|
|
|
"shear-y", tg_tool->trans_info[SHEAR_Y],
|
|
|
|
NULL);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
|
2017-06-17 09:02:01 +08:00
|
|
|
static void
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_shear_tool_widget_changed (GimpTransformGridTool *tg_tool)
|
2017-06-17 09:02:01 +08:00
|
|
|
{
|
|
|
|
GimpOrientationType orientation;
|
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
g_object_get (tg_tool->widget,
|
2017-06-17 09:02:01 +08:00
|
|
|
"orientation", &orientation,
|
2018-06-10 04:25:03 +08:00
|
|
|
"shear-x", &tg_tool->trans_info[SHEAR_X],
|
|
|
|
"shear-y", &tg_tool->trans_info[SHEAR_Y],
|
2017-06-17 09:02:01 +08:00
|
|
|
NULL);
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[ORIENTATION] = orientation;
|
2017-06-17 09:02:01 +08:00
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
|
2017-06-17 09:02:01 +08:00
|
|
|
}
|
|
|
|
|
2002-11-14 19:54:57 +08:00
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
shear_x_mag_changed (GtkAdjustment *adj,
|
|
|
|
GimpTransformGridTool *tg_tool)
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2006-03-31 21:36:34 +08:00
|
|
|
gdouble value = gtk_adjustment_get_value (adj);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
if (value != tg_tool->trans_info[SHEAR_X])
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2018-06-16 03:42:19 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_HORIZONTAL;
|
2004-08-06 21:56:34 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[SHEAR_X] = value;
|
|
|
|
tg_tool->trans_info[SHEAR_Y] = 0.0; /* can only shear in one axis */
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
2011-08-13 23:42:41 +08:00
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-06-10 04:25:03 +08:00
|
|
|
shear_y_mag_changed (GtkAdjustment *adj,
|
|
|
|
GimpTransformGridTool *tg_tool)
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2006-03-31 21:36:34 +08:00
|
|
|
gdouble value = gtk_adjustment_get_value (adj);
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
if (value != tg_tool->trans_info[SHEAR_Y])
|
2002-11-14 19:54:57 +08:00
|
|
|
{
|
2018-06-16 03:42:19 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[ORIENTATION] = GIMP_ORIENTATION_VERTICAL;
|
2004-08-06 21:56:34 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tg_tool->trans_info[SHEAR_Y] = value;
|
|
|
|
tg_tool->trans_info[SHEAR_X] = 0.0; /* can only shear in one axis */
|
2002-11-14 19:54:57 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
2011-08-13 23:42:41 +08:00
|
|
|
|
2018-06-16 03:42:19 +08:00
|
|
|
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
2002-11-14 19:54:57 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|