2003-05-12 15:56:36 +00: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
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
2004-04-14 23:37:34 +00:00
|
|
|
#include "gimpcontext.h"
|
2003-05-12 15:56:36 +00:00
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpitem.h"
|
|
|
|
#include "gimpitem-linked.h"
|
|
|
|
#include "gimplist.h"
|
2004-08-10 18:47:21 +00:00
|
|
|
#include "gimpprogress.h"
|
2003-05-12 15:56:36 +00:00
|
|
|
|
|
|
|
|
2003-05-13 13:57:11 +00:00
|
|
|
/* public functions */
|
|
|
|
|
2003-05-12 15:56:36 +00:00
|
|
|
void
|
|
|
|
gimp_item_linked_translate (GimpItem *item,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo)
|
|
|
|
{
|
2004-11-16 13:41:55 +00:00
|
|
|
GList *linked_list;
|
|
|
|
GList *list;
|
2003-05-12 15:56:36 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2003-05-13 13:57:11 +00:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2004-11-16 13:52:04 +00:00
|
|
|
linked_list = gimp_item_linked_get_list (item, GIMP_ITEM_LINKED_ALL);
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2003-05-13 13:57:11 +00:00
|
|
|
for (list = linked_list; list; list = g_list_next (list))
|
|
|
|
gimp_item_translate (GIMP_ITEM (list->data),
|
|
|
|
offset_x, offset_y, push_undo);
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2003-05-13 13:57:11 +00:00
|
|
|
g_list_free (linked_list);
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_item_linked_flip (GimpItem *item,
|
2004-04-14 23:37:34 +00:00
|
|
|
GimpContext *context,
|
2003-05-12 15:56:36 +00:00
|
|
|
GimpOrientationType flip_type,
|
2003-05-13 13:57:11 +00:00
|
|
|
gdouble axis,
|
|
|
|
gboolean clip_result)
|
2003-05-12 15:56:36 +00:00
|
|
|
{
|
2004-11-16 13:41:55 +00:00
|
|
|
GList *linked_list;
|
|
|
|
GList *list;
|
2003-05-12 15:56:36 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-14 23:37:34 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-13 13:57:11 +00:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2004-11-16 13:52:04 +00:00
|
|
|
linked_list = gimp_item_linked_get_list (item, GIMP_ITEM_LINKED_ALL);
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2003-05-13 13:57:11 +00:00
|
|
|
for (list = linked_list; list; list = g_list_next (list))
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_flip (GIMP_ITEM (list->data), context,
|
2003-05-13 13:57:11 +00:00
|
|
|
flip_type, axis, clip_result);
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2003-05-13 13:57:11 +00:00
|
|
|
g_list_free (linked_list);
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 15:26:38 +00:00
|
|
|
void
|
|
|
|
gimp_item_linked_rotate (GimpItem *item,
|
2004-04-14 23:37:34 +00:00
|
|
|
GimpContext *context,
|
2003-05-20 15:26:38 +00:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result)
|
|
|
|
{
|
2004-11-16 13:41:55 +00:00
|
|
|
GList *linked_list;
|
|
|
|
GList *list;
|
2003-05-20 15:26:38 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-14 23:37:34 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-20 15:26:38 +00:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2003-05-20 15:26:38 +00:00
|
|
|
|
2004-11-16 13:52:04 +00:00
|
|
|
linked_list = gimp_item_linked_get_list (item,
|
2003-05-20 18:13:07 +00:00
|
|
|
GIMP_ITEM_LINKED_LAYERS |
|
|
|
|
GIMP_ITEM_LINKED_VECTORS);
|
2003-05-20 15:26:38 +00:00
|
|
|
|
|
|
|
for (list = linked_list; list; list = g_list_next (list))
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_rotate (GIMP_ITEM (list->data), context,
|
2003-05-20 15:26:38 +00:00
|
|
|
rotate_type, center_x, center_y, clip_result);
|
|
|
|
|
|
|
|
g_list_free (linked_list);
|
2003-05-20 18:13:07 +00:00
|
|
|
|
2004-11-16 13:52:04 +00:00
|
|
|
linked_list = gimp_item_linked_get_list (item, GIMP_ITEM_LINKED_CHANNELS);
|
2003-05-20 18:13:07 +00:00
|
|
|
|
|
|
|
for (list = linked_list; list; list = g_list_next (list))
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_rotate (GIMP_ITEM (list->data), context,
|
2003-05-20 18:13:07 +00:00
|
|
|
rotate_type, center_x, center_y, TRUE);
|
|
|
|
|
|
|
|
g_list_free (linked_list);
|
2003-05-20 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2003-05-12 15:56:36 +00:00
|
|
|
void
|
|
|
|
gimp_item_linked_transform (GimpItem *item,
|
2004-04-14 23:37:34 +00:00
|
|
|
GimpContext *context,
|
2003-07-07 13:50:48 +00:00
|
|
|
const GimpMatrix3 *matrix,
|
2003-05-12 15:56:36 +00:00
|
|
|
GimpTransformDirection direction,
|
|
|
|
GimpInterpolationType interpolation_type,
|
2004-03-13 17:45:58 +00:00
|
|
|
gboolean supersample,
|
|
|
|
gint recursion_level,
|
2003-05-12 15:56:36 +00:00
|
|
|
gboolean clip_result,
|
2004-08-10 18:47:21 +00:00
|
|
|
GimpProgress *progress)
|
2003-05-12 15:56:36 +00:00
|
|
|
{
|
2004-11-16 13:41:55 +00:00
|
|
|
GList *linked_list;
|
|
|
|
GList *list;
|
2003-05-12 15:56:36 +00:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_ITEM (item));
|
2004-04-14 23:37:34 +00:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2003-05-13 13:57:11 +00:00
|
|
|
g_return_if_fail (gimp_item_get_linked (item) == TRUE);
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_if_fail (gimp_item_is_attached (item));
|
2004-08-10 18:47:21 +00:00
|
|
|
g_return_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress));
|
2003-05-12 15:56:36 +00:00
|
|
|
|
2004-11-16 13:52:04 +00:00
|
|
|
linked_list = gimp_item_linked_get_list (item, GIMP_ITEM_LINKED_ALL);
|
2003-05-13 13:57:11 +00:00
|
|
|
|
|
|
|
for (list = linked_list; list; list = g_list_next (list))
|
2004-04-14 23:37:34 +00:00
|
|
|
gimp_item_transform (GIMP_ITEM (list->data), context,
|
2003-05-13 13:57:11 +00:00
|
|
|
matrix, direction,
|
2004-03-13 17:45:58 +00:00
|
|
|
interpolation_type,
|
|
|
|
supersample, recursion_level,
|
2004-08-10 18:47:21 +00:00
|
|
|
clip_result, progress);
|
2003-05-13 13:57:11 +00:00
|
|
|
|
|
|
|
g_list_free (linked_list);
|
|
|
|
}
|
|
|
|
|
2003-09-11 18:02:39 +00:00
|
|
|
/**
|
|
|
|
* gimp_item_linked_get_list:
|
2004-11-16 13:52:04 +00:00
|
|
|
* @item: A linked @item.
|
|
|
|
* @which: Which items to return.
|
2004-04-14 23:37:34 +00:00
|
|
|
*
|
2003-09-11 18:02:39 +00:00
|
|
|
* This function returns a #GList og #GimpItem's for which the
|
2004-04-14 23:37:34 +00:00
|
|
|
* "linked" property is #TRUE. Note that the passed in @item
|
2003-09-11 18:02:39 +00:00
|
|
|
* must be linked too.
|
2004-04-14 23:37:34 +00:00
|
|
|
*
|
2003-09-11 18:02:39 +00:00
|
|
|
* Return value: The list of linked items, excluding the passed @item.
|
|
|
|
**/
|
|
|
|
GList *
|
2004-11-16 13:52:04 +00:00
|
|
|
gimp_item_linked_get_list (GimpItem *item,
|
2003-05-20 18:13:07 +00:00
|
|
|
GimpItemLinkedMask which)
|
2003-05-13 13:57:11 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
GimpImage *image;
|
2004-11-16 13:52:04 +00:00
|
|
|
GimpItem *linked_item;
|
|
|
|
GList *list;
|
|
|
|
GList *linked_list = NULL;
|
2003-05-13 13:57:11 +00:00
|
|
|
|
2003-09-11 18:02:39 +00:00
|
|
|
g_return_val_if_fail (GIMP_IS_ITEM (item), NULL);
|
2004-11-16 13:52:04 +00:00
|
|
|
g_return_val_if_fail (gimp_item_get_linked (item), NULL);
|
2004-11-16 13:41:55 +00:00
|
|
|
g_return_val_if_fail (gimp_item_is_attached (item), NULL);
|
2003-09-11 18:02:39 +00:00
|
|
|
|
2006-03-28 17:08:36 +00:00
|
|
|
image = gimp_item_get_image (item);
|
2004-11-16 13:52:04 +00:00
|
|
|
|
2003-05-20 18:13:07 +00:00
|
|
|
if (which & GIMP_ITEM_LINKED_LAYERS)
|
2003-05-12 15:56:36 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
for (list = GIMP_LIST (image->layers)->list;
|
2003-05-20 18:13:07 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2005-05-28 00:21:58 +00:00
|
|
|
linked_item = list->data;
|
2003-05-20 18:13:07 +00:00
|
|
|
|
|
|
|
if (linked_item != item && gimp_item_get_linked (linked_item))
|
|
|
|
linked_list = g_list_prepend (linked_list, linked_item);
|
|
|
|
}
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 18:13:07 +00:00
|
|
|
if (which & GIMP_ITEM_LINKED_CHANNELS)
|
2003-05-12 15:56:36 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
for (list = GIMP_LIST (image->channels)->list;
|
2003-05-20 18:13:07 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2005-05-28 00:21:58 +00:00
|
|
|
linked_item = list->data;
|
2003-05-20 18:13:07 +00:00
|
|
|
|
|
|
|
if (linked_item != item && gimp_item_get_linked (linked_item))
|
|
|
|
linked_list = g_list_prepend (linked_list, linked_item);
|
|
|
|
}
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|
|
|
|
|
2003-05-20 18:13:07 +00:00
|
|
|
if (which & GIMP_ITEM_LINKED_VECTORS)
|
2003-05-12 15:56:36 +00:00
|
|
|
{
|
2006-03-28 17:08:36 +00:00
|
|
|
for (list = GIMP_LIST (image->vectors)->list;
|
2003-05-20 18:13:07 +00:00
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
2005-05-28 00:21:58 +00:00
|
|
|
linked_item = list->data;
|
2003-05-20 18:13:07 +00:00
|
|
|
|
|
|
|
if (linked_item != item && gimp_item_get_linked (linked_item))
|
|
|
|
linked_list = g_list_prepend (linked_list, linked_item);
|
|
|
|
}
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|
2003-05-13 13:57:11 +00:00
|
|
|
|
|
|
|
return g_list_reverse (linked_list);
|
2003-05-12 15:56:36 +00:00
|
|
|
}
|