1997-11-25 06:05:25 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2000-03-22 01:47:32 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2003-05-12 23:56:36 +08:00
|
|
|
#include "core/gimpitem-linked.h"
|
2004-12-06 22:37:00 +08:00
|
|
|
#include "core/gimplayer.h"
|
|
|
|
#include "core/gimplayermask.h"
|
2005-07-12 03:21:52 +08:00
|
|
|
#include "core/gimppickable.h"
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2001-01-23 21:01:48 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpflipoptions.h"
|
2001-04-01 01:08:55 +08:00
|
|
|
#include "gimpfliptool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.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
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-12-31 12:07:42 +08:00
|
|
|
/* local function prototypes */
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
static void gimp_flip_tool_class_init (GimpFlipToolClass *klass);
|
|
|
|
static void gimp_flip_tool_init (GimpFlipTool *flip_tool);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
static void gimp_flip_tool_modifier_key (GimpTool *tool,
|
2001-11-09 03:14:51 +08:00
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
2004-12-06 22:37:00 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2001-11-09 03:14:51 +08:00
|
|
|
static void gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
2004-12-06 22:37:00 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2000-12-31 12:07:42 +08:00
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
static TileManager * gimp_flip_tool_transform (GimpTransformTool *tool,
|
2003-05-31 07:52:24 +08:00
|
|
|
GimpItem *item,
|
2004-12-06 22:37:00 +08:00
|
|
|
gboolean mask_empty,
|
|
|
|
GimpDisplay *gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
static GimpTransformToolClass *parent_class = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_flip_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_FLIP_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_FLIP_OPTIONS,
|
|
|
|
gimp_flip_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-flip-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Flip"),
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Flip the layer or selection"),
|
2004-04-29 21:19:28 +08:00
|
|
|
N_("_Flip"), "<shift>F",
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_FLIP,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_FLIP,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-04-01 01:08:55 +08:00
|
|
|
gimp_flip_tool_get_type (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1999-04-27 10:09:03 +08:00
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
if (! tool_type)
|
1999-04-13 01:55:06 +08:00
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
|
|
|
sizeof (GimpFlipToolClass),
|
2004-12-06 22:37:00 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_flip_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpFlipTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_flip_tool_init,
|
2001-04-01 01:08:55 +08:00
|
|
|
};
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_TRANSFORM_TOOL,
|
2004-12-06 22:37:00 +08:00
|
|
|
"GimpFlipTool",
|
2001-08-14 22:53:55 +08:00
|
|
|
&tool_info, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
return tool_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_flip_tool_class_init (GimpFlipToolClass *klass)
|
|
|
|
{
|
2004-12-06 22:37:00 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpTransformToolClass *trans_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
|
|
|
tool_class->modifier_key = gimp_flip_tool_modifier_key;
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->cursor_update = gimp_flip_tool_cursor_update;
|
2001-04-01 01:08:55 +08:00
|
|
|
|
|
|
|
trans_class->transform = gimp_flip_tool_transform;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
|
|
|
{
|
2004-12-06 22:37:00 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (flip_tool);
|
|
|
|
GimpTransformTool *transform_tool = GIMP_TRANSFORM_TOOL (flip_tool);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2002-05-03 05:03:27 +08:00
|
|
|
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_FLIP_HORIZONTAL);
|
2002-06-17 01:13:39 +08:00
|
|
|
gimp_tool_control_set_toggle_tool_cursor (tool->control,
|
2004-06-05 07:08:29 +08:00
|
|
|
GIMP_TOOL_CURSOR_FLIP_VERTICAL);
|
2001-11-20 02:23:43 +08:00
|
|
|
|
|
|
|
transform_tool->use_grid = FALSE;
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
static void
|
|
|
|
gimp_flip_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
2004-12-06 22:37:00 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2004-12-06 22:37:00 +08:00
|
|
|
GimpFlipOptions *options = GIMP_FLIP_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
if (key == GDK_CONTROL_MASK)
|
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
switch (options->flip_type)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2003-02-08 01:12:21 +08:00
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options,
|
2003-02-08 01:12:21 +08:00
|
|
|
"flip-type", GIMP_ORIENTATION_VERTICAL,
|
|
|
|
NULL);
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2003-02-28 09:14:30 +08:00
|
|
|
g_object_set (options,
|
2003-02-08 01:12:21 +08:00
|
|
|
"flip-type", GIMP_ORIENTATION_HORIZONTAL,
|
|
|
|
NULL);
|
2001-11-09 03:14:51 +08:00
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2001-11-09 03:14:51 +08:00
|
|
|
default:
|
|
|
|
break;
|
2004-12-06 22:37:00 +08:00
|
|
|
}
|
2001-11-09 03:14:51 +08:00
|
|
|
}
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-11-09 03:14:51 +08:00
|
|
|
gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
2004-12-06 22:37:00 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2003-02-05 22:39:40 +08:00
|
|
|
GimpFlipOptions *options;
|
|
|
|
gboolean bad_cursor = TRUE;
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_FLIP_OPTIONS (tool->tool_info->tool_options);
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2004-07-14 00:36:29 +08:00
|
|
|
if (gimp_image_coords_in_active_drawable (gdisp->gimage, coords))
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2003-09-03 23:13:19 +08:00
|
|
|
GimpChannel *selection = gimp_image_get_mask (gdisp->gimage);
|
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
/* Is there a selected region? If so, is cursor inside? */
|
2003-09-03 23:13:19 +08:00
|
|
|
if (gimp_channel_is_empty (selection) ||
|
2005-07-12 03:21:52 +08:00
|
|
|
gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection),
|
|
|
|
coords->x, coords->y))
|
2003-05-08 22:06:03 +08:00
|
|
|
{
|
|
|
|
bad_cursor = FALSE;
|
|
|
|
}
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
2002-02-05 01:43:01 +08:00
|
|
|
if (bad_cursor)
|
|
|
|
{
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_BAD);
|
|
|
|
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_CURSOR_BAD);
|
2002-02-05 01:43:01 +08:00
|
|
|
}
|
2001-04-01 01:08:55 +08:00
|
|
|
else
|
2002-02-05 01:43:01 +08:00
|
|
|
{
|
2005-11-20 06:16:34 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
|
|
|
|
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_CURSOR_MOUSE);
|
2002-02-05 01:43:01 +08:00
|
|
|
}
|
|
|
|
|
2005-11-24 03:14:05 +08:00
|
|
|
gimp_tool_control_set_toggled (tool->control,
|
|
|
|
options->flip_type == GIMP_ORIENTATION_VERTICAL);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2002-02-05 01:43:01 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static TileManager *
|
|
|
|
gimp_flip_tool_transform (GimpTransformTool *trans_tool,
|
2003-05-31 07:52:24 +08:00
|
|
|
GimpItem *active_item,
|
2004-12-06 22:37:00 +08:00
|
|
|
gboolean mask_empty,
|
|
|
|
GimpDisplay *gdisp)
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2003-05-31 07:52:24 +08:00
|
|
|
GimpTransformOptions *tr_options;
|
|
|
|
GimpFlipOptions *options;
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context;
|
2003-05-31 07:52:24 +08:00
|
|
|
gdouble axis = 0.0;
|
|
|
|
TileManager *ret = NULL;
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
options = GIMP_FLIP_OPTIONS (GIMP_TOOL (trans_tool)->tool_info->tool_options);
|
2003-05-31 07:52:24 +08:00
|
|
|
tr_options = GIMP_TRANSFORM_OPTIONS (options);
|
2004-04-15 07:37:34 +08:00
|
|
|
context = GIMP_CONTEXT (options);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
switch (options->flip_type)
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2003-05-31 07:52:24 +08:00
|
|
|
axis = ((gdouble) trans_tool->x1 +
|
|
|
|
(gdouble) (trans_tool->x2 - trans_tool->x1) / 2.0);
|
2003-05-12 23:56:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2003-05-31 07:52:24 +08:00
|
|
|
axis = ((gdouble) trans_tool->y1 +
|
|
|
|
(gdouble) (trans_tool->y2 - trans_tool->y1) / 2.0);
|
2003-05-12 23:56:36 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_item_get_linked (active_item))
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_linked_flip (active_item, context, options->flip_type, axis,
|
|
|
|
FALSE);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2004-12-06 22:37:00 +08:00
|
|
|
if (GIMP_IS_LAYER (active_item) &&
|
|
|
|
gimp_layer_get_mask (GIMP_LAYER (active_item)) &&
|
|
|
|
mask_empty)
|
|
|
|
{
|
|
|
|
GimpLayerMask *mask = gimp_layer_get_mask (GIMP_LAYER (active_item));
|
|
|
|
|
|
|
|
gimp_item_flip (GIMP_ITEM (mask), context,
|
|
|
|
options->flip_type, axis, FALSE);
|
|
|
|
}
|
|
|
|
|
2003-05-31 07:52:24 +08:00
|
|
|
switch (tr_options->type)
|
|
|
|
{
|
|
|
|
case GIMP_TRANSFORM_TYPE_LAYER:
|
|
|
|
case GIMP_TRANSFORM_TYPE_SELECTION:
|
2005-03-22 06:47:06 +08:00
|
|
|
if (trans_tool->original)
|
|
|
|
ret = gimp_drawable_transform_tiles_flip (GIMP_DRAWABLE (active_item),
|
|
|
|
context,
|
|
|
|
trans_tool->original,
|
|
|
|
options->flip_type, axis,
|
|
|
|
FALSE);
|
2003-05-31 07:52:24 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TRANSFORM_TYPE_PATH:
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_flip (active_item, context, options->flip_type, axis, FALSE);
|
2003-05-31 07:52:24 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|