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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://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"
|
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
|
|
|
|
|
|
|
|
2003-05-13 21:57:11 +08:00
|
|
|
/* public functions */
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
gboolean
|
|
|
|
gimp_item_linked_is_locked (const GimpItem *item)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
|
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
|
|
|
|
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
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
|
|
|
{
|
|
|
|
GimpItem *item = l->data;
|
|
|
|
|
2012-11-12 00:17:47 +08:00
|
|
|
/* temporarily set the item to not being linked, or we will
|
|
|
|
* run into a recursion because gimp_item_is_position_locked()
|
|
|
|
* call this function if the item is linked
|
|
|
|
*/
|
|
|
|
gimp_item_set_linked (item, FALSE, FALSE);
|
|
|
|
|
2012-11-09 18:17:25 +08:00
|
|
|
if (gimp_item_is_position_locked (item))
|
2012-11-12 00:17:47 +08:00
|
|
|
locked = TRUE;
|
|
|
|
|
|
|
|
gimp_item_set_linked (item, TRUE, FALSE);
|
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)
|
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
GList *list;
|
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
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2009-08-25 21:55:30 +08:00
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_translate (gimp_item_get_image (item), list,
|
|
|
|
offset_x, offset_y, push_undo);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
g_list_free (list);
|
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
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
GList *list;
|
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
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2009-08-25 21:55:30 +08:00
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_flip (gimp_item_get_image (item), list, context,
|
|
|
|
flip_type, axis, clip_result);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
g_list_free (list);
|
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)
|
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
GList *list;
|
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
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_LAYERS |
|
|
|
|
GIMP_ITEM_TYPE_VECTORS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2009-08-25 21:55:30 +08:00
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_rotate (gimp_item_get_image (item), list, context,
|
|
|
|
rotate_type, center_x, center_y, clip_result);
|
2003-05-20 23:26:38 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
g_list_free (list);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_CHANNELS,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2009-08-25 21:55:30 +08:00
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_rotate (gimp_item_get_image (item), list, context,
|
|
|
|
rotate_type, center_x, center_y, TRUE);
|
2003-05-21 02:13:07 +08:00
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
g_list_free (list);
|
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
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
GList *list;
|
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
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
list = gimp_image_item_list_get_list (gimp_item_get_image (item), item,
|
|
|
|
GIMP_ITEM_TYPE_ALL,
|
|
|
|
GIMP_ITEM_SET_LINKED);
|
2003-05-13 21:57:11 +08:00
|
|
|
|
2009-08-25 21:55:30 +08:00
|
|
|
list = gimp_image_item_list_filter (item, list, TRUE, FALSE);
|
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
gimp_image_item_list_transform (gimp_item_get_image (item), list, context,
|
|
|
|
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
|
|
|
|
2006-05-21 19:32:41 +08:00
|
|
|
g_list_free (list);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|