1997-11-24 22:05:25 +00:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 05:44:11 +00:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-24 22:05:25 +00:00
|
|
|
*/
|
2000-12-16 21:37:03 +00: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 20:30:56 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
#include <gtk/gtk.h>
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-01-23 23:56:18 +00:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-01-24 22:36:18 +00:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-23 23:56:18 +00:00
|
|
|
|
2002-05-03 12:45:22 +00:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2002-05-10 23:30:09 +00:00
|
|
|
#ifdef __GNUC__
|
2002-05-03 12:45:22 +00:00
|
|
|
#warning FIXME #include "gui/gui-types.h"
|
2002-05-10 23:30:09 +00:00
|
|
|
#endif
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "gui/gui-types.h"
|
2000-12-16 21:37:03 +00:00
|
|
|
|
2001-05-09 02:32:03 +00:00
|
|
|
#include "core/gimpimage.h"
|
2001-11-19 18:23:43 +00:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
|
|
|
#include "core/gimpdrawable-transform-utils.h"
|
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-24 18:43:31 +00:00
|
|
|
|
2002-08-30 21:00:42 +00:00
|
|
|
#include "widgets/gimpviewabledialog.h"
|
|
|
|
|
2001-09-25 23:23:09 +00:00
|
|
|
#include "display/gimpdisplay.h"
|
2002-06-26 22:16:59 +00:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2001-01-23 13:01:48 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
#include "gui/info-dialog.h"
|
|
|
|
|
2001-04-24 18:43:31 +00:00
|
|
|
#include "gimprotatetool.h"
|
2001-04-28 20:14:32 +00:00
|
|
|
#include "transform_options.h"
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* index into trans_info array */
|
1999-06-26 11:16:47 +00:00
|
|
|
#define ANGLE 0
|
|
|
|
#define REAL_ANGLE 1
|
|
|
|
#define CENTER_X 2
|
|
|
|
#define CENTER_Y 3
|
1998-08-13 20:19:09 +00:00
|
|
|
|
1999-06-26 11:16:47 +00:00
|
|
|
#define EPSILON 0.018 /* ~ 1 degree */
|
1999-08-04 23:22:29 +00:00
|
|
|
#define FIFTEEN_DEG (G_PI / 12.0)
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2000-12-31 04:07:42 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
/* local function prototypes */
|
2001-04-24 18:43:31 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
static void gimp_rotate_tool_class_init (GimpRotateToolClass *klass);
|
|
|
|
static void gimp_rotate_tool_init (GimpRotateTool *rotate_tool);
|
|
|
|
|
|
|
|
static TileManager * gimp_rotate_tool_transform (GimpTransformTool *tr_tool,
|
2001-10-29 11:47:11 +00:00
|
|
|
GimpDisplay *gdisp,
|
2001-04-24 18:43:31 +00:00
|
|
|
TransformState state);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
static void rotate_tool_recalc (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void rotate_tool_motion (GimpTransformTool *tr_tool,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
static void rotate_info_update (GimpTransformTool *tr_tool);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
static void rotate_angle_changed (GtkWidget *entry,
|
|
|
|
gpointer data);
|
|
|
|
static void rotate_center_changed (GtkWidget *entry,
|
|
|
|
gpointer data);
|
2000-12-31 04:07:42 +00:00
|
|
|
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
/* variables local to this file */
|
1999-06-26 11:16:47 +00:00
|
|
|
static gdouble angle_val;
|
|
|
|
static gdouble center_vals[2];
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-06 12:13:54 +00:00
|
|
|
/* needed for size update */
|
2000-12-31 04:07:42 +00:00
|
|
|
static GtkWidget *sizeentry = NULL;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-04-24 18:43:31 +00:00
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
|
|
|
|
2001-07-07 12:17:23 +00:00
|
|
|
|
2001-04-24 18:43:31 +00:00
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
2002-03-29 03:50:29 +00:00
|
|
|
gimp_rotate_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 11:31:08 +00:00
|
|
|
gpointer data)
|
2001-04-24 18:43:31 +00:00
|
|
|
{
|
2002-03-29 03:50:29 +00:00
|
|
|
(* callback) (GIMP_TYPE_ROTATE_TOOL,
|
2001-11-20 23:00:47 +00:00
|
|
|
transform_options_new,
|
|
|
|
FALSE,
|
2002-03-21 12:17:17 +00: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 08:44:57 +00:00
|
|
|
_("Rotate"),
|
2001-11-20 23:00:47 +00:00
|
|
|
_("Rotate the layer or selection"),
|
|
|
|
N_("/Tools/Transform Tools/Rotate"), "<shift>R",
|
|
|
|
NULL, "tools/rotate.html",
|
2002-03-29 03:50:29 +00:00
|
|
|
GIMP_STOCK_TOOL_ROTATE,
|
2002-05-03 11:31:08 +00:00
|
|
|
data);
|
2001-04-24 18:43:31 +00:00
|
|
|
}
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
GType
|
2001-04-24 18:43:31 +00:00
|
|
|
gimp_rotate_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static GType tool_type = 0;
|
2001-04-24 18:43:31 +00:00
|
|
|
|
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 14:53:55 +00:00
|
|
|
static const GTypeInfo tool_info =
|
2001-04-24 18:43:31 +00:00
|
|
|
{
|
|
|
|
sizeof (GimpRotateToolClass),
|
2001-08-14 14:53:55 +00:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_rotate_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpRotateTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_rotate_tool_init,
|
2001-04-24 18:43:31 +00:00
|
|
|
};
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
|
|
|
"GimpRotateTool",
|
|
|
|
&tool_info, 0);
|
2001-04-24 18:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tool_type;
|
|
|
|
}
|
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2001-04-24 18:43:31 +00:00
|
|
|
static void
|
|
|
|
gimp_rotate_tool_class_init (GimpRotateToolClass *klass)
|
|
|
|
{
|
|
|
|
GimpTransformToolClass *trans_class;
|
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2001-04-24 18:43:31 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-04-24 18:43:31 +00:00
|
|
|
|
2001-08-14 14:53:55 +00:00
|
|
|
trans_class->transform = gimp_rotate_tool_transform;
|
2001-04-24 18:43:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_rotate_tool_init (GimpRotateTool *rotate_tool)
|
|
|
|
{
|
2001-11-20 23:00:47 +00:00
|
|
|
GimpTool *tool;
|
2001-04-24 18:43:31 +00:00
|
|
|
|
2001-11-20 23:00:47 +00:00
|
|
|
tool = GIMP_TOOL (rotate_tool);
|
2001-04-28 20:14:32 +00:00
|
|
|
|
2002-05-02 21:03:27 +00:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_ROTATE_TOOL_CURSOR);
|
2001-04-24 18:43:31 +00:00
|
|
|
}
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2000-12-31 04:07:42 +00:00
|
|
|
static TileManager *
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_rotate_tool_transform (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp,
|
|
|
|
TransformState state)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_INIT:
|
2001-11-19 18:23:43 +00:00
|
|
|
angle_val = 0.0;
|
2001-04-24 18:43:31 +00:00
|
|
|
center_vals[0] = transform_tool->cx;
|
|
|
|
center_vals[1] = transform_tool->cy;
|
1999-05-31 21:46:43 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
if (! transform_tool->info_dialog)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
GtkWidget *widget;
|
|
|
|
GtkWidget *spinbutton2;
|
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
transform_tool->info_dialog =
|
2002-08-30 21:00:42 +00:00
|
|
|
info_dialog_new (NULL,
|
|
|
|
_("Rotate"), "rotate",
|
|
|
|
GIMP_STOCK_TOOL_ROTATE,
|
|
|
|
_("Rotation Information"),
|
2001-11-22 13:01:26 +00:00
|
|
|
gimp_standard_help_func,
|
|
|
|
"tools/transform_rotate.html");
|
|
|
|
|
|
|
|
gimp_transform_tool_info_dialog_connect (transform_tool,
|
2001-11-22 14:28:39 +00:00
|
|
|
GIMP_STOCK_TOOL_ROTATE);
|
1999-04-02 19:46:59 +00:00
|
|
|
|
|
|
|
widget =
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog, _("Angle:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
&angle_val,
|
|
|
|
-180, 180, 1, 15, 1, 1, 2,
|
2001-08-01 02:57:58 +00:00
|
|
|
G_CALLBACK (rotate_angle_changed),
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-04-02 19:46:59 +00:00
|
|
|
gtk_spin_button_set_wrap (GTK_SPIN_BUTTON (widget), TRUE);
|
|
|
|
|
1999-07-09 14:51:01 +00:00
|
|
|
/* this looks strange (-180, 181), but it works */
|
2001-11-22 13:01:26 +00:00
|
|
|
widget = info_dialog_add_scale (transform_tool->info_dialog, "",
|
|
|
|
&angle_val,
|
1999-07-09 14:51:01 +00:00
|
|
|
-180, 181, 0.01, 0.1, 1, -1,
|
2001-08-01 02:57:58 +00:00
|
|
|
G_CALLBACK (rotate_angle_changed),
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
2001-12-29 13:26:29 +00:00
|
|
|
gtk_widget_set_size_request (widget, 180, -1);
|
1999-04-02 19:46:59 +00:00
|
|
|
|
|
|
|
spinbutton2 =
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_spinbutton (transform_tool->info_dialog,
|
|
|
|
_("Center X:"),
|
|
|
|
NULL,
|
1999-04-02 19:46:59 +00:00
|
|
|
-1, 1, 1, 10, 1, 1, 2, NULL, NULL);
|
1999-04-06 12:13:54 +00:00
|
|
|
sizeentry =
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_add_sizeentry (transform_tool->info_dialog, _("Y:"),
|
1999-04-02 19:46:59 +00:00
|
|
|
center_vals, 1,
|
1999-05-22 17:56:35 +00:00
|
|
|
gdisp->gimage->unit, "%a",
|
1999-04-06 12:13:54 +00:00
|
|
|
TRUE, TRUE, FALSE,
|
1999-04-05 12:48:48 +00:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-24 21:27:11 +00:00
|
|
|
G_CALLBACK (rotate_center_changed),
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
1999-04-05 12:48:48 +00:00
|
|
|
GTK_SPIN_BUTTON (spinbutton2), NULL);
|
1999-04-02 19:46:59 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (transform_tool->info_dialog->info_table),
|
1999-04-02 19:46:59 +00:00
|
|
|
1, 6);
|
2001-11-22 13:01:26 +00:00
|
|
|
gtk_table_set_row_spacing (GTK_TABLE (transform_tool->info_dialog->info_table),
|
1999-04-02 19:46:59 +00:00
|
|
|
2, 0);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
1999-05-31 21:46:43 +00:00
|
|
|
|
2002-08-30 21:00:42 +00:00
|
|
|
gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (transform_tool->info_dialog->shell),
|
|
|
|
GIMP_VIEWABLE (gimp_image_active_drawable (gdisp->gimage)));
|
|
|
|
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_block_by_func (G_OBJECT (sizeentry),
|
|
|
|
rotate_center_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
gdisp->gimage->unit);
|
2002-06-26 22:16:59 +00:00
|
|
|
|
|
|
|
if (GIMP_DISPLAY_SHELL (gdisp->shell)->dot_for_dot)
|
2000-02-07 20:35:13 +00:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
gdisp->gimage->xresolution, FALSE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
gdisp->gimage->yresolution, FALSE);
|
|
|
|
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
-65536,
|
|
|
|
65536 + gdisp->gimage->width);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
-65536,
|
|
|
|
65536 + gdisp->gimage->height);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2001-04-24 18:43:31 +00:00
|
|
|
transform_tool->x1, transform_tool->x2);
|
1999-04-06 12:13:54 +00:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
2001-04-24 18:43:31 +00:00
|
|
|
transform_tool->y1, transform_tool->y2);
|
1999-04-06 12:13:54 +00:00
|
|
|
|
1999-05-31 21:46:43 +00:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
center_vals[0]);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
center_vals[1]);
|
|
|
|
|
2001-08-01 02:57:58 +00:00
|
|
|
g_signal_handlers_unblock_by_func (G_OBJECT (sizeentry),
|
|
|
|
rotate_center_changed,
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool);
|
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
gtk_widget_set_sensitive (transform_tool->info_dialog->shell, TRUE);
|
1999-05-31 21:46:43 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
transform_tool->trans_info[ANGLE] = angle_val;
|
2001-04-24 18:43:31 +00:00
|
|
|
transform_tool->trans_info[REAL_ANGLE] = angle_val;
|
2001-11-08 19:14:51 +00:00
|
|
|
transform_tool->trans_info[CENTER_X] = center_vals[0];
|
|
|
|
transform_tool->trans_info[CENTER_Y] = center_vals[1];
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_MOTION:
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_motion (transform_tool, gdisp);
|
|
|
|
rotate_tool_recalc (transform_tool, gdisp);
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_RECALC:
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_recalc (transform_tool, gdisp);
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
|
2000-12-29 15:22:01 +00:00
|
|
|
case TRANSFORM_FINISH:
|
2001-11-19 18:23:43 +00:00
|
|
|
return gimp_transform_tool_transform_tiles (transform_tool,
|
|
|
|
_("Rotating..."));
|
1997-11-24 22:05:25 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_info_update (GimpTransformTool *transform_tool)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-04-24 18:43:31 +00:00
|
|
|
angle_val = gimp_rad_to_deg (transform_tool->trans_info[ANGLE]);
|
2001-11-08 19:14:51 +00:00
|
|
|
center_vals[0] = transform_tool->trans_info[CENTER_X];
|
|
|
|
center_vals[1] = transform_tool->trans_info[CENTER_Y];
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-22 13:01:26 +00:00
|
|
|
info_dialog_update (transform_tool->info_dialog);
|
|
|
|
info_dialog_popup (transform_tool->info_dialog);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
1998-08-15 13:34:54 +00:00
|
|
|
static void
|
2000-01-05 11:18:38 +00:00
|
|
|
rotate_angle_changed (GtkWidget *widget,
|
1999-04-02 19:46:59 +00:00
|
|
|
gpointer data)
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-04-24 18:43:31 +00:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
|
|
|
gdouble value;
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
|
|
|
|
|
|
|
value = gimp_deg_to_rad (GTK_ADJUSTMENT (widget)->value);
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
if (value != transform_tool->trans_info[ANGLE])
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool->trans_info[ANGLE] = value;
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_recalc (transform_tool, tool->gdisp);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 13:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2000-01-05 11:18:38 +00:00
|
|
|
rotate_center_changed (GtkWidget *widget,
|
1999-04-02 19:46:59 +00:00
|
|
|
gpointer data)
|
1998-08-15 13:34:54 +00:00
|
|
|
{
|
2001-04-24 18:43:31 +00:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpTransformTool *transform_tool;
|
2002-02-19 16:35:13 +00:00
|
|
|
gdouble cx;
|
|
|
|
gdouble cy;
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
tool = GIMP_TOOL (data);
|
|
|
|
transform_tool = GIMP_TRANSFORM_TOOL (data);
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2002-02-19 16:35:13 +00:00
|
|
|
cx = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
cy = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
1998-08-15 13:34:54 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
if ((cx != transform_tool->trans_info[CENTER_X]) ||
|
|
|
|
(cy != transform_tool->trans_info[CENTER_Y]))
|
|
|
|
{
|
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool->trans_info[CENTER_X] = cx;
|
|
|
|
transform_tool->trans_info[CENTER_Y] = cy;
|
|
|
|
transform_tool->cx = cx;
|
|
|
|
transform_tool->cy = cy;
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_recalc (transform_tool, tool->gdisp);
|
2001-11-08 19:14:51 +00:00
|
|
|
|
2001-11-19 18:23:43 +00:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1998-08-15 13:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-24 22:05:25 +00:00
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_motion (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-29 16:44:51 +00:00
|
|
|
TransformOptions *options;
|
|
|
|
gdouble angle1, angle2, angle;
|
|
|
|
gdouble cx, cy;
|
|
|
|
gdouble x1, y1, x2, y2;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-04-24 18:43:31 +00:00
|
|
|
if (transform_tool->function == TRANSFORM_HANDLE_CENTER)
|
1998-08-13 20:19:09 +00:00
|
|
|
{
|
2001-11-08 19:14:51 +00:00
|
|
|
transform_tool->trans_info[CENTER_X] = transform_tool->curx;
|
|
|
|
transform_tool->trans_info[CENTER_Y] = transform_tool->cury;
|
2001-11-19 18:23:43 +00:00
|
|
|
transform_tool->cx = transform_tool->curx;
|
|
|
|
transform_tool->cy = transform_tool->cury;
|
1998-08-13 20:19:09 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-11-29 16:44:51 +00:00
|
|
|
options = (TransformOptions *) GIMP_TOOL (transform_tool)->tool_info->tool_options;
|
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
cx = transform_tool->trans_info[CENTER_X];
|
|
|
|
cy = transform_tool->trans_info[CENTER_Y];
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-19 16:35:13 +00:00
|
|
|
x1 = transform_tool->curx - cx;
|
2001-04-24 18:43:31 +00:00
|
|
|
x2 = transform_tool->lastx - cx;
|
|
|
|
y1 = cy - transform_tool->cury;
|
|
|
|
y2 = cy - transform_tool->lasty;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* find the first angle */
|
|
|
|
angle1 = atan2 (y1, x1);
|
|
|
|
|
|
|
|
/* find the angle */
|
|
|
|
angle2 = atan2 (y2, x2);
|
|
|
|
|
|
|
|
angle = angle2 - angle1;
|
|
|
|
|
1999-08-04 23:22:29 +00:00
|
|
|
if (angle > G_PI || angle < -G_PI)
|
2000-02-18 18:20:04 +00:00
|
|
|
angle = angle2 - ((angle1 < 0) ? 2.0 * G_PI + angle1 : angle1 - 2.0 * G_PI);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* increment the transform tool's angle */
|
2001-04-24 18:43:31 +00:00
|
|
|
transform_tool->trans_info[REAL_ANGLE] += angle;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* limit the angle to between 0 and 360 degrees */
|
2001-04-24 18:43:31 +00:00
|
|
|
if (transform_tool->trans_info[REAL_ANGLE] < - G_PI)
|
|
|
|
transform_tool->trans_info[REAL_ANGLE] =
|
|
|
|
2.0 * G_PI - transform_tool->trans_info[REAL_ANGLE];
|
|
|
|
else if (transform_tool->trans_info[REAL_ANGLE] > G_PI)
|
|
|
|
transform_tool->trans_info[REAL_ANGLE] =
|
|
|
|
transform_tool->trans_info[REAL_ANGLE] - 2.0 * G_PI;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
1999-05-31 14:11:10 +00:00
|
|
|
/* constrain the angle to 15-degree multiples if ctrl is held down */
|
2001-11-29 16:44:51 +00:00
|
|
|
if (options->constrain_1)
|
|
|
|
{
|
|
|
|
transform_tool->trans_info[ANGLE] =
|
|
|
|
FIFTEEN_DEG * (int) ((transform_tool->trans_info[REAL_ANGLE] +
|
|
|
|
FIFTEEN_DEG / 2.0) /
|
|
|
|
FIFTEEN_DEG);
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
else
|
2001-11-29 16:44:51 +00:00
|
|
|
{
|
|
|
|
transform_tool->trans_info[ANGLE] = transform_tool->trans_info[REAL_ANGLE];
|
|
|
|
}
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|
|
|
|
|
2000-01-05 11:18:38 +00:00
|
|
|
static void
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_tool_recalc (GimpTransformTool *transform_tool,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-24 22:05:25 +00:00
|
|
|
{
|
2001-11-19 18:23:43 +00:00
|
|
|
gdouble cx, cy;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2001-11-08 19:14:51 +00:00
|
|
|
cx = transform_tool->trans_info[CENTER_X];
|
|
|
|
cy = transform_tool->trans_info[CENTER_Y];
|
|
|
|
|
|
|
|
transform_tool->cx = cx;
|
|
|
|
transform_tool->cy = cy;
|
1997-11-24 22:05:25 +00:00
|
|
|
|
2002-02-19 16:35:13 +00:00
|
|
|
gimp_drawable_transform_matrix_rotate_center (transform_tool->cx,
|
|
|
|
transform_tool->cy,
|
|
|
|
transform_tool->trans_info[ANGLE],
|
|
|
|
transform_tool->transform);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* transform the bounding box */
|
2001-04-24 18:43:31 +00:00
|
|
|
gimp_transform_tool_transform_bounding_box (transform_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
|
|
|
|
/* update the information dialog */
|
2001-11-19 18:23:43 +00:00
|
|
|
rotate_info_update (transform_tool);
|
1997-11-24 22:05:25 +00:00
|
|
|
}
|