2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-05-12 23:56:36 +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
|
2003-05-12 23:56:36 +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
|
2003-05-12 23:56:36 +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/>.
|
2003-05-12 23:56:36 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-10-15 07:58:39 +08:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.h>
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimpcontext.h"
|
2003-05-12 23:56:36 +08:00
|
|
|
#include "gimpimage.h"
|
2006-05-21 19:32:41 +08:00
|
|
|
#include "gimpimage-item-list.h"
|
2015-06-25 18:25:41 +08:00
|
|
|
#include "gimpimage-undo.h"
|
2003-05-12 23:56:36 +08:00
|
|
|
#include "gimpitem.h"
|
|
|
|
#include "gimpitem-linked.h"
|
|
|
|
#include "gimplist.h"
|
2004-08-11 02:47:21 +08:00
|
|
|
#include "gimpprogress.h"
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2003-05-13 21:57:11 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
gboolean
|
2016-05-20 05:51:44 +08:00
|
|
|
gimp_item_linked_is_locked (GimpItem *item)
|
2012-11-09 18:17:25 +08:00
|
|
|
{
|
|
|
|
GList *list;
|
|
|
|
GList *l;
|
|
|
|
gboolean locked = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM (item), FALSE);
|
|
|
|
g_return_val_if_fail (gimp_item_get_linked (item) == TRUE, FALSE);
|
|
|
|
g_return_val_if_fail (gimp_item_is_attached (item), FALSE);
|
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item),
|
2012-11-09 18:17:25 +08:00
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
list = gimp_image_item_list_filter (list);
|
2012-11-09 18:17:25 +08:00
|
|
|
|
2012-11-12 00:17:47 +08:00
|
|
|
for (l = list; l && ! locked; l = g_list_next (l))
|
2012-11-09 18:17:25 +08:00
|
|
|
{
|
2018-05-11 23:56:37 +08:00
|
|
|
/* We must not use gimp_item_is_position_locked(), especially
|
|
|
|
* since a child implementation may call the current function and
|
|
|
|
* end up in infinite loop.
|
|
|
|
* We are only interested in the value of `lock_position` flag.
|
2012-11-12 00:17:47 +08:00
|
|
|
*/
|
2018-05-11 23:56:37 +08:00
|
|
|
if (gimp_item_get_lock_position (l->data))
|
2012-11-12 00:17:47 +08:00
|
|
|
locked = TRUE;
|
2012-11-09 18:17:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
g_list_free (list);
|
|
|
|
|
|
|
|
return locked;
|
|
|
|
}
|
|
|
|
|
2003-05-12 23:56:36 +08:00
|
|
|
void
|
|
|
|
gimp_item_linked_translate (GimpItem *item,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
2015-06-26 17:56:59 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GList *items;
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2003-05-13 21:57:11 +08:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-26 17:56:59 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_get_list (image,
|
2015-06-26 17:56:59 +08:00
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2009-08-25 21:55:30 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_filter (items);
|
2015-06-26 17:56:59 +08:00
|
|
|
|
|
|
|
gimp_image_item_list_translate (gimp_item_get_image (item), items,
|
2006-05-21 19:32:41 +08:00
|
|
|
offset_x, offset_y, push_undo);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-26 17:56:59 +08:00
|
|
|
g_list_free (items);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_item_linked_flip (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-12 23:56:36 +08:00
|
|
|
GimpOrientationType flip_type,
|
2003-05-13 21:57:11 +08:00
|
|
|
gdouble axis,
|
|
|
|
gboolean clip_result)
|
2003-05-12 23:56:36 +08:00
|
|
|
{
|
2015-06-25 18:25:41 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GList *items;
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-13 21:57:11 +08:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_get_list (image,
|
2015-06-25 18:25:41 +08:00
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_filter (items);
|
2009-08-25 21:55:30 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
gimp_image_item_list_flip (image, items, context,
|
2006-05-21 19:32:41 +08:00
|
|
|
flip_type, axis, clip_result);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
g_list_free (items);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|
|
|
|
|
2003-05-20 23:26:38 +08:00
|
|
|
void
|
|
|
|
gimp_item_linked_rotate (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 23:26:38 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result)
|
|
|
|
{
|
2015-06-25 18:25:41 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GList *items;
|
|
|
|
GList *channels;
|
2003-05-20 23:26:38 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-20 23:26:38 +08:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_get_list (image,
|
2015-06-25 18:25:41 +08:00
|
|
|
GIMP_ITEM_TYPE_LAYERS |
|
|
|
|
GIMP_ITEM_TYPE_VECTORS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_filter (items);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
channels = gimp_image_item_list_get_list (image,
|
2015-06-25 18:25:41 +08:00
|
|
|
GIMP_ITEM_TYPE_CHANNELS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2015-06-29 05:48:47 +08:00
|
|
|
channels = gimp_image_item_list_filter (channels);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
if (items && channels)
|
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM,
|
|
|
|
C_("undo-type", "Rotate Items"));
|
2009-08-25 21:55:30 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
gimp_image_item_list_rotate (image, items, context,
|
|
|
|
rotate_type, center_x, center_y, clip_result);
|
|
|
|
gimp_image_item_list_rotate (image, channels, context,
|
2006-05-21 19:32:41 +08:00
|
|
|
rotate_type, center_x, center_y, TRUE);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
if (items && channels)
|
|
|
|
gimp_image_undo_group_end (image);
|
|
|
|
|
|
|
|
g_list_free (items);
|
|
|
|
g_list_free (channels);
|
2003-05-20 23:26:38 +08:00
|
|
|
}
|
|
|
|
|
2003-05-12 23:56:36 +08:00
|
|
|
void
|
|
|
|
gimp_item_linked_transform (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-07-07 21:50:48 +08:00
|
|
|
const GimpMatrix3 *matrix,
|
2003-05-12 23:56:36 +08:00
|
|
|
GimpTransformDirection direction,
|
|
|
|
GimpInterpolationType interpolation_type,
|
2006-12-25 00:48:08 +08:00
|
|
|
GimpTransformResize clip_result,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-12 23:56:36 +08:00
|
|
|
{
|
2015-06-25 18:25:41 +08:00
|
|
|
GimpImage *image;
|
|
|
|
GList *items;
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-13 21:57:11 +08:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2004-08-11 02:47:21 +08:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_get_list (image,
|
2015-06-25 18:25:41 +08:00
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2015-06-29 05:48:47 +08:00
|
|
|
items = gimp_image_item_list_filter (items);
|
2009-08-25 21:55:30 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
gimp_image_item_list_transform (image, items, context,
|
2006-05-21 19:32:41 +08:00
|
|
|
matrix, direction,
|
2013-05-31 07:15:32 +08:00
|
|
|
interpolation_type,
|
2006-05-21 19:32:41 +08:00
|
|
|
clip_result, progress);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2015-06-25 18:25:41 +08:00
|
|
|
g_list_free (items);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|