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-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
|
|
|
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "appenv.h"
|
2000-02-29 03:25:42 +08:00
|
|
|
#include "cursorutil.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "draw_core.h"
|
|
|
|
#include "drawable.h"
|
|
|
|
#include "tools.h"
|
|
|
|
#include "edit_selection.h"
|
|
|
|
#include "floating_sel.h"
|
|
|
|
#include "gimage_mask.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "undo.h"
|
1998-12-06 05:48:37 +08:00
|
|
|
#include "gimprc.h"
|
2000-02-16 21:52:33 +08:00
|
|
|
#include "path_transform.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
2000-02-10 22:23:11 +08:00
|
|
|
#include "libgimp/gimpmath.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +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
|
1998-07-27 05:49:42 +08:00
|
|
|
#define STATUSBAR_SIZE 128
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-06-22 06:12:07 +08:00
|
|
|
typedef struct _EditSelection EditSelection;
|
|
|
|
struct _EditSelection
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gint origx, origy; /* last x and y coords */
|
|
|
|
gint cumlx, cumly; /* cumulative changes to x and yed */
|
2000-06-14 05:44:48 +08:00
|
|
|
gint offset_x,offset_y; /* Offset of display at start sel */
|
2000-02-10 22:23:11 +08:00
|
|
|
gint x, y; /* current x and y coords */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-10 22:23:11 +08:00
|
|
|
gint x1, y1; /* bounding box of selection mask */
|
|
|
|
gint x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
EditType edit_type; /* translate the mask or layer? */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
DrawCore * core; /* selection core for drawing bounds*/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
ButtonReleaseFunc old_button_release;/* old button press member func */
|
|
|
|
MotionFunc old_motion; /* old motion member function */
|
|
|
|
ToolCtlFunc old_control; /* old control member function */
|
|
|
|
CursorUpdateFunc old_cursor_update; /* old cursor update function */
|
1999-07-03 01:40:10 +08:00
|
|
|
gboolean old_scroll_lock; /* old value of scroll lock */
|
|
|
|
gboolean old_auto_snap_to; /* old value of auto snap to */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
gboolean first_move; /* we undo_freeze after the first */
|
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
guint context_id; /* for the statusbar */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* static EditSelection structure--there is ever only one present */
|
|
|
|
static EditSelection edit_select;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
edit_selection_snap (GDisplay *gdisp,
|
2000-02-10 22:23:11 +08:00
|
|
|
gdouble x,
|
|
|
|
gdouble y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gdouble x1, y1;
|
|
|
|
gdouble x2, y2;
|
|
|
|
gdouble dx, dy;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-02-10 22:23:11 +08:00
|
|
|
gdisplay_untransform_coords_f (gdisp, x, y, &x, &y, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
dx = x - edit_select.origx;
|
|
|
|
dy = y - edit_select.origy;
|
2000-02-10 22:23:11 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
x1 = edit_select.x1 + dx;
|
|
|
|
y1 = edit_select.y1 + dy;
|
|
|
|
|
2000-02-10 22:23:11 +08:00
|
|
|
if (gdisp->draw_guides &&
|
|
|
|
gdisp->snap_to_guides &&
|
|
|
|
gdisp->gimage->guides)
|
|
|
|
{
|
|
|
|
x2 = edit_select.x2 + dx;
|
|
|
|
y2 = edit_select.y2 + dy;
|
|
|
|
|
|
|
|
gdisplay_transform_coords_f (gdisp, x1, y1, &x1, &y1, TRUE);
|
|
|
|
gdisplay_transform_coords_f (gdisp, x2, y2, &x2, &y2, TRUE);
|
|
|
|
|
|
|
|
gdisplay_snap_rectangle (gdisp, x1, y1, x2, y2, &x1, &y1);
|
|
|
|
|
|
|
|
gdisplay_untransform_coords_f (gdisp, x1, y1, &x1, &y1, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_select.x = (int)x1 - (edit_select.x1 - edit_select.origx);
|
|
|
|
edit_select.y = (int)y1 - (edit_select.y1 - edit_select.origy);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
init_edit_selection (Tool *tool,
|
|
|
|
gpointer gdisp_ptr,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
EditType edit_type)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
Layer *layer;
|
2000-02-10 22:23:11 +08:00
|
|
|
gint x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
|
comment typo fix, plus add %D* to default image-title-format string, so
Fri Oct 1 12:46:12 1999 Austin Donnelly <austin@gimp.org>
* gimprc.in: comment typo fix, plus add %D* to default
image-title-format string, so people get a '*' in the titlebar
if their image is dirty.
* app/fileops.c: initialise filename before using it.
* app/gdisplay.c: empty parameter list () is K&R - should be
stronger (void) in ANSI C.
* app/gimpdrawable.c: gimp_drawable_{dirty,clean} functions
removed - no one uses them anyway. Parasite undo type is
proper parasite undo type, not MISC_UNDO.
* app/gimpdrawableP.h: drawable dirty bit removed.
* app/gimpimage.c: don't change the resolution if there's no
difference from the old one. Call gdisplay_shrink_wrap() to
re-calculate scale factors and refresh the display on
resolution change. Layer undo doesn't have sub-types
anymore, uses main UndoType instead.
* app/layer.h: Remove LayerUndoType
* app/qmask.c: fix qmask undo so it actually works.
* app/undo.h: new types for undo_push_layer{,_mask} and
undo_push_qmask.
* app/undo.c: change way group boundaries are represented:
each Undo has a group_boundary boolean set to TRUE if this is
the start or the end of a group, and the type of the Undo is
the group's type. Within a group, each Undo keeps its own
type. This allows pop funcs and free funcs to do
type-specific things (eg needed by layer and channel stuff).
Don't maintain per-drawable dirty flags anymore. Floating
sel to layer and layer rename now uses meaningful undo types.
* app/undo_types.h: more specific undo types:
LAYER_{ADD,REMOVE}_UNDO, LAYER_MASK_{ADD,REMOVE}_UNDO,
LAYER_RENAME_UNDO, and PARASITE_{ATTACH,DETACH}_UNDO.
* app/undo_history.c: oops - undo stack was being placed into gtk
list in wrong order.
* app/edit_selection.c: push more descriptive LAYER_DISPLACE_UNDO
rather than MISC_UNDO.
* app/layers_dialog.c: better tagging of undo types
1999-10-02 02:43:24 +08:00
|
|
|
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO);
|
1999-03-21 23:38:11 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Move the (x, y) point from screen to image space */
|
|
|
|
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, TRUE);
|
|
|
|
|
|
|
|
edit_select.x = edit_select.origx = x;
|
|
|
|
edit_select.y = edit_select.origy = y;
|
|
|
|
|
1999-03-21 23:38:11 +08:00
|
|
|
edit_select.cumlx = 0;
|
|
|
|
edit_select.cumly = 0;
|
|
|
|
|
2000-06-14 05:44:48 +08:00
|
|
|
edit_select.offset_x = gdisp->offset_x;
|
|
|
|
edit_select.offset_y = gdisp->offset_y;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Make a check to see if it should be a floating selection translation */
|
1999-05-05 17:10:35 +08:00
|
|
|
if (edit_type == MaskToLayerTranslate && gimage_floating_sel (gdisp->gimage))
|
|
|
|
edit_type = FloatingSelTranslate;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (edit_type == LayerTranslate)
|
|
|
|
{
|
|
|
|
layer = gimage_get_active_layer (gdisp->gimage);
|
|
|
|
if (layer_is_floating_sel (layer))
|
|
|
|
edit_type = FloatingSelTranslate;
|
|
|
|
}
|
|
|
|
|
|
|
|
edit_select.edit_type = edit_type;
|
|
|
|
|
|
|
|
edit_select.old_button_release = tool->button_release_func;
|
|
|
|
edit_select.old_motion = tool->motion_func;
|
|
|
|
edit_select.old_control = tool->control_func;
|
|
|
|
edit_select.old_cursor_update = tool->cursor_update_func;
|
|
|
|
edit_select.old_scroll_lock = tool->scroll_lock;
|
|
|
|
edit_select.old_auto_snap_to = tool->auto_snap_to;
|
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
edit_select.first_move = TRUE;
|
|
|
|
|
1999-03-21 23:38:11 +08:00
|
|
|
/* find the bounding box of the selection mask -
|
1997-11-25 06:05:25 +08:00
|
|
|
* this is used for the case of a MaskToLayerTranslate,
|
|
|
|
* where the translation will result in floating the selection
|
|
|
|
* mask and translating the resulting layer
|
|
|
|
*/
|
|
|
|
drawable_mask_bounds (gimage_active_drawable (gdisp->gimage),
|
|
|
|
&edit_select.x1, &edit_select.y1,
|
|
|
|
&edit_select.x2, &edit_select.y2);
|
|
|
|
|
|
|
|
edit_selection_snap (gdisp, bevent->x, bevent->y);
|
|
|
|
|
|
|
|
/* reset the function pointers on the selection tool */
|
|
|
|
tool->button_release_func = edit_selection_button_release;
|
1999-11-05 22:39:04 +08:00
|
|
|
tool->motion_func = edit_selection_motion;
|
|
|
|
tool->control_func = edit_selection_control;
|
|
|
|
tool->cursor_update_func = edit_selection_cursor_update;
|
|
|
|
tool->scroll_lock = EDIT_SELECT_SCROLL_LOCK;
|
|
|
|
tool->auto_snap_to = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* pause the current selection */
|
|
|
|
selection_pause (gdisp->select);
|
|
|
|
|
1998-07-24 02:33:01 +08:00
|
|
|
/* initialize the statusbar display */
|
1998-07-27 05:49:42 +08:00
|
|
|
edit_select.context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar), "edit_select");
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id, _("Move: 0, 0"));
|
1998-07-24 02:33:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Create and start the selection core */
|
|
|
|
edit_select.core = draw_core_new (edit_selection_draw);
|
|
|
|
draw_core_start (edit_select.core,
|
|
|
|
gdisp->canvas->window,
|
|
|
|
tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_selection_button_release (Tool *tool,
|
|
|
|
GdkEventButton *bevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gint x, y;
|
1997-11-25 06:05:25 +08:00
|
|
|
GDisplay * gdisp;
|
|
|
|
Layer *layer;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
|
|
|
|
/* resume the current selection and ungrab the pointer */
|
|
|
|
selection_resume (gdisp->select);
|
|
|
|
|
|
|
|
gdk_pointer_ungrab (bevent->time);
|
|
|
|
gdk_flush ();
|
|
|
|
|
2000-02-10 22:23:11 +08:00
|
|
|
gtk_statusbar_pop (GTK_STATUSBAR (gdisp->statusbar), edit_select.context_id);
|
1998-07-24 02:33:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Stop and free the selection core */
|
|
|
|
draw_core_stop (edit_select.core, tool);
|
|
|
|
draw_core_free (edit_select.core);
|
|
|
|
edit_select.core = NULL;
|
|
|
|
tool->state = INACTIVE;
|
|
|
|
|
|
|
|
tool->button_release_func = edit_select.old_button_release;
|
|
|
|
tool->motion_func = edit_select.old_motion;
|
|
|
|
tool->control_func = edit_select.old_control;
|
|
|
|
tool->cursor_update_func = edit_select.old_cursor_update;
|
|
|
|
tool->scroll_lock = edit_select.old_scroll_lock;
|
|
|
|
tool->auto_snap_to = edit_select.old_auto_snap_to;
|
|
|
|
|
1999-12-18 04:59:37 +08:00
|
|
|
/* MaskTranslate is performed here at movement end, not 'live' like
|
|
|
|
* the other translation types.
|
|
|
|
*/
|
|
|
|
if (edit_select.edit_type == MaskTranslate)
|
2000-02-10 22:23:11 +08:00
|
|
|
{
|
|
|
|
edit_selection_snap (gdisp, bevent->x, bevent->y);
|
|
|
|
x = edit_select.x;
|
|
|
|
y = edit_select.y;
|
|
|
|
|
|
|
|
/* move the selection -- whether there has been net movement or not!
|
|
|
|
* (to ensure that there's something on the undo stack)
|
|
|
|
*/
|
|
|
|
gimage_mask_translate (gdisp->gimage,
|
|
|
|
edit_select.cumlx,
|
|
|
|
edit_select.cumly);
|
|
|
|
|
|
|
|
if (edit_select.first_move)
|
|
|
|
{
|
|
|
|
gimp_image_undo_freeze (gdisp->gimage);
|
|
|
|
edit_select.first_move = FALSE;
|
|
|
|
}
|
|
|
|
}
|
1999-12-18 04:59:37 +08:00
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
/* thaw the undo again */
|
|
|
|
gimp_image_undo_thaw (gdisp->gimage);
|
|
|
|
|
1999-04-25 04:58:55 +08:00
|
|
|
if (edit_select.cumlx == 0 && edit_select.cumly == 0)
|
|
|
|
{
|
|
|
|
/* The user either didn't actually move the selection,
|
|
|
|
or moved it around and eventually just put it back in
|
|
|
|
exactly the same spot. */
|
2000-02-10 22:23:11 +08:00
|
|
|
|
|
|
|
/* If no movement occured and the type is FloatingSelTranslate,
|
1999-04-25 04:58:55 +08:00
|
|
|
check if the layer is a floating selection. If so, anchor. */
|
2000-02-10 22:23:11 +08:00
|
|
|
if (edit_select.edit_type == FloatingSelTranslate)
|
1999-04-25 04:58:55 +08:00
|
|
|
{
|
|
|
|
layer = gimage_get_active_layer (gdisp->gimage);
|
|
|
|
if (layer_is_floating_sel (layer))
|
|
|
|
floating_sel_anchor (layer);
|
|
|
|
}
|
|
|
|
}
|
1999-10-19 04:55:25 +08:00
|
|
|
else
|
|
|
|
{
|
2000-02-16 21:52:33 +08:00
|
|
|
path_transform_xy (gdisp->gimage, edit_select.cumlx, edit_select.cumly);
|
1999-10-19 04:55:25 +08:00
|
|
|
}
|
1999-11-05 22:39:04 +08:00
|
|
|
|
1999-03-21 23:38:11 +08:00
|
|
|
undo_push_group_end (gdisp->gimage);
|
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
if (bevent->state & GDK_BUTTON3_MASK) /* OPERATION CANCELLED */
|
1999-03-21 23:38:11 +08:00
|
|
|
{
|
|
|
|
/* Operation cancelled - undo the undo-group! */
|
1999-11-05 22:39:04 +08:00
|
|
|
undo_pop (gdisp->gimage);
|
1999-03-21 23:38:11 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_selection_motion (Tool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay * gdisp;
|
1998-07-27 05:49:42 +08:00
|
|
|
gchar offset[STATUSBAR_SIZE];
|
2000-02-29 03:25:42 +08:00
|
|
|
gdouble lastmotion_x, lastmotion_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (tool->state != ACTIVE)
|
1999-03-21 23:38:11 +08:00
|
|
|
{
|
2000-02-29 03:25:42 +08:00
|
|
|
g_warning ("BUG: Tracking motion while !ACTIVE");
|
1999-03-21 23:38:11 +08:00
|
|
|
return;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
gdk_flush();
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_pause (edit_select.core, tool);
|
|
|
|
|
|
|
|
|
2000-02-29 03:25:42 +08:00
|
|
|
/* Perform motion compression so that we don't lag and/or waste time. */
|
|
|
|
|
|
|
|
if (!gtkutil_compress_motion(gtk_get_event_widget((GdkEvent*)mevent),
|
|
|
|
&lastmotion_x, &lastmotion_y))
|
|
|
|
{
|
|
|
|
lastmotion_x = mevent->x;
|
|
|
|
lastmotion_y = mevent->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* now do the actual move. */
|
|
|
|
|
|
|
|
edit_selection_snap (gdisp, RINT(lastmotion_x), RINT(lastmotion_y));
|
|
|
|
|
|
|
|
/******************************************* adam's live move *******/
|
1999-03-21 23:38:11 +08:00
|
|
|
/********************************************************************/
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gint x, y;
|
1999-03-21 23:38:11 +08:00
|
|
|
Layer *layer;
|
|
|
|
Layer *floating_layer;
|
|
|
|
GSList *layer_list;
|
|
|
|
|
|
|
|
x = edit_select.x;
|
|
|
|
y = edit_select.y;
|
|
|
|
|
|
|
|
/* if there has been movement, move the selection */
|
|
|
|
if (edit_select.origx != x || edit_select.origy != y)
|
|
|
|
{
|
|
|
|
gint xoffset, yoffset;
|
|
|
|
|
|
|
|
xoffset = x - edit_select.origx;
|
|
|
|
yoffset = y - edit_select.origy;
|
|
|
|
|
|
|
|
edit_select.cumlx += xoffset;
|
|
|
|
edit_select.cumly += yoffset;
|
|
|
|
|
|
|
|
switch (edit_select.edit_type)
|
|
|
|
{
|
|
|
|
case MaskTranslate:
|
1999-12-18 04:59:37 +08:00
|
|
|
/* we don't do the actual edit selection move here. */
|
1999-04-25 04:58:55 +08:00
|
|
|
edit_select.origx = x;
|
|
|
|
edit_select.origy = y;
|
1999-03-21 23:38:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LayerTranslate:
|
|
|
|
if ((floating_layer = gimage_floating_sel (gdisp->gimage)))
|
|
|
|
floating_sel_relax (floating_layer, TRUE);
|
1999-02-07 23:16:45 +08:00
|
|
|
|
1999-03-21 23:38:11 +08:00
|
|
|
/* translate the layer--and any "linked" layers as well */
|
|
|
|
layer_list = gdisp->gimage->layers;
|
|
|
|
while (layer_list)
|
|
|
|
{
|
|
|
|
layer = (Layer *) layer_list->data;
|
|
|
|
if (layer == gdisp->gimage->active_layer ||
|
|
|
|
layer_linked (layer))
|
|
|
|
{
|
|
|
|
layer_translate (layer, xoffset, yoffset);
|
|
|
|
}
|
|
|
|
layer_list = g_slist_next (layer_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (floating_layer)
|
|
|
|
floating_sel_rigor (floating_layer, TRUE);
|
1999-11-05 22:39:04 +08:00
|
|
|
|
|
|
|
if (edit_select.first_move)
|
|
|
|
{
|
|
|
|
gimp_image_undo_freeze (gdisp->gimage);
|
|
|
|
edit_select.first_move = FALSE;
|
|
|
|
}
|
1999-03-21 23:38:11 +08:00
|
|
|
break;
|
1999-04-25 04:58:55 +08:00
|
|
|
|
|
|
|
case MaskToLayerTranslate:
|
2000-02-10 22:43:51 +08:00
|
|
|
if (!gimage_mask_float (gdisp->gimage,
|
|
|
|
gimage_active_drawable (gdisp->gimage),
|
|
|
|
0, 0))
|
|
|
|
{
|
|
|
|
/* no region to float, abort safely */
|
|
|
|
draw_core_resume (edit_select.core, tool);
|
|
|
|
return;
|
|
|
|
}
|
2000-02-10 22:23:11 +08:00
|
|
|
|
2000-02-10 22:43:51 +08:00
|
|
|
/* this is always the first move, since we switch to
|
|
|
|
FloatingSelTranslate when finished here */
|
2000-02-10 22:23:11 +08:00
|
|
|
gimp_image_undo_freeze (gdisp->gimage);
|
|
|
|
edit_select.first_move = FALSE;
|
1999-04-25 04:58:55 +08:00
|
|
|
|
|
|
|
edit_select.origx -= edit_select.x1;
|
|
|
|
edit_select.origy -= edit_select.y1;
|
2000-02-10 22:23:11 +08:00
|
|
|
edit_select.x2 -= edit_select.x1;
|
|
|
|
edit_select.y2 -= edit_select.y1;
|
|
|
|
edit_select.x1 = 0;
|
|
|
|
edit_select.y1 = 0;
|
|
|
|
|
|
|
|
edit_select.edit_type = FloatingSelTranslate;
|
1999-04-25 04:58:55 +08:00
|
|
|
break;
|
1999-03-21 23:38:11 +08:00
|
|
|
|
|
|
|
case FloatingSelTranslate:
|
|
|
|
layer = gimage_get_active_layer (gdisp->gimage);
|
|
|
|
|
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
layer_translate (layer, xoffset, yoffset);
|
|
|
|
floating_sel_rigor (layer, TRUE);
|
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
if (edit_select.first_move)
|
|
|
|
{
|
|
|
|
gimp_image_undo_freeze (gdisp->gimage);
|
|
|
|
edit_select.first_move = FALSE;
|
|
|
|
}
|
1999-03-21 23:38:11 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_warning ("esm / BAD FALLTHROUGH");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdisplay_flush(gdisp);
|
|
|
|
}
|
|
|
|
/********************************************************************/
|
|
|
|
/********************************************************************/
|
|
|
|
|
1999-02-07 23:16:45 +08:00
|
|
|
|
1998-07-24 02:33:01 +08:00
|
|
|
gtk_statusbar_pop (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id);
|
1999-03-04 01:48:29 +08:00
|
|
|
if (gdisp->dot_for_dot)
|
|
|
|
{
|
|
|
|
g_snprintf (offset, STATUSBAR_SIZE, gdisp->cursor_format_str,
|
|
|
|
_("Move: "),
|
1999-03-21 23:38:11 +08:00
|
|
|
edit_select.cumlx,
|
1999-03-04 01:48:29 +08:00
|
|
|
", ",
|
1999-03-21 23:38:11 +08:00
|
|
|
edit_select.cumly);
|
1999-03-04 01:48:29 +08:00
|
|
|
}
|
|
|
|
else /* show real world units */
|
|
|
|
{
|
1999-05-23 01:56:35 +08:00
|
|
|
gdouble unit_factor = gimp_unit_get_factor (gdisp->gimage->unit);
|
1999-03-04 01:48:29 +08:00
|
|
|
|
|
|
|
g_snprintf (offset, STATUSBAR_SIZE, gdisp->cursor_format_str,
|
|
|
|
_("Move: "),
|
1999-03-21 23:38:11 +08:00
|
|
|
(edit_select.cumlx) * unit_factor /
|
1999-03-04 01:48:29 +08:00
|
|
|
gdisp->gimage->xresolution,
|
|
|
|
", ",
|
1999-03-21 23:38:11 +08:00
|
|
|
(edit_select.cumly) * unit_factor /
|
1999-03-04 01:48:29 +08:00
|
|
|
gdisp->gimage->yresolution);
|
|
|
|
}
|
|
|
|
gtk_statusbar_push (GTK_STATUSBAR(gdisp->statusbar), edit_select.context_id,
|
|
|
|
offset);
|
1998-07-24 02:33:01 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_resume (edit_select.core, tool);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_selection_draw (Tool *tool)
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gint i;
|
|
|
|
gint diff_x, diff_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
GDisplay * gdisp;
|
|
|
|
GdkSegment * seg;
|
|
|
|
Selection * select;
|
|
|
|
Layer *layer;
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *layer_list;
|
2000-02-10 22:23:11 +08:00
|
|
|
gint floating_sel;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint x3, y3, x4, y4;
|
|
|
|
gint off_x, off_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdisp = (GDisplay *) tool->gdisp_ptr;
|
|
|
|
select = gdisp->select;
|
|
|
|
|
|
|
|
switch (edit_select.edit_type)
|
|
|
|
{
|
|
|
|
case MaskTranslate:
|
|
|
|
layer = gimage_get_active_layer (gdisp->gimage);
|
|
|
|
floating_sel = layer_is_floating_sel (layer);
|
|
|
|
|
2000-02-10 22:43:51 +08:00
|
|
|
diff_x = SCALEX (gdisp, edit_select.cumlx);
|
|
|
|
diff_y = SCALEY (gdisp, edit_select.cumly);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* offset the current selection */
|
|
|
|
seg = select->segs_in;
|
|
|
|
for (i = 0; i < select->num_segs_in; i++)
|
|
|
|
{
|
|
|
|
seg->x1 += diff_x;
|
|
|
|
seg->x2 += diff_x;
|
|
|
|
seg->y1 += diff_y;
|
|
|
|
seg->y2 += diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
seg = select->segs_out;
|
|
|
|
for (i = 0; i < select->num_segs_out; i++)
|
|
|
|
{
|
|
|
|
seg->x1 += diff_x;
|
|
|
|
seg->x2 += diff_x;
|
|
|
|
seg->y1 += diff_y;
|
|
|
|
seg->y2 += diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! floating_sel)
|
|
|
|
gdk_draw_segments (edit_select.core->win, edit_select.core->gc,
|
|
|
|
select->segs_in, select->num_segs_in);
|
1999-03-21 23:38:11 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
gdk_draw_segments (edit_select.core->win, edit_select.core->gc,
|
|
|
|
select->segs_out, select->num_segs_out);
|
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
/* reset the current selection */
|
1997-11-25 06:05:25 +08:00
|
|
|
seg = select->segs_in;
|
|
|
|
for (i = 0; i < select->num_segs_in; i++)
|
|
|
|
{
|
|
|
|
seg->x1 -= diff_x;
|
|
|
|
seg->x2 -= diff_x;
|
|
|
|
seg->y1 -= diff_y;
|
|
|
|
seg->y2 -= diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
seg = select->segs_out;
|
|
|
|
for (i = 0; i < select->num_segs_out; i++)
|
|
|
|
{
|
|
|
|
seg->x1 -= diff_x;
|
|
|
|
seg->x2 -= diff_x;
|
|
|
|
seg->y1 -= diff_y;
|
|
|
|
seg->y2 -= diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MaskToLayerTranslate:
|
|
|
|
gdisplay_transform_coords (gdisp, edit_select.x1, edit_select.y1, &x1, &y1, TRUE);
|
|
|
|
gdisplay_transform_coords (gdisp, edit_select.x2, edit_select.y2, &x2, &y2, TRUE);
|
|
|
|
gdk_draw_rectangle (edit_select.core->win,
|
|
|
|
edit_select.core->gc, 0,
|
2000-02-10 22:23:11 +08:00
|
|
|
x1, y1,
|
|
|
|
x2 - x1 + 1, y2 - y1 + 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LayerTranslate:
|
|
|
|
gdisplay_transform_coords (gdisp, 0, 0, &x1, &y1, TRUE);
|
|
|
|
gdisplay_transform_coords (gdisp,
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_width ( GIMP_DRAWABLE (gdisp->gimage->active_layer)),
|
|
|
|
drawable_height ( GIMP_DRAWABLE (gdisp->gimage->active_layer)),
|
1997-11-25 06:05:25 +08:00
|
|
|
&x2, &y2, TRUE);
|
|
|
|
|
|
|
|
/* Now, expand the rectangle to include all linked layers as well */
|
|
|
|
layer_list = gdisp->gimage->layers;
|
|
|
|
while (layer_list)
|
|
|
|
{
|
|
|
|
layer = (Layer *) layer_list->data;
|
1998-01-22 15:02:57 +08:00
|
|
|
if (((layer) != gdisp->gimage->active_layer) && layer_linked (layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
|
|
|
|
gdisplay_transform_coords (gdisp, off_x, off_y, &x3, &y3, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplay_transform_coords (gdisp,
|
1998-01-22 15:02:57 +08:00
|
|
|
off_x + drawable_width (GIMP_DRAWABLE (layer)),
|
|
|
|
off_y + drawable_height (GIMP_DRAWABLE (layer)),
|
1997-11-25 06:05:25 +08:00
|
|
|
&x4, &y4, FALSE);
|
|
|
|
if (x3 < x1)
|
|
|
|
x1 = x3;
|
|
|
|
if (y3 < y1)
|
|
|
|
y1 = y3;
|
|
|
|
if (x4 > x2)
|
|
|
|
x2 = x4;
|
|
|
|
if (y4 > y2)
|
|
|
|
y2 = y4;
|
|
|
|
}
|
1998-01-29 16:03:27 +08:00
|
|
|
layer_list = g_slist_next (layer_list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gdk_draw_rectangle (edit_select.core->win,
|
|
|
|
edit_select.core->gc, 0,
|
2000-02-10 22:23:11 +08:00
|
|
|
x1, y1,
|
1999-11-05 22:39:04 +08:00
|
|
|
x2 - x1, y2 - y1);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FloatingSelTranslate:
|
2000-06-14 05:44:48 +08:00
|
|
|
diff_x = SCALEX (gdisp, edit_select.cumlx) - gdisp->offset_x + edit_select.offset_x;
|
|
|
|
diff_y = SCALEY (gdisp, edit_select.cumly) - gdisp->offset_y + edit_select.offset_y;
|
|
|
|
|
2000-02-10 22:43:51 +08:00
|
|
|
|
|
|
|
seg = select->segs_in;
|
1997-11-25 06:05:25 +08:00
|
|
|
for (i = 0; i < select->num_segs_in; i++)
|
|
|
|
{
|
|
|
|
seg->x1 += diff_x;
|
|
|
|
seg->x2 += diff_x;
|
|
|
|
seg->y1 += diff_y;
|
|
|
|
seg->y2 += diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the items */
|
|
|
|
gdk_draw_segments (edit_select.core->win, edit_select.core->gc,
|
|
|
|
select->segs_in, select->num_segs_in);
|
|
|
|
|
|
|
|
/* reset the the current selection */
|
|
|
|
seg = select->segs_in;
|
|
|
|
for (i = 0; i < select->num_segs_in; i++)
|
|
|
|
{
|
|
|
|
seg->x1 -= diff_x;
|
|
|
|
seg->x2 -= diff_x;
|
|
|
|
seg->y1 -= diff_y;
|
|
|
|
seg->y2 -= diff_y;
|
|
|
|
seg++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
1999-06-22 06:12:07 +08:00
|
|
|
edit_selection_control (Tool *tool,
|
|
|
|
ToolAction action,
|
|
|
|
gpointer gdisp_ptr)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
2000-06-14 18:59:16 +08:00
|
|
|
case PAUSE:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_pause (edit_select.core, tool);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2000-06-14 18:59:16 +08:00
|
|
|
case RESUME:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_resume (edit_select.core, tool);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
2000-06-14 18:59:16 +08:00
|
|
|
case HALT:
|
1997-11-25 06:05:25 +08:00
|
|
|
draw_core_stop (edit_select.core, tool);
|
|
|
|
draw_core_free (edit_select.core);
|
|
|
|
break;
|
1999-06-22 06:12:07 +08:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
edit_selection_cursor_update (Tool *tool,
|
|
|
|
GdkEventMotion *mevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
2000-06-14 18:59:16 +08:00
|
|
|
gdisplay_install_tool_cursor (gdisp, GIMP_MOUSE_CURSOR,
|
|
|
|
TOOL_TYPE_NONE,
|
|
|
|
CURSOR_MODIFIER_MOVE,
|
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2000-02-10 22:23:11 +08:00
|
|
|
static gint
|
1998-07-24 02:33:01 +08:00
|
|
|
process_event_queue_keys (GdkEventKey *kevent, ...)
|
1998-07-20 22:05:33 +08:00
|
|
|
/* GdkKeyType, GdkModifierType, value ... 0
|
|
|
|
* could move this function to a more central location so it can be used
|
|
|
|
* by other tools? */
|
|
|
|
{
|
|
|
|
#define FILTER_MAX_KEYS 50
|
|
|
|
va_list argp;
|
|
|
|
GdkEvent *event;
|
|
|
|
GList *list = NULL;
|
|
|
|
guint keys[FILTER_MAX_KEYS];
|
|
|
|
GdkModifierType modifiers[FILTER_MAX_KEYS];
|
2000-02-10 22:23:11 +08:00
|
|
|
gint values[FILTER_MAX_KEYS];
|
|
|
|
gint i = 0, nkeys = 0, value = 0, done = 0, discard_event;
|
1998-07-20 22:05:33 +08:00
|
|
|
GtkWidget *orig_widget;
|
|
|
|
|
|
|
|
va_start(argp, kevent);
|
|
|
|
while (nkeys <FILTER_MAX_KEYS && (keys[nkeys] = va_arg (argp, guint)) != 0)
|
|
|
|
{
|
|
|
|
modifiers[nkeys] = va_arg (argp, GdkModifierType);
|
|
|
|
values[nkeys] = va_arg (argp, int);
|
|
|
|
nkeys++;
|
|
|
|
}
|
|
|
|
va_end(argp);
|
|
|
|
|
|
|
|
for (i = 0; i < nkeys; i++)
|
|
|
|
if (kevent->keyval == keys[i] && kevent->state == modifiers[i])
|
|
|
|
value += values[i];
|
|
|
|
|
|
|
|
orig_widget = gtk_get_event_widget((GdkEvent*)kevent);
|
|
|
|
|
|
|
|
while (gdk_events_pending() > 0 && !done)
|
|
|
|
{
|
|
|
|
discard_event = 0;
|
|
|
|
event = gdk_event_get();
|
2000-03-09 02:32:31 +08:00
|
|
|
if (!event || orig_widget != gtk_get_event_widget(event))
|
1998-07-20 22:05:33 +08:00
|
|
|
{
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (event->any.type == GDK_KEY_PRESS)
|
|
|
|
{
|
|
|
|
for (i = 0; i < nkeys; i++)
|
|
|
|
if (event->key.keyval == keys[i] &&
|
|
|
|
event->key.state == modifiers[i])
|
|
|
|
{
|
|
|
|
discard_event = 1;
|
|
|
|
value += values[i];
|
|
|
|
}
|
|
|
|
if (!discard_event)
|
|
|
|
done = 1;
|
|
|
|
}
|
|
|
|
/* 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 = 1;
|
|
|
|
}
|
|
|
|
|
2000-03-09 02:32:31 +08:00
|
|
|
if (!event)
|
|
|
|
; /* Do nothing */
|
|
|
|
else if (!discard_event)
|
2000-02-29 03:25:42 +08:00
|
|
|
list = g_list_append(list, event);
|
1998-07-20 22:05:33 +08:00
|
|
|
else
|
|
|
|
gdk_event_free(event);
|
|
|
|
}
|
|
|
|
while (list) /* unget the unused events and free the list */
|
|
|
|
{
|
|
|
|
gdk_event_put((GdkEvent*)list->data);
|
|
|
|
gdk_event_free((GdkEvent*)list->data);
|
|
|
|
list = g_list_remove_link (list, list);
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
#undef FILTER_MAX_KEYS
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
void
|
|
|
|
edit_sel_arrow_keys_func (Tool *tool,
|
|
|
|
GdkEventKey *kevent,
|
|
|
|
gpointer gdisp_ptr)
|
|
|
|
{
|
2000-02-10 22:23:11 +08:00
|
|
|
gint inc_x, inc_y, mask_inc_x, mask_inc_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
GDisplay *gdisp;
|
|
|
|
Layer *layer;
|
|
|
|
Layer *floating_layer;
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *layer_list;
|
1997-11-25 06:05:25 +08:00
|
|
|
EditType edit_type;
|
|
|
|
|
|
|
|
layer = NULL;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
inc_x = process_event_queue_keys(kevent,
|
|
|
|
GDK_Left, 0, -1,
|
|
|
|
GDK_Left, GDK_SHIFT_MASK, -1*ARROW_VELOCITY,
|
|
|
|
GDK_Right, 0, 1,
|
|
|
|
GDK_Right, GDK_SHIFT_MASK, ARROW_VELOCITY,
|
|
|
|
0);
|
|
|
|
inc_y = process_event_queue_keys(kevent,
|
|
|
|
GDK_Up, 0, -1,
|
|
|
|
GDK_Up, GDK_SHIFT_MASK, -1*ARROW_VELOCITY,
|
|
|
|
GDK_Down, 0, 1,
|
|
|
|
GDK_Down, GDK_SHIFT_MASK, ARROW_VELOCITY,
|
|
|
|
0);
|
|
|
|
|
|
|
|
mask_inc_x = process_event_queue_keys(kevent,
|
|
|
|
GDK_Left, GDK_MOD1_MASK, -1,
|
|
|
|
GDK_Left, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
|
|
|
-1*ARROW_VELOCITY,
|
|
|
|
GDK_Right, GDK_MOD1_MASK, 1,
|
|
|
|
GDK_Right, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
|
|
|
ARROW_VELOCITY,
|
|
|
|
0);
|
|
|
|
mask_inc_y = process_event_queue_keys(kevent,
|
|
|
|
GDK_Up, GDK_MOD1_MASK, -1,
|
|
|
|
GDK_Up, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
|
|
|
-1*ARROW_VELOCITY,
|
|
|
|
GDK_Down, GDK_MOD1_MASK, 1,
|
|
|
|
GDK_Down, (GDK_MOD1_MASK | GDK_SHIFT_MASK),
|
|
|
|
ARROW_VELOCITY,
|
|
|
|
0);
|
|
|
|
if (inc_x == 0 && inc_y == 0 && mask_inc_x == 0 && mask_inc_y == 0)
|
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-11-05 22:39:04 +08:00
|
|
|
undo_push_group_start (gdisp->gimage, LAYER_DISPLACE_UNDO);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
if (mask_inc_x != 0 || mask_inc_y != 0)
|
|
|
|
gimage_mask_translate (gdisp->gimage, mask_inc_x, mask_inc_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
if (inc_x != 0 || inc_y != 0)
|
|
|
|
{
|
|
|
|
layer = gimage_get_active_layer (gdisp->gimage);
|
|
|
|
if (layer_is_floating_sel (layer))
|
|
|
|
edit_type = FloatingSelTranslate;
|
|
|
|
else
|
|
|
|
edit_type = LayerTranslate;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
switch (edit_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-07-20 22:05:33 +08:00
|
|
|
case MaskToLayerTranslate:
|
|
|
|
gimage_mask_float (gdisp->gimage,
|
|
|
|
gimage_active_drawable (gdisp->gimage),
|
|
|
|
inc_x, inc_y);
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
case LayerTranslate:
|
|
|
|
|
|
|
|
if ((floating_layer = gimage_floating_sel (gdisp->gimage)))
|
|
|
|
floating_sel_relax (floating_layer, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
/* translate the layer--and any "linked" layers as well */
|
|
|
|
layer_list = gdisp->gimage->layers;
|
|
|
|
while (layer_list)
|
|
|
|
{
|
|
|
|
layer = (Layer *) layer_list->data;
|
|
|
|
if (((layer) == gdisp->gimage->active_layer) || layer_linked (layer))
|
|
|
|
layer_translate (layer, inc_x, inc_y);
|
|
|
|
layer_list = g_slist_next (layer_list);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
if (floating_layer)
|
|
|
|
floating_sel_rigor (floating_layer, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
case FloatingSelTranslate:
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
floating_sel_relax (layer, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
layer_translate (layer, inc_x, inc_y);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
floating_sel_rigor (layer, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-07-20 22:05:33 +08:00
|
|
|
default:
|
|
|
|
/* this won't occur */
|
|
|
|
break;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1998-07-20 22:05:33 +08:00
|
|
|
}
|
|
|
|
undo_push_group_end (gdisp->gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
gdisplays_flush ();
|
|
|
|
}
|