1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2001-08-06 00:08:19 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
2004-10-30 23:02:39 +08:00
|
|
|
#include "config/gimpguiconfig.h"
|
2004-02-19 04:31:11 +08:00
|
|
|
|
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
include the new "paint-funcs/paint-funcs-types.h".
2001-11-28 Michael Natterer <mitch@gimp.org>
* app/base/base-types.h: include the new
"paint-funcs/paint-funcs-types.h".
* app/paint-funcs/Makefile.am
* app/paint-funcs/paint-funcs-types.h: new file. Includes
"base/base-types.h".
* app/paint-funcs/paint-funcs.[ch]: removed the enums here,
include "paint-funcs-types.h".
* app/widgets/widgets-types.h: include "display/display-types.h"
* app/display/display-types.h: include "widgets/widgets-types.h".
* app/tools/tools-types.h: include "display/display-types.h"
* app/gui/gui-types.h: include "tools/tools-types.h".
The order of namespaces/dependencies should be (but is not):
(base, paint-funcs) -> (core, file, xcf, pdb) ->
(widgets, display) -> tools -> gui
* app/path.c: include "tools/tools-types.h".
* app/core/Makefile.am
* app/core/gimpimage-guides.[ch]
* app/core/gimpimage-merge.[ch]
* app/core/gimpimage-resize.[ch]
* app/core/gimpimage-scale.[ch]: new files.
* app/core/gimpimage.[ch]: removed the stuff which is in the new
files. Reordered all functions in both the .h and .c files,
commented the groups of functions.
* app/core/gimpcontainer.c: create the handler_id using a counter,
not the address of a pointer, because the address *may* be the
same twice, added debugging output.
* app/core/gimpviewable.[ch]: added primitive support for getting
a preview GdkPixbuf.
* app/nav_window.c
* app/undo.c
* app/undo_history.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-mask.[ch]
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-callbacks.c
* app/display/gimpdisplayshell-dnd.c
* app/display/gimpdisplayshell-render.c
* app/display/gimpdisplayshell-scale.c
* app/display/gimpdisplayshell-scroll.c
* app/gui/image-commands.c
* app/gui/info-window.c
* app/gui/layers-commands.c
* app/gui/palette-import-dialog.c
* app/tools/gimpbycolorselecttool.c
* app/tools/gimpeditselectiontool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimpmovetool.c
* app/widgets/gimpcontainerview-utils.c
* app/xcf/xcf-load.c: changed accordingly, some cleanup.
* tools/pdbgen/pdb/guides.pdb
* tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions.
* app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu
items to the name of the last plug-in (Fixes #50986).
* app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and
"Redo" to the resp. undo names. Much simplified the WM icon stuff
by removing most code and using gimp_viewable_get_new_preview_pixbuf().
* app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark
returned by gimp_container_add_handler().
* app/pdb/guides_cmds.c
* app/pdb/image_cmds.c
* libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
|
|
|
#include "core/gimpimage-guides.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimplayer.h"
|
2004-01-12 22:13:24 +08:00
|
|
|
#include "core/gimplayermask.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core/gimplayer-floating-sel.h"
|
2001-11-26 21:17:18 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
2003-03-20 19:31:33 +08:00
|
|
|
#include "display/gimpdisplayshell-appearance.h"
|
2004-02-07 08:16:52 +08:00
|
|
|
#include "display/gimpdisplayshell-draw.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "display/gimpdisplayshell-transform.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpeditselectiontool.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpmoveoptions.h"
|
2001-03-08 09:07:03 +08:00
|
|
|
#include "gimpmovetool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
1998-12-16 08:37:09 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2004-11-10 09:17:40 +08:00
|
|
|
#define SWAP_ORIENT(orient) ((orient) == GIMP_ORIENTATION_HORIZONTAL ? \
|
|
|
|
GIMP_ORIENTATION_VERTICAL : \
|
|
|
|
GIMP_ORIENTATION_HORIZONTAL)
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-11-26 21:17:18 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_move_tool_control (GimpTool *tool,
|
2002-02-19 01:00:09 +08:00
|
|
|
GimpToolAction action,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_move_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_move_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_move_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-26 21:17:18 +08:00
|
|
|
static void gimp_move_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2003-10-29 23:03:56 +08:00
|
|
|
static void gimp_move_tool_oper_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2006-03-25 22:23:09 +08:00
|
|
|
gboolean proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-11 07:03:22 +08:00
|
|
|
static void gimp_move_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display);
|
2001-11-11 07:03:22 +08:00
|
|
|
|
2001-11-12 22:45:58 +08:00
|
|
|
static void gimp_move_tool_draw (GimpDrawTool *draw_tool);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
static void gimp_move_tool_start_guide (GimpMoveTool *move,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display,
|
2003-02-08 01:12:21 +08:00
|
|
|
GimpOrientationType orientation);
|
2002-02-08 01:37:34 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpMoveTool, gimp_move_tool, GIMP_TYPE_DRAW_TOOL);
|
|
|
|
|
|
|
|
#define parent_class gimp_move_tool_parent_class
|
2001-02-22 05:56:39 +08:00
|
|
|
|
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_move_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
2001-02-22 05:56:39 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_MOVE_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_MOVE_OPTIONS,
|
|
|
|
gimp_move_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-move-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Move"),
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Move layers & selections"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Move"), "M",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_MOVE,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_MOVE,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-02-22 05:56:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_move_tool_class_init (GimpMoveToolClass *klass)
|
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
tool_class->control = gimp_move_tool_control;
|
|
|
|
tool_class->button_press = gimp_move_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_move_tool_button_release;
|
|
|
|
tool_class->motion = gimp_move_tool_motion;
|
2004-06-13 02:41:52 +08:00
|
|
|
tool_class->key_press = gimp_edit_selection_tool_key_press;
|
2001-11-26 21:17:18 +08:00
|
|
|
tool_class->modifier_key = gimp_move_tool_modifier_key;
|
2003-10-29 23:03:56 +08:00
|
|
|
tool_class->oper_update = gimp_move_tool_oper_update;
|
2001-11-11 07:03:22 +08:00
|
|
|
tool_class->cursor_update = gimp_move_tool_cursor_update;
|
2001-11-12 22:45:58 +08:00
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_move_tool_draw;
|
2001-02-22 05:56:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_move_tool_init (GimpMoveTool *move_tool)
|
|
|
|
{
|
2003-10-31 19:51:47 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (move_tool);
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
move_tool->floating_layer = NULL;
|
|
|
|
move_tool->guide = NULL;
|
2003-03-28 21:52:01 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
move_tool->moving_guide = FALSE;
|
|
|
|
move_tool->guide_position = -1;
|
|
|
|
move_tool->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
move_tool->saved_type = GIMP_TRANSFORM_TYPE_LAYER;
|
|
|
|
|
|
|
|
move_tool->old_active_layer = NULL;
|
|
|
|
move_tool->old_active_vectors = NULL;
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2005-11-24 03:14:05 +08:00
|
|
|
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
|
|
|
gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
|
|
|
GIMP_TOOL_CURSOR_MOVE);
|
2001-02-22 05:56:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-02-19 01:00:09 +08:00
|
|
|
gimp_move_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2001-02-22 05:56:39 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2001-02-22 05:56:39 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
switch (action)
|
2001-02-22 05:56:39 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
case PAUSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME:
|
2004-03-09 21:24:15 +08:00
|
|
|
if (move->guide &&
|
2003-10-31 19:51:47 +08:00
|
|
|
gimp_display_shell_get_show_guides (GIMP_DISPLAY_SHELL (shell)))
|
2003-08-22 01:40:29 +08:00
|
|
|
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (shell),
|
2004-03-09 21:24:15 +08:00
|
|
|
move->guide, TRUE);
|
2001-08-14 22:53:55 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case HALT:
|
2004-03-09 21:24:15 +08:00
|
|
|
if (move->guide &&
|
2003-10-31 19:51:47 +08:00
|
|
|
gimp_display_shell_get_show_guides (GIMP_DISPLAY_SHELL (shell)))
|
2003-08-22 01:40:29 +08:00
|
|
|
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (shell),
|
2004-03-09 21:24:15 +08:00
|
|
|
move->guide, FALSE);
|
2001-08-14 22:53:55 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2001-02-22 05:56:39 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
2001-02-22 05:56:39 +08:00
|
|
|
}
|
1999-04-09 06:25:54 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_move_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (tool->tool_info->tool_options);
|
2001-11-26 21:17:18 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2002-02-05 19:35:03 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
move->floating_layer = NULL;
|
|
|
|
move->guide = NULL;
|
|
|
|
move->moving_guide = FALSE;
|
|
|
|
move->old_active_layer = NULL;
|
|
|
|
move->old_active_vectors = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
if (! options->move_current)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
if (options->move_type == GIMP_TRANSFORM_TYPE_PATH)
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
|
|
|
GimpVectors *vectors;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
|
2003-09-17 00:23:38 +08:00
|
|
|
coords, 7, 7,
|
2004-10-30 21:52:20 +08:00
|
|
|
NULL, NULL, NULL, NULL, NULL,
|
|
|
|
&vectors))
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
2004-10-07 05:04:13 +08:00
|
|
|
move->old_active_vectors =
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_get_active_vectors (display->image);
|
2004-10-07 05:04:13 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_set_active_vectors (display->image, vectors);
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
2004-01-12 22:13:24 +08:00
|
|
|
else
|
2004-03-09 21:24:15 +08:00
|
|
|
{
|
|
|
|
/* no path picked */
|
|
|
|
return;
|
|
|
|
}
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
2004-03-09 21:24:15 +08:00
|
|
|
else if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER)
|
|
|
|
{
|
|
|
|
GimpGuide *guide;
|
|
|
|
GimpLayer *layer;
|
|
|
|
gint snap_distance;
|
|
|
|
|
|
|
|
snap_distance =
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
|
2004-03-09 21:24:15 +08:00
|
|
|
|
|
|
|
if (gimp_display_shell_get_show_guides (shell) &&
|
2006-03-29 01:55:52 +08:00
|
|
|
(guide = gimp_image_find_guide (display->image,
|
2004-03-09 21:24:15 +08:00
|
|
|
coords->x, coords->y,
|
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance))))
|
|
|
|
{
|
|
|
|
move->guide = guide;
|
|
|
|
move->moving_guide = TRUE;
|
|
|
|
move->guide_position = guide->position;
|
|
|
|
move->guide_orientation = guide->orientation;
|
2004-02-19 04:31:11 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
|
|
|
gimp_tool_control_activate (tool->control);
|
2004-02-19 04:31:11 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
gimp_display_shell_selection_visibility (shell,
|
|
|
|
GIMP_SELECTION_PAUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status_length (tool, display,
|
2005-05-07 21:24:47 +08:00
|
|
|
_("Move Guide: "),
|
2004-11-10 09:17:40 +08:00
|
|
|
SWAP_ORIENT (move->guide_orientation),
|
|
|
|
move->guide_position);
|
2004-11-09 21:03:07 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
return;
|
|
|
|
}
|
2006-03-29 01:55:52 +08:00
|
|
|
else if ((layer = gimp_image_pick_correlate_layer (display->image,
|
2004-03-09 21:24:15 +08:00
|
|
|
coords->x,
|
|
|
|
coords->y)))
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_floating_sel (display->image) &&
|
2004-03-09 21:24:15 +08:00
|
|
|
! gimp_layer_is_floating_sel (layer))
|
|
|
|
{
|
|
|
|
/* If there is a floating selection, and this aint it,
|
|
|
|
* use the move tool to anchor it.
|
|
|
|
*/
|
2006-03-29 01:55:52 +08:00
|
|
|
move->floating_layer = gimp_image_floating_sel (display->image);
|
2004-03-09 21:24:15 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
2003-04-13 19:43:47 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-07 05:04:13 +08:00
|
|
|
move->old_active_layer =
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_get_active_layer (display->image);
|
2004-10-07 05:04:13 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_set_active_layer (display->image, layer);
|
2004-03-09 21:24:15 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* no guide and no layer picked */
|
2004-03-05 05:01:26 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-03-05 05:01:26 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
switch (options->move_type)
|
|
|
|
{
|
|
|
|
case GIMP_TRANSFORM_TYPE_PATH:
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_get_active_vectors (display->image))
|
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_VECTORS, TRUE);
|
2004-03-09 21:24:15 +08:00
|
|
|
break;
|
2004-03-05 05:01:26 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
case GIMP_TRANSFORM_TYPE_SELECTION:
|
2006-03-29 01:55:52 +08:00
|
|
|
if (! gimp_channel_is_empty (gimp_image_get_mask (display->image)))
|
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_MASK, TRUE);
|
2004-03-09 21:24:15 +08:00
|
|
|
break;
|
2004-03-05 05:01:26 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
case GIMP_TRANSFORM_TYPE_LAYER:
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDrawable *drawable = gimp_image_active_drawable (display->image);
|
2004-03-09 21:24:15 +08:00
|
|
|
|
|
|
|
if (GIMP_IS_LAYER_MASK (drawable))
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_LAYER_MASK, TRUE);
|
2004-03-09 21:24:15 +08:00
|
|
|
else if (GIMP_IS_CHANNEL (drawable))
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_CHANNEL, TRUE);
|
2004-03-09 21:24:15 +08:00
|
|
|
else if (GIMP_IS_LAYER (drawable))
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_start (tool, display, coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GIMP_TRANSLATE_MODE_LAYER, TRUE);
|
2004-03-09 21:24:15 +08:00
|
|
|
}
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-03-16 19:13:24 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_move_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-10-30 23:02:39 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
|
|
|
GimpGuiConfig *config = GIMP_GUI_CONFIG (display->image->gimp->config);
|
2002-06-27 06:16:59 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
if (gimp_tool_control_is_active (tool->control))
|
|
|
|
gimp_tool_control_halt (tool->control);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
if (move->moving_guide)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-28 21:52:01 +08:00
|
|
|
gboolean delete_guide = FALSE;
|
2004-01-15 22:36:43 +08:00
|
|
|
gint x, y, width, height;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2004-11-09 21:03:07 +08:00
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, FALSE);
|
2003-03-28 21:52:01 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
|
|
|
if (state & GDK_BUTTON3_MASK)
|
|
|
|
{
|
|
|
|
move->moving_guide = FALSE;
|
|
|
|
move->guide_position = -1;
|
|
|
|
move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-04-04 01:37:31 +08:00
|
|
|
gimp_display_shell_selection_visibility (shell,
|
|
|
|
GIMP_SELECTION_RESUME);
|
2003-03-28 21:52:01 +08:00
|
|
|
return;
|
|
|
|
}
|
2002-06-27 06:16:59 +08:00
|
|
|
|
2004-01-15 22:36:43 +08:00
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
switch (move->guide_orientation)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2004-01-15 22:36:43 +08:00
|
|
|
if ((move->guide_position < y) ||
|
|
|
|
(move->guide_position > (y + height)))
|
1999-10-14 07:07:45 +08:00
|
|
|
delete_guide = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2004-01-15 22:36:43 +08:00
|
|
|
if ((move->guide_position < x) ||
|
|
|
|
(move->guide_position > (x + width)))
|
1999-10-14 07:07:45 +08:00
|
|
|
delete_guide = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2000-12-29 00:19:55 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1999-10-14 07:07:45 +08:00
|
|
|
if (delete_guide)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-28 21:52:01 +08:00
|
|
|
if (move->guide)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_remove_guide (display->image, move->guide, TRUE);
|
2003-10-29 23:03:56 +08:00
|
|
|
move->guide = NULL;
|
2003-03-28 21:52:01 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-03-28 21:52:01 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (move->guide)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_move_guide (display->image, move->guide,
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position, TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (move->guide_orientation)
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2006-03-29 01:55:52 +08:00
|
|
|
move->guide = gimp_image_add_hguide (display->image,
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position,
|
|
|
|
TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2006-03-29 01:55:52 +08:00
|
|
|
move->guide = gimp_image_add_vguide (display->image,
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position,
|
|
|
|
TRUE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_display_shell_selection_visibility (shell, GIMP_SELECTION_RESUME);
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_flush (display->image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (move->guide)
|
2001-11-01 05:20:09 +08:00
|
|
|
gimp_display_shell_draw_guide (shell, move->guide, TRUE);
|
2003-03-28 21:52:01 +08:00
|
|
|
|
|
|
|
move->moving_guide = FALSE;
|
|
|
|
move->guide_position = -1;
|
|
|
|
move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-10-30 23:02:39 +08:00
|
|
|
if (! config->move_tool_changes_active || (state & GDK_BUTTON3_MASK))
|
2004-10-07 05:04:13 +08:00
|
|
|
{
|
2004-10-30 23:02:39 +08:00
|
|
|
if (move->old_active_layer)
|
2004-10-30 21:52:20 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_set_active_layer (display->image,
|
2004-10-30 21:52:20 +08:00
|
|
|
move->old_active_layer);
|
2004-10-30 23:02:39 +08:00
|
|
|
move->old_active_layer = NULL;
|
2004-10-30 21:52:20 +08:00
|
|
|
}
|
2004-10-07 05:04:13 +08:00
|
|
|
|
2004-10-30 23:02:39 +08:00
|
|
|
if (move->old_active_vectors)
|
2004-10-30 21:52:20 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_set_active_vectors (display->image,
|
2004-10-30 21:52:20 +08:00
|
|
|
move->old_active_vectors);
|
2004-10-30 23:02:39 +08:00
|
|
|
move->old_active_vectors = NULL;
|
2004-10-30 21:52:20 +08:00
|
|
|
}
|
2004-10-07 05:04:13 +08:00
|
|
|
}
|
|
|
|
|
1999-10-14 07:07:45 +08:00
|
|
|
/* Take care of the case where the user "cancels" the action */
|
2001-11-09 03:14:51 +08:00
|
|
|
if (! (state & GDK_BUTTON3_MASK))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-10-07 05:04:13 +08:00
|
|
|
if (move->floating_layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-10-07 05:04:13 +08:00
|
|
|
floating_sel_anchor (move->floating_layer);
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_flush (display->image);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_move_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1998-03-16 19:13:24 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
if (move->moving_guide)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-11-09 21:03:07 +08:00
|
|
|
gint tx, ty;
|
|
|
|
gboolean delete_guide = FALSE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1999-04-06 07:33:50 +08:00
|
|
|
|
2002-06-27 06:16:59 +08:00
|
|
|
gimp_display_shell_transform_xy (shell,
|
|
|
|
coords->x, coords->y,
|
|
|
|
&tx, &ty,
|
|
|
|
FALSE);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
if (tx < 0 || tx >= shell->disp_width ||
|
|
|
|
ty < 0 || ty >= shell->disp_height)
|
1999-04-06 07:33:50 +08:00
|
|
|
{
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position = -1;
|
2004-11-09 21:03:07 +08:00
|
|
|
|
|
|
|
delete_guide = TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
else
|
|
|
|
{
|
2004-11-09 21:03:07 +08:00
|
|
|
gint x, y, width, height;
|
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
if (move->guide_orientation == GIMP_ORIENTATION_HORIZONTAL)
|
2004-05-04 21:09:39 +08:00
|
|
|
move->guide_position = RINT (coords->y);
|
2001-11-09 03:14:51 +08:00
|
|
|
else
|
2004-05-04 21:09:39 +08:00
|
|
|
move->guide_position = RINT (coords->x);
|
2004-11-09 21:03:07 +08:00
|
|
|
|
|
|
|
gimp_display_shell_untransform_viewport (shell, &x, &y,
|
|
|
|
&width, &height);
|
|
|
|
|
|
|
|
switch (move->guide_orientation)
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
|
|
|
if ((move->guide_position < y) ||
|
|
|
|
(move->guide_position > (y + height)))
|
|
|
|
delete_guide = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
|
|
|
if ((move->guide_position < x) ||
|
|
|
|
(move->guide_position > (x + width)))
|
|
|
|
delete_guide = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-10 09:17:40 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
2004-11-10 09:17:40 +08:00
|
|
|
|
2004-11-09 21:03:07 +08:00
|
|
|
if (delete_guide)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status (tool, display,
|
2004-11-10 09:17:40 +08:00
|
|
|
move->guide ?
|
|
|
|
_("Remove Guide") : _("Cancel Guide"));
|
2004-11-09 21:03:07 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status_length (tool, display,
|
2004-11-10 09:17:40 +08:00
|
|
|
move->guide ?
|
|
|
|
_("Move Guide: ") : _("Add Guide: "),
|
|
|
|
SWAP_ORIENT (move->guide_orientation),
|
|
|
|
move->guide_position);
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-11-26 21:17:18 +08:00
|
|
|
static void
|
|
|
|
gimp_move_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2001-11-26 21:17:18 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
|
|
|
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (tool->tool_info->tool_options);
|
2001-11-26 21:17:18 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (key == GDK_SHIFT_MASK)
|
2001-11-26 21:17:18 +08:00
|
|
|
{
|
2003-09-17 00:23:38 +08:00
|
|
|
g_object_set (options, "move-current", ! options->move_current, NULL);
|
2001-11-26 21:17:18 +08:00
|
|
|
}
|
2003-09-17 00:23:38 +08:00
|
|
|
else if (key == GDK_MOD1_MASK || key == GDK_CONTROL_MASK)
|
2001-11-26 21:17:18 +08:00
|
|
|
{
|
2003-09-17 00:23:38 +08:00
|
|
|
GimpTransformType button_type;
|
|
|
|
|
|
|
|
button_type = options->move_type;
|
|
|
|
|
|
|
|
if (press)
|
|
|
|
{
|
|
|
|
if (key == (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
|
|
|
|
{
|
|
|
|
/* first modifier pressed */
|
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
move->saved_type = options->move_type;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (! (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
|
|
|
|
{
|
|
|
|
/* last modifier released */
|
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
button_type = move->saved_type;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state & GDK_MOD1_MASK)
|
|
|
|
{
|
|
|
|
button_type = GIMP_TRANSFORM_TYPE_SELECTION;
|
|
|
|
}
|
|
|
|
else if (state & GDK_CONTROL_MASK)
|
|
|
|
{
|
|
|
|
button_type = GIMP_TRANSFORM_TYPE_PATH;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (button_type != options->move_type)
|
|
|
|
{
|
|
|
|
g_object_set (options, "move-type", button_type, NULL);
|
|
|
|
}
|
2001-11-26 21:17:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-10-29 23:03:56 +08:00
|
|
|
static void
|
|
|
|
gimp_move_tool_oper_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2006-03-25 22:23:09 +08:00
|
|
|
gboolean proximity,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2003-10-29 23:03:56 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (tool->tool_info->tool_options);
|
|
|
|
GimpGuide *guide = NULL;
|
2003-10-29 23:03:56 +08:00
|
|
|
|
|
|
|
if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER &&
|
|
|
|
! options->move_current &&
|
|
|
|
gimp_display_shell_get_show_guides (shell) &&
|
2006-03-25 22:23:09 +08:00
|
|
|
proximity)
|
2003-10-29 23:03:56 +08:00
|
|
|
{
|
2004-02-19 04:31:11 +08:00
|
|
|
gint snap_distance;
|
|
|
|
|
2004-07-14 18:31:59 +08:00
|
|
|
snap_distance =
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
|
2004-07-14 18:31:59 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
guide = gimp_image_find_guide (display->image, coords->x, coords->y,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance));
|
2003-10-29 23:03:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (move->guide && move->guide != guide)
|
2004-03-09 21:24:15 +08:00
|
|
|
gimp_display_shell_draw_guide (shell, move->guide, FALSE);
|
2003-10-29 23:03:56 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
move->guide = guide;
|
|
|
|
|
|
|
|
if (move->guide)
|
|
|
|
gimp_display_shell_draw_guide (shell, move->guide, TRUE);
|
2003-10-29 23:03:56 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2001-11-11 07:03:22 +08:00
|
|
|
gimp_move_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveOptions *options = GIMP_MOVE_OPTIONS (tool->tool_info->tool_options);
|
2003-10-29 23:03:56 +08:00
|
|
|
|
2004-06-14 18:19:39 +08:00
|
|
|
GimpCursorType cursor = GIMP_CURSOR_BAD;
|
2004-06-05 07:08:29 +08:00
|
|
|
GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_MOVE;
|
2003-10-29 23:03:56 +08:00
|
|
|
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (options->move_type == GIMP_TRANSFORM_TYPE_PATH)
|
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_PATHS;
|
2003-10-29 23:03:56 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (options->move_current)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_get_active_vectors (display->image))
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
|
2003-09-17 00:23:38 +08:00
|
|
|
coords, 7, 7,
|
2003-09-18 21:20:40 +08:00
|
|
|
NULL, NULL, NULL, NULL, NULL, NULL))
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
2005-11-20 06:16:34 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_HAND;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (options->move_type == GIMP_TRANSFORM_TYPE_SELECTION)
|
2000-03-29 07:39:32 +08:00
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_RECT_SELECT;
|
2003-10-29 23:03:56 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
if (! gimp_channel_is_empty (gimp_image_get_mask (display->image)))
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2000-03-29 07:39:32 +08:00
|
|
|
}
|
2001-11-26 21:17:18 +08:00
|
|
|
else if (options->move_current)
|
2000-03-29 07:39:32 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_active_drawable (display->image))
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2000-03-29 07:39:32 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
|
|
|
{
|
2003-10-29 23:03:56 +08:00
|
|
|
GimpGuide *guide;
|
|
|
|
GimpLayer *layer;
|
2004-03-09 21:24:15 +08:00
|
|
|
gint snap_distance;
|
2004-02-19 04:31:11 +08:00
|
|
|
|
2004-03-09 21:24:15 +08:00
|
|
|
snap_distance =
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-10-29 23:03:56 +08:00
|
|
|
if (gimp_display_shell_get_show_guides (shell) &&
|
2006-03-29 01:55:52 +08:00
|
|
|
(guide = gimp_image_find_guide (display->image, coords->x, coords->y,
|
2004-02-19 04:31:11 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance))))
|
2003-10-29 23:03:56 +08:00
|
|
|
{
|
2005-11-20 06:16:34 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_HAND;
|
2003-10-29 23:03:56 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2006-03-29 01:55:52 +08:00
|
|
|
else if ((layer = gimp_image_pick_correlate_layer (display->image,
|
2001-11-09 03:14:51 +08:00
|
|
|
coords->x, coords->y)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* if there is a floating selection, and this aint it... */
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_floating_sel (display->image) &&
|
2001-01-29 07:25:25 +08:00
|
|
|
! gimp_layer_is_floating_sel (layer))
|
2001-02-25 03:29:47 +08:00
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2004-12-17 23:16:36 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_MOVE;
|
2003-10-29 23:03:56 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_ANCHOR;
|
2001-02-25 03:29:47 +08:00
|
|
|
}
|
2006-03-29 01:55:52 +08:00
|
|
|
else if (layer == gimp_image_get_active_layer (display->image))
|
2001-02-25 03:29:47 +08:00
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2001-02-25 03:29:47 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2001-02-25 03:29:47 +08:00
|
|
|
{
|
2005-11-20 06:16:34 +08:00
|
|
|
cursor = GIMP_CURSOR_MOUSE;
|
2004-06-05 07:08:29 +08:00
|
|
|
tool_cursor = GIMP_TOOL_CURSOR_HAND;
|
2003-10-29 23:03:56 +08:00
|
|
|
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
2001-02-25 03:29:47 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
2003-10-29 23:03:56 +08:00
|
|
|
|
|
|
|
gimp_tool_control_set_cursor (tool->control, cursor);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
|
|
|
|
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_move_tool_draw (GimpDrawTool *draw_tool)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpMoveTool *move = GIMP_MOVE_TOOL (draw_tool);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-03-28 21:52:01 +08:00
|
|
|
if (move->moving_guide && move->guide_position != -1)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2003-03-28 21:52:01 +08:00
|
|
|
switch (move->guide_orientation)
|
2001-11-12 22:45:58 +08:00
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_draw_line (draw_tool,
|
2003-03-28 21:52:01 +08:00
|
|
|
0, move->guide_position,
|
2006-03-29 01:55:52 +08:00
|
|
|
draw_tool->display->image->width,
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position,
|
2001-11-12 22:45:58 +08:00
|
|
|
FALSE);
|
|
|
|
break;
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_draw_line (draw_tool,
|
2003-03-28 21:52:01 +08:00
|
|
|
move->guide_position, 0,
|
|
|
|
move->guide_position,
|
2006-03-29 01:55:52 +08:00
|
|
|
draw_tool->display->image->height,
|
2001-11-12 22:45:58 +08:00
|
|
|
FALSE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2003-03-28 21:52:01 +08:00
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_move_tool_start_hguide (GimpTool *tool,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
g_return_if_fail (GIMP_IS_MOVE_TOOL (tool));
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2004-03-09 21:24:15 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_move_tool_start_guide (GIMP_MOVE_TOOL (tool), display,
|
2004-03-09 21:24:15 +08:00
|
|
|
GIMP_ORIENTATION_HORIZONTAL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-10-29 19:47:11 +08:00
|
|
|
gimp_move_tool_start_vguide (GimpTool *tool,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2002-02-08 01:37:34 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
g_return_if_fail (GIMP_IS_MOVE_TOOL (tool));
|
2006-03-29 01:55:52 +08:00
|
|
|
g_return_if_fail (GIMP_IS_DISPLAY (display));
|
2004-03-09 21:24:15 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_move_tool_start_guide (GIMP_MOVE_TOOL (tool), display,
|
2004-03-09 21:24:15 +08:00
|
|
|
GIMP_ORIENTATION_VERTICAL);
|
2002-02-08 01:37:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-09 21:24:15 +08:00
|
|
|
gimp_move_tool_start_guide (GimpMoveTool *move,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display,
|
2003-02-08 01:12:21 +08:00
|
|
|
GimpOrientationType orientation)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-09 21:24:15 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (move);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_shell_selection_visibility (GIMP_DISPLAY_SHELL (display->shell),
|
2001-11-11 07:03:22 +08:00
|
|
|
GIMP_SELECTION_PAUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool->display = display;
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (tool->control);
|
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-10-29 23:03:56 +08:00
|
|
|
if (move->guide)
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (display->shell),
|
2001-11-01 05:20:09 +08:00
|
|
|
move->guide, FALSE);
|
1999-10-14 07:07:45 +08:00
|
|
|
|
2003-10-29 23:03:56 +08:00
|
|
|
move->guide = NULL;
|
2003-03-28 21:52:01 +08:00
|
|
|
move->moving_guide = TRUE;
|
|
|
|
move->guide_position = -1;
|
|
|
|
move->guide_orientation = orientation;
|
2001-11-12 22:45:58 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_set_cursor (tool, display,
|
2005-11-20 06:16:34 +08:00
|
|
|
GIMP_CURSOR_MOUSE,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_HAND,
|
2003-09-17 18:42:26 +08:00
|
|
|
GIMP_CURSOR_MODIFIER_MOVE);
|
2002-02-08 01:37:34 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (move), display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|