2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* 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-10-23 17:05:45 +08:00
|
|
|
|
2000-02-16 21:52:33 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <stdlib.h>
|
1998-07-20 22:05:33 +08:00
|
|
|
#include <stdarg.h>
|
2000-02-29 03:25:42 +08:00
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-02-29 03:25:42 +08:00
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-09-26 01:03:03 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/boundary.h"
|
|
|
|
|
2004-04-15 07:37:34 +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"
|
2006-05-21 19:32:41 +08:00
|
|
|
#include "core/gimpimage-item-list.h"
|
2003-02-13 01:11:34 +08:00
|
|
|
#include "core/gimpimage-undo.h"
|
2003-09-12 02:02:39 +08:00
|
|
|
#include "core/gimpitem-linked.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"
|
2004-07-14 00:36:29 +08:00
|
|
|
#include "core/gimpprojection.h"
|
2003-10-06 20:17:11 +08:00
|
|
|
#include "core/gimpselection.h"
|
2003-03-19 00:42:45 +08:00
|
|
|
#include "core/gimpundostack.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
#include "vectors/gimpvectors.h"
|
|
|
|
|
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"
|
2001-11-11 07:03:22 +08:00
|
|
|
#include "display/gimpdisplayshell-selection.h"
|
2003-01-04 02:01:30 +08:00
|
|
|
#include "display/gimpdisplayshell-transform.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
|
|
|
|
#include "gimpdrawtool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimpeditselectiontool.h"
|
|
|
|
#include "gimptoolcontrol.h"
|
2001-11-01 05:20:09 +08:00
|
|
|
#include "tool_manager.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2000-10-23 17:05:45 +08:00
|
|
|
|
1999-07-03 01:40:10 +08:00
|
|
|
#define EDIT_SELECT_SCROLL_LOCK FALSE
|
1997-11-25 06:05:25 +08:00
|
|
|
#define ARROW_VELOCITY 25
|
|
|
|
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
static void gimp_edit_selection_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_edit_selection_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
static void gimp_edit_selection_tool_draw (GimpDrawTool *tool);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
G_DEFINE_TYPE (GimpEditSelectionTool, gimp_edit_selection_tool,
|
2006-05-15 17:46:31 +08:00
|
|
|
GIMP_TYPE_DRAW_TOOL)
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_edit_selection_tool_parent_class
|
2001-02-28 10:29:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_edit_selection_tool_class_init (GimpEditSelectionToolClass *klass)
|
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
|
|
|
tool_class->button_release = gimp_edit_selection_tool_button_release;
|
|
|
|
tool_class->motion = gimp_edit_selection_tool_motion;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
draw_class->draw = gimp_edit_selection_tool_draw;
|
2001-02-28 10:29:25 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2001-02-28 10:29:25 +08:00
|
|
|
gimp_edit_selection_tool_init (GimpEditSelectionTool *edit_selection_tool)
|
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (edit_selection_tool);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2002-05-03 05:03:27 +08:00
|
|
|
gimp_tool_control_set_scroll_lock (tool->control, EDIT_SELECT_SCROLL_LOCK);
|
|
|
|
gimp_tool_control_set_motion_mode (tool->control, GIMP_MOTION_MODE_COMPRESS);
|
2002-03-29 11:50:29 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
edit_selection_tool->origx = 0;
|
|
|
|
edit_selection_tool->origy = 0;
|
|
|
|
|
|
|
|
edit_selection_tool->cumlx = 0;
|
|
|
|
edit_selection_tool->cumly = 0;
|
|
|
|
|
|
|
|
edit_selection_tool->first_move = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-05-06 02:45:58 +08:00
|
|
|
gimp_edit_selection_tool_calc_coords (GimpEditSelectionTool *edit_select,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display,
|
2003-05-06 02:45:58 +08:00
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-03-20 19:31:33 +08:00
|
|
|
GimpDisplayShell *shell;
|
|
|
|
gdouble x1, y1;
|
|
|
|
gdouble dx, dy;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
dx = x - edit_select->origx;
|
|
|
|
dy = y - edit_select->origy;
|
2003-07-10 06:40:27 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
x1 = edit_select->x1 + dx;
|
|
|
|
y1 = edit_select->y1 + dy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-06 02:45:58 +08:00
|
|
|
edit_select->x = (gint) floor (x1) - (edit_select->x1 - edit_select->origx);
|
|
|
|
edit_select->y = (gint) floor (y1) - (edit_select->y1 - edit_select->origy);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-26 22:50:51 +08:00
|
|
|
gimp_edit_selection_tool_start (GimpTool *parent_tool,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display,
|
2004-07-26 22:50:51 +08:00
|
|
|
GimpCoords *coords,
|
2004-10-07 05:04:13 +08:00
|
|
|
GimpTranslateMode edit_mode,
|
|
|
|
gboolean propagate_release)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-02-28 10:29:25 +08:00
|
|
|
GimpEditSelectionTool *edit_select;
|
2001-11-01 05:20:09 +08:00
|
|
|
GimpDisplayShell *shell;
|
2003-09-17 00:23:38 +08:00
|
|
|
GimpItem *active_item;
|
2005-07-18 23:54:49 +08:00
|
|
|
GimpChannel *channel;
|
2001-11-09 03:14:51 +08:00
|
|
|
gint off_x, off_y;
|
2005-07-18 23:54:49 +08:00
|
|
|
const BoundSeg *segs_in;
|
|
|
|
const BoundSeg *segs_out;
|
|
|
|
gint num_groups;
|
2003-03-20 00:58:17 +08:00
|
|
|
const gchar *undo_desc;
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
edit_select = g_object_new (GIMP_TYPE_EDIT_SELECTION_TOOL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
edit_select->propagate_release = propagate_release;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
shell = GIMP_DISPLAY_SHELL (display->shell);
|
2001-11-01 05:20:09 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make a check to see if it should be a floating selection translation */
|
2006-08-16 05:15:49 +08:00
|
|
|
if ((edit_mode == GIMP_TRANSLATE_MODE_MASK_TO_LAYER ||
|
|
|
|
edit_mode == GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER) &&
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_floating_sel (display->image))
|
2001-02-28 10:29:25 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
2001-02-28 10:29:25 +08:00
|
|
|
}
|
1999-05-05 17:10:35 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_mode == GIMP_TRANSLATE_MODE_LAYER)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpLayer *layer = gimp_image_get_active_layer (display->image);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_select->edit_mode = edit_mode;
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2004-04-15 23:07:30 +08:00
|
|
|
else
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2004-04-15 23:07:30 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_select->edit_mode)
|
2004-01-12 22:13:24 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
|
|
|
case GIMP_TRANSLATE_MODE_LAYER:
|
2004-04-15 23:07:30 +08:00
|
|
|
undo_desc = GIMP_ITEM_GET_CLASS (active_item)->translate_desc;
|
2004-01-12 22:13:24 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK:
|
2004-01-12 22:13:24 +08:00
|
|
|
undo_desc = _("Move Selection");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-09-22 20:46:35 +08:00
|
|
|
undo_desc = _("Move Floating Selection");
|
2004-01-12 22:13:24 +08:00
|
|
|
break;
|
|
|
|
}
|
2003-03-20 00:58:17 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_undo_group_start (display->image,
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_select->edit_mode ==
|
|
|
|
GIMP_TRANSLATE_MODE_MASK ?
|
2003-03-20 00:58:17 +08:00
|
|
|
GIMP_UNDO_GROUP_MASK :
|
2003-05-09 04:26:01 +08:00
|
|
|
GIMP_UNDO_GROUP_ITEM_DISPLACE,
|
2003-03-20 00:58:17 +08:00
|
|
|
undo_desc);
|
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
gimp_item_offsets (active_item, &off_x, &off_y);
|
1999-11-05 22:39:04 +08:00
|
|
|
|
2003-03-20 00:58:17 +08:00
|
|
|
edit_select->x = edit_select->origx = coords->x - off_x;
|
|
|
|
edit_select->y = edit_select->origy = coords->y - off_y;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_select->edit_mode)
|
2004-01-12 22:13:24 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
2005-07-18 23:54:49 +08:00
|
|
|
channel = GIMP_CHANNEL (active_item);
|
|
|
|
break;
|
2004-01-12 22:13:24 +08:00
|
|
|
|
|
|
|
default:
|
2006-03-29 01:55:52 +08:00
|
|
|
channel = gimp_image_get_mask (display->image);
|
2004-01-12 22:13:24 +08:00
|
|
|
break;
|
|
|
|
}
|
2003-03-20 00:58:17 +08:00
|
|
|
|
2005-07-18 23:54:49 +08:00
|
|
|
gimp_channel_boundary (channel,
|
|
|
|
&segs_in, &segs_out,
|
|
|
|
&edit_select->num_segs_in, &edit_select->num_segs_out,
|
|
|
|
0, 0, 0, 0);
|
|
|
|
|
2005-08-20 23:46:37 +08:00
|
|
|
edit_select->segs_in = boundary_sort (segs_in, edit_select->num_segs_in,
|
2005-07-18 23:54:49 +08:00
|
|
|
&num_groups);
|
|
|
|
edit_select->num_segs_in += num_groups;
|
|
|
|
|
2005-08-20 23:46:37 +08:00
|
|
|
edit_select->segs_out = boundary_sort (segs_out, edit_select->num_segs_out,
|
2005-07-18 23:54:49 +08:00
|
|
|
&num_groups);
|
|
|
|
edit_select->num_segs_out += num_groups;
|
2003-04-13 19:43:47 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
|
|
|
edit_select->x1 = 0;
|
|
|
|
edit_select->y1 = 0;
|
2006-03-29 01:55:52 +08:00
|
|
|
edit_select->x2 = display->image->width;
|
|
|
|
edit_select->y2 = display->image->height;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* find the bounding box of the selection mask -
|
2004-07-26 22:50:51 +08:00
|
|
|
* this is used for the case of a GIMP_TRANSLATE_MODE_MASK_TO_LAYER,
|
2003-09-17 00:23:38 +08:00
|
|
|
* where the translation will result in floating the selection
|
|
|
|
* mask and translating the resulting layer
|
|
|
|
*/
|
|
|
|
gimp_drawable_mask_bounds (GIMP_DRAWABLE (active_item),
|
|
|
|
&edit_select->x1, &edit_select->y1,
|
|
|
|
&edit_select->x2, &edit_select->y2);
|
|
|
|
}
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_calc_coords (edit_select, display,
|
2003-05-06 02:45:58 +08:00
|
|
|
edit_select->origx,
|
|
|
|
edit_select->origy);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-04-17 10:57:33 +08:00
|
|
|
{
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_select->edit_mode)
|
2003-04-17 10:57:33 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
2004-01-12 22:13:24 +08:00
|
|
|
gimp_channel_bounds (GIMP_CHANNEL (active_item),
|
|
|
|
&x1, &y1, &x2, &y2);
|
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
2004-01-12 22:13:24 +08:00
|
|
|
gimp_channel_bounds (GIMP_CHANNEL (active_item),
|
|
|
|
&x1, &y1, &x2, &y2);
|
|
|
|
x1 += off_x;
|
|
|
|
y1 += off_y;
|
|
|
|
x2 += off_x;
|
|
|
|
y2 += off_y;
|
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK:
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_channel_bounds (gimp_image_get_mask (display->image),
|
2003-09-04 01:17:18 +08:00
|
|
|
&x1, &y1, &x2, &y2);
|
2003-04-17 10:57:33 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK_TO_LAYER:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER:
|
2003-04-17 10:57:33 +08:00
|
|
|
x1 = edit_select->x1 + off_x;
|
|
|
|
y1 = edit_select->y1 + off_y;
|
|
|
|
x2 = edit_select->x2 + off_x;
|
|
|
|
y2 = edit_select->y2 + off_y;
|
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER:
|
|
|
|
case GIMP_TRANSLATE_MODE_FLOATING_SEL:
|
2003-05-09 21:05:37 +08:00
|
|
|
x1 = off_x;
|
|
|
|
y1 = off_y;
|
2003-09-17 00:23:38 +08:00
|
|
|
x2 = x1 + gimp_item_width (active_item);
|
|
|
|
y2 = y1 + gimp_item_height (active_item);
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (gimp_item_get_linked (active_item))
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
2003-09-12 02:02:39 +08:00
|
|
|
GList *linked;
|
2003-05-09 21:05:37 +08:00
|
|
|
GList *list;
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-09-12 02:02:39 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
/* Expand the rectangle to include all linked layers as well */
|
2003-09-12 02:02:39 +08:00
|
|
|
for (list = linked; list; list = g_list_next (list))
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
2003-09-12 02:02:39 +08:00
|
|
|
gint x3, y3;
|
|
|
|
gint x4, y4;
|
|
|
|
|
|
|
|
gimp_item_offsets (item, &x3, &y3);
|
|
|
|
|
|
|
|
x4 = x3 + gimp_item_width (item);
|
|
|
|
y4 = y3 + gimp_item_height (item);
|
|
|
|
|
|
|
|
if (x3 < x1)
|
|
|
|
x1 = x3;
|
|
|
|
if (y3 < y1)
|
|
|
|
y1 = y3;
|
|
|
|
if (x4 > x2)
|
|
|
|
x2 = x4;
|
|
|
|
if (y4 > y2)
|
|
|
|
y2 = y4;
|
|
|
|
}
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2003-09-12 02:02:39 +08:00
|
|
|
g_list_free (linked);
|
2003-05-09 21:05:37 +08:00
|
|
|
}
|
2003-04-17 10:57:33 +08:00
|
|
|
break;
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
|
|
|
gdouble xd1, yd1, xd2, yd2;
|
|
|
|
|
|
|
|
gimp_vectors_bounds (GIMP_VECTORS (active_item),
|
|
|
|
&xd1, &yd1, &xd2, &yd2);
|
|
|
|
|
|
|
|
if (gimp_item_get_linked (active_item))
|
|
|
|
{
|
|
|
|
/* Expand the rectangle to include all linked layers as well */
|
|
|
|
|
|
|
|
GList *linked;
|
|
|
|
GList *list;
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_VECTORS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-09-17 00:23:38 +08:00
|
|
|
|
|
|
|
for (list = linked; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
|
|
|
gdouble x3, y3;
|
|
|
|
gdouble x4, y4;
|
|
|
|
|
|
|
|
gimp_vectors_bounds (GIMP_VECTORS (item), &x3, &y3, &x4, &y4);
|
|
|
|
|
|
|
|
if (x3 < xd1)
|
|
|
|
xd1 = x3;
|
|
|
|
if (y3 < yd1)
|
|
|
|
yd1 = y3;
|
|
|
|
if (x4 > xd2)
|
|
|
|
xd2 = x4;
|
|
|
|
if (y4 > yd2)
|
|
|
|
yd2 = y4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
x1 = ROUND (xd1);
|
|
|
|
y1 = ROUND (yd1);
|
|
|
|
x2 = ROUND (xd2);
|
|
|
|
y2 = ROUND (yd2);
|
|
|
|
}
|
|
|
|
break;
|
2003-04-17 10:57:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gimp_tool_control_set_snap_offsets (GIMP_TOOL (edit_select)->control,
|
|
|
|
x1 - coords->x,
|
|
|
|
y1 - coords->y,
|
|
|
|
x2 - x1,
|
|
|
|
y2 - y1);
|
|
|
|
}
|
|
|
|
|
2002-05-03 19:31:08 +08:00
|
|
|
gimp_tool_control_activate (GIMP_TOOL (edit_select)->control);
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL (edit_select)->display = display;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool_manager_push_tool (display->image->gimp, GIMP_TOOL (edit_select));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* pause the current selection */
|
2006-09-05 01:18:38 +08:00
|
|
|
gimp_display_shell_selection_control (shell, GIMP_SELECTION_PAUSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-24 02:33:01 +08:00
|
|
|
/* initialize the statusbar display */
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_push_status_coords (GIMP_TOOL (edit_select), display,
|
2007-01-21 09:24:51 +08:00
|
|
|
_("Move: "), 0, ", ", 0, NULL);
|
2002-02-03 20:10:23 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_draw_tool_start (GIMP_DRAW_TOOL (edit_select), display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
gimp_edit_selection_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
|
2004-01-12 22:13:24 +08:00
|
|
|
GimpItem *active_item;
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2002-02-05 19:35:03 +08:00
|
|
|
/* resume the current selection */
|
2006-09-05 01:18:38 +08:00
|
|
|
gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
1998-07-24 02:33:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Stop and free the selection core */
|
2001-02-28 10:29:25 +08:00
|
|
|
gimp_draw_tool_stop (GIMP_DRAW_TOOL (edit_select));
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
tool_manager_pop_tool (display->image->gimp);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2004-01-12 22:13:24 +08:00
|
|
|
else
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2004-01-12 22:13:24 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_calc_coords (edit_select, display,
|
2004-01-12 22:13:24 +08:00
|
|
|
coords->x,
|
|
|
|
coords->y);
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
/* GIMP_TRANSLATE_MODE_MASK is performed here at movement end, not 'live' like
|
1999-12-18 04:59:37 +08:00
|
|
|
* the other translation types.
|
|
|
|
*/
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_MASK)
|
2000-02-10 22:23:11 +08:00
|
|
|
{
|
2003-09-17 00:23:38 +08:00
|
|
|
/* move the selection -- whether there has been movement or not!
|
2000-02-10 22:23:11 +08:00
|
|
|
* (to ensure that there's something on the undo stack)
|
|
|
|
*/
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_item_translate (GIMP_ITEM (gimp_image_get_mask (display->image)),
|
2003-09-03 18:19:47 +08:00
|
|
|
edit_select->cumlx,
|
|
|
|
edit_select->cumly,
|
|
|
|
TRUE);
|
2004-01-12 22:13:24 +08:00
|
|
|
}
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
/* GIMP_TRANSLATE_MODE_CHANNEL and GIMP_TRANSLATE_MODE_LAYER_MASK
|
|
|
|
* need to be preformed after thawing the undo.
|
2004-01-12 22:13:24 +08:00
|
|
|
*/
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_CHANNEL ||
|
|
|
|
edit_select->edit_mode == GIMP_TRANSLATE_MODE_LAYER_MASK)
|
2004-01-12 22:13:24 +08:00
|
|
|
{
|
|
|
|
/* move the channel -- whether there has been movement or not!
|
|
|
|
* (to ensure that there's something on the undo stack)
|
|
|
|
*/
|
|
|
|
gimp_item_translate (active_item,
|
|
|
|
edit_select->cumlx,
|
|
|
|
edit_select->cumly,
|
|
|
|
TRUE);
|
|
|
|
}
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS ||
|
|
|
|
edit_select->edit_mode == GIMP_TRANSLATE_MODE_CHANNEL ||
|
|
|
|
edit_select->edit_mode == GIMP_TRANSLATE_MODE_LAYER)
|
1999-04-25 04:58:55 +08:00
|
|
|
{
|
2007-02-28 02:55:12 +08:00
|
|
|
if ((release_type != GIMP_BUTTON_RELEASE_CANCEL) &&
|
2004-01-12 22:13:24 +08:00
|
|
|
(edit_select->cumlx != 0 ||
|
|
|
|
edit_select->cumly != 0))
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
2003-09-17 00:23:38 +08:00
|
|
|
if (gimp_item_get_linked (active_item))
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
2003-09-17 00:23:38 +08:00
|
|
|
/* translate all linked channels as well */
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
GList *linked;
|
2003-09-12 02:02:39 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_CHANNELS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_translate (display->image,
|
|
|
|
linked,
|
|
|
|
edit_select->cumlx,
|
|
|
|
edit_select->cumly,
|
|
|
|
TRUE);
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
g_list_free (linked);
|
|
|
|
}
|
|
|
|
}
|
1999-10-19 04:55:25 +08:00
|
|
|
}
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_undo_group_end (display->image);
|
1999-03-21 23:38:11 +08:00
|
|
|
|
2007-02-28 02:55:12 +08:00
|
|
|
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
|
1999-03-21 23:38:11 +08:00
|
|
|
{
|
|
|
|
/* Operation cancelled - undo the undo-group! */
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_undo (display->image);
|
1999-03-21 23:38:11 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_flush (display->image);
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2003-04-13 19:43:47 +08:00
|
|
|
g_free (edit_select->segs_in);
|
|
|
|
g_free (edit_select->segs_out);
|
|
|
|
|
|
|
|
edit_select->segs_in = NULL;
|
|
|
|
edit_select->segs_out = NULL;
|
|
|
|
edit_select->num_segs_in = 0;
|
|
|
|
edit_select->num_segs_out = 0;
|
|
|
|
|
2004-10-07 05:04:13 +08:00
|
|
|
if (edit_select->propagate_release &&
|
2006-03-29 01:55:52 +08:00
|
|
|
tool_manager_get_active (display->image->gimp))
|
2004-10-07 05:04:13 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
tool_manager_button_release_active (display->image->gimp,
|
2004-10-07 05:04:13 +08:00
|
|
|
coords, time, state,
|
2006-03-29 01:55:52 +08:00
|
|
|
display);
|
2004-10-07 05:04:13 +08:00
|
|
|
}
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (edit_select);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_edit_selection_tool_motion (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
2004-07-26 21:15:22 +08:00
|
|
|
GdkModifierType state,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (tool);
|
2003-09-17 00:23:38 +08:00
|
|
|
GimpItem *active_item;
|
2003-05-08 22:06:03 +08:00
|
|
|
gint off_x, off_y;
|
2002-03-19 21:14:25 +08:00
|
|
|
gdouble motion_x, motion_y;
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2000-10-23 17:05:45 +08:00
|
|
|
gdk_flush ();
|
1999-02-07 23:16:45 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
else
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
|
|
|
|
gimp_item_offsets (active_item, &off_x, &off_y);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
motion_x = coords->x - off_x;
|
|
|
|
motion_y = coords->y - off_y;
|
2000-02-29 03:25:42 +08:00
|
|
|
|
|
|
|
/* now do the actual move. */
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_edit_selection_tool_calc_coords (edit_select, display,
|
2003-05-06 02:45:58 +08:00
|
|
|
motion_x,
|
|
|
|
motion_y);
|
2003-09-03 18:19:47 +08:00
|
|
|
|
2000-02-29 03:25:42 +08:00
|
|
|
/******************************************* adam's live move *******/
|
1999-03-21 23:38:11 +08:00
|
|
|
/********************************************************************/
|
|
|
|
{
|
2003-05-09 21:05:37 +08:00
|
|
|
gint x, y;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
x = edit_select->x;
|
|
|
|
y = edit_select->y;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
|
|
|
/* if there has been movement, move the selection */
|
2001-02-28 10:29:25 +08:00
|
|
|
if (edit_select->origx != x || edit_select->origy != y)
|
1999-03-21 23:38:11 +08:00
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
gint xoffset, yoffset;
|
2003-07-10 06:40:27 +08:00
|
|
|
|
2004-07-26 21:15:22 +08:00
|
|
|
xoffset = x - edit_select->origx;
|
|
|
|
yoffset = y - edit_select->origy;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
2004-07-26 21:15:22 +08:00
|
|
|
edit_select->cumlx += xoffset;
|
|
|
|
edit_select->cumly += yoffset;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_select->edit_mode)
|
2004-07-26 21:15:22 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK:
|
2004-07-26 21:15:22 +08:00
|
|
|
/* we don't do the actual edit selection move here. */
|
|
|
|
edit_select->origx = x;
|
|
|
|
edit_select->origy = y;
|
|
|
|
break;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
2004-07-26 21:15:22 +08:00
|
|
|
edit_select->origx = x;
|
|
|
|
edit_select->origy = y;
|
2003-09-17 00:23:38 +08:00
|
|
|
|
|
|
|
/* fallthru */
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER:
|
2004-04-13 21:54:54 +08:00
|
|
|
/* for CHANNEL_TRANSLATE, only translate the linked layers
|
|
|
|
* and vectors on-the-fly, the channel is translated
|
|
|
|
* on button_release.
|
|
|
|
*/
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode != GIMP_TRANSLATE_MODE_CHANNEL)
|
2004-07-26 21:15:22 +08:00
|
|
|
gimp_item_translate (active_item, xoffset, yoffset,
|
|
|
|
edit_select->first_move);
|
2003-09-12 02:02:39 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
if (gimp_item_get_linked (active_item))
|
|
|
|
{
|
|
|
|
/* translate all linked layers & vectors as well */
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
GList *linked;
|
2003-09-12 02:02:39 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS |
|
|
|
|
GIMP_ITEM_TYPE_VECTORS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-09-12 02:02:39 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_translate (display->image,
|
|
|
|
linked,
|
|
|
|
xoffset, yoffset,
|
|
|
|
edit_select->first_move);
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
g_list_free (linked);
|
|
|
|
}
|
2004-07-26 21:15:22 +08:00
|
|
|
break;
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK_TO_LAYER:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER:
|
2006-03-29 01:55:52 +08:00
|
|
|
if (! gimp_selection_float (gimp_image_get_mask (display->image),
|
2003-10-06 20:17:11 +08:00
|
|
|
GIMP_DRAWABLE (active_item),
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_get_user_context (display->image->gimp),
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_select->edit_mode ==
|
|
|
|
GIMP_TRANSLATE_MODE_MASK_TO_LAYER,
|
2003-10-06 20:17:11 +08:00
|
|
|
0, 0))
|
2004-07-26 21:15:22 +08:00
|
|
|
{
|
|
|
|
/* no region to float, abort safely */
|
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
2000-02-10 22:23:11 +08:00
|
|
|
|
2004-07-26 21:15:22 +08:00
|
|
|
return;
|
|
|
|
}
|
1999-04-25 04:58:55 +08:00
|
|
|
|
2004-07-26 21:15:22 +08:00
|
|
|
edit_select->origx -= edit_select->x1;
|
|
|
|
edit_select->origy -= edit_select->y1;
|
|
|
|
edit_select->x2 -= edit_select->x1;
|
|
|
|
edit_select->y2 -= edit_select->y1;
|
|
|
|
edit_select->x1 = 0;
|
|
|
|
edit_select->y1 = 0;
|
2000-02-10 22:23:11 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_select->edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
2003-04-07 17:31:28 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2003-04-07 17:31:28 +08:00
|
|
|
/* fall through */
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_FLOATING_SEL:
|
2004-07-26 21:15:22 +08:00
|
|
|
gimp_item_translate (active_item, xoffset, yoffset,
|
|
|
|
edit_select->first_move);
|
|
|
|
break;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
2004-07-26 21:15:22 +08:00
|
|
|
default:
|
|
|
|
g_warning ("esm / BAD FALLTHROUGH");
|
|
|
|
}
|
2004-10-07 05:04:13 +08:00
|
|
|
|
|
|
|
edit_select->first_move = FALSE;
|
1999-03-21 23:38:11 +08:00
|
|
|
}
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_projection_flush (display->image->projection);
|
1999-03-21 23:38:11 +08:00
|
|
|
}
|
|
|
|
/********************************************************************/
|
|
|
|
/********************************************************************/
|
1999-02-07 23:16:45 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_tool_pop_status (tool, display);
|
|
|
|
gimp_tool_push_status_coords (tool, display,
|
2002-02-03 20:10:23 +08:00
|
|
|
_("Move: "),
|
|
|
|
edit_select->cumlx,
|
|
|
|
", ",
|
2007-01-21 09:24:51 +08:00
|
|
|
edit_select->cumly,
|
|
|
|
NULL);
|
1998-07-24 02:33:01 +08:00
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-02-28 10:29:25 +08:00
|
|
|
static void
|
|
|
|
gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-26 21:15:22 +08:00
|
|
|
GimpEditSelectionTool *edit_select = GIMP_EDIT_SELECTION_TOOL (draw_tool);
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display = GIMP_TOOL (draw_tool)->display;
|
2003-09-17 00:23:38 +08:00
|
|
|
GimpItem *active_item;
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_VECTORS)
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
else
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_select->edit_mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK:
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
2004-01-12 22:13:24 +08:00
|
|
|
gboolean floating_sel = FALSE;
|
|
|
|
gint off_x = 0;
|
|
|
|
gint off_y = 0;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
if (edit_select->edit_mode == GIMP_TRANSLATE_MODE_MASK)
|
2004-01-12 22:13:24 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpLayer *layer = gimp_image_get_active_layer (display->image);
|
2004-01-12 22:13:24 +08:00
|
|
|
|
|
|
|
if (layer)
|
|
|
|
floating_sel = gimp_layer_is_floating_sel (layer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_item_offsets (active_item, &off_x, &off_y);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
if (! floating_sel)
|
2003-07-11 00:01:45 +08:00
|
|
|
gimp_draw_tool_draw_boundary (draw_tool,
|
|
|
|
edit_select->segs_in,
|
|
|
|
edit_select->num_segs_in,
|
2004-01-12 22:13:24 +08:00
|
|
|
edit_select->cumlx + off_x,
|
2004-02-22 00:06:56 +08:00
|
|
|
edit_select->cumly + off_y,
|
|
|
|
FALSE);
|
2004-01-12 22:13:24 +08:00
|
|
|
|
|
|
|
if (edit_select->segs_out)
|
|
|
|
{
|
|
|
|
gimp_draw_tool_draw_boundary (draw_tool,
|
|
|
|
edit_select->segs_out,
|
|
|
|
edit_select->num_segs_out,
|
|
|
|
edit_select->cumlx + off_x,
|
2004-02-22 00:06:56 +08:00
|
|
|
edit_select->cumly + off_y,
|
|
|
|
FALSE);
|
2004-01-12 22:13:24 +08:00
|
|
|
}
|
2004-07-26 22:50:51 +08:00
|
|
|
else if (edit_select->edit_mode != GIMP_TRANSLATE_MODE_MASK)
|
2004-01-12 22:13:24 +08:00
|
|
|
{
|
|
|
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
edit_select->cumlx + off_x,
|
|
|
|
edit_select->cumly + off_y,
|
|
|
|
active_item->width,
|
|
|
|
active_item->height,
|
|
|
|
FALSE);
|
|
|
|
}
|
2003-05-09 21:05:37 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK_TO_LAYER:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER:
|
2001-11-12 22:45:58 +08:00
|
|
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
edit_select->x1,
|
|
|
|
edit_select->y1,
|
|
|
|
edit_select->x2 - edit_select->x1,
|
|
|
|
edit_select->y2 - edit_select->y1,
|
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER:
|
2003-05-09 21:05:37 +08:00
|
|
|
{
|
|
|
|
GimpItem *active_item;
|
|
|
|
gint x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_layer (display->image));
|
2001-02-19 21:06:09 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
gimp_item_offsets (active_item, &x1, &y1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
x2 = x1 + gimp_item_width (active_item);
|
|
|
|
y2 = y1 + gimp_item_height (active_item);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
if (gimp_item_get_linked (active_item))
|
|
|
|
{
|
|
|
|
/* Expand the rectangle to include all linked layers as well */
|
2001-02-28 10:29:25 +08:00
|
|
|
|
2003-09-12 02:02:39 +08:00
|
|
|
GList *linked;
|
|
|
|
GList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-12 02:02:39 +08:00
|
|
|
for (list = linked; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
|
|
|
gint x3, y3;
|
|
|
|
gint x4, y4;
|
|
|
|
|
|
|
|
gimp_item_offsets (item, &x3, &y3);
|
|
|
|
|
|
|
|
x4 = x3 + gimp_item_width (item);
|
|
|
|
y4 = y3 + gimp_item_height (item);
|
|
|
|
|
|
|
|
if (x3 < x1)
|
|
|
|
x1 = x3;
|
|
|
|
if (y3 < y1)
|
|
|
|
y1 = y3;
|
|
|
|
if (x4 > x2)
|
|
|
|
x2 = x4;
|
|
|
|
if (y4 > y2)
|
|
|
|
y2 = y4;
|
2003-05-09 21:05:37 +08:00
|
|
|
}
|
2003-09-12 02:02:39 +08:00
|
|
|
|
|
|
|
g_list_free (linked);
|
2003-05-09 21:05:37 +08:00
|
|
|
}
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
x1, y1,
|
|
|
|
x2 - x1, y2 - y1,
|
|
|
|
FALSE);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
|
|
|
GimpItem *active_item;
|
|
|
|
gdouble x1, y1, x2, y2;
|
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
|
|
|
|
gimp_vectors_bounds (GIMP_VECTORS (active_item), &x1, &y1, &x2, &y2);
|
|
|
|
|
|
|
|
if (gimp_item_get_linked (active_item))
|
|
|
|
{
|
|
|
|
/* Expand the rectangle to include all linked vectors as well */
|
|
|
|
|
|
|
|
GList *linked;
|
|
|
|
GList *list;
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
linked = gimp_image_item_list_get_list (display->image,
|
|
|
|
active_item,
|
|
|
|
GIMP_ITEM_TYPE_VECTORS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-09-17 00:23:38 +08:00
|
|
|
|
|
|
|
for (list = linked; list; list = g_list_next (list))
|
|
|
|
{
|
|
|
|
GimpItem *item = list->data;
|
|
|
|
gdouble x3, y3;
|
|
|
|
gdouble x4, y4;
|
|
|
|
|
|
|
|
gimp_vectors_bounds (GIMP_VECTORS (item), &x3, &y3, &x4, &y4);
|
|
|
|
|
|
|
|
if (x3 < x1)
|
|
|
|
x1 = x3;
|
|
|
|
if (y3 < y1)
|
|
|
|
y1 = y3;
|
|
|
|
if (x4 > x2)
|
|
|
|
x2 = x4;
|
|
|
|
if (y4 > y2)
|
|
|
|
y2 = y4;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (linked);
|
|
|
|
}
|
|
|
|
|
|
|
|
gimp_draw_tool_draw_rectangle (draw_tool,
|
|
|
|
FALSE,
|
|
|
|
ROUND (x1), ROUND (y1),
|
|
|
|
ROUND (x2 - x1), ROUND (y2 - y1),
|
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_FLOATING_SEL:
|
2003-07-11 00:01:45 +08:00
|
|
|
gimp_draw_tool_draw_boundary (draw_tool,
|
|
|
|
edit_select->segs_in,
|
|
|
|
edit_select->num_segs_in,
|
|
|
|
edit_select->cumlx,
|
2004-02-22 00:06:56 +08:00
|
|
|
edit_select->cumly,
|
|
|
|
FALSE);
|
1999-06-22 06:12:07 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-09-12 02:02:39 +08:00
|
|
|
|
|
|
|
GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
static gint
|
2003-07-10 06:40:27 +08:00
|
|
|
process_event_queue_keys (GdkEventKey *kevent,
|
2004-07-26 21:15:22 +08:00
|
|
|
... /* GdkKeyType, GdkModifierType, value ... 0 */)
|
1998-07-20 22:05:33 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
#define FILTER_MAX_KEYS 50
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
va_list argp;
|
|
|
|
GdkEvent *event;
|
|
|
|
GList *event_list = NULL;
|
|
|
|
GList *list;
|
|
|
|
guint keys[FILTER_MAX_KEYS];
|
|
|
|
GdkModifierType modifiers[FILTER_MAX_KEYS];
|
|
|
|
gint values[FILTER_MAX_KEYS];
|
2003-03-19 00:42:45 +08:00
|
|
|
gint i = 0;
|
|
|
|
gint n_keys = 0;
|
|
|
|
gint value = 0;
|
|
|
|
gboolean done = FALSE;
|
2001-11-09 03:14:51 +08:00
|
|
|
GtkWidget *orig_widget;
|
1998-07-20 22:05:33 +08:00
|
|
|
|
2000-10-23 17:05:45 +08:00
|
|
|
va_start (argp, kevent);
|
2001-11-09 03:14:51 +08:00
|
|
|
|
2004-07-07 06:58:33 +08:00
|
|
|
while (n_keys < FILTER_MAX_KEYS &&
|
|
|
|
(keys[n_keys] = va_arg (argp, guint)) != 0)
|
2000-10-23 17:05:45 +08:00
|
|
|
{
|
2003-03-19 00:42:45 +08:00
|
|
|
modifiers[n_keys] = va_arg (argp, GdkModifierType);
|
|
|
|
values[n_keys] = va_arg (argp, gint);
|
|
|
|
n_keys++;
|
2000-10-23 17:05:45 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
|
|
|
|
va_end (argp);
|
1998-07-20 22:05:33 +08:00
|
|
|
|
2003-03-19 00:42:45 +08:00
|
|
|
for (i = 0; i < n_keys; i++)
|
|
|
|
if (kevent->keyval == keys[i] &&
|
|
|
|
(kevent->state & modifiers[i]) == modifiers[i])
|
|
|
|
value += values[i];
|
1998-07-20 22:05:33 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
orig_widget = gtk_get_event_widget ((GdkEvent *) kevent);
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
while (gdk_events_pending () > 0 && ! done)
|
|
|
|
{
|
2003-03-19 00:42:45 +08:00
|
|
|
gboolean discard_event = FALSE;
|
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
event = gdk_event_get ();
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (! event || orig_widget != gtk_get_event_widget (event))
|
|
|
|
{
|
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (event->any.type == GDK_KEY_PRESS)
|
|
|
|
{
|
2003-03-19 00:42:45 +08:00
|
|
|
for (i = 0; i < n_keys; i++)
|
|
|
|
if (event->key.keyval == keys[i] &&
|
|
|
|
(event->key.state & modifiers[i]) == modifiers[i])
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
|
|
|
discard_event = TRUE;
|
|
|
|
value += values[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! discard_event)
|
|
|
|
done = TRUE;
|
|
|
|
}
|
|
|
|
/* should there be more types here? */
|
|
|
|
else if (event->any.type != GDK_KEY_RELEASE &&
|
|
|
|
event->any.type != GDK_MOTION_NOTIFY &&
|
|
|
|
event->any.type != GDK_EXPOSE)
|
|
|
|
done = FALSE;
|
2003-03-19 00:42:45 +08:00
|
|
|
}
|
1998-07-20 22:05:33 +08:00
|
|
|
|
2003-03-19 00:42:45 +08:00
|
|
|
if (! event)
|
|
|
|
; /* Do nothing */
|
|
|
|
else if (! discard_event)
|
|
|
|
event_list = g_list_prepend (event_list, event);
|
|
|
|
else
|
|
|
|
gdk_event_free (event);
|
|
|
|
}
|
2000-10-23 17:05:45 +08:00
|
|
|
|
|
|
|
event_list = g_list_reverse (event_list);
|
|
|
|
|
|
|
|
/* unget the unused events and free the list */
|
2001-11-09 03:14:51 +08:00
|
|
|
for (list = event_list; list; list = g_list_next (list))
|
2000-10-23 17:05:45 +08:00
|
|
|
{
|
2001-11-09 03:14:51 +08:00
|
|
|
gdk_event_put ((GdkEvent *) list->data);
|
|
|
|
gdk_event_free ((GdkEvent *) list->data);
|
2000-10-23 17:05:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (event_list);
|
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
return value;
|
2001-11-09 03:14:51 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
#undef FILTER_MAX_KEYS
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-06-24 18:16:08 +08:00
|
|
|
gboolean
|
2004-06-13 02:41:52 +08:00
|
|
|
gimp_edit_selection_tool_key_press (GimpTool *tool,
|
2004-07-26 21:15:22 +08:00
|
|
|
GdkEventKey *kevent,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2007-03-07 17:34:47 +08:00
|
|
|
{
|
|
|
|
GimpTransformType translate_type;
|
|
|
|
|
|
|
|
if (kevent->state & GDK_MOD1_MASK)
|
|
|
|
translate_type = GIMP_TRANSFORM_TYPE_SELECTION;
|
|
|
|
else if (kevent->state & GDK_CONTROL_MASK)
|
|
|
|
translate_type = GIMP_TRANSFORM_TYPE_PATH;
|
|
|
|
else
|
|
|
|
translate_type = GIMP_TRANSFORM_TYPE_LAYER;
|
|
|
|
|
|
|
|
return gimp_edit_selection_tool_translate (tool, kevent, translate_type,
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_edit_selection_tool_translate (GimpTool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
GimpTransformType translate_type,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
gint inc_x = 0;
|
|
|
|
gint inc_y = 0;
|
|
|
|
GimpUndo *undo;
|
|
|
|
gboolean push_undo = TRUE;
|
|
|
|
GimpItem *item = NULL;
|
|
|
|
GimpTranslateMode edit_mode = GIMP_TRANSLATE_MODE_MASK;
|
|
|
|
GimpUndoType undo_type = GIMP_UNDO_GROUP_MASK;
|
|
|
|
const gchar *undo_desc = NULL;
|
|
|
|
gint velocity;
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2004-07-07 06:58:33 +08:00
|
|
|
/* bail out early if it is not an arrow key event */
|
2004-06-13 03:29:50 +08:00
|
|
|
|
|
|
|
if (kevent->keyval != GDK_Left &&
|
|
|
|
kevent->keyval != GDK_Right &&
|
|
|
|
kevent->keyval != GDK_Up &&
|
|
|
|
kevent->keyval != GDK_Down)
|
2004-06-24 18:16:08 +08:00
|
|
|
return FALSE;
|
2004-06-13 03:29:50 +08:00
|
|
|
|
2007-03-07 03:56:08 +08:00
|
|
|
/* adapt arrow velocity to the zoom factor when holding <shift> */
|
2005-09-26 01:03:03 +08:00
|
|
|
velocity = (ARROW_VELOCITY /
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_zoom_model_get_factor (GIMP_DISPLAY_SHELL (display->shell)->zoom));
|
2005-09-26 01:03:03 +08:00
|
|
|
velocity = MAX (1.0, velocity);
|
2004-07-07 06:58:33 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
/* check the event queue for key events with the same modifier mask
|
|
|
|
* as the current event, allowing only GDK_SHIFT_MASK to vary between
|
|
|
|
* them.
|
2003-03-19 00:42:45 +08:00
|
|
|
*/
|
2007-03-07 17:34:47 +08:00
|
|
|
inc_x = process_event_queue_keys (kevent,
|
|
|
|
GDK_Left,
|
|
|
|
kevent->state | GDK_SHIFT_MASK,
|
|
|
|
-1 * velocity,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Left,
|
|
|
|
kevent->state & ~GDK_SHIFT_MASK,
|
|
|
|
-1,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Right,
|
|
|
|
kevent->state | GDK_SHIFT_MASK,
|
|
|
|
1 * velocity,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Right,
|
|
|
|
kevent->state & ~GDK_SHIFT_MASK,
|
|
|
|
1,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
0);
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
inc_y = process_event_queue_keys (kevent,
|
|
|
|
GDK_Up,
|
|
|
|
kevent->state | GDK_SHIFT_MASK,
|
|
|
|
-1 * velocity,
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Up,
|
|
|
|
kevent->state & ~GDK_SHIFT_MASK,
|
|
|
|
-1,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Down,
|
|
|
|
kevent->state | GDK_SHIFT_MASK,
|
|
|
|
1 * velocity,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
GDK_Down,
|
|
|
|
kevent->state & ~GDK_SHIFT_MASK,
|
|
|
|
1,
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (inc_x != 0 || inc_y != 0)
|
2003-03-19 00:42:45 +08:00
|
|
|
{
|
2007-03-07 17:34:47 +08:00
|
|
|
switch (translate_type)
|
|
|
|
{
|
|
|
|
case GIMP_TRANSFORM_TYPE_SELECTION:
|
|
|
|
item = GIMP_ITEM (gimp_image_get_mask (display->image));
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_MASK;
|
|
|
|
undo_type = GIMP_UNDO_GROUP_MASK;
|
|
|
|
break;
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
case GIMP_TRANSFORM_TYPE_PATH:
|
|
|
|
item = GIMP_ITEM (gimp_image_get_active_vectors (display->image));
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_VECTORS;
|
2003-09-17 00:23:38 +08:00
|
|
|
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
2007-03-07 17:34:47 +08:00
|
|
|
break;
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
case GIMP_TRANSFORM_TYPE_LAYER:
|
|
|
|
item = GIMP_ITEM (gimp_image_active_drawable (display->image));
|
2003-09-17 00:23:38 +08:00
|
|
|
|
2007-03-07 17:34:47 +08:00
|
|
|
if (item)
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
2007-03-07 17:34:47 +08:00
|
|
|
if (GIMP_IS_LAYER_MASK (item))
|
|
|
|
{
|
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_LAYER_MASK;
|
|
|
|
}
|
|
|
|
else if (GIMP_IS_CHANNEL (item))
|
2003-09-17 00:23:38 +08:00
|
|
|
{
|
2007-03-07 17:34:47 +08:00
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_CHANNEL;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
2007-03-07 17:34:47 +08:00
|
|
|
else if (gimp_layer_is_floating_sel (GIMP_LAYER (item)))
|
|
|
|
{
|
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_FLOATING_SEL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
edit_mode = GIMP_TRANSLATE_MODE_LAYER;
|
|
|
|
}
|
|
|
|
|
|
|
|
undo_type = GIMP_UNDO_GROUP_ITEM_DISPLACE;
|
2003-09-17 00:23:38 +08:00
|
|
|
}
|
2007-03-07 17:34:47 +08:00
|
|
|
break;
|
2003-03-19 00:42:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-09-17 00:23:38 +08:00
|
|
|
if (! item)
|
2004-06-24 18:16:08 +08:00
|
|
|
return TRUE;
|
2003-03-20 00:58:17 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_mode)
|
2004-04-15 23:07:30 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_FLOATING_SEL:
|
2004-09-22 20:46:35 +08:00
|
|
|
undo_desc = _("Move Floating Selection");
|
2004-04-15 23:07:30 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
undo_desc = GIMP_ITEM_GET_CLASS (item)->translate_desc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-03-20 07:42:42 +08:00
|
|
|
/* compress undo */
|
2006-03-29 01:55:52 +08:00
|
|
|
undo = gimp_image_undo_can_compress (display->image, GIMP_TYPE_UNDO_STACK,
|
2004-08-03 22:09:49 +08:00
|
|
|
undo_type);
|
|
|
|
|
|
|
|
if (undo &&
|
|
|
|
g_object_get_data (G_OBJECT (undo),
|
|
|
|
"edit-selection-tool") == (gpointer) tool &&
|
|
|
|
g_object_get_data (G_OBJECT (undo),
|
|
|
|
"edit-selection-item") == (gpointer) item &&
|
|
|
|
g_object_get_data (G_OBJECT (undo),
|
|
|
|
"edit-selection-type") == GINT_TO_POINTER (edit_mode))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-08-03 22:09:49 +08:00
|
|
|
push_undo = FALSE;
|
2003-03-19 00:42:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (push_undo)
|
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
if (gimp_image_undo_group_start (display->image, undo_type, undo_desc))
|
2003-03-19 00:42:45 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
undo = gimp_image_undo_can_compress (display->image,
|
2004-08-03 22:09:49 +08:00
|
|
|
GIMP_TYPE_UNDO_STACK,
|
|
|
|
undo_type);
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2004-08-03 22:09:49 +08:00
|
|
|
if (undo)
|
2003-03-19 00:42:45 +08:00
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (undo), "edit-selection-tool",
|
|
|
|
tool);
|
2003-09-17 00:23:38 +08:00
|
|
|
g_object_set_data (G_OBJECT (undo), "edit-selection-item",
|
|
|
|
item);
|
2003-03-19 00:42:45 +08:00
|
|
|
g_object_set_data (G_OBJECT (undo), "edit-selection-type",
|
2004-07-26 22:50:51 +08:00
|
|
|
GINT_TO_POINTER (edit_mode));
|
2003-03-19 00:42:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
switch (edit_mode)
|
2003-03-19 00:42:45 +08:00
|
|
|
{
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_LAYER_MASK:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK:
|
2003-09-17 00:23:38 +08:00
|
|
|
gimp_item_translate (item, inc_x, inc_y, push_undo);
|
|
|
|
break;
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_MASK_TO_LAYER:
|
|
|
|
case GIMP_TRANSLATE_MODE_MASK_COPY_TO_LAYER:
|
2003-09-17 00:23:38 +08:00
|
|
|
/* this won't happen */
|
|
|
|
break;
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_VECTORS:
|
|
|
|
case GIMP_TRANSLATE_MODE_CHANNEL:
|
|
|
|
case GIMP_TRANSLATE_MODE_LAYER:
|
2004-04-13 21:54:54 +08:00
|
|
|
gimp_item_translate (item, inc_x, inc_y, push_undo);
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
/* translate all linked items as well */
|
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
gimp_item_linked_translate (item, inc_x, inc_y, push_undo);
|
2003-09-17 00:23:38 +08:00
|
|
|
break;
|
|
|
|
|
2004-07-26 22:50:51 +08:00
|
|
|
case GIMP_TRANSLATE_MODE_FLOATING_SEL:
|
2003-09-17 00:23:38 +08:00
|
|
|
gimp_item_translate (item, inc_x, inc_y, push_undo);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2000-10-23 17:05:45 +08:00
|
|
|
|
2003-03-19 00:42:45 +08:00
|
|
|
if (push_undo)
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_undo_group_end (display->image);
|
2004-03-20 07:42:42 +08:00
|
|
|
else
|
2006-08-30 05:44:51 +08:00
|
|
|
gimp_undo_refresh_preview (undo,
|
|
|
|
gimp_get_user_context (display->image->gimp));
|
2003-03-19 00:42:45 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_image_flush (display->image);
|
2004-06-24 18:16:08 +08:00
|
|
|
|
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|