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
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (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
|
2018-07-12 05:27:07 +08:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
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"
|
|
|
|
|
2008-05-23 22:09:55 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.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
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
#include "config/gimpdisplayconfig.h"
|
|
|
|
|
2001-11-20 02:23:43 +08:00
|
|
|
#include "core/gimpdrawable-transform.h"
|
2017-06-12 02:48:04 +08:00
|
|
|
#include "core/gimpguide.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2019-08-11 03:57:55 +08:00
|
|
|
#include "core/gimpimage-flip.h"
|
2017-06-22 15:43:50 +08:00
|
|
|
#include "core/gimpimage-pick-item.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"
|
2019-08-11 03:57:55 +08:00
|
|
|
#include "core/gimpprogress.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2011-10-07 03:59:07 +08:00
|
|
|
#include "widgets/gimpwidgets-utils.h"
|
2002-12-20 00:33:29 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
#include "display/gimpcanvasitem.h"
|
2001-09-26 07:23:09 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2017-06-12 02:48:04 +08:00
|
|
|
#include "display/gimpdisplayshell.h"
|
|
|
|
#include "display/gimpdisplayshell-appearance.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 */
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
static void gimp_flip_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_flip_tool_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_flip_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
|
|
|
|
static void gimp_flip_tool_draw (GimpDrawTool *draw_tool);
|
|
|
|
|
|
|
|
static gchar * gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool);
|
|
|
|
static GeglBuffer * gimp_flip_tool_transform (GimpTransformTool *tr_tool,
|
2020-05-26 22:15:15 +08:00
|
|
|
GList *objects,
|
2018-06-10 04:25:03 +08:00
|
|
|
GeglBuffer *orig_buffer,
|
|
|
|
gint orig_offset_x,
|
|
|
|
gint orig_offset_y,
|
|
|
|
GimpColorProfile **buffer_profile,
|
|
|
|
gint *new_offset_x,
|
|
|
|
gint *new_offset_y);
|
2017-06-12 02:48:04 +08:00
|
|
|
|
|
|
|
static GimpOrientationType gimp_flip_tool_get_flip_type (GimpFlipTool *flip);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpFlipTool, gimp_flip_tool, GIMP_TYPE_TRANSFORM_TOOL)
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
#define parent_class gimp_flip_tool_parent_class
|
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,
|
2015-09-09 03:18:49 +08:00
|
|
|
GIMP_CONTEXT_PROP_MASK_BACKGROUND,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-flip-tool",
|
2002-11-01 07:06:09 +08:00
|
|
|
_("Flip"),
|
2006-10-17 17:38:51 +08:00
|
|
|
_("Flip Tool: "
|
|
|
|
"Reverse the layer, selection or path horizontally or vertically"),
|
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,
|
2017-03-05 23:01:59 +08:00
|
|
|
GIMP_ICON_TOOL_FLIP,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-04-01 01:08:55 +08:00
|
|
|
static void
|
|
|
|
gimp_flip_tool_class_init (GimpFlipToolClass *klass)
|
|
|
|
{
|
2017-06-12 02:48:04 +08:00
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_CLASS (klass);
|
2017-06-12 02:48:04 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tool_class->button_press = gimp_flip_tool_button_press;
|
|
|
|
tool_class->modifier_key = gimp_flip_tool_modifier_key;
|
|
|
|
tool_class->oper_update = gimp_flip_tool_oper_update;
|
|
|
|
tool_class->cursor_update = gimp_flip_tool_cursor_update;
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
draw_tool_class->draw = gimp_flip_tool_draw;
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
tr_class->get_undo_desc = gimp_flip_tool_get_undo_desc;
|
|
|
|
tr_class->transform = gimp_flip_tool_transform;
|
2017-02-12 23:06:34 +08:00
|
|
|
|
2019-02-04 23:21:31 +08:00
|
|
|
tr_class->undo_desc = C_("undo-type", "Flip");
|
2018-06-10 04:25:03 +08:00
|
|
|
tr_class->progress_text = _("Flipping");
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_flip_tool_init (GimpFlipTool *flip_tool)
|
|
|
|
{
|
2006-06-20 16:22:39 +08:00
|
|
|
GimpTool *tool = GIMP_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);
|
2008-08-21 00:22:09 +08:00
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
GIMP_CURSOR_PRECISION_PIXEL_CENTER);
|
2006-06-02 04:30:52 +08:00
|
|
|
gimp_tool_control_set_cursor (tool->control, GIMP_CURSOR_MOUSE);
|
|
|
|
gimp_tool_control_set_toggle_cursor (tool->control, GIMP_CURSOR_MOUSE);
|
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);
|
2017-06-12 02:48:04 +08:00
|
|
|
|
|
|
|
flip_tool->guide = NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
static void
|
|
|
|
gimp_flip_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonPressType press_type,
|
|
|
|
GimpDisplay *display)
|
2017-09-20 19:41:46 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
|
2017-09-20 19:41:46 +08:00
|
|
|
|
2019-08-11 03:57:55 +08:00
|
|
|
tool->display = display;
|
|
|
|
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_transform_tool_transform (tr_tool, display);
|
2019-08-11 03:57:55 +08:00
|
|
|
|
|
|
|
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
|
2017-09-20 19:41:46 +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,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
2006-09-06 02:25:31 +08:00
|
|
|
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tool);
|
2001-11-20 02:23:43 +08:00
|
|
|
|
2011-10-07 03:59:07 +08:00
|
|
|
if (key == gimp_get_toggle_behavior_mask ())
|
2001-11-09 03:14:51 +08:00
|
|
|
{
|
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
|
2017-06-12 02:48:04 +08:00
|
|
|
gimp_flip_tool_oper_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
gboolean proximity,
|
|
|
|
GimpDisplay *display)
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2017-06-12 02:48:04 +08:00
|
|
|
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
|
|
|
|
GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
|
|
|
|
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tool);
|
|
|
|
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
|
|
|
GimpImage *image = gimp_display_get_image (display);
|
|
|
|
GimpGuide *guide = NULL;
|
|
|
|
|
|
|
|
if (gimp_display_shell_get_show_guides (shell) &&
|
|
|
|
proximity)
|
|
|
|
{
|
|
|
|
gint snap_distance = display->config->snap_distance;
|
|
|
|
|
2017-06-22 15:43:50 +08:00
|
|
|
guide = gimp_image_pick_guide (image, coords->x, coords->y,
|
2017-06-12 02:48:04 +08:00
|
|
|
FUNSCALEX (shell, snap_distance),
|
|
|
|
FUNSCALEY (shell, snap_distance));
|
|
|
|
}
|
2001-11-01 05:20:09 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
if (flip->guide != guide ||
|
|
|
|
(guide && ! gimp_draw_tool_is_active (draw_tool)))
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2017-06-12 02:48:04 +08:00
|
|
|
gimp_draw_tool_pause (draw_tool);
|
|
|
|
|
|
|
|
if (gimp_draw_tool_is_active (draw_tool) &&
|
|
|
|
draw_tool->display != display)
|
|
|
|
gimp_draw_tool_stop (draw_tool);
|
|
|
|
|
|
|
|
flip->guide = guide;
|
|
|
|
|
|
|
|
if (! gimp_draw_tool_is_active (draw_tool))
|
|
|
|
gimp_draw_tool_start (draw_tool, display);
|
|
|
|
|
|
|
|
gimp_draw_tool_resume (draw_tool);
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
gtk_widget_set_sensitive (options->direction_frame, guide == NULL);
|
|
|
|
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->oper_update (tool,
|
|
|
|
coords, state, proximity,
|
|
|
|
display);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_flip_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool);
|
|
|
|
GimpFlipTool *flip = GIMP_FLIP_TOOL (tool);
|
2020-05-26 22:15:15 +08:00
|
|
|
GList *selected_objects;
|
2018-06-10 04:25:03 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
selected_objects = gimp_transform_tool_check_selected_objects (tr_tool, display, NULL);
|
|
|
|
|
|
|
|
if (! selected_objects)
|
2018-06-10 04:25:03 +08:00
|
|
|
{
|
|
|
|
gimp_tool_set_cursor (tool, display,
|
|
|
|
gimp_tool_control_get_cursor (tool->control),
|
|
|
|
gimp_tool_control_get_tool_cursor (tool->control),
|
|
|
|
GIMP_CURSOR_MODIFIER_BAD);
|
|
|
|
return;
|
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
g_list_free (selected_objects);
|
2002-02-05 01:43:01 +08:00
|
|
|
|
2005-11-24 03:14:05 +08:00
|
|
|
gimp_tool_control_set_toggled (tool->control,
|
2017-06-12 02:48:04 +08:00
|
|
|
gimp_flip_tool_get_flip_type (flip) ==
|
2006-06-02 04:30:52 +08:00
|
|
|
GIMP_ORIENTATION_VERTICAL);
|
2001-04-01 01:08:55 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
static void
|
|
|
|
gimp_flip_tool_draw (GimpDrawTool *draw_tool)
|
|
|
|
{
|
|
|
|
GimpFlipTool *flip = GIMP_FLIP_TOOL (draw_tool);
|
|
|
|
|
|
|
|
if (flip->guide)
|
|
|
|
{
|
|
|
|
GimpCanvasItem *item;
|
|
|
|
GimpGuideStyle style;
|
|
|
|
|
|
|
|
style = gimp_guide_get_style (flip->guide);
|
|
|
|
|
|
|
|
item = gimp_draw_tool_add_guide (draw_tool,
|
|
|
|
gimp_guide_get_orientation (flip->guide),
|
|
|
|
gimp_guide_get_position (flip->guide),
|
|
|
|
style);
|
|
|
|
gimp_canvas_item_set_highlight (item, TRUE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-27 14:37:30 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_flip_tool_get_undo_desc (GimpTransformTool *tr_tool)
|
|
|
|
{
|
2017-06-12 02:48:04 +08:00
|
|
|
GimpFlipTool *flip = GIMP_FLIP_TOOL (tr_tool);
|
2011-08-27 14:37:30 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
switch (gimp_flip_tool_get_flip_type (flip))
|
2011-08-27 14:37:30 +08:00
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
|
|
|
return g_strdup (C_("undo-type", "Flip horizontally"));
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
|
|
|
return g_strdup (C_("undo-type", "Flip vertically"));
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* probably this is not actually reached today, but
|
|
|
|
* could be if someone defined FLIP_DIAGONAL, say...
|
|
|
|
*/
|
2019-02-04 23:21:31 +08:00
|
|
|
return GIMP_TRANSFORM_TOOL_CLASS (parent_class)->get_undo_desc (tr_tool);
|
2011-08-27 14:37:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
static GeglBuffer *
|
2018-06-10 04:25:03 +08:00
|
|
|
gimp_flip_tool_transform (GimpTransformTool *tr_tool,
|
2020-05-26 22:15:15 +08:00
|
|
|
GList *objects,
|
2012-03-21 21:30:47 +08:00
|
|
|
GeglBuffer *orig_buffer,
|
2011-03-27 01:45:58 +08:00
|
|
|
gint orig_offset_x,
|
|
|
|
gint orig_offset_y,
|
2016-05-09 00:35:40 +08:00
|
|
|
GimpColorProfile **buffer_profile,
|
2011-03-26 15:30:15 +08:00
|
|
|
gint *new_offset_x,
|
|
|
|
gint *new_offset_y)
|
2001-04-01 01:08:55 +08:00
|
|
|
{
|
2018-06-10 04:25:03 +08:00
|
|
|
GimpFlipTool *flip = GIMP_FLIP_TOOL (tr_tool);
|
|
|
|
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (tr_tool);
|
|
|
|
GimpTransformOptions *tr_options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool);
|
2017-06-12 02:49:23 +08:00
|
|
|
GimpContext *context = GIMP_CONTEXT (options);
|
|
|
|
GimpOrientationType flip_type = GIMP_ORIENTATION_UNKNOWN;
|
|
|
|
gdouble axis = 0.0;
|
|
|
|
gboolean clip_result = FALSE;
|
|
|
|
GeglBuffer *ret = NULL;
|
2017-06-12 02:48:04 +08:00
|
|
|
|
|
|
|
flip_type = gimp_flip_tool_get_flip_type (flip);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
if (flip->guide)
|
2003-05-12 23:56:36 +08:00
|
|
|
{
|
2017-06-12 02:48:04 +08:00
|
|
|
axis = gimp_guide_get_position (flip->guide);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (flip_type)
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
2018-06-10 04:25:03 +08:00
|
|
|
axis = ((gdouble) tr_tool->x1 +
|
|
|
|
(gdouble) (tr_tool->x2 - tr_tool->x1) / 2.0);
|
2017-06-12 02:48:04 +08:00
|
|
|
break;
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
2018-06-10 04:25:03 +08:00
|
|
|
axis = ((gdouble) tr_tool->y1 +
|
|
|
|
(gdouble) (tr_tool->y2 - tr_tool->y1) / 2.0);
|
2017-06-12 02:48:04 +08:00
|
|
|
break;
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2017-06-12 02:48:04 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|
|
|
|
|
2017-06-12 02:49:23 +08:00
|
|
|
switch (tr_options->clip)
|
|
|
|
{
|
|
|
|
case GIMP_TRANSFORM_RESIZE_ADJUST:
|
|
|
|
clip_result = FALSE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_TRANSFORM_RESIZE_CLIP:
|
|
|
|
clip_result = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
}
|
|
|
|
|
2012-03-21 21:30:47 +08:00
|
|
|
if (orig_buffer)
|
2003-05-31 07:52:24 +08:00
|
|
|
{
|
2011-04-04 14:19:12 +08:00
|
|
|
/* this happens when transforming a selection cut out of a
|
app, pdb: use gimp_item_get_clip() everywhere
Remove the special clipping-mode handling for channels throughout
the transform (and drawable-filter) code, and rather use
gimp_item_get_clip(), added in the previous commit, instead. As
mentioned in the previous commit, we only modify the clipping mode
in top-level code, while having lower-level code use the clipping
mode as-is. This not only hides the actual clipping-mode logic
from the transform code, but, in particular, allows code performing
transformation internally to use arbitrary clipping modes.
Also, this commit fixes a bunch of PDB bugs all over the place :)
2019-08-10 02:51:27 +08:00
|
|
|
* normal drawable
|
2011-03-18 04:52:43 +08:00
|
|
|
*/
|
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_DRAWABLE (objects->data), NULL);
|
2019-08-11 03:57:55 +08:00
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
ret = gimp_drawable_transform_buffer_flip (GIMP_DRAWABLE (objects->data),
|
2012-03-21 21:30:47 +08:00
|
|
|
context,
|
|
|
|
orig_buffer,
|
|
|
|
orig_offset_x,
|
|
|
|
orig_offset_y,
|
2017-06-12 02:48:04 +08:00
|
|
|
flip_type, axis,
|
2017-06-12 02:49:23 +08:00
|
|
|
clip_result,
|
2016-05-09 00:35:40 +08:00
|
|
|
buffer_profile,
|
2012-03-21 21:30:47 +08:00
|
|
|
new_offset_x,
|
|
|
|
new_offset_y);
|
2011-03-18 04:52:43 +08:00
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
else if (g_list_length (objects) == 1 && GIMP_IS_IMAGE (objects->data))
|
2019-08-11 03:57:55 +08:00
|
|
|
{
|
|
|
|
/* this happens for images */
|
|
|
|
GimpTransformToolClass *tr_class = GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool);
|
|
|
|
GimpProgress *progress;
|
|
|
|
|
|
|
|
progress = gimp_progress_start (GIMP_PROGRESS (tr_tool), FALSE,
|
|
|
|
"%s", tr_class->progress_text);
|
|
|
|
|
2020-05-26 22:15:15 +08:00
|
|
|
gimp_image_flip_full (GIMP_IMAGE (objects->data), context,
|
2019-08-11 03:57:55 +08:00
|
|
|
flip_type, axis, clip_result,
|
|
|
|
progress);
|
|
|
|
|
|
|
|
if (progress)
|
|
|
|
gimp_progress_end (progress);
|
|
|
|
}
|
2020-05-26 22:15:15 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* this happens for entire drawables, paths and layer groups */
|
|
|
|
|
|
|
|
GList *iter;
|
|
|
|
|
|
|
|
for (iter = objects; iter; iter = iter->next)
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM (iter->data), NULL);
|
|
|
|
|
|
|
|
item = GIMP_ITEM (iter->data);
|
|
|
|
|
|
|
|
if (gimp_item_get_linked (item))
|
|
|
|
{
|
|
|
|
gimp_item_linked_flip (item, context,
|
|
|
|
flip_type, axis, clip_result);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
clip_result = gimp_item_get_clip (item, clip_result);
|
|
|
|
|
|
|
|
gimp_item_flip (item, context,
|
|
|
|
flip_type, axis, clip_result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-05-31 07:52:24 +08:00
|
|
|
|
|
|
|
return ret;
|
2001-04-01 01:08:55 +08:00
|
|
|
}
|
2017-06-12 02:48:04 +08:00
|
|
|
|
|
|
|
static GimpOrientationType
|
|
|
|
gimp_flip_tool_get_flip_type (GimpFlipTool *flip)
|
|
|
|
{
|
|
|
|
GimpFlipOptions *options = GIMP_FLIP_TOOL_GET_OPTIONS (flip);
|
|
|
|
|
|
|
|
if (flip->guide)
|
|
|
|
{
|
|
|
|
switch (gimp_guide_get_orientation (flip->guide))
|
|
|
|
{
|
|
|
|
case GIMP_ORIENTATION_HORIZONTAL:
|
|
|
|
return GIMP_ORIENTATION_VERTICAL;
|
|
|
|
|
|
|
|
case GIMP_ORIENTATION_VERTICAL:
|
|
|
|
return GIMP_ORIENTATION_HORIZONTAL;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return gimp_guide_get_orientation (flip->guide);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return options->flip_type;
|
|
|
|
}
|
|
|
|
}
|