2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-24 14:05:25 -08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-24 14:05:25 -08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-24 14: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-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1997-11-24 14:05:25 -08:00
|
|
|
*/
|
2000-12-16 13:37:03 -08:00
|
|
|
|
app/appenv.h New file. Includes <math.h>. Move G_PI, RINT(), ROUND() etc
1999-09-01 Tor Lillqvist <tml@iki.fi>
* app/appenv.h
* libgimp/gimpmath.h: New file. Includes <math.h>. Move G_PI,
RINT(), ROUND() etc from app/appenv.h here, so plug-ins can
use them, too. Remove some commented-out old stuff in appenv.h.
* libgimp/gimp.h: Include gimpmath.h.
* libgimp/gimp.c (gimp_main): Win32: Don't install signal
handlers, we can't do anything useful in the handler ourselves
anyway (it would be nice to print out a backtrace, but that seems
pretty hard to do, even if not impossible). Let Windows inform the
user about the crash. If the plug-in was compiled with MSVC, and
the user also has it, she is offered a chance to start the
debugger automatically anyway.
* app/*several*.c: Include gimpmath.h for G_PI etc. Don't include
<math.h>, as gimpmath.h includes it.
* plug-ins/*/*many*.c: Include config.h. Don't include <math.h>.
Remove all the duplicated definitions of G_PI and rint(). Use
RINT() instead of rint().
* app/app_procs.[ch]: app_exit() takes a gboolean.
* app/batch.c
* app/commands.c
* app/interface.c: Call app_exit() with FALSE or TRUE.
* app/main.c (on_error): Call gimp_fatal_error. (main): Don't
install any signal handler on Win32 here, either.
* app/errors.c (gimp_fatal_error, gimp_terminate): Win32: Format
the message and call MessageBox with it. g_on_error_query doesn't
do anything useful on Win32, and printf'ing a message to stdout or
stderr doesn't do anything, either, in a windowing application.
1999-09-01 13:30:56 -07:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-09 13:24:04 -07:00
|
|
|
#include <gegl.h>
|
2000-12-29 07:22:01 -08:00
|
|
|
#include <gtk/gtk.h>
|
2008-05-31 10:51:52 -07:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
2000-12-16 13:37:03 -08:00
|
|
|
|
2007-03-09 05:00:01 -08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-24 14:36:18 -08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 15:56:18 -08:00
|
|
|
|
2002-05-03 05:45:22 -07:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
|
2003-09-15 10:41:18 -07:00
|
|
|
#include "core/gimp-transform-utils.h"
|
2001-05-08 19:32:03 -07:00
|
|
|
#include "core/gimpimage.h"
|
2001-04-24 11:43:31 -07:00
|
|
|
|
2003-08-21 18:42:57 -07:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-08-30 14:00:42 -07:00
|
|
|
|
2001-09-25 16:23:09 -07:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-26 15:16:59 -07:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2013-06-07 02:52:48 -07:00
|
|
|
#include "display/gimptoolgui.h"
|
2017-06-16 18:02:01 -07:00
|
|
|
#include "display/gimptoolrotategrid.h"
|
2001-01-23 05:01:48 -08:00
|
|
|
|
2001-04-24 11:43:31 -07:00
|
|
|
#include "gimprotatetool.h"
|
2003-04-15 09:05:52 -07:00
|
|
|
#include "gimptoolcontrol.h"
|
2018-06-09 13:25:03 -07:00
|
|
|
#include "gimptransformgridoptions.h"
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2003-03-25 08:38:19 -08:00
|
|
|
#include "gimp-intl.h"
|
2000-12-29 07:22:01 -08:00
|
|
|
|
|
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
/* index into trans_info array */
|
2011-03-27 15:50:46 -07:00
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
ANGLE,
|
2011-08-11 11:11:09 -07:00
|
|
|
PIVOT_X,
|
|
|
|
|
PIVOT_Y
|
2011-03-27 15:50:46 -07:00
|
|
|
};
|
1998-08-13 13:19:09 -07:00
|
|
|
|
1997-11-24 14:05:25 -08:00
|
|
|
|
2017-06-16 18:02:01 -07:00
|
|
|
#define SB_WIDTH 10
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
(cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
|
|
|
#define EPSILON 1e-6
|
2006-03-31 05:36:34 -08:00
|
|
|
|
2000-12-30 20:07:42 -08:00
|
|
|
|
2001-11-19 10:23:43 -08:00
|
|
|
/* local function prototypes */
|
2001-04-24 11:43:31 -07:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
static gboolean gimp_rotate_tool_key_press (GimpTool *tool,
|
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
|
GimpDisplay *display);
|
2017-06-16 18:02:01 -07: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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
static gboolean gimp_rotate_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
|
|
|
|
|
GimpMatrix3 *transform);
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
(cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
|
|
|
static void gimp_rotate_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
|
|
|
|
|
const GimpMatrix3 *transform);
|
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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
static gchar * gimp_rotate_tool_get_undo_desc (GimpTransformGridTool *tg_tool);
|
2018-06-09 13:25:03 -07:00
|
|
|
static void gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool);
|
|
|
|
|
static void gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool);
|
|
|
|
|
static void gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool);
|
|
|
|
|
static GimpToolWidget * gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool);
|
2018-06-15 12:42:19 -07:00
|
|
|
static void gimp_rotate_tool_update_widget (GimpTransformGridTool *tg_tool);
|
|
|
|
|
static void gimp_rotate_tool_widget_changed (GimpTransformGridTool *tg_tool);
|
2000-12-30 20:07:42 -08:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
static void rotate_angle_changed (GtkAdjustment *adj,
|
|
|
|
|
GimpTransformGridTool *tg_tool);
|
|
|
|
|
static void rotate_center_changed (GtkWidget *entry,
|
|
|
|
|
GimpTransformGridTool *tg_tool);
|
2000-12-30 20:07:42 -08:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GimpRotateTool, gimp_rotate_tool, GIMP_TYPE_TRANSFORM_GRID_TOOL)
|
2001-04-24 11:43:31 -07:00
|
|
|
|
2005-12-13 01:13:50 -08:00
|
|
|
#define parent_class gimp_rotate_tool_parent_class
|
2001-07-07 05:17:23 -07:00
|
|
|
|
2001-04-24 11:43:31 -07:00
|
|
|
|
2003-08-21 18:42:57 -07:00
|
|
|
void
|
2002-03-28 19:50:29 -08:00
|
|
|
gimp_rotate_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 04:31:08 -07:00
|
|
|
gpointer data)
|
2001-04-24 11:43:31 -07:00
|
|
|
{
|
2002-03-28 19:50:29 -08:00
|
|
|
(* callback) (GIMP_TYPE_ROTATE_TOOL,
|
2018-06-09 13:25:03 -07:00
|
|
|
GIMP_TYPE_TRANSFORM_GRID_OPTIONS,
|
|
|
|
|
gimp_transform_grid_options_gui,
|
2015-09-08 12:18:49 -07:00
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
2002-03-21 04:17:17 -08:00
|
|
|
"gimp-rotate-tool",
|
GimpViewableDialogs everywhere, cleanup:
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 01:44:57 -07:00
|
|
|
_("Rotate"),
|
2006-10-17 02:38:51 -07:00
|
|
|
_("Rotate Tool: Rotate the layer, selection or path"),
|
2004-04-29 06:19:28 -07:00
|
|
|
N_("_Rotate"), "<shift>R",
|
2003-08-21 18:42:57 -07:00
|
|
|
NULL, GIMP_HELP_TOOL_ROTATE,
|
2017-03-05 07:01:59 -08:00
|
|
|
GIMP_ICON_TOOL_ROTATE,
|
2002-05-03 04:31:08 -07:00
|
|
|
data);
|
2001-04-24 11:43:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
|
|
|
|
{
|
2018-06-09 13:25:03 -07:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
|
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
|
|
|
|
GimpTransformGridToolClass *tg_class = GIMP_TRANSFORM_GRID_TOOL_CLASS (klass);
|
|
|
|
|
|
|
|
|
|
tool_class->key_press = gimp_rotate_tool_key_press;
|
2001-04-24 11:43:31 -07: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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
tg_class->info_to_matrix = gimp_rotate_tool_info_to_matrix;
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
(cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
|
|
|
tg_class->matrix_to_info = gimp_rotate_tool_matrix_to_info;
|
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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
tg_class->get_undo_desc = gimp_rotate_tool_get_undo_desc;
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_class->dialog = gimp_rotate_tool_dialog;
|
|
|
|
|
tg_class->dialog_update = gimp_rotate_tool_dialog_update;
|
|
|
|
|
tg_class->prepare = gimp_rotate_tool_prepare;
|
|
|
|
|
tg_class->get_widget = gimp_rotate_tool_get_widget;
|
2018-06-15 12:42:19 -07:00
|
|
|
tg_class->update_widget = gimp_rotate_tool_update_widget;
|
|
|
|
|
tg_class->widget_changed = gimp_rotate_tool_widget_changed;
|
2017-02-12 07:06:34 -08:00
|
|
|
|
2019-02-04 07:21:31 -08:00
|
|
|
tr_class->undo_desc = C_("undo-type", "Rotate");
|
2018-06-09 13:25:03 -07:00
|
|
|
tr_class->progress_text = _("Rotating");
|
|
|
|
|
tg_class->ok_button_label = _("R_otate");
|
2001-04-24 11:43:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
|
|
|
|
{
|
2018-06-09 13:25:03 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (rotate_tool);
|
2001-04-28 13:14:32 -07:00
|
|
|
|
2004-06-04 16:08:29 -07:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_ROTATE);
|
2001-04-24 11:43:31 -07:00
|
|
|
}
|
1998-08-15 06:34:54 -07:00
|
|
|
|
2008-05-31 10:51:52 -07:00
|
|
|
static gboolean
|
|
|
|
|
gimp_rotate_tool_key_press (GimpTool *tool,
|
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
|
GimpDisplay *display)
|
|
|
|
|
{
|
2008-07-11 12:38:28 -07:00
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
2008-05-31 10:51:52 -07:00
|
|
|
|
|
|
|
|
if (display == draw_tool->display)
|
|
|
|
|
{
|
2008-07-11 12:38:28 -07:00
|
|
|
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tool);
|
|
|
|
|
GtkSpinButton *angle_spin = GTK_SPIN_BUTTON (rotate->angle_spin_button);
|
|
|
|
|
|
2008-05-31 10:51:52 -07:00
|
|
|
switch (kevent->keyval)
|
|
|
|
|
{
|
2011-03-29 06:27:25 -07:00
|
|
|
case GDK_KEY_Up:
|
2008-05-31 10:51:52 -07:00
|
|
|
gtk_spin_button_spin (angle_spin, GTK_SPIN_STEP_FORWARD, 0.0);
|
2008-07-11 12:38:28 -07:00
|
|
|
return TRUE;
|
2008-05-31 10:51:52 -07:00
|
|
|
|
2011-03-29 06:27:25 -07:00
|
|
|
case GDK_KEY_Down:
|
2008-05-31 10:51:52 -07:00
|
|
|
gtk_spin_button_spin (angle_spin, GTK_SPIN_STEP_BACKWARD, 0.0);
|
2008-07-11 12:38:28 -07:00
|
|
|
return TRUE;
|
2008-05-31 10:51:52 -07:00
|
|
|
|
2012-01-22 11:45:42 -08:00
|
|
|
case GDK_KEY_Right:
|
2008-05-31 10:51:52 -07:00
|
|
|
gtk_spin_button_spin (angle_spin, GTK_SPIN_PAGE_FORWARD, 0.0);
|
2008-07-11 12:38:28 -07:00
|
|
|
return TRUE;
|
2008-05-31 10:51:52 -07:00
|
|
|
|
2012-01-22 11:45:42 -08:00
|
|
|
case GDK_KEY_Left:
|
2008-05-31 10:51:52 -07:00
|
|
|
gtk_spin_button_spin (angle_spin, GTK_SPIN_PAGE_BACKWARD, 0.0);
|
2008-07-11 12:38:28 -07:00
|
|
|
return TRUE;
|
2008-05-31 10:51:52 -07:00
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-07-11 12:38:28 -07:00
|
|
|
return GIMP_TOOL_CLASS (parent_class)->key_press (tool, kevent, display);
|
2008-05-31 10:51:52 -07: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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
static gboolean
|
|
|
|
|
gimp_rotate_tool_info_to_matrix (GimpTransformGridTool *tg_tool,
|
|
|
|
|
GimpMatrix3 *transform)
|
2018-06-15 12:42:19 -07: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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
gimp_matrix3_identity (transform);
|
|
|
|
|
gimp_transform_matrix_rotate_center (transform,
|
2018-06-15 12:42:19 -07:00
|
|
|
tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y],
|
|
|
|
|
tg_tool->trans_info[ANGLE]);
|
|
|
|
|
|
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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
return TRUE;
|
2018-06-15 12:42:19 -07:00
|
|
|
}
|
|
|
|
|
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
(cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
|
|
|
static void
|
|
|
|
|
gimp_rotate_tool_matrix_to_info (GimpTransformGridTool *tg_tool,
|
|
|
|
|
const GimpMatrix3 *transform)
|
|
|
|
|
{
|
|
|
|
|
gdouble c;
|
|
|
|
|
gdouble s;
|
|
|
|
|
gdouble x;
|
|
|
|
|
gdouble y;
|
|
|
|
|
gdouble q;
|
|
|
|
|
|
|
|
|
|
c = transform->coeff[0][0];
|
|
|
|
|
s = transform->coeff[1][0];
|
|
|
|
|
x = transform->coeff[0][2];
|
|
|
|
|
y = transform->coeff[1][2];
|
|
|
|
|
|
|
|
|
|
tg_tool->trans_info[ANGLE] = atan2 (s, c);
|
|
|
|
|
|
|
|
|
|
q = 2.0 * (1.0 - transform->coeff[0][0]);
|
|
|
|
|
|
2019-02-05 01:38:00 -08:00
|
|
|
if (fabs (q) > EPSILON)
|
app: in GimpTransformGridTool, allow linking forward/backward transforms
Add a GimpTransformGridTool::matrix_to_info() virtual function,
which should extract the tool-specific transformation parameters
given a transformation matrix, and the old parameter set (which is
needed in some tools, to derive the parameters that aren't encoded
in the matrix, such as the pivot point). The transformation matrix
can be any combination of matrices calculated by the tool, and
their inverses. Subclasses should only implement this function if
every such matrix can be mapped back to transformation parameters.
This is currently the case for all the transform-grid tools, except
for the shear tool (since it only supports shearing along one of
the horizontal or the vertical directions, however, the combined
matrix may require shearing in both directions).
When a transform-grid tool implements this function, show a chain-
button between the two transform-direction radio-buttons in the
tool options. When the chain-button is linked, whenever the
transform corresponding to the active direction is modified, adjust
the transform corresponding to the non-active direction such that
the overall transform remains the same.
One notable workflow that this enables is transforming a layer
while adjusting a different area than its boundary, by first
defining the area while the transform-directions are linked, and
then transforming the area while the transform-directions are
unlinked.
(cherry picked from commit 39e23267f7ac76030f02e5f68bf7994a02bb81a1)
2019-02-04 12:33:44 -08:00
|
|
|
{
|
|
|
|
|
tg_tool->trans_info[PIVOT_X] = ((1.0 - c) * x - s * y) / q;
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y] = (s * x + (1.0 - c) * y) / q;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GimpMatrix3 transfer;
|
|
|
|
|
|
|
|
|
|
gimp_transform_grid_tool_info_to_matrix (tg_tool, &transfer);
|
|
|
|
|
gimp_matrix3_invert (&transfer);
|
|
|
|
|
gimp_matrix3_mult (transform, &transfer);
|
|
|
|
|
|
|
|
|
|
gimp_matrix3_transform_point (&transfer,
|
|
|
|
|
tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y],
|
|
|
|
|
&tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
&tg_tool->trans_info[PIVOT_Y]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-09 13:25:03 -07: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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
gimp_rotate_tool_get_undo_desc (GimpTransformGridTool *tg_tool)
|
2018-06-09 13:25:03 -07:00
|
|
|
{
|
2019-02-05 01:38:00 -08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
gdouble center_x;
|
|
|
|
|
gdouble center_y;
|
|
|
|
|
|
|
|
|
|
center_x = (tr_tool->x1 + tr_tool->x2) / 2.0;
|
|
|
|
|
center_y = (tr_tool->y1 + tr_tool->y2) / 2.0;
|
2018-06-09 13:25:03 -07:00
|
|
|
|
2019-02-05 01:38:00 -08:00
|
|
|
if (fabs (tg_tool->trans_info[PIVOT_X] - center_x) <= EPSILON &&
|
|
|
|
|
fabs (tg_tool->trans_info[PIVOT_Y] - center_y) <= EPSILON)
|
2019-02-04 06:52:53 -08:00
|
|
|
{
|
|
|
|
|
return g_strdup_printf (C_("undo-type",
|
|
|
|
|
"Rotate by %-3.3g°"),
|
|
|
|
|
gimp_rad_to_deg (tg_tool->trans_info[ANGLE]));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return g_strdup_printf (C_("undo-type",
|
|
|
|
|
"Rotate by %-3.3g° around (%g, %g)"),
|
|
|
|
|
gimp_rad_to_deg (tg_tool->trans_info[ANGLE]),
|
|
|
|
|
tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y]);
|
|
|
|
|
}
|
2018-06-09 13:25:03 -07:00
|
|
|
}
|
|
|
|
|
|
2002-11-14 03:54:57 -08:00
|
|
|
static void
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool)
|
2002-11-14 03:54:57 -08:00
|
|
|
{
|
2018-06-09 13:25:03 -07:00
|
|
|
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
2006-03-31 05:36:34 -08:00
|
|
|
GtkWidget *table;
|
|
|
|
|
GtkWidget *button;
|
|
|
|
|
GtkWidget *scale;
|
2014-06-21 13:39:37 -07:00
|
|
|
GtkAdjustment *adj;
|
2006-03-31 05:36:34 -08:00
|
|
|
|
|
|
|
|
table = gtk_table_new (4, 2, FALSE);
|
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (table), 1, 6);
|
2018-06-09 13:25:03 -07:00
|
|
|
gtk_box_pack_start (GTK_BOX (gimp_tool_gui_get_vbox (tg_tool->gui)), table,
|
2013-06-07 02:52:48 -07:00
|
|
|
FALSE, FALSE, 0);
|
2006-03-31 05:36:34 -08:00
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
2014-06-21 13:39:37 -07:00
|
|
|
rotate->angle_adj = (GtkAdjustment *)
|
|
|
|
|
gtk_adjustment_new (0, -180, 180, 0.1, 15, 0);
|
|
|
|
|
button = gtk_spin_button_new (rotate->angle_adj, 1.0, 2);
|
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (button), TRUE);
|
2006-03-31 05:36:34 -08:00
|
|
|
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (button), TRUE);
|
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (button), SB_WIDTH);
|
2006-10-18 03:29:16 -07:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0, _("_Angle:"),
|
2006-03-31 05:36:34 -08:00
|
|
|
0.0, 0.5, button, 1, TRUE);
|
2008-05-31 10:51:52 -07:00
|
|
|
rotate->angle_spin_button = button;
|
2006-03-31 05:36:34 -08:00
|
|
|
|
|
|
|
|
g_signal_connect (rotate->angle_adj, "value-changed",
|
2006-04-12 05:49:29 -07:00
|
|
|
G_CALLBACK (rotate_angle_changed),
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2006-03-31 05:36:34 -08:00
|
|
|
|
2011-10-02 05:09:45 -07:00
|
|
|
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, rotate->angle_adj);
|
2006-03-31 05:36:34 -08:00
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), scale, 1, 2, 1, 2,
|
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
|
|
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
2014-06-21 13:39:37 -07:00
|
|
|
adj = (GtkAdjustment *) gtk_adjustment_new (0, -1, 1, 1, 10, 0);
|
|
|
|
|
button = gtk_spin_button_new (adj, 1.0, 2);
|
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (button), TRUE);
|
2006-03-31 05:36:34 -08:00
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (button), SB_WIDTH);
|
2006-10-18 03:29:16 -07:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2, _("Center _X:"),
|
2006-03-31 05:36:34 -08:00
|
|
|
0.0, 0.5, button, 1, TRUE);
|
|
|
|
|
|
|
|
|
|
rotate->sizeentry = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
|
|
|
|
TRUE, TRUE, FALSE, SB_WIDTH,
|
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (rotate->sizeentry),
|
2006-03-31 05:36:34 -08:00
|
|
|
GTK_SPIN_BUTTON (button), NULL);
|
2006-10-23 15:36:45 -07:00
|
|
|
gimp_size_entry_set_pixel_digits (GIMP_SIZE_ENTRY (rotate->sizeentry), 2);
|
2006-10-18 03:29:16 -07:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3, _("Center _Y:"),
|
2006-03-31 05:36:34 -08:00
|
|
|
0.0, 0.5, rotate->sizeentry, 1, TRUE);
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2006-03-31 05:36:34 -08:00
|
|
|
g_signal_connect (rotate->sizeentry, "value-changed",
|
|
|
|
|
G_CALLBACK (rotate_center_changed),
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2002-11-14 03:54:57 -08:00
|
|
|
}
|
|
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
static void
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_rotate_tool_dialog_update (GimpTransformGridTool *tg_tool)
|
2004-08-06 09:27:13 -07:00
|
|
|
{
|
2018-06-09 13:25:03 -07:00
|
|
|
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
2004-08-06 09:27:13 -07:00
|
|
|
|
2010-10-19 03:27:33 -07:00
|
|
|
gtk_adjustment_set_value (rotate->angle_adj,
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_rad_to_deg (tg_tool->trans_info[ANGLE]));
|
2006-03-31 05:36:34 -08:00
|
|
|
|
|
|
|
|
g_signal_handlers_block_by_func (rotate->sizeentry,
|
|
|
|
|
rotate_center_changed,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2006-03-31 05:36:34 -08:00
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[PIVOT_X]);
|
2006-03-31 05:36:34 -08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[PIVOT_Y]);
|
2006-03-31 05:36:34 -08:00
|
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
|
|
|
|
rotate_center_changed,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2004-08-06 09:27:13 -07:00
|
|
|
}
|
|
|
|
|
|
2002-11-14 03:54:57 -08:00
|
|
|
static void
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_rotate_tool_prepare (GimpTransformGridTool *tg_tool)
|
1997-11-24 14:05:25 -08:00
|
|
|
{
|
2018-06-09 13:25:03 -07:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
GimpRotateTool *rotate = GIMP_ROTATE_TOOL (tg_tool);
|
|
|
|
|
GimpDisplay *display = GIMP_TOOL (tg_tool)->display;
|
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
|
gdouble xres;
|
|
|
|
|
gdouble yres;
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[ANGLE] = 0.0;
|
|
|
|
|
tg_tool->trans_info[PIVOT_X] = (gdouble) (tr_tool->x1 + tr_tool->x2) / 2.0;
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y] = (gdouble) (tr_tool->y1 + tr_tool->y2) / 2.0;
|
2004-08-06 09:27:13 -07:00
|
|
|
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_get_resolution (image, &xres, &yres);
|
2007-12-26 09:33:41 -08:00
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
g_signal_handlers_block_by_func (rotate->sizeentry,
|
2002-11-14 03:54:57 -08:00
|
|
|
rotate_center_changed,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (rotate->sizeentry),
|
2009-10-04 10:56:39 -07:00
|
|
|
gimp_display_get_shell (display)->unit);
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
|
2007-12-26 09:33:41 -08:00
|
|
|
xres, FALSE);
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
|
2007-12-26 09:33:41 -08:00
|
|
|
yres, FALSE);
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
|
2002-11-14 03:54:57 -08:00
|
|
|
-65536,
|
2007-12-25 08:21:40 -08:00
|
|
|
65536 +
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_get_width (image));
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
|
2002-11-14 03:54:57 -08:00
|
|
|
-65536,
|
2007-12-25 08:21:40 -08:00
|
|
|
65536 +
|
2009-10-06 10:20:44 -07:00
|
|
|
gimp_image_get_height (image));
|
2002-11-14 03:54:57 -08:00
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (rotate->sizeentry), 0,
|
2002-11-14 03:54:57 -08:00
|
|
|
tr_tool->x1, tr_tool->x2);
|
2004-08-06 09:27:13 -07:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (rotate->sizeentry), 1,
|
2002-11-14 03:54:57 -08:00
|
|
|
tr_tool->y1, tr_tool->y2);
|
|
|
|
|
|
2004-08-06 09:27:13 -07:00
|
|
|
g_signal_handlers_unblock_by_func (rotate->sizeentry,
|
2002-11-14 03:54:57 -08:00
|
|
|
rotate_center_changed,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool);
|
2002-11-14 03:54:57 -08:00
|
|
|
}
|
|
|
|
|
|
2017-06-16 18:02:01 -07:00
|
|
|
static GimpToolWidget *
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_rotate_tool_get_widget (GimpTransformGridTool *tg_tool)
|
2002-11-14 03:54:57 -08:00
|
|
|
{
|
2018-06-09 13:25:03 -07: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-16 18:02:01 -07:00
|
|
|
|
|
|
|
|
widget = gimp_tool_rotate_grid_new (shell,
|
|
|
|
|
tr_tool->x1,
|
|
|
|
|
tr_tool->y1,
|
|
|
|
|
tr_tool->x2,
|
|
|
|
|
tr_tool->y2,
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y],
|
|
|
|
|
tg_tool->trans_info[ANGLE]);
|
2017-06-16 18:02:01 -07:00
|
|
|
|
|
|
|
|
g_object_set (widget,
|
2017-06-19 14:29:01 -07:00
|
|
|
"inside-function", GIMP_TRANSFORM_FUNCTION_ROTATE,
|
|
|
|
|
"outside-function", GIMP_TRANSFORM_FUNCTION_ROTATE,
|
|
|
|
|
"use-pivot-handle", TRUE,
|
2017-06-16 18:02:01 -07:00
|
|
|
NULL);
|
|
|
|
|
|
|
|
|
|
return widget;
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-06-15 12:42:19 -07:00
|
|
|
gimp_rotate_tool_update_widget (GimpTransformGridTool *tg_tool)
|
1997-11-24 14:05:25 -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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->update_widget (tg_tool);
|
2018-06-09 13:25:03 -07:00
|
|
|
|
2018-06-15 12:42:19 -07:00
|
|
|
g_object_set (tg_tool->widget,
|
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.
(cherry picked from commit de8e81f81f356a704aba345e87c460e542570155)
2019-02-04 07:30:18 -08:00
|
|
|
"angle", tg_tool->trans_info[ANGLE],
|
|
|
|
|
"pivot-x", tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
"pivot-y", tg_tool->trans_info[PIVOT_Y],
|
2018-06-15 12:42:19 -07:00
|
|
|
NULL);
|
1997-11-24 14:05:25 -08:00
|
|
|
}
|
|
|
|
|
|
2017-06-16 18:02:01 -07:00
|
|
|
static void
|
2018-06-15 12:42:19 -07:00
|
|
|
gimp_rotate_tool_widget_changed (GimpTransformGridTool *tg_tool)
|
2017-06-16 18:02:01 -07:00
|
|
|
{
|
2018-06-15 12:42:19 -07:00
|
|
|
g_object_get (tg_tool->widget,
|
2018-06-09 13:25:03 -07:00
|
|
|
"angle", &tg_tool->trans_info[ANGLE],
|
|
|
|
|
"pivot-x", &tg_tool->trans_info[PIVOT_X],
|
|
|
|
|
"pivot-y", &tg_tool->trans_info[PIVOT_Y],
|
2017-06-16 18:02:01 -07:00
|
|
|
NULL);
|
|
|
|
|
|
2018-06-15 12:42:19 -07:00
|
|
|
GIMP_TRANSFORM_GRID_TOOL_CLASS (parent_class)->widget_changed (tg_tool);
|
2017-06-16 18:02:01 -07:00
|
|
|
}
|
|
|
|
|
|
1998-08-15 06:34:54 -07:00
|
|
|
static void
|
2018-06-09 13:25:03 -07:00
|
|
|
rotate_angle_changed (GtkAdjustment *adj,
|
|
|
|
|
GimpTransformGridTool *tg_tool)
|
1998-08-15 06:34:54 -07:00
|
|
|
{
|
2006-03-31 05:36:34 -08:00
|
|
|
gdouble value = gimp_deg_to_rad (gtk_adjustment_get_value (adj));
|
1998-08-15 06:34:54 -07:00
|
|
|
|
2019-02-05 01:38:00 -08:00
|
|
|
if (fabs (value - tg_tool->trans_info[ANGLE]) > EPSILON)
|
1998-08-15 06:34:54 -07:00
|
|
|
{
|
2018-06-15 12:42:19 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[ANGLE] = value;
|
1998-08-15 06:34:54 -07:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
2011-08-13 08:42:41 -07:00
|
|
|
|
2018-06-15 12:42:19 -07:00
|
|
|
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
1998-08-15 06:34:54 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2018-06-09 13:25:03 -07:00
|
|
|
rotate_center_changed (GtkWidget *widget,
|
|
|
|
|
GimpTransformGridTool *tg_tool)
|
1998-08-15 06:34:54 -07:00
|
|
|
{
|
2011-08-11 11:11:09 -07:00
|
|
|
gdouble px = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
|
gdouble py = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
1998-08-15 06:34:54 -07:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
if ((px != tg_tool->trans_info[PIVOT_X]) ||
|
|
|
|
|
(py != tg_tool->trans_info[PIVOT_Y]))
|
2001-11-19 10:23:43 -08:00
|
|
|
{
|
2018-06-15 12:42:19 -07:00
|
|
|
GimpTool *tool = GIMP_TOOL (tg_tool);
|
|
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
|
|
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
tg_tool->trans_info[PIVOT_X] = px;
|
|
|
|
|
tg_tool->trans_info[PIVOT_Y] = py;
|
2001-11-08 11:14:51 -08:00
|
|
|
|
2018-06-09 13:25:03 -07:00
|
|
|
gimp_transform_grid_tool_push_internal_undo (tg_tool);
|
2011-08-13 08:42:41 -07:00
|
|
|
|
2018-06-15 12:42:19 -07:00
|
|
|
gimp_transform_tool_recalc_matrix (tr_tool, tool->display);
|
1998-08-15 06:34:54 -07:00
|
|
|
}
|
|
|
|
|
}
|