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-14 21:52:16 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1998-09-24 09:19:57 +08:00
|
|
|
#include <stdlib.h>
|
2000-12-14 21:52:16 +08:00
|
|
|
#include <string.h>
|
2000-04-28 01:27:28 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
|
|
|
|
2006-08-29 22:46:32 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/boundary.h"
|
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
#include "base/tile.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimpcontext.h"
|
2001-11-01 05:18:57 +08:00
|
|
|
#include "gimpcontainer.h"
|
2005-02-19 00:16:24 +08:00
|
|
|
#include "gimpdrawable-convert.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimpdrawable-invert.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimpimage-undo-push.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimpimage-undo.h"
|
|
|
|
#include "gimpimage.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "gimplayer-floating-sel.h"
|
2004-04-15 07:37:34 +08:00
|
|
|
#include "gimplayer.h"
|
2001-01-29 00:44:22 +08:00
|
|
|
#include "gimplayermask.h"
|
2001-11-23 07:46:13 +08:00
|
|
|
#include "gimpmarshal.h"
|
2005-07-12 03:21:52 +08:00
|
|
|
#include "gimppickable.h"
|
2001-07-10 03:48:30 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
|
|
|
|
2001-03-05 04:06:48 +08:00
|
|
|
enum
|
|
|
|
{
|
2001-03-12 01:24:47 +08:00
|
|
|
OPACITY_CHANGED,
|
|
|
|
MODE_CHANGED,
|
2005-07-11 05:17:22 +08:00
|
|
|
LOCK_ALPHA_CHANGED,
|
2001-03-05 04:06:48 +08:00
|
|
|
MASK_CHANGED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2005-07-12 00:46:28 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_OPACITY,
|
|
|
|
PROP_MODE,
|
|
|
|
PROP_LOCK_ALPHA
|
|
|
|
};
|
|
|
|
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static void gimp_layer_pickable_iface_init (GimpPickableInterface *iface);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2005-07-12 00:46:28 +08:00
|
|
|
static void gimp_layer_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_layer_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void gimp_layer_dispose (GObject *object);
|
2003-02-11 21:52:47 +08:00
|
|
|
static void gimp_layer_finalize (GObject *object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
static void gimp_layer_name_changed (GimpObject *object);
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64 gimp_layer_get_memsize (GimpObject *object,
|
|
|
|
gint64 *gui_size);
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2003-02-11 21:52:47 +08:00
|
|
|
static void gimp_layer_invalidate_preview (GimpViewable *viewable);
|
2004-09-22 20:46:35 +08:00
|
|
|
static gchar * gimp_layer_get_description (GimpViewable *viewable,
|
|
|
|
gchar **tooltip);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2004-02-17 19:45:46 +08:00
|
|
|
static void gimp_layer_removed (GimpItem *item);
|
2004-01-27 00:18:16 +08:00
|
|
|
static gboolean gimp_layer_is_attached (GimpItem *item);
|
2003-02-11 21:52:47 +08:00
|
|
|
static GimpItem * gimp_layer_duplicate (GimpItem *item,
|
|
|
|
GType new_type,
|
|
|
|
gboolean add_alpha);
|
2005-01-14 02:17:24 +08:00
|
|
|
static void gimp_layer_convert (GimpItem *item,
|
|
|
|
GimpImage *dest_image);
|
2004-02-02 04:38:26 +08:00
|
|
|
static gboolean gimp_layer_rename (GimpItem *item,
|
2003-03-17 08:14:59 +08:00
|
|
|
const gchar *new_name,
|
|
|
|
const gchar *undo_desc);
|
2003-05-09 03:11:17 +08:00
|
|
|
static void gimp_layer_translate (GimpItem *item,
|
|
|
|
gint offset_x,
|
2003-05-09 21:05:37 +08:00
|
|
|
gint offset_y,
|
|
|
|
gboolean push_undo);
|
2003-05-07 19:09:00 +08:00
|
|
|
static void gimp_layer_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
2004-02-09 08:09:20 +08:00
|
|
|
GimpInterpolationType interp_type,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress);
|
2003-05-07 21:01:17 +08:00
|
|
|
static void gimp_layer_resize (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-07 21:01:17 +08:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
2003-05-12 23:56:36 +08:00
|
|
|
static void gimp_layer_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-20 18:36:29 +08:00
|
|
|
static void gimp_layer_rotate (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 18:36:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result);
|
2003-05-12 23:56:36 +08:00
|
|
|
static void gimp_layer_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,
|
2004-03-14 01:45:58 +08:00
|
|
|
gboolean supersample,
|
|
|
|
gint recursion_level,
|
2003-05-12 23:56:36 +08:00
|
|
|
gboolean clip_result,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress);
|
2003-10-06 22:40:12 +08:00
|
|
|
static void gimp_layer_invalidate_boundary (GimpDrawable *drawable);
|
|
|
|
static void gimp_layer_get_active_components (const GimpDrawable *drawable,
|
|
|
|
gboolean *active);
|
2004-03-13 21:56:09 +08:00
|
|
|
static void gimp_layer_set_tiles (GimpDrawable *drawable,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
TileManager *tiles,
|
2004-03-16 03:34:35 +08:00
|
|
|
GimpImageType type,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y);
|
2005-07-12 03:21:52 +08:00
|
|
|
static gint gimp_layer_get_opacity_at (GimpPickable *pickable,
|
|
|
|
gint x,
|
|
|
|
gint y);
|
2003-09-04 19:33:06 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
static void gimp_layer_transform_color (GimpImage *image,
|
2003-02-11 21:52:47 +08:00
|
|
|
PixelRegion *layerPR,
|
|
|
|
PixelRegion *bufPR,
|
2006-10-26 06:14:36 +08:00
|
|
|
GimpImageType dest_type,
|
2005-08-09 08:07:21 +08:00
|
|
|
GimpImageType src_type);
|
2000-12-17 06:02:10 +08:00
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void gimp_layer_layer_mask_update (GimpDrawable *layer_mask,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpLayer *layer);
|
|
|
|
|
2000-12-17 06:02:10 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpLayer, gimp_layer, GIMP_TYPE_DRAWABLE,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_PICKABLE,
|
2006-05-15 17:46:31 +08:00
|
|
|
gimp_layer_pickable_iface_init))
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
#define parent_class gimp_layer_parent_class
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2005-12-11 03:24:36 +08:00
|
|
|
static guint layer_signals[LAST_SIGNAL] = { 0 };
|
2001-01-10 08:36:54 +08:00
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
|
|
|
|
static void
|
2000-12-29 00:19:55 +08:00
|
|
|
gimp_layer_class_init (GimpLayerClass *klass)
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
2004-03-17 00:23:06 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
|
|
|
|
GimpViewableClass *viewable_class = GIMP_VIEWABLE_CLASS (klass);
|
|
|
|
GimpItemClass *item_class = GIMP_ITEM_CLASS (klass);
|
|
|
|
GimpDrawableClass *drawable_class = GIMP_DRAWABLE_CLASS (klass);
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
layer_signals[OPACITY_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("opacity-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, opacity_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
layer_signals[MODE_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("mode-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, mode_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
layer_signals[LOCK_ALPHA_CHANGED] =
|
|
|
|
g_signal_new ("lock-alpha-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, lock_alpha_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2001-03-05 04:06:48 +08:00
|
|
|
layer_signals[MASK_CHANGED] =
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_new ("mask-changed",
|
2006-04-12 20:49:29 +08:00
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GimpLayerClass, mask_changed),
|
|
|
|
NULL, NULL,
|
|
|
|
gimp_marshal_VOID__VOID,
|
|
|
|
G_TYPE_NONE, 0);
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2005-07-12 00:46:28 +08:00
|
|
|
object_class->set_property = gimp_layer_set_property;
|
|
|
|
object_class->get_property = gimp_layer_get_property;
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
object_class->dispose = gimp_layer_dispose;
|
2003-09-04 19:33:06 +08:00
|
|
|
object_class->finalize = gimp_layer_finalize;
|
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
gimp_object_class->name_changed = gimp_layer_name_changed;
|
2003-09-04 19:33:06 +08:00
|
|
|
gimp_object_class->get_memsize = gimp_layer_get_memsize;
|
|
|
|
|
|
|
|
viewable_class->default_stock_id = "gimp-layer";
|
|
|
|
viewable_class->invalidate_preview = gimp_layer_invalidate_preview;
|
2004-09-22 20:46:35 +08:00
|
|
|
viewable_class->get_description = gimp_layer_get_description;
|
2003-09-04 19:33:06 +08:00
|
|
|
|
2004-02-17 19:45:46 +08:00
|
|
|
item_class->removed = gimp_layer_removed;
|
2004-01-27 00:18:16 +08:00
|
|
|
item_class->is_attached = gimp_layer_is_attached;
|
2003-09-04 19:33:06 +08:00
|
|
|
item_class->duplicate = gimp_layer_duplicate;
|
2005-01-14 02:17:24 +08:00
|
|
|
item_class->convert = gimp_layer_convert;
|
2003-09-04 19:33:06 +08:00
|
|
|
item_class->rename = gimp_layer_rename;
|
|
|
|
item_class->translate = gimp_layer_translate;
|
|
|
|
item_class->scale = gimp_layer_scale;
|
|
|
|
item_class->resize = gimp_layer_resize;
|
|
|
|
item_class->flip = gimp_layer_flip;
|
|
|
|
item_class->rotate = gimp_layer_rotate;
|
|
|
|
item_class->transform = gimp_layer_transform;
|
|
|
|
item_class->default_name = _("Layer");
|
|
|
|
item_class->rename_desc = _("Rename Layer");
|
2004-04-13 19:43:27 +08:00
|
|
|
item_class->translate_desc = _("Move Layer");
|
|
|
|
item_class->scale_desc = _("Scale Layer");
|
|
|
|
item_class->resize_desc = _("Resize Layer");
|
|
|
|
item_class->flip_desc = _("Flip Layer");
|
|
|
|
item_class->rotate_desc = _("Rotate Layer");
|
|
|
|
item_class->transform_desc = _("Transform Layer");
|
2003-09-04 19:33:06 +08:00
|
|
|
|
2003-10-06 22:40:12 +08:00
|
|
|
drawable_class->invalidate_boundary = gimp_layer_invalidate_boundary;
|
|
|
|
drawable_class->get_active_components = gimp_layer_get_active_components;
|
2004-03-13 21:56:09 +08:00
|
|
|
drawable_class->set_tiles = gimp_layer_set_tiles;
|
2003-09-04 19:33:06 +08:00
|
|
|
|
|
|
|
klass->opacity_changed = NULL;
|
|
|
|
klass->mode_changed = NULL;
|
2005-07-11 05:17:22 +08:00
|
|
|
klass->lock_alpha_changed = NULL;
|
2003-09-04 19:33:06 +08:00
|
|
|
klass->mask_changed = NULL;
|
2005-07-12 00:46:28 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_OPACITY,
|
|
|
|
g_param_spec_double ("opacity", NULL, NULL,
|
|
|
|
GIMP_OPACITY_TRANSPARENT,
|
|
|
|
GIMP_OPACITY_OPAQUE,
|
|
|
|
GIMP_OPACITY_OPAQUE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READABLE));
|
2005-07-12 00:46:28 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_MODE,
|
|
|
|
g_param_spec_enum ("mode", NULL, NULL,
|
|
|
|
GIMP_TYPE_LAYER_MODE_EFFECTS,
|
|
|
|
GIMP_NORMAL_MODE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READABLE));
|
2005-07-12 00:46:28 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_LOCK_ALPHA,
|
|
|
|
g_param_spec_boolean ("lock-alpha",
|
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_READABLE));
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_init (GimpLayer *layer)
|
|
|
|
{
|
2005-07-11 05:17:22 +08:00
|
|
|
layer->opacity = GIMP_OPACITY_OPAQUE;
|
|
|
|
layer->mode = GIMP_NORMAL_MODE;
|
|
|
|
layer->lock_alpha = FALSE;
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
layer->mask = NULL;
|
1998-01-22 15:02:57 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
/* floating selection */
|
|
|
|
layer->fs.backing_store = NULL;
|
|
|
|
layer->fs.drawable = NULL;
|
|
|
|
layer->fs.initial = TRUE;
|
|
|
|
layer->fs.boundary_known = FALSE;
|
|
|
|
layer->fs.segs = NULL;
|
|
|
|
layer->fs.num_segs = 0;
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
|
|
|
|
2005-07-12 03:21:52 +08:00
|
|
|
static void
|
2005-12-11 03:24:36 +08:00
|
|
|
gimp_layer_pickable_iface_init (GimpPickableInterface *iface)
|
2005-07-12 03:21:52 +08:00
|
|
|
{
|
2005-12-11 03:24:36 +08:00
|
|
|
iface->get_opacity_at = gimp_layer_get_opacity_at;
|
2005-07-12 03:21:52 +08:00
|
|
|
}
|
|
|
|
|
2005-07-12 00:46:28 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OPACITY:
|
|
|
|
case PROP_MODE:
|
|
|
|
case PROP_LOCK_ALPHA:
|
|
|
|
g_assert_not_reached ();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpLayer *layer = GIMP_LAYER (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OPACITY:
|
|
|
|
g_value_set_double (value, layer->opacity);
|
|
|
|
break;
|
|
|
|
case PROP_MODE:
|
|
|
|
g_value_set_enum (value, layer->mode);
|
|
|
|
break;
|
|
|
|
case PROP_LOCK_ALPHA:
|
|
|
|
g_value_set_boolean (value, layer->lock_alpha);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GimpLayer *layer = GIMP_LAYER (object);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
g_signal_handlers_disconnect_by_func (layer->mask,
|
|
|
|
gimp_layer_layer_mask_update,
|
|
|
|
layer);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_finalize (GObject *object)
|
|
|
|
{
|
2003-09-02 21:43:26 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (object);
|
2001-08-11 22:39:19 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (layer->mask);
|
2001-08-11 22:39:19 +08:00
|
|
|
layer->mask = NULL;
|
|
|
|
}
|
|
|
|
|
2004-03-17 00:23:06 +08:00
|
|
|
if (layer->fs.backing_store)
|
|
|
|
{
|
|
|
|
tile_manager_unref (layer->fs.backing_store);
|
|
|
|
layer->fs.backing_store = NULL;
|
|
|
|
}
|
|
|
|
|
2001-08-11 22:39:19 +08:00
|
|
|
if (layer->fs.segs)
|
|
|
|
{
|
|
|
|
g_free (layer->fs.segs);
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
layer->fs.segs = NULL;
|
|
|
|
layer->fs.num_segs = 0;
|
2001-08-11 22:39:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_name_changed (GimpObject *object)
|
|
|
|
{
|
|
|
|
GimpLayer *layer = GIMP_LAYER (object);
|
|
|
|
|
2004-05-24 18:49:34 +08:00
|
|
|
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
|
|
|
|
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
|
2004-02-02 04:38:26 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
2006-04-07 18:51:22 +08:00
|
|
|
gchar *mask_name = g_strdup_printf (_("%s mask"),
|
|
|
|
gimp_object_get_name (object));
|
2004-02-02 04:38:26 +08:00
|
|
|
|
2006-04-07 18:51:22 +08:00
|
|
|
gimp_object_take_name (GIMP_OBJECT (layer->mask), mask_name);
|
2004-02-02 04:38:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-17 01:51:36 +08:00
|
|
|
static gint64
|
2003-08-25 18:49:33 +08:00
|
|
|
gimp_layer_get_memsize (GimpObject *object,
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 *gui_size)
|
2002-01-31 00:14:26 +08:00
|
|
|
{
|
2004-02-02 04:38:26 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (object);
|
2003-11-17 01:51:36 +08:00
|
|
|
gint64 memsize = 0;
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
2003-08-25 18:49:33 +08:00
|
|
|
memsize += gimp_object_get_memsize (GIMP_OBJECT (layer->mask), gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
|
|
|
if (layer->fs.backing_store)
|
2004-09-20 03:47:26 +08:00
|
|
|
*gui_size += tile_manager_get_memsize (layer->fs.backing_store, FALSE);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
*gui_size += layer->fs.num_segs * sizeof (BoundSeg);
|
2002-01-31 00:14:26 +08:00
|
|
|
|
2003-08-25 18:49:33 +08:00
|
|
|
return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object,
|
|
|
|
gui_size);
|
2002-01-31 00:14:26 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
static void
|
2001-02-05 06:10:54 +08:00
|
|
|
gimp_layer_invalidate_preview (GimpViewable *viewable)
|
1998-01-22 15:02:57 +08:00
|
|
|
{
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (viewable);
|
2002-06-07 03:07:59 +08:00
|
|
|
|
2001-06-18 21:10:03 +08:00
|
|
|
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
|
|
|
|
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
|
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
2001-06-18 21:10:03 +08:00
|
|
|
floating_sel_invalidate (layer);
|
1998-01-22 15:02:57 +08:00
|
|
|
}
|
|
|
|
|
2004-09-22 20:46:35 +08:00
|
|
|
static gchar *
|
|
|
|
gimp_layer_get_description (GimpViewable *viewable,
|
|
|
|
gchar **tooltip)
|
|
|
|
{
|
|
|
|
if (gimp_layer_is_floating_sel (GIMP_LAYER (viewable)))
|
|
|
|
{
|
|
|
|
return g_strdup_printf (_("Floating Selection\n(%s)"),
|
|
|
|
gimp_object_get_name (GIMP_OBJECT (viewable)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return GIMP_VIEWABLE_CLASS (parent_class)->get_description (viewable,
|
|
|
|
tooltip);
|
|
|
|
}
|
|
|
|
|
2003-10-06 22:40:12 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_get_active_components (const GimpDrawable *drawable,
|
|
|
|
gboolean *active)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (drawable);
|
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
2003-10-06 22:40:12 +08:00
|
|
|
gint i;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
/* first copy the image active channels */
|
2003-10-06 22:40:12 +08:00
|
|
|
for (i = 0; i < MAX_CHANNELS; i++)
|
2006-03-29 01:08:36 +08:00
|
|
|
active[i] = image->active[i];
|
2003-10-06 22:40:12 +08:00
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable) && layer->lock_alpha)
|
2003-10-06 22:40:12 +08:00
|
|
|
active[gimp_drawable_bytes (drawable) - 1] = FALSE;
|
|
|
|
}
|
|
|
|
|
2004-03-13 21:56:09 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_set_tiles (GimpDrawable *drawable,
|
|
|
|
gboolean push_undo,
|
|
|
|
const gchar *undo_desc,
|
|
|
|
TileManager *tiles,
|
2004-03-16 03:34:35 +08:00
|
|
|
GimpImageType type,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2004-03-13 21:56:09 +08:00
|
|
|
{
|
2004-03-16 03:34:35 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (drawable);
|
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_relax (layer, FALSE);
|
|
|
|
|
2004-03-13 21:56:09 +08:00
|
|
|
GIMP_DRAWABLE_CLASS (parent_class)->set_tiles (drawable,
|
|
|
|
push_undo, undo_desc,
|
2004-03-16 03:34:35 +08:00
|
|
|
tiles, type,
|
|
|
|
offset_x, offset_y);
|
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_rigor (layer, FALSE);
|
2004-03-13 21:56:09 +08:00
|
|
|
}
|
|
|
|
|
2004-02-17 19:45:46 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_removed (GimpItem *item)
|
|
|
|
{
|
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
|
|
|
|
|
|
|
if (layer->mask)
|
|
|
|
gimp_item_removed (GIMP_ITEM (layer->mask));
|
|
|
|
|
|
|
|
if (GIMP_ITEM_CLASS (parent_class)->removed)
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->removed (item);
|
|
|
|
}
|
|
|
|
|
2004-01-27 00:18:16 +08:00
|
|
|
static gboolean
|
|
|
|
gimp_layer_is_attached (GimpItem *item)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
return (GIMP_IS_IMAGE (item->image) &&
|
|
|
|
gimp_container_have (item->image->layers, GIMP_OBJECT (item)));
|
2004-01-27 00:18:16 +08:00
|
|
|
}
|
|
|
|
|
2003-02-11 21:52:47 +08:00
|
|
|
static GimpItem *
|
|
|
|
gimp_layer_duplicate (GimpItem *item,
|
|
|
|
GType new_type,
|
|
|
|
gboolean add_alpha)
|
|
|
|
{
|
2005-12-23 09:15:19 +08:00
|
|
|
GimpItem *new_item;
|
2003-02-11 21:52:47 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
|
|
|
|
new_item = GIMP_ITEM_CLASS (parent_class)->duplicate (item, new_type,
|
|
|
|
add_alpha);
|
|
|
|
|
2005-12-23 09:15:19 +08:00
|
|
|
if (GIMP_IS_LAYER (new_item))
|
2003-02-11 21:52:47 +08:00
|
|
|
{
|
2006-02-13 00:07:39 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2005-12-23 09:15:19 +08:00
|
|
|
GimpLayer *new_layer = GIMP_LAYER (new_item);
|
|
|
|
|
|
|
|
new_layer->mode = layer->mode;
|
|
|
|
new_layer->opacity = layer->opacity;
|
|
|
|
new_layer->lock_alpha = layer->lock_alpha;
|
|
|
|
|
|
|
|
/* duplicate the layer mask if necessary */
|
|
|
|
if (layer->mask)
|
|
|
|
{
|
|
|
|
GimpItem *new_mask =
|
|
|
|
gimp_item_duplicate (GIMP_ITEM (layer->mask),
|
|
|
|
G_TYPE_FROM_INSTANCE (layer->mask),
|
|
|
|
FALSE);
|
|
|
|
gimp_layer_add_mask (new_layer, GIMP_LAYER_MASK (new_mask), FALSE);
|
|
|
|
}
|
2003-02-11 21:52:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return new_item;
|
|
|
|
}
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
static void
|
2005-01-14 02:17:24 +08:00
|
|
|
gimp_layer_convert (GimpItem *item,
|
|
|
|
GimpImage *dest_image)
|
2003-08-28 01:21:49 +08:00
|
|
|
{
|
2004-12-23 19:53:14 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
|
|
|
GimpDrawable *drawable = GIMP_DRAWABLE (item);
|
|
|
|
GimpImageBaseType old_base_type;
|
2003-08-28 01:21:49 +08:00
|
|
|
GimpImageBaseType new_base_type;
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
old_base_type = GIMP_IMAGE_TYPE_BASE_TYPE (gimp_drawable_type (drawable));
|
2005-01-14 02:17:24 +08:00
|
|
|
new_base_type = gimp_image_base_type (dest_image);
|
2003-08-28 01:21:49 +08:00
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
if (old_base_type != new_base_type)
|
2003-08-28 01:21:49 +08:00
|
|
|
{
|
|
|
|
TileManager *new_tiles;
|
|
|
|
GimpImageType new_type;
|
|
|
|
|
|
|
|
new_type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (new_base_type);
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2003-08-28 01:21:49 +08:00
|
|
|
new_type = GIMP_IMAGE_TYPE_WITH_ALPHA (new_type);
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
new_tiles = tile_manager_new (gimp_item_width (item),
|
|
|
|
gimp_item_height (item),
|
2003-08-28 01:21:49 +08:00
|
|
|
GIMP_IMAGE_TYPE_BYTES (new_type));
|
|
|
|
|
|
|
|
switch (new_base_type)
|
|
|
|
{
|
|
|
|
case GIMP_RGB:
|
2004-12-23 19:53:14 +08:00
|
|
|
gimp_drawable_convert_rgb (drawable,
|
2003-08-28 01:21:49 +08:00
|
|
|
new_tiles,
|
2004-12-23 19:53:14 +08:00
|
|
|
old_base_type);
|
2003-08-28 01:21:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY:
|
2004-12-23 19:53:14 +08:00
|
|
|
gimp_drawable_convert_grayscale (drawable,
|
2003-08-28 01:21:49 +08:00
|
|
|
new_tiles,
|
2004-12-23 19:53:14 +08:00
|
|
|
old_base_type);
|
2003-08-28 01:21:49 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED:
|
|
|
|
{
|
|
|
|
PixelRegion layerPR;
|
|
|
|
PixelRegion newPR;
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
pixel_region_init (&layerPR, drawable->tiles,
|
2003-08-28 01:21:49 +08:00
|
|
|
0, 0,
|
2004-12-23 19:53:14 +08:00
|
|
|
gimp_item_width (item),
|
|
|
|
gimp_item_height (item),
|
2003-08-28 01:21:49 +08:00
|
|
|
FALSE);
|
|
|
|
pixel_region_init (&newPR, new_tiles,
|
|
|
|
0, 0,
|
2004-12-23 19:53:14 +08:00
|
|
|
gimp_item_width (item),
|
|
|
|
gimp_item_height (item),
|
2003-08-28 01:21:49 +08:00
|
|
|
TRUE);
|
|
|
|
|
2005-11-17 01:59:50 +08:00
|
|
|
gimp_layer_transform_color (dest_image,
|
2003-08-28 01:21:49 +08:00
|
|
|
&newPR, &layerPR,
|
2006-10-26 06:14:36 +08:00
|
|
|
new_type,
|
2005-08-09 08:07:21 +08:00
|
|
|
gimp_drawable_type (drawable));
|
2003-08-28 01:21:49 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-12-23 19:53:14 +08:00
|
|
|
gimp_drawable_set_tiles_full (drawable, FALSE, NULL,
|
2004-03-16 03:34:35 +08:00
|
|
|
new_tiles, new_type,
|
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y);
|
2004-03-14 19:34:31 +08:00
|
|
|
tile_manager_unref (new_tiles);
|
2003-08-28 01:21:49 +08:00
|
|
|
}
|
|
|
|
|
2005-01-14 02:17:24 +08:00
|
|
|
if (layer->mask)
|
|
|
|
gimp_item_set_image (GIMP_ITEM (layer->mask), dest_image);
|
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->convert (item, dest_image);
|
2003-08-28 01:21:49 +08:00
|
|
|
}
|
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
static gboolean
|
2003-03-17 08:14:59 +08:00
|
|
|
gimp_layer_rename (GimpItem *item,
|
|
|
|
const gchar *new_name,
|
|
|
|
const gchar *undo_desc)
|
|
|
|
{
|
2004-02-02 04:38:26 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (item);
|
2004-02-02 04:38:26 +08:00
|
|
|
gboolean attached;
|
|
|
|
gboolean floating_sel;
|
2003-03-17 08:14:59 +08:00
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
attached = gimp_item_is_attached (item);
|
|
|
|
floating_sel = gimp_layer_is_floating_sel (layer);
|
|
|
|
|
|
|
|
if (floating_sel)
|
2003-03-17 08:14:59 +08:00
|
|
|
{
|
2004-02-02 04:38:26 +08:00
|
|
|
if (GIMP_IS_CHANNEL (layer->fs.drawable))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (attached)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_start (image,
|
2004-02-02 04:38:26 +08:00
|
|
|
GIMP_UNDO_GROUP_ITEM_PROPERTIES,
|
|
|
|
undo_desc);
|
2003-03-17 08:14:59 +08:00
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
floating_sel_to_layer (layer);
|
|
|
|
}
|
2003-03-17 08:14:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->rename (item, new_name, undo_desc);
|
|
|
|
|
2004-02-02 04:38:26 +08:00
|
|
|
if (attached && floating_sel)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2004-02-02 04:38:26 +08:00
|
|
|
|
|
|
|
return TRUE;
|
2003-03-17 08:14:59 +08:00
|
|
|
}
|
|
|
|
|
2003-05-09 03:11:17 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_translate (GimpItem *item,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint offset_x,
|
|
|
|
gint offset_y,
|
2003-05-09 21:05:37 +08:00
|
|
|
gboolean push_undo)
|
2003-05-09 03:11:17 +08:00
|
|
|
{
|
2004-02-02 04:38:26 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-09 03:11:17 +08:00
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
if (push_undo)
|
2004-04-13 19:43:27 +08:00
|
|
|
gimp_image_undo_push_item_displace (gimp_item_get_image (item), NULL, item);
|
2003-05-09 21:05:37 +08:00
|
|
|
|
2003-05-09 03:11:17 +08:00
|
|
|
/* update the old region */
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, item->width, item->height);
|
|
|
|
|
|
|
|
/* invalidate the selection boundary because of a layer modification */
|
2003-09-04 19:33:06 +08:00
|
|
|
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
|
2003-05-09 03:11:17 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_relax (layer, FALSE);
|
|
|
|
|
2003-05-09 21:05:37 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->translate (item, offset_x, offset_y,
|
|
|
|
push_undo);
|
2003-05-09 03:11:17 +08:00
|
|
|
|
2004-04-13 21:54:54 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_rigor (layer, FALSE);
|
|
|
|
|
2003-05-09 03:11:17 +08:00
|
|
|
/* update the new region */
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer), 0, 0, item->width, item->height);
|
|
|
|
|
2003-08-28 01:21:49 +08:00
|
|
|
if (layer->mask)
|
2003-05-09 03:11:17 +08:00
|
|
|
{
|
|
|
|
GIMP_ITEM (layer->mask)->offset_x = item->offset_x;
|
|
|
|
GIMP_ITEM (layer->mask)->offset_y = item->offset_y;
|
|
|
|
|
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->mask));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-05-07 19:09:00 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_scale (GimpItem *item,
|
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint new_offset_x,
|
|
|
|
gint new_offset_y,
|
2004-02-09 08:09:20 +08:00
|
|
|
GimpInterpolationType interpolation_type,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-07 19:09:00 +08:00
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-07 19:09:00 +08:00
|
|
|
|
|
|
|
GIMP_ITEM_CLASS (parent_class)->scale (item, new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
2004-08-11 02:47:21 +08:00
|
|
|
interpolation_type, progress);
|
2003-05-07 19:09:00 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
2004-04-13 19:43:27 +08:00
|
|
|
gimp_item_scale (GIMP_ITEM (layer->mask),
|
|
|
|
new_width, new_height,
|
|
|
|
new_offset_x, new_offset_y,
|
2004-08-11 02:47:21 +08:00
|
|
|
interpolation_type, progress);
|
2003-05-07 19:09:00 +08:00
|
|
|
}
|
|
|
|
|
2003-05-07 21:01:17 +08:00
|
|
|
static void
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_layer_resize (GimpItem *item,
|
|
|
|
GimpContext *context,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint new_width,
|
|
|
|
gint new_height,
|
|
|
|
gint offset_x,
|
|
|
|
gint offset_y)
|
2003-05-07 21:01:17 +08:00
|
|
|
{
|
2004-03-17 00:23:06 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-07 21:01:17 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->resize (item, context, new_width, new_height,
|
2003-05-07 21:01:17 +08:00
|
|
|
offset_x, offset_y);
|
|
|
|
|
|
|
|
if (layer->mask)
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_resize (GIMP_ITEM (layer->mask), context,
|
2004-04-13 19:43:27 +08:00
|
|
|
new_width, new_height, offset_x, offset_y);
|
2003-05-07 21:01:17 +08:00
|
|
|
}
|
|
|
|
|
2003-05-12 23:56:36 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_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-04-13 19:43:27 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->flip (item, context, flip_type, axis,
|
|
|
|
clip_result);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_flip (GIMP_ITEM (layer->mask), context,
|
2003-05-13 21:57:11 +08:00
|
|
|
flip_type, axis, clip_result);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|
|
|
|
|
2003-05-20 18:36:29 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_rotate (GimpItem *item,
|
2004-04-15 07:37:34 +08:00
|
|
|
GimpContext *context,
|
2003-05-20 18:36:29 +08:00
|
|
|
GimpRotationType rotate_type,
|
|
|
|
gdouble center_x,
|
|
|
|
gdouble center_y,
|
|
|
|
gboolean clip_result)
|
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-20 18:36:29 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->rotate (item, context,
|
2003-05-20 18:36:29 +08:00
|
|
|
rotate_type, center_x, center_y,
|
|
|
|
clip_result);
|
|
|
|
|
|
|
|
if (layer->mask)
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_rotate (GIMP_ITEM (layer->mask), context,
|
2003-05-20 18:36:29 +08:00
|
|
|
rotate_type, center_x, center_y, clip_result);
|
|
|
|
}
|
|
|
|
|
2003-05-12 23:56:36 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_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,
|
2004-03-14 01:45:58 +08:00
|
|
|
gboolean supersample,
|
|
|
|
gint recursion_level,
|
2003-05-12 23:56:36 +08:00
|
|
|
gboolean clip_result,
|
2004-08-11 02:47:21 +08:00
|
|
|
GimpProgress *progress)
|
2003-05-12 23:56:36 +08:00
|
|
|
{
|
2004-04-13 19:43:27 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (item);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
2006-05-14 05:49:29 +08:00
|
|
|
#ifdef __GNUC__
|
|
|
|
#warning FIXME: make interpolated transformations work on layers without alpha
|
|
|
|
#endif
|
|
|
|
if (interpolation_type != GIMP_INTERPOLATION_NONE &&
|
|
|
|
! gimp_drawable_has_alpha (GIMP_DRAWABLE (item)))
|
|
|
|
gimp_layer_add_alpha (layer);
|
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
GIMP_ITEM_CLASS (parent_class)->transform (item, context, matrix, direction,
|
2004-03-14 01:45:58 +08:00
|
|
|
interpolation_type,
|
|
|
|
supersample, recursion_level,
|
2004-08-11 02:47:21 +08:00
|
|
|
clip_result, progress);
|
2003-05-12 23:56:36 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_transform (GIMP_ITEM (layer->mask), context,
|
2003-05-13 21:57:11 +08:00
|
|
|
matrix, direction,
|
2004-03-14 01:45:58 +08:00
|
|
|
interpolation_type,
|
|
|
|
supersample, recursion_level,
|
2004-08-11 02:47:21 +08:00
|
|
|
clip_result, progress);
|
2003-09-04 19:33:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_layer_invalidate_boundary (GimpDrawable *drawable)
|
|
|
|
{
|
2004-02-02 04:38:26 +08:00
|
|
|
GimpLayer *layer = GIMP_LAYER (drawable);
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2003-09-04 19:33:06 +08:00
|
|
|
GimpChannel *mask;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! (image = gimp_item_get_image (GIMP_ITEM (layer))))
|
2003-09-04 19:33:06 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Turn the current selection off */
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_selection_control (image, GIMP_SELECTION_OFF);
|
2003-09-04 19:33:06 +08:00
|
|
|
|
|
|
|
/* clear the affected region surrounding the layer */
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_selection_control (image, GIMP_SELECTION_LAYER_OFF);
|
2003-09-04 19:33:06 +08:00
|
|
|
|
|
|
|
/* get the selection mask channel */
|
2006-03-29 01:08:36 +08:00
|
|
|
mask = gimp_image_get_mask (image);
|
2003-09-04 19:33:06 +08:00
|
|
|
|
|
|
|
/* Only bother with the bounds if there is a selection */
|
|
|
|
if (! gimp_channel_is_empty (mask))
|
|
|
|
{
|
|
|
|
mask->bounds_known = FALSE;
|
|
|
|
mask->boundary_known = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
|
|
|
floating_sel_invalidate (layer);
|
2003-05-12 23:56:36 +08:00
|
|
|
}
|
|
|
|
|
2005-07-12 03:21:52 +08:00
|
|
|
static gint
|
|
|
|
gimp_layer_get_opacity_at (GimpPickable *pickable,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint x,
|
|
|
|
gint y)
|
2005-07-12 03:21:52 +08:00
|
|
|
{
|
|
|
|
GimpLayer *layer = GIMP_LAYER (pickable);
|
|
|
|
Tile *tile;
|
|
|
|
gint val = 0;
|
|
|
|
|
|
|
|
if (x >= 0 && x < GIMP_ITEM (layer)->width &&
|
|
|
|
y >= 0 && y < GIMP_ITEM (layer)->height &&
|
|
|
|
gimp_item_get_visible (GIMP_ITEM (layer)))
|
|
|
|
{
|
|
|
|
/* If the point is inside, and the layer has no
|
|
|
|
* alpha channel, success!
|
|
|
|
*/
|
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
2006-04-12 20:49:29 +08:00
|
|
|
return OPAQUE_OPACITY;
|
2005-07-12 03:21:52 +08:00
|
|
|
|
|
|
|
/* Otherwise, determine if the alpha value at
|
|
|
|
* the given point is non-zero
|
|
|
|
*/
|
|
|
|
tile = tile_manager_get_tile (GIMP_DRAWABLE (layer)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
x, y, TRUE, FALSE);
|
2005-07-12 03:21:52 +08:00
|
|
|
|
|
|
|
val = * ((guchar *) tile_data_pointer (tile,
|
2006-04-12 20:49:29 +08:00
|
|
|
x % TILE_WIDTH,
|
|
|
|
y % TILE_HEIGHT) +
|
|
|
|
tile_bpp (tile) - 1);
|
2005-07-12 03:21:52 +08:00
|
|
|
|
|
|
|
if (layer->mask)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
gint mask_val;
|
2005-07-12 03:21:52 +08:00
|
|
|
|
|
|
|
mask_val = gimp_pickable_get_opacity_at (GIMP_PICKABLE (layer->mask),
|
|
|
|
x, y);
|
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
val = val * mask_val / 255;
|
|
|
|
}
|
2005-07-12 03:21:52 +08:00
|
|
|
|
|
|
|
tile_release (tile, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
static void
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_transform_color (GimpImage *image,
|
2006-04-12 20:49:29 +08:00
|
|
|
PixelRegion *layerPR,
|
|
|
|
PixelRegion *bufPR,
|
2006-10-26 06:14:36 +08:00
|
|
|
GimpImageType dest_type,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpImageType src_type)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-09 08:07:21 +08:00
|
|
|
GimpImageBaseType base_type = GIMP_IMAGE_TYPE_BASE_TYPE (src_type);
|
|
|
|
gboolean alpha = GIMP_IMAGE_TYPE_HAS_ALPHA (src_type);
|
|
|
|
gpointer pr;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
for (pr = pixel_regions_register (2, layerPR, bufPR);
|
|
|
|
pr != NULL;
|
2000-05-13 01:07:54 +08:00
|
|
|
pr = pixel_regions_process (pr))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-02-16 07:38:59 +08:00
|
|
|
const guchar *src = bufPR->data;
|
|
|
|
guchar *dest = layerPR->data;
|
|
|
|
gint h = layerPR->h;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
while (h--)
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2005-02-16 07:38:59 +08:00
|
|
|
const guchar *s = src;
|
|
|
|
guchar *d = dest;
|
|
|
|
gint i;
|
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
for (i = 0; i < layerPR->w; i++)
|
|
|
|
{
|
2006-10-26 06:14:36 +08:00
|
|
|
gimp_image_transform_color (image, dest_type, d, base_type, s);
|
2005-02-16 07:38:59 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
/* alpha channel */
|
2005-08-09 08:07:21 +08:00
|
|
|
d[layerPR->bytes - 1] = (alpha ?
|
|
|
|
s[bufPR->bytes - 1] : OPAQUE_OPACITY);
|
2005-02-16 07:38:59 +08:00
|
|
|
|
|
|
|
s += bufPR->bytes;
|
|
|
|
d += layerPR->bytes;
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
src += bufPR->rowstride;
|
|
|
|
dest += layerPR->rowstride;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
static void
|
|
|
|
gimp_layer_layer_mask_update (GimpDrawable *drawable,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpLayer *layer)
|
|
|
|
{
|
|
|
|
GimpLayerMask *layer_mask = GIMP_LAYER_MASK (drawable);
|
|
|
|
|
|
|
|
if (layer_mask->apply_mask || layer_mask->show_mask)
|
|
|
|
{
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
x, y, width, height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayer *
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_new (GimpImage *image,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
GimpImageType type,
|
|
|
|
const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpLayerModeEffects mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayer *layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
2002-03-04 22:52:54 +08:00
|
|
|
g_return_val_if_fail (width > 0, NULL);
|
|
|
|
g_return_val_if_fail (height > 0, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-08-10 22:41:39 +08:00
|
|
|
layer = g_object_new (GIMP_TYPE_LAYER, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gimp_drawable_configure (GIMP_DRAWABLE (layer),
|
2006-04-12 20:49:29 +08:00
|
|
|
image,
|
2003-02-01 00:37:03 +08:00
|
|
|
0, 0, width, height,
|
2001-12-13 07:48:18 +08:00
|
|
|
type,
|
|
|
|
name);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
layer->opacity = opacity;
|
2002-03-04 22:52:54 +08:00
|
|
|
layer->mode = mode;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
return layer;
|
|
|
|
}
|
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
/**
|
|
|
|
* gimp_layer_new_from_tiles:
|
|
|
|
* @tiles: The buffer to make the new layer from.
|
2006-03-29 01:08:36 +08:00
|
|
|
* @dest_image: The image the new layer will be added to.
|
2002-05-21 19:29:20 +08:00
|
|
|
* @type: The #GimpImageType of the new layer.
|
2002-03-04 22:52:54 +08:00
|
|
|
* @name: The new layer's name.
|
|
|
|
* @opacity: The new layer's opacity.
|
|
|
|
* @mode: The new layer's mode.
|
2003-08-28 01:21:49 +08:00
|
|
|
*
|
2002-03-04 22:52:54 +08:00
|
|
|
* Copies %tiles to a layer taking into consideration the
|
|
|
|
* possibility of transforming the contents to meet the requirements
|
|
|
|
* of the target image type
|
2003-08-28 01:21:49 +08:00
|
|
|
*
|
2002-03-04 22:52:54 +08:00
|
|
|
* Return value: The new layer.
|
|
|
|
**/
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayer *
|
2002-02-26 01:58:50 +08:00
|
|
|
gimp_layer_new_from_tiles (TileManager *tiles,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *dest_image,
|
2002-05-21 19:29:20 +08:00
|
|
|
GimpImageType type,
|
2006-04-12 20:49:29 +08:00
|
|
|
const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpLayerModeEffects mode)
|
2005-04-10 01:56:04 +08:00
|
|
|
{
|
|
|
|
PixelRegion bufPR;
|
|
|
|
|
|
|
|
g_return_val_if_fail (tiles != NULL, NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
2005-04-10 01:56:04 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
|
|
|
pixel_region_init (&bufPR, tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
2005-04-10 01:56:04 +08:00
|
|
|
tile_manager_width (tiles),
|
|
|
|
tile_manager_height (tiles),
|
|
|
|
FALSE);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
return gimp_layer_new_from_region (&bufPR, dest_image, type,
|
2005-04-10 01:56:04 +08:00
|
|
|
name, opacity, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_layer_new_from_pixbuf:
|
2005-04-14 01:45:53 +08:00
|
|
|
* @pixbuf: The pixbuf to make the new layer from.
|
2006-03-29 01:08:36 +08:00
|
|
|
* @dest_image: The image the new layer will be added to.
|
2005-04-10 01:56:04 +08:00
|
|
|
* @type: The #GimpImageType of the new layer.
|
|
|
|
* @name: The new layer's name.
|
|
|
|
* @opacity: The new layer's opacity.
|
|
|
|
* @mode: The new layer's mode.
|
|
|
|
*
|
|
|
|
* Copies %pixbuf to a layer taking into consideration the
|
|
|
|
* possibility of transforming the contents to meet the requirements
|
|
|
|
* of the target image type
|
|
|
|
*
|
|
|
|
* Return value: The new layer.
|
|
|
|
**/
|
|
|
|
GimpLayer *
|
|
|
|
gimp_layer_new_from_pixbuf (GdkPixbuf *pixbuf,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *dest_image,
|
2005-04-10 01:56:04 +08:00
|
|
|
GimpImageType type,
|
|
|
|
const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpLayerModeEffects mode)
|
|
|
|
{
|
|
|
|
PixelRegion bufPR = { 0, };
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
2005-04-10 01:56:04 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2005-09-04 01:16:58 +08:00
|
|
|
pixel_region_init_data (&bufPR, gdk_pixbuf_get_pixels (pixbuf),
|
|
|
|
gdk_pixbuf_get_n_channels (pixbuf),
|
|
|
|
gdk_pixbuf_get_rowstride (pixbuf),
|
|
|
|
0, 0,
|
|
|
|
gdk_pixbuf_get_width (pixbuf),
|
|
|
|
gdk_pixbuf_get_height (pixbuf));
|
2005-04-10 01:56:04 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
return gimp_layer_new_from_region (&bufPR, dest_image, type,
|
2005-04-10 01:56:04 +08:00
|
|
|
name, opacity, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_layer_new_from_region:
|
|
|
|
* @region: A readable pixel region.
|
2006-03-29 01:08:36 +08:00
|
|
|
* @dest_image: The image the new layer will be added to.
|
2005-04-10 01:56:04 +08:00
|
|
|
* @type: The #GimpImageType of the new layer.
|
|
|
|
* @name: The new layer's name.
|
|
|
|
* @opacity: The new layer's opacity.
|
|
|
|
* @mode: The new layer's mode.
|
|
|
|
*
|
|
|
|
* Copies %region to a layer taking into consideration the
|
|
|
|
* possibility of transforming the contents to meet the requirements
|
|
|
|
* of the target image type
|
|
|
|
*
|
|
|
|
* Return value: The new layer.
|
|
|
|
**/
|
|
|
|
GimpLayer *
|
|
|
|
gimp_layer_new_from_region (PixelRegion *region,
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *dest_image,
|
2005-04-10 01:56:04 +08:00
|
|
|
GimpImageType type,
|
|
|
|
const gchar *name,
|
|
|
|
gdouble opacity,
|
|
|
|
GimpLayerModeEffects mode)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-07-07 23:07:17 +08:00
|
|
|
GimpLayer *new_layer;
|
|
|
|
PixelRegion layerPR;
|
|
|
|
GimpImageType src_type;
|
|
|
|
gint width;
|
2004-07-07 23:25:27 +08:00
|
|
|
gint height;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-04-10 01:56:04 +08:00
|
|
|
g_return_val_if_fail (region != NULL, NULL);
|
2006-03-29 01:08:36 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-04-10 01:56:04 +08:00
|
|
|
width = region->w;
|
|
|
|
height = region->h;
|
2002-03-04 22:52:54 +08:00
|
|
|
|
2005-04-10 01:56:04 +08:00
|
|
|
switch (region->bytes)
|
2004-07-07 23:07:17 +08:00
|
|
|
{
|
|
|
|
case 1: src_type = GIMP_GRAY_IMAGE; break;
|
|
|
|
case 2: src_type = GIMP_GRAYA_IMAGE; break;
|
|
|
|
case 3: src_type = GIMP_RGB_IMAGE; break;
|
|
|
|
case 4: src_type = GIMP_RGBA_IMAGE; break;
|
|
|
|
default:
|
|
|
|
g_return_val_if_reached (NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
new_layer = gimp_layer_new (dest_image, width, height, type, name,
|
2006-04-12 20:49:29 +08:00
|
|
|
opacity, mode);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
if (! new_layer)
|
1999-08-22 19:45:31 +08:00
|
|
|
{
|
2006-08-09 05:06:36 +08:00
|
|
|
g_warning ("%s: could not allocate new layer", G_STRFUNC);
|
1999-08-22 19:45:31 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
pixel_region_init (&layerPR, GIMP_DRAWABLE (new_layer)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0, width, height,
|
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-07-07 23:07:17 +08:00
|
|
|
switch (type)
|
2001-12-13 07:48:18 +08:00
|
|
|
{
|
2004-07-07 23:07:17 +08:00
|
|
|
case GIMP_RGB_IMAGE:
|
|
|
|
switch (src_type)
|
|
|
|
{
|
|
|
|
case GIMP_RGB_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
copy_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_RGBA_IMAGE:
|
|
|
|
switch (src_type)
|
|
|
|
{
|
|
|
|
case GIMP_RGBA_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
copy_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RGB_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
add_alpha_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
2005-08-09 08:07:21 +08:00
|
|
|
case GIMP_GRAY_IMAGE:
|
2004-07-07 23:07:17 +08:00
|
|
|
case GIMP_GRAYA_IMAGE:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_transform_color (dest_image, &layerPR, region,
|
2006-10-26 06:14:36 +08:00
|
|
|
type, src_type);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAY_IMAGE:
|
|
|
|
switch (src_type)
|
|
|
|
{
|
|
|
|
case GIMP_GRAY_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
copy_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_GRAYA_IMAGE:
|
|
|
|
switch (src_type)
|
|
|
|
{
|
2005-08-09 08:07:21 +08:00
|
|
|
case GIMP_RGB_IMAGE:
|
2004-07-07 23:07:17 +08:00
|
|
|
case GIMP_RGBA_IMAGE:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_transform_color (dest_image, &layerPR, region,
|
2006-10-26 06:14:36 +08:00
|
|
|
type, src_type);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
case GIMP_GRAYA_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
copy_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
case GIMP_GRAY_IMAGE:
|
2005-04-10 01:56:04 +08:00
|
|
|
add_alpha_region (region, &layerPR);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXED_IMAGE:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GIMP_INDEXEDA_IMAGE:
|
|
|
|
switch (src_type)
|
|
|
|
{
|
2005-08-09 08:07:21 +08:00
|
|
|
case GIMP_RGB_IMAGE:
|
2004-07-07 23:07:17 +08:00
|
|
|
case GIMP_RGBA_IMAGE:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_transform_color (dest_image, &layerPR, region,
|
2006-10-26 06:14:36 +08:00
|
|
|
type, src_type);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
2005-08-09 08:07:21 +08:00
|
|
|
case GIMP_GRAY_IMAGE:
|
2004-07-07 23:07:17 +08:00
|
|
|
case GIMP_GRAYA_IMAGE:
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_layer_transform_color (dest_image, &layerPR, region,
|
2006-10-26 06:14:36 +08:00
|
|
|
type, src_type);
|
2004-07-07 23:07:17 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_warning ("%s: unhandled type conversion", G_STRFUNC);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2001-12-13 07:48:18 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return new_layer;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayerMask *
|
|
|
|
gimp_layer_add_mask (GimpLayer *layer,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpLayerMask *mask,
|
2001-03-05 04:06:48 +08:00
|
|
|
gboolean push_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2001-03-05 04:06:48 +08:00
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
|
|
|
|
|
2004-11-16 21:41:55 +08:00
|
|
|
if (! gimp_item_is_attached (GIMP_ITEM (layer)))
|
|
|
|
push_undo = FALSE;
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image)
|
2001-03-05 04:06:48 +08:00
|
|
|
{
|
2003-03-24 05:30:09 +08:00
|
|
|
g_message (_("Cannot add layer mask to layer "
|
2001-03-05 04:06:48 +08:00
|
|
|
"which is not part of an image."));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (layer->mask)
|
2001-03-05 04:06:48 +08:00
|
|
|
{
|
2003-03-24 05:30:09 +08:00
|
|
|
g_message (_("Unable to add a layer mask since "
|
2006-04-12 20:49:29 +08:00
|
|
|
"the layer already has one."));
|
2001-03-05 04:06:48 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-02-01 00:47:20 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
2001-03-05 04:06:48 +08:00
|
|
|
{
|
2003-03-24 05:30:09 +08:00
|
|
|
g_message (_("Cannot add layer mask to a layer "
|
2001-03-05 04:06:48 +08:00
|
|
|
"with no alpha channel."));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-05-08 21:12:46 +08:00
|
|
|
if ((gimp_item_width (GIMP_ITEM (layer)) !=
|
|
|
|
gimp_item_width (GIMP_ITEM (mask))) ||
|
|
|
|
(gimp_item_height (GIMP_ITEM (layer)) !=
|
|
|
|
gimp_item_height (GIMP_ITEM (mask))))
|
2001-03-05 04:06:48 +08:00
|
|
|
{
|
2004-03-17 00:23:06 +08:00
|
|
|
g_message (_("Cannot add layer mask of different "
|
|
|
|
"dimensions than specified layer."));
|
2001-03-05 04:06:48 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-11-16 21:41:55 +08:00
|
|
|
if (push_undo)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_push_layer_mask_add (image, _("Add Layer Mask"),
|
2004-11-16 21:41:55 +08:00
|
|
|
layer, mask);
|
|
|
|
|
2006-10-17 01:09:17 +08:00
|
|
|
layer->mask = g_object_ref_sink (mask);
|
2003-12-10 02:59:35 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
gimp_layer_mask_set_layer (mask, layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
if (mask->apply_mask || mask->show_mask)
|
|
|
|
{
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_signal_connect (mask, "update",
|
|
|
|
G_CALLBACK (gimp_layer_layer_mask_update),
|
|
|
|
layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (layer, layer_signals[MASK_CHANGED], 0);
|
2001-03-05 04:06:48 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return layer->mask;
|
|
|
|
}
|
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayerMask *
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_layer_create_mask (const GimpLayer *layer,
|
2006-05-15 00:24:31 +08:00
|
|
|
GimpAddMaskType add_mask_type,
|
|
|
|
GimpChannel *channel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-05-08 01:00:57 +08:00
|
|
|
GimpDrawable *drawable;
|
2003-05-08 19:52:31 +08:00
|
|
|
GimpItem *item;
|
2002-02-21 00:15:53 +08:00
|
|
|
PixelRegion srcPR;
|
|
|
|
PixelRegion destPR;
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayerMask *mask;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2001-01-29 00:44:22 +08:00
|
|
|
gchar *mask_name;
|
2002-03-04 01:38:12 +08:00
|
|
|
GimpRGB black = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-07 03:07:59 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
2006-05-15 00:24:31 +08:00
|
|
|
g_return_val_if_fail (add_mask_type != GIMP_ADD_CHANNEL_MASK ||
|
|
|
|
GIMP_IS_CHANNEL (channel), NULL);
|
2002-06-07 03:07:59 +08:00
|
|
|
|
2003-05-08 01:00:57 +08:00
|
|
|
drawable = GIMP_DRAWABLE (layer);
|
2003-05-08 19:52:31 +08:00
|
|
|
item = GIMP_ITEM (layer);
|
2006-05-15 00:24:31 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2001-02-28 15:54:05 +08:00
|
|
|
|
2001-01-10 11:13:03 +08:00
|
|
|
mask_name = g_strdup_printf (_("%s mask"),
|
2006-04-12 20:49:29 +08:00
|
|
|
gimp_object_get_name (GIMP_OBJECT (layer)));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
mask = gimp_layer_mask_new (image,
|
2006-04-12 20:49:29 +08:00
|
|
|
item->width,
|
|
|
|
item->height,
|
|
|
|
mask_name, &black);
|
2002-02-21 00:15:53 +08:00
|
|
|
|
|
|
|
g_free (mask_name);
|
|
|
|
|
2002-08-27 22:17:46 +08:00
|
|
|
switch (add_mask_type)
|
|
|
|
{
|
|
|
|
case GIMP_ADD_WHITE_MASK:
|
|
|
|
gimp_channel_all (GIMP_CHANNEL (mask), FALSE);
|
|
|
|
return mask;
|
|
|
|
|
|
|
|
case GIMP_ADD_BLACK_MASK:
|
2003-09-03 07:07:40 +08:00
|
|
|
gimp_channel_clear (GIMP_CHANNEL (mask), NULL, FALSE);
|
2002-08-27 22:17:46 +08:00
|
|
|
return mask;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&destPR, gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (mask)->width,
|
2003-08-28 01:21:49 +08:00
|
|
|
GIMP_ITEM (mask)->height,
|
2006-04-12 20:49:29 +08:00
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
switch (add_mask_type)
|
|
|
|
{
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_ADD_WHITE_MASK:
|
|
|
|
case GIMP_ADD_BLACK_MASK:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2001-12-13 07:48:18 +08:00
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_ADD_ALPHA_MASK:
|
2003-11-27 00:00:14 +08:00
|
|
|
case GIMP_ADD_ALPHA_TRANSFER_MASK:
|
2003-05-08 01:00:57 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
item->width, item->height,
|
|
|
|
FALSE);
|
2003-05-08 19:52:31 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
extract_alpha_region (&srcPR, NULL, &destPR);
|
2003-11-26 23:48:50 +08:00
|
|
|
|
2003-11-27 00:00:14 +08:00
|
|
|
if (add_mask_type == GIMP_ADD_ALPHA_TRANSFER_MASK)
|
2003-11-26 23:48:50 +08:00
|
|
|
{
|
|
|
|
void *pr;
|
|
|
|
gint w, h;
|
|
|
|
guchar *alpha_ptr;
|
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
gimp_drawable_push_undo (drawable,
|
2003-11-26 23:48:50 +08:00
|
|
|
_("Transfer Alpha to Mask"),
|
|
|
|
0, 0,
|
|
|
|
item->width,
|
|
|
|
item->height,
|
|
|
|
NULL, FALSE);
|
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
2003-11-26 23:48:50 +08:00
|
|
|
0, 0,
|
|
|
|
item->width, item->height,
|
|
|
|
TRUE);
|
|
|
|
|
|
|
|
for (pr = pixel_regions_register (1, &srcPR);
|
|
|
|
pr != NULL;
|
|
|
|
pr = pixel_regions_process (pr))
|
|
|
|
{
|
|
|
|
h = srcPR.h;
|
|
|
|
|
|
|
|
while (h--)
|
|
|
|
{
|
|
|
|
w = srcPR.w;
|
|
|
|
alpha_ptr = (srcPR.data + h * srcPR.rowstride +
|
|
|
|
srcPR.bytes - 1);
|
|
|
|
|
|
|
|
while (w--)
|
|
|
|
{
|
|
|
|
*alpha_ptr = OPAQUE_OPACITY;
|
|
|
|
alpha_ptr += srcPR.bytes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-04-12 20:49:29 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2001-12-13 07:48:18 +08:00
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_ADD_SELECTION_MASK:
|
2006-05-15 00:24:31 +08:00
|
|
|
case GIMP_ADD_CHANNEL_MASK:
|
2002-02-21 00:15:53 +08:00
|
|
|
{
|
2006-05-15 00:24:31 +08:00
|
|
|
gboolean channel_empty;
|
|
|
|
gint copy_x, copy_y;
|
|
|
|
gint copy_width, copy_height;
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
if (add_mask_type == GIMP_ADD_SELECTION_MASK)
|
|
|
|
channel = GIMP_CHANNEL (gimp_image_get_mask (image));
|
|
|
|
|
|
|
|
channel_empty = gimp_channel_is_empty (channel);
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_rectangle_intersect (0, 0, image->width, image->height,
|
2003-05-14 23:32:07 +08:00
|
|
|
item->offset_x, item->offset_y,
|
|
|
|
item->width, item->height,
|
|
|
|
©_x, ©_y, ©_width, ©_height);
|
2003-05-08 01:00:57 +08:00
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
if (copy_width < item->width ||
|
|
|
|
copy_height < item->height ||
|
|
|
|
channel_empty)
|
2003-09-03 07:07:40 +08:00
|
|
|
gimp_channel_clear (GIMP_CHANNEL (mask), NULL, FALSE);
|
2003-05-08 01:00:57 +08:00
|
|
|
|
2006-05-15 00:24:31 +08:00
|
|
|
if ((copy_width || copy_height) && ! channel_empty)
|
2003-05-08 01:00:57 +08:00
|
|
|
{
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&srcPR,
|
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel)),
|
2003-05-14 23:32:07 +08:00
|
|
|
copy_x, copy_y,
|
|
|
|
copy_width, copy_height,
|
2003-05-08 01:00:57 +08:00
|
|
|
FALSE);
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&destPR,
|
|
|
|
gimp_drawable_get_tiles (GIMP_DRAWABLE (mask)),
|
2003-05-14 23:32:07 +08:00
|
|
|
copy_x - item->offset_x, copy_y - item->offset_y,
|
|
|
|
copy_width, copy_height,
|
|
|
|
TRUE);
|
2003-05-08 01:00:57 +08:00
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
2003-08-28 01:21:49 +08:00
|
|
|
|
2003-05-14 23:32:07 +08:00
|
|
|
GIMP_CHANNEL (mask)->bounds_known = FALSE;
|
2003-05-08 01:00:57 +08:00
|
|
|
}
|
2002-02-21 00:15:53 +08:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
case GIMP_ADD_COPY_MASK:
|
2002-02-21 00:15:53 +08:00
|
|
|
{
|
2003-03-03 20:36:42 +08:00
|
|
|
TileManager *copy_tiles = NULL;
|
2002-02-21 00:15:53 +08:00
|
|
|
GimpImageType layer_type;
|
|
|
|
|
2003-05-08 01:00:57 +08:00
|
|
|
layer_type = drawable->type;
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2003-03-03 20:36:42 +08:00
|
|
|
if (GIMP_IMAGE_TYPE_BASE_TYPE (layer_type) != GIMP_GRAY)
|
|
|
|
{
|
|
|
|
GimpImageType copy_type;
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2003-03-03 20:36:42 +08:00
|
|
|
copy_type = (GIMP_IMAGE_TYPE_HAS_ALPHA (layer_type) ?
|
|
|
|
GIMP_GRAYA_IMAGE : GIMP_GRAY_IMAGE);
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
copy_tiles = tile_manager_new (item->width,
|
|
|
|
item->height,
|
2003-03-03 20:36:42 +08:00
|
|
|
GIMP_IMAGE_TYPE_BYTES (copy_type));
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2003-05-08 01:00:57 +08:00
|
|
|
gimp_drawable_convert_grayscale (drawable,
|
2003-03-03 20:36:42 +08:00
|
|
|
copy_tiles,
|
|
|
|
GIMP_IMAGE_TYPE_BASE_TYPE (layer_type));
|
|
|
|
|
|
|
|
pixel_region_init (&srcPR, copy_tiles,
|
|
|
|
0, 0,
|
2003-08-28 01:21:49 +08:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2003-03-03 20:36:42 +08:00
|
|
|
FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-05-15 00:24:31 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_get_tiles (drawable),
|
2003-03-03 20:36:42 +08:00
|
|
|
0, 0,
|
2003-08-28 01:21:49 +08:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2003-03-03 20:36:42 +08:00
|
|
|
FALSE);
|
|
|
|
}
|
2002-02-21 00:15:53 +08:00
|
|
|
|
2003-05-08 01:00:57 +08:00
|
|
|
if (gimp_drawable_has_alpha (drawable))
|
2002-02-21 00:15:53 +08:00
|
|
|
{
|
2003-03-03 20:36:42 +08:00
|
|
|
guchar black_uchar[] = { 0, 0, 0, 0 };
|
|
|
|
|
2002-02-21 00:15:53 +08:00
|
|
|
flatten_region (&srcPR, &destPR, black_uchar);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
|
2003-03-03 20:36:42 +08:00
|
|
|
if (copy_tiles)
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (copy_tiles);
|
2002-02-21 00:15:53 +08:00
|
|
|
}
|
2002-08-27 22:17:46 +08:00
|
|
|
|
|
|
|
GIMP_CHANNEL (mask)->bounds_known = FALSE;
|
2002-02-21 00:15:53 +08:00
|
|
|
break;
|
|
|
|
}
|
2001-01-29 00:44:22 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-03-18 19:07:34 +08:00
|
|
|
gimp_layer_apply_mask (GimpLayer *layer,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpMaskApplyMode mode,
|
2002-03-18 19:07:34 +08:00
|
|
|
gboolean push_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-05-08 19:52:31 +08:00
|
|
|
GimpItem *item;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2002-02-24 01:29:19 +08:00
|
|
|
PixelRegion srcPR, maskPR;
|
|
|
|
gboolean view_changed = FALSE;
|
2001-03-05 04:06:48 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
if (! layer->mask)
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* this operation can only be done to layers with an alpha channel */
|
2002-02-01 00:47:20 +08:00
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image)
|
2001-03-05 04:06:48 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (push_undo)
|
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_LAYER_APPLY_MASK,
|
2004-02-29 02:56:55 +08:00
|
|
|
(mode == GIMP_MASK_APPLY) ?
|
|
|
|
_("Apply Layer Mask") :
|
|
|
|
_("Delete Layer Mask"));
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_push_layer_mask_remove (image, NULL, layer, layer->mask);
|
2001-03-05 04:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* check if applying the mask changes the projection */
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
if (layer->mask->show_mask ||
|
|
|
|
(mode == GIMP_MASK_APPLY && ! layer->mask->apply_mask) ||
|
|
|
|
(mode == GIMP_MASK_DISCARD && layer->mask->apply_mask))
|
2001-03-05 04:06:48 +08:00
|
|
|
{
|
|
|
|
view_changed = TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-03-18 19:07:34 +08:00
|
|
|
if (mode == GIMP_MASK_APPLY)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-05 04:06:48 +08:00
|
|
|
if (push_undo)
|
2003-02-14 22:14:29 +08:00
|
|
|
gimp_drawable_push_undo (GIMP_DRAWABLE (layer), NULL,
|
2002-06-07 03:44:05 +08:00
|
|
|
0, 0,
|
2003-05-08 19:52:31 +08:00
|
|
|
item->width,
|
|
|
|
item->height,
|
2002-06-07 03:44:05 +08:00
|
|
|
NULL, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Combine the current layer's alpha channel and the mask */
|
2003-08-28 01:21:49 +08:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
item->width,
|
|
|
|
item->height,
|
|
|
|
TRUE);
|
2003-08-28 01:21:49 +08:00
|
|
|
pixel_region_init (&maskPR, GIMP_DRAWABLE (layer->mask)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
item->width,
|
|
|
|
item->height,
|
|
|
|
FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-25 09:24:46 +08:00
|
|
|
apply_mask_to_region (&srcPR, &maskPR, OPAQUE_OPACITY);
|
2001-03-05 04:06:48 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
To optimize duplicate and/or wrong image updates away, introduced new
2003-09-06 Michael Natterer <mitch@gimp.org>
To optimize duplicate and/or wrong image updates away, introduced
new policy that a child object must never explicitly update or
invalidate its parent object (just like the GUI is not updated
explicitly by the core):
* app/core/gimpdrawable.[ch]: added new signal
GimpDrawable::update(). Never update or invalidate the image when
the drawable is updated or invalidated.
(gimp_drawable_set_visible): don't gimp_drawable_update() the
drawable since its pixels have not changed.
* app/core/gimpimage.[ch]: connect to the "add" and "remove"
signals of the layers and channels containers. Also connect to the
"update" and "visibility_changed" signals of all drawables in
these containers (optimizes away updates issued by drawables which
are not yet added to the image and updates of the selection
mask). Also, don't propagate updates to the image if the emitting
drawable is invisible (optimizes away updates issued by invisible
drawables).
(gimp_image_add_layer,channel)
(gimp_image_remove_layer,channel): don't update the image since
that's done by our "add" and "remove" handlers now.
(gimp_image_position_layer,channel): update just the image, not
the drawable since its pixels have not changed.
(gimp_image_real_colormap_changed)
(gimp_image_set_component_visible): always call
gimp_image_update() *and* gimp_viewable_invalidate_preview() to
get everything updated, since update and invalidate of images are
not connected.
* app/core/gimpimage-undo-push.c (undo_pop_layer,channel): don't
update the drawable since (a) its pixels don't change and (b) the
image updates itself upon adding/removing now.
(undo_pop_layer_mod): replaced gimp_image_update() by
gimp_drawable_update() (just for consistency with other similar
functions).
* app/core/gimplayer.c: connect to "update" of the layer mask and
issue updates on the layer if the mask update has any effect on
the projection.
(gimp_layer_create_mask): don't set the mask's offsets here since
they may be different when we later add the mask to the layer.
* app/core/gimplayermask.c (gimp_layer_mask_set_layer): set the
mask offsets here instead.
* app/core/gimpchannel.c (gimp_channel_translate): update the
channel even if push_undo == FALSE.
* app/paint/gimppaintcore.c (gimp_paint_core_finish)
* app/tools/gimpinktool.c (ink_finish): invalidate both the
drawable and the image preview since invalidating the drawable
doesn't invalidate the image any more.
* app/text/gimptextlayer.c (gimp_text_layer_render_now): also
update the new extents of the text layer, not only the old one.
(gimp_text_layer_render_layout): don't update the drawable since
gimp_drawable_fill() already updated it.
2003-09-07 04:06:53 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (layer->mask,
|
|
|
|
gimp_layer_layer_mask_update,
|
|
|
|
layer);
|
|
|
|
|
2004-02-17 19:45:46 +08:00
|
|
|
gimp_item_removed (GIMP_ITEM (layer->mask));
|
2003-01-06 06:07:10 +08:00
|
|
|
g_object_unref (layer->mask);
|
2001-03-06 21:28:39 +08:00
|
|
|
layer->mask = NULL;
|
2001-03-05 04:06:48 +08:00
|
|
|
|
|
|
|
if (push_undo)
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
2001-03-05 04:06:48 +08:00
|
|
|
|
|
|
|
/* If applying actually changed the view */
|
|
|
|
if (view_changed)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
item->width,
|
|
|
|
item->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-03-24 20:21:58 +08:00
|
|
|
else
|
|
|
|
{
|
2003-04-07 17:27:08 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
|
2003-03-24 20:21:58 +08:00
|
|
|
}
|
2001-03-05 04:06:48 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (layer, layer_signals[MASK_CHANGED], 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 00:44:22 +08:00
|
|
|
gimp_layer_add_alpha (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 00:44:22 +08:00
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
TileManager *new_tiles;
|
2003-08-28 01:21:49 +08:00
|
|
|
GimpImageType new_type;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-06-07 03:07:59 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2001-12-13 07:48:18 +08:00
|
|
|
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
|
|
|
return;
|
|
|
|
|
2003-08-28 01:21:49 +08:00
|
|
|
new_type = gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer));
|
|
|
|
|
|
|
|
/* Allocate the new tiles */
|
|
|
|
new_tiles = tile_manager_new (GIMP_ITEM (layer)->width,
|
2006-04-12 20:49:29 +08:00
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
GIMP_IMAGE_TYPE_BYTES (new_type));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Configure the pixel regions */
|
2003-08-28 01:21:49 +08:00
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
FALSE);
|
2003-08-28 01:21:49 +08:00
|
|
|
pixel_region_init (&destPR, new_tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Add an alpha channel */
|
|
|
|
add_alpha_region (&srcPR, &destPR);
|
|
|
|
|
2004-03-14 19:34:31 +08:00
|
|
|
/* Set the new tiles */
|
2004-03-16 03:34:35 +08:00
|
|
|
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer),
|
2004-11-16 21:41:55 +08:00
|
|
|
gimp_item_is_attached (GIMP_ITEM (layer)),
|
|
|
|
_("Add Alpha Channel"),
|
2004-03-16 03:34:35 +08:00
|
|
|
new_tiles, new_type,
|
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y);
|
2004-03-14 19:34:31 +08:00
|
|
|
tile_manager_unref (new_tiles);
|
2000-02-27 02:46:08 +08:00
|
|
|
}
|
|
|
|
|
2005-08-08 00:38:35 +08:00
|
|
|
void
|
|
|
|
gimp_layer_flatten (GimpLayer *layer,
|
|
|
|
GimpContext *context)
|
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
TileManager *new_tiles;
|
|
|
|
GimpImageType new_type;
|
|
|
|
guchar bg[4];
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
|
|
|
|
|
|
|
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
new_type = gimp_drawable_type_without_alpha (GIMP_DRAWABLE (layer));
|
|
|
|
|
2006-10-26 06:14:36 +08:00
|
|
|
gimp_image_get_background (gimp_item_get_image (GIMP_ITEM (layer)), context,
|
|
|
|
gimp_drawable_type (GIMP_DRAWABLE (layer)),
|
|
|
|
bg);
|
2005-08-08 00:38:35 +08:00
|
|
|
|
|
|
|
/* Allocate the new tiles */
|
|
|
|
new_tiles = tile_manager_new (GIMP_ITEM (layer)->width,
|
2006-04-12 20:49:29 +08:00
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
GIMP_IMAGE_TYPE_BYTES (new_type));
|
2005-08-08 00:38:35 +08:00
|
|
|
|
|
|
|
/* Configure the pixel regions */
|
|
|
|
pixel_region_init (&srcPR, GIMP_DRAWABLE (layer)->tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
FALSE);
|
2005-08-08 00:38:35 +08:00
|
|
|
pixel_region_init (&destPR, new_tiles,
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
TRUE);
|
2005-08-08 00:38:35 +08:00
|
|
|
|
|
|
|
/* Remove alpha channel */
|
|
|
|
flatten_region (&srcPR, &destPR, bg);
|
|
|
|
|
|
|
|
/* Set the new tiles */
|
|
|
|
gimp_drawable_set_tiles_full (GIMP_DRAWABLE (layer),
|
|
|
|
gimp_item_is_attached (GIMP_ITEM (layer)),
|
|
|
|
_("Remove Alpha Channel"),
|
|
|
|
new_tiles, new_type,
|
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y);
|
|
|
|
tile_manager_unref (new_tiles);
|
|
|
|
}
|
|
|
|
|
1999-11-27 22:00:26 +08:00
|
|
|
void
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_layer_resize_to_image (GimpLayer *layer,
|
|
|
|
GimpContext *context)
|
1999-11-27 22:00:26 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2001-01-29 00:44:22 +08:00
|
|
|
gint offset_x;
|
|
|
|
gint offset_y;
|
1999-11-27 22:00:26 +08:00
|
|
|
|
2002-06-07 03:07:59 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
2004-11-16 21:41:55 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (layer)));
|
2004-04-15 07:37:34 +08:00
|
|
|
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
2002-06-07 03:07:59 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (GIMP_ITEM (layer));
|
1999-11-27 22:00:26 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_ITEM_RESIZE,
|
2003-02-13 19:23:50 +08:00
|
|
|
_("Layer to Image Size"));
|
1999-11-27 22:00:26 +08:00
|
|
|
|
2004-04-15 07:37:34 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer), &offset_x, &offset_y);
|
|
|
|
gimp_item_resize (GIMP_ITEM (layer), context,
|
2006-03-29 01:08:36 +08:00
|
|
|
image->width, image->height, offset_x, offset_y);
|
1999-11-27 22:00:26 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_group_end (image);
|
1999-11-27 22:00:26 +08:00
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
BoundSeg *
|
2001-01-29 00:44:22 +08:00
|
|
|
gimp_layer_boundary (GimpLayer *layer,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint *num_segs)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-05-08 19:52:31 +08:00
|
|
|
GimpItem *item;
|
1997-11-25 06:05:25 +08:00
|
|
|
BoundSeg *new_segs;
|
|
|
|
|
2002-06-07 03:07:59 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Create the four boundary segments that encompass this
|
|
|
|
* layer's boundary.
|
|
|
|
*/
|
2001-01-29 00:44:22 +08:00
|
|
|
new_segs = g_new (BoundSeg, 4);
|
1997-11-25 06:05:25 +08:00
|
|
|
*num_segs = 4;
|
|
|
|
|
|
|
|
/* if the layer is a floating selection */
|
2001-01-29 00:44:22 +08:00
|
|
|
if (gimp_layer_is_floating_sel (layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-08-22 19:45:31 +08:00
|
|
|
if (GIMP_IS_CHANNEL (layer->fs.drawable))
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
/* if the owner drawable is a channel, just return nothing */
|
2001-01-29 00:44:22 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
g_free (new_segs);
|
|
|
|
*num_segs = 0;
|
|
|
|
return NULL;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
else
|
2006-04-12 20:49:29 +08:00
|
|
|
{
|
|
|
|
/* otherwise, set the layer to the owner drawable */
|
2001-01-29 00:44:22 +08:00
|
|
|
|
2006-04-12 20:49:29 +08:00
|
|
|
layer = GIMP_LAYER (layer->fs.drawable);
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
new_segs[0].x1 = item->offset_x;
|
|
|
|
new_segs[0].y1 = item->offset_y;
|
|
|
|
new_segs[0].x2 = item->offset_x;
|
|
|
|
new_segs[0].y2 = item->offset_y + item->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
new_segs[0].open = 1;
|
|
|
|
|
2003-06-24 06:02:56 +08:00
|
|
|
new_segs[1].x1 = item->offset_x;
|
2003-05-08 19:52:31 +08:00
|
|
|
new_segs[1].y1 = item->offset_y;
|
|
|
|
new_segs[1].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[1].y2 = item->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
new_segs[1].open = 1;
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
new_segs[2].x1 = item->offset_x + item->width;
|
|
|
|
new_segs[2].y1 = item->offset_y;
|
|
|
|
new_segs[2].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[2].y2 = item->offset_y + item->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
new_segs[2].open = 0;
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
new_segs[3].x1 = item->offset_x;
|
|
|
|
new_segs[3].y1 = item->offset_y + item->height;
|
|
|
|
new_segs[3].x2 = item->offset_x + item->width;
|
|
|
|
new_segs[3].y2 = item->offset_y + item->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
new_segs[3].open = 0;
|
|
|
|
|
|
|
|
return new_segs;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
/**********************/
|
|
|
|
/* access functions */
|
|
|
|
/**********************/
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-29 00:44:22 +08:00
|
|
|
GimpLayerMask *
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_layer_get_mask (const GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-12-13 07:48:18 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return layer->mask;
|
|
|
|
}
|
|
|
|
|
1999-08-22 19:45:31 +08:00
|
|
|
gboolean
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_layer_is_floating_sel (const GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 00:44:22 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
|
|
|
return (layer->fs.drawable != NULL);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
void
|
|
|
|
gimp_layer_set_opacity (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
gdouble opacity,
|
|
|
|
gboolean push_undo)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
opacity = CLAMP (opacity, GIMP_OPACITY_TRANSPARENT, GIMP_OPACITY_OPAQUE);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
if (layer->opacity != opacity)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer)))
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_push_layer_opacity (image, NULL, layer);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
}
|
2003-08-28 01:21:49 +08:00
|
|
|
|
2002-03-04 22:52:54 +08:00
|
|
|
layer->opacity = opacity;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (layer, layer_signals[OPACITY_CHANGED], 0);
|
2005-07-12 00:46:28 +08:00
|
|
|
g_object_notify (G_OBJECT (layer), "opacity");
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gdouble
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_layer_get_opacity (const GimpLayer *layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2002-03-04 01:38:12 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), GIMP_OPACITY_OPAQUE);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2002-06-07 03:07:59 +08:00
|
|
|
return layer->opacity;
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-12-09 07:12:59 +08:00
|
|
|
gimp_layer_set_mode (GimpLayer *layer,
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
GimpLayerModeEffects mode,
|
|
|
|
gboolean push_undo)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
|
|
|
if (layer->mode != mode)
|
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer)))
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_push_layer_mode (image, NULL, layer);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
}
|
2003-08-28 01:21:49 +08:00
|
|
|
|
2001-03-12 01:24:47 +08:00
|
|
|
layer->mode = mode;
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_emit (layer, layer_signals[MODE_CHANGED], 0);
|
2005-07-12 00:46:28 +08:00
|
|
|
g_object_notify (G_OBJECT (layer), "mode");
|
2001-07-08 06:49:01 +08:00
|
|
|
|
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
2006-04-12 20:49:29 +08:00
|
|
|
0, 0,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-12-09 07:12:59 +08:00
|
|
|
GimpLayerModeEffects
|
2001-12-13 07:48:18 +08:00
|
|
|
gimp_layer_get_mode (const GimpLayer *layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2001-12-09 07:12:59 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), GIMP_NORMAL_MODE);
|
2001-03-12 01:24:47 +08:00
|
|
|
|
|
|
|
return layer->mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-07-11 05:17:22 +08:00
|
|
|
gimp_layer_set_lock_alpha (GimpLayer *layer,
|
|
|
|
gboolean lock_alpha,
|
|
|
|
gboolean push_undo)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
lock_alpha = lock_alpha ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if (layer->lock_alpha != lock_alpha)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
2004-11-16 21:41:55 +08:00
|
|
|
if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer)))
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image = gimp_item_get_image (GIMP_ITEM (layer));
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_undo_push_layer_lock_alpha (image, NULL, layer);
|
Made drawable/layer properties (visibility, opacity etc.) undoable (fixes
2003-03-17 Michael Natterer <mitch@gimp.org>
Made drawable/layer properties (visibility, opacity etc.)
undoable (fixes bug #73893).
* app/core/core-enums.[ch]: added undo types/groups for
visibility, mode, opacity, linked and preserve_trans.
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpitemundo.[ch]: new GimpUndo subclass which holds a
ref'ed GimpItem pointer so (1) this doesn't need to be done by all
undo steps related to an item and (2) the item the undo step is
for can be determined from outside the undo system.
* app/core/gimpimage-undo.[ch]: added gimp_image_undo_push_item()
which returns a new GimpItemUndo.
* app/core/gimpimage-undo-push.[ch]: use it for all item related
undo steps. Removed lots of GimpItem, GimpLayer, GimpDrawable
and GimpVectors pointers from the private undo structs. Added
undo push functions for the new undo types added above.
* app/core/gimpdrawable.[ch] (gimp_drawable_set_visible): added
"gboolean push_undo" parameter.
* app/core/gimplayer.[ch] (gimp_layer_set_opacity, _mode,
_preserve_trans, _linked): added "gboolean push_undo" parameters.
* app/core/gimpimage-mask.c
* app/core/gimpimage-merge.c
* app/core/gimplayer-floating-sel.c
* app/tools/gimpmovetool.c
* app/xcf/xcf-load.c
* app/widgets/gimpdrawablelistitem.c
* app/widgets/gimplayerlistitem.c
* app/widgets/gimplayerlistview.c: changed accordingly.
* tools/pdbgen/pdb/channel.pdb
* tools/pdbgen/pdb/layer.pdb: ditto. Added '$undo' paramaters to
the foo_accessors() functions. Removed $func from foo_accesors()
because we don't manipulate items without using getters/setters
any longer.
* app/pdb/channel_cmds.c
* app/pdb/layer_cmds.c: regenerated.
* app/widgets/gimpcellrenderertoggle.[ch]: added "clicked" signal
which carries an additional "GdkModifierType state" parameter as
in GimpCellRendererViewable .
* app/widgets/gimpcontainertreeview.c: emit "clicked" from
the toggle renderer, not "toggled" so the callbacks get the
modifier state.
* app/widgets/gimpdrawabletreeview.c: resurrected the "exclusive
visible by <shift>+click" feature as in 1.2.
* app/widgets/gimplayertreeview.c: compress layer opacity undos by
looking at the top of the undo stack and not pushing an undo if
there already is a GIMP_UNDO_DRAWABLE_OPACITY for the active
layer.
2003-03-18 02:02:41 +08:00
|
|
|
}
|
2003-08-28 01:21:49 +08:00
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
layer->lock_alpha = lock_alpha;
|
2001-03-12 01:24:47 +08:00
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
g_signal_emit (layer, layer_signals[LOCK_ALPHA_CHANGED], 0);
|
2005-07-12 00:46:28 +08:00
|
|
|
g_object_notify (G_OBJECT (layer), "lock-alpha");
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
2005-07-11 05:17:22 +08:00
|
|
|
gimp_layer_get_lock_alpha (const GimpLayer *layer)
|
2001-03-12 01:24:47 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
|
|
|
|
2005-07-11 05:17:22 +08:00
|
|
|
return layer->lock_alpha;
|
2001-03-12 01:24:47 +08:00
|
|
|
}
|