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-17 05:37:03 +08:00
|
|
|
|
2000-04-28 01:27:28 +08:00
|
|
|
#include "config.h"
|
2000-01-26 07:06:12 +08:00
|
|
|
|
2002-02-22 06:19:45 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "core-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-15 19:25:25 +08:00
|
|
|
#include "base/boundary.h"
|
|
|
|
#include "base/pixel-region.h"
|
|
|
|
#include "base/tile-manager.h"
|
|
|
|
|
2001-04-07 23:58:26 +08:00
|
|
|
#include "paint-funcs/paint-funcs.h"
|
|
|
|
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "gimpimage.h"
|
2003-02-13 19:23:50 +08:00
|
|
|
#include "gimpimage-undo.h"
|
2003-02-14 22:14:29 +08:00
|
|
|
#include "gimpimage-undo-push.h"
|
2002-02-22 06:19:45 +08:00
|
|
|
#include "gimplayer.h"
|
|
|
|
#include "gimplayer-floating-sel.h"
|
|
|
|
#include "gimplayermask.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_attach (GimpLayer *layer,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-08 10:01:52 +08:00
|
|
|
GimpImage *gimage;
|
2001-01-29 07:25:25 +08:00
|
|
|
GimpLayer *floating_sel;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
2004-01-27 00:18:16 +08:00
|
|
|
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (drawable != GIMP_DRAWABLE (layer));
|
|
|
|
g_return_if_fail (gimp_item_get_image (GIMP_ITEM (layer)) ==
|
|
|
|
gimp_item_get_image (GIMP_ITEM (drawable)));
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
|
|
|
|
|
2004-03-23 17:40:16 +08:00
|
|
|
floating_sel = gimp_image_floating_sel (gimage);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* If there is already a floating selection, anchor it */
|
2004-03-23 17:40:16 +08:00
|
|
|
if (floating_sel)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-03-23 17:40:16 +08:00
|
|
|
floating_sel_anchor (floating_sel);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-14 03:25:34 +08:00
|
|
|
/* if we were pasting to the old floating selection, paste now
|
|
|
|
* to the drawable
|
|
|
|
*/
|
2004-03-23 05:23:12 +08:00
|
|
|
if (drawable == (GimpDrawable *) floating_sel)
|
2000-12-30 08:16:50 +08:00
|
|
|
drawable = gimp_image_active_drawable (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* set the drawable and allocate a backing store */
|
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
|
|
|
gimp_layer_set_preserve_trans (layer, TRUE, FALSE);
|
2003-12-09 23:37:46 +08:00
|
|
|
layer->fs.drawable = drawable;
|
|
|
|
layer->fs.backing_store = tile_manager_new (GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
gimp_drawable_bytes (drawable));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* add the layer to the gimage */
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_add_layer (gimage, layer, 0);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* store the affected area from the drawable in the backing store */
|
|
|
|
floating_sel_rigor (layer, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_remove (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-08 10:01:52 +08:00
|
|
|
GimpImage *gimage;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer->fs.drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-03-29 17:57:39 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_FS_REMOVE,
|
|
|
|
_("Remove Floating Selection"));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* store the affected area from the drawable in the backing store */
|
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
|
2004-09-20 00:56:03 +08:00
|
|
|
/* Invalidate the preview of the obscured drawable. We do this here
|
1997-11-25 06:05:25 +08:00
|
|
|
* because it will not be done until the floating selection is removed,
|
2004-09-20 00:56:03 +08:00
|
|
|
* at which point the obscured drawable's preview will not be declared
|
|
|
|
* invalid.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
2001-02-05 06:10:54 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* remove the layer from the gimage */
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_remove_layer (gimage, layer);
|
2004-03-29 17:57:39 +08:00
|
|
|
|
|
|
|
gimp_image_undo_group_end (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_anchor (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-01-22 09:07:33 +08:00
|
|
|
GimpImage *gimage;
|
|
|
|
GimpDrawable *drawable;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
2001-07-14 03:25:34 +08:00
|
|
|
|
2001-01-29 07:25:25 +08:00
|
|
|
if (! gimp_layer_is_floating_sel (layer))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Cannot anchor this layer because "
|
2001-07-14 03:25:34 +08:00
|
|
|
"it is not a floating selection."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start a floating selection anchoring undo */
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_FS_ANCHOR,
|
|
|
|
_("Anchor Floating Selection"));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-02-05 06:10:54 +08:00
|
|
|
/* Invalidate the previews of the layer that will be composited
|
|
|
|
* with the floating section.
|
|
|
|
*/
|
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->fs.drawable));
|
1999-09-12 05:51:08 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Relax the floating selection */
|
|
|
|
floating_sel_relax (layer, TRUE);
|
|
|
|
|
|
|
|
/* Composite the floating selection contents */
|
1999-08-22 19:45:31 +08:00
|
|
|
floating_sel_composite (layer,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-22 09:07:33 +08:00
|
|
|
drawable = layer->fs.drawable;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* remove the floating selection */
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_remove_layer (gimage, layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* end the group undo */
|
2003-02-13 19:23:50 +08:00
|
|
|
gimp_image_undo_group_end (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* invalidate the boundaries */
|
2003-09-04 19:44:57 +08:00
|
|
|
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (gimp_image_get_mask (gimage)));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-01-26 23:34:47 +08:00
|
|
|
floating_sel_activate_drawable (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-03-08 10:01:52 +08:00
|
|
|
GimpImage *gimage;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
|
|
|
gimage = gimp_item_get_image (GIMP_ITEM (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* set the underlying drawable to active */
|
2004-01-26 23:34:47 +08:00
|
|
|
if (GIMP_IS_LAYER_MASK (layer->fs.drawable))
|
2001-02-25 22:37:12 +08:00
|
|
|
{
|
2004-01-26 23:34:47 +08:00
|
|
|
GimpLayerMask *mask = GIMP_LAYER_MASK (layer->fs.drawable);
|
|
|
|
|
|
|
|
gimp_image_set_active_layer (gimage, gimp_layer_mask_get_layer (mask));
|
2001-02-25 22:37:12 +08:00
|
|
|
}
|
1999-08-22 19:45:31 +08:00
|
|
|
else if (GIMP_IS_CHANNEL (layer->fs.drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-12-30 08:16:50 +08:00
|
|
|
gimp_image_set_active_channel (gimage, GIMP_CHANNEL (layer->fs.drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2004-01-26 23:34:47 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
gimp_image_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable));
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_to_layer (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-05-08 22:06:03 +08:00
|
|
|
GimpItem *item;
|
2001-03-08 10:01:52 +08:00
|
|
|
GimpImage *gimage;
|
2002-02-24 01:29:19 +08:00
|
|
|
gint off_x, off_y;
|
|
|
|
gint width, height;
|
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-05-08 22:06:03 +08:00
|
|
|
item = GIMP_ITEM (layer);
|
|
|
|
|
|
|
|
if (! (gimage = gimp_item_get_image (item)))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* Check if the floating layer belongs to a channel... */
|
1999-08-22 19:45:31 +08:00
|
|
|
if (GIMP_IS_CHANNEL (layer->fs.drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2003-11-14 23:33:40 +08:00
|
|
|
g_message (_("Cannot create a new layer from the floating selection "
|
|
|
|
"because it belongs to a layer mask or channel."));
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* restore the contents of the drawable */
|
1999-08-22 19:45:31 +08:00
|
|
|
floating_sel_restore (layer,
|
2003-05-08 22:06:03 +08:00
|
|
|
item->offset_x,
|
|
|
|
item->offset_y,
|
|
|
|
item->width,
|
|
|
|
item->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* determine whether the resulting layer needs an update */
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer->fs.drawable), &off_x, &off_y);
|
|
|
|
|
2003-05-08 21:12:46 +08:00
|
|
|
width = gimp_item_width (GIMP_ITEM (layer->fs.drawable));
|
|
|
|
height = gimp_item_height (GIMP_ITEM (layer->fs.drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
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
|
|
|
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_FS_TO_LAYER,
|
|
|
|
_("Floating Selection to Layer"));
|
|
|
|
|
|
|
|
gimp_image_undo_push_fs_to_layer (gimage, NULL,
|
|
|
|
layer, layer->fs.drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* clear the selection */
|
2003-09-04 19:33:06 +08:00
|
|
|
gimp_drawable_invalidate_boundary (GIMP_DRAWABLE (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Set pointers */
|
2002-02-24 01:29:19 +08:00
|
|
|
layer->fs.drawable = NULL;
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage->floating_sel = NULL;
|
2003-09-12 03:52:29 +08:00
|
|
|
gimp_item_set_visible (GIMP_ITEM (layer), TRUE, TRUE);
|
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
|
|
|
|
|
|
|
gimp_image_undo_group_end (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-09-22 20:46:35 +08:00
|
|
|
gimp_object_name_changed (GIMP_OBJECT (layer));
|
|
|
|
|
2001-07-08 06:49:01 +08:00
|
|
|
gimp_drawable_update (GIMP_DRAWABLE (layer),
|
|
|
|
0, 0,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
2003-08-30 22:25:05 +08:00
|
|
|
|
2001-05-08 09:32:25 +08:00
|
|
|
gimp_image_floating_selection_changed (gimage);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_store (GimpLayer *layer,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
2001-01-29 07:25:25 +08:00
|
|
|
gint offx, offy;
|
|
|
|
gint x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Check the backing store & make sure it has the correct dimensions */
|
2003-05-08 21:12:46 +08:00
|
|
|
if ((tile_manager_width (layer->fs.backing_store) !=
|
|
|
|
gimp_item_width (GIMP_ITEM(layer))) ||
|
|
|
|
(tile_manager_height (layer->fs.backing_store) !=
|
|
|
|
gimp_item_height (GIMP_ITEM(layer))) ||
|
|
|
|
(tile_manager_bpp (layer->fs.backing_store) !=
|
|
|
|
gimp_drawable_bytes (layer->fs.drawable)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* free the backing store and allocate anew */
|
2003-05-27 01:02:06 +08:00
|
|
|
tile_manager_unref (layer->fs.backing_store);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-01-15 05:11:52 +08:00
|
|
|
layer->fs.backing_store =
|
2003-05-08 19:52:31 +08:00
|
|
|
tile_manager_new (GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height,
|
2001-01-15 05:11:52 +08:00
|
|
|
gimp_drawable_bytes (layer->fs.drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* What this function does is save the specified area of the
|
|
|
|
* drawable that this floating selection obscures. We do this so
|
|
|
|
* that it will be possible to subsequently restore the drawable's area
|
|
|
|
*/
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer->fs.drawable), &offx, &offy);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Find the minimum area we need to uncover -- in gimage space */
|
2003-05-08 19:52:31 +08:00
|
|
|
x1 = MAX (GIMP_ITEM (layer)->offset_x, offx);
|
|
|
|
y1 = MAX (GIMP_ITEM (layer)->offset_y, offy);
|
|
|
|
x2 = MIN (GIMP_ITEM (layer)->offset_x + GIMP_ITEM (layer)->width,
|
2003-05-08 21:12:46 +08:00
|
|
|
offx + gimp_item_width (GIMP_ITEM (layer->fs.drawable)));
|
2003-05-08 19:52:31 +08:00
|
|
|
y2 = MIN (GIMP_ITEM (layer)->offset_y + GIMP_ITEM (layer)->height,
|
2003-05-08 21:12:46 +08:00
|
|
|
offy + gimp_item_height (GIMP_ITEM (layer->fs.drawable)));
|
2000-01-26 07:06:12 +08:00
|
|
|
|
|
|
|
x1 = CLAMP (x, x1, x2);
|
|
|
|
y1 = CLAMP (y, y1, y2);
|
|
|
|
x2 = CLAMP (x + w, x1, x2);
|
|
|
|
y2 = CLAMP (y + h, y1, y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if ((x2 - x1) > 0 && (y2 - y1) > 0)
|
|
|
|
{
|
|
|
|
/* Copy the area from the drawable to the backing store */
|
2001-01-15 05:11:52 +08:00
|
|
|
pixel_region_init (&srcPR, gimp_drawable_data (layer->fs.drawable),
|
1997-11-25 06:05:25 +08:00
|
|
|
(x1 - offx), (y1 - offy), (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, layer->fs.backing_store,
|
2003-05-08 19:52:31 +08:00
|
|
|
(x1 - GIMP_ITEM (layer)->offset_x),
|
|
|
|
(y1 - GIMP_ITEM (layer)->offset_y),
|
2000-01-26 07:06:12 +08:00
|
|
|
(x2 - x1), (y2 - y1), TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_restore (GimpLayer *layer,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
2001-01-29 07:25:25 +08:00
|
|
|
gint offx, offy;
|
|
|
|
gint x1, y1, x2, y2;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* What this function does is "uncover" the specified area in the
|
|
|
|
* drawable that this floating selection obscures. We do this so
|
|
|
|
* that either the floating selection can be removed or it can be
|
|
|
|
* translated
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Find the minimum area we need to uncover -- in gimage space */
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer->fs.drawable), &offx, &offy);
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
x1 = MAX (GIMP_ITEM (layer)->offset_x, offx);
|
|
|
|
y1 = MAX (GIMP_ITEM (layer)->offset_y, offy);
|
|
|
|
x2 = MIN (GIMP_ITEM (layer)->offset_x + GIMP_ITEM (layer)->width,
|
2003-05-08 21:12:46 +08:00
|
|
|
offx + gimp_item_width (GIMP_ITEM (layer->fs.drawable)));
|
2003-05-08 19:52:31 +08:00
|
|
|
y2 = MIN (GIMP_ITEM(layer)->offset_y + GIMP_ITEM (layer)->height,
|
2003-05-08 21:12:46 +08:00
|
|
|
offy + gimp_item_height (GIMP_ITEM (layer->fs.drawable)));
|
2000-01-26 07:06:12 +08:00
|
|
|
|
|
|
|
x1 = CLAMP (x, x1, x2);
|
|
|
|
y1 = CLAMP (y, y1, y2);
|
|
|
|
x2 = CLAMP (x + w, x1, x2);
|
|
|
|
y2 = CLAMP (y + h, y1, y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if ((x2 - x1) > 0 && (y2 - y1) > 0)
|
|
|
|
{
|
|
|
|
/* Copy the area from the backing store to the drawable */
|
|
|
|
pixel_region_init (&srcPR, layer->fs.backing_store,
|
2003-05-08 19:52:31 +08:00
|
|
|
(x1 - GIMP_ITEM (layer)->offset_x),
|
|
|
|
(y1 - GIMP_ITEM (layer)->offset_y),
|
2000-01-26 07:06:12 +08:00
|
|
|
(x2 - x1), (y2 - y1), FALSE);
|
2001-01-15 05:11:52 +08:00
|
|
|
pixel_region_init (&destPR, gimp_drawable_data (layer->fs.drawable),
|
1997-11-25 06:05:25 +08:00
|
|
|
(x1 - offx), (y1 - offy), (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_rigor (GimpLayer *layer,
|
2003-02-14 22:14:29 +08:00
|
|
|
gboolean push_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* store the affected area from the drawable in the backing store */
|
2000-01-26 07:06:12 +08:00
|
|
|
floating_sel_store (layer,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
layer->fs.initial = TRUE;
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
if (push_undo)
|
|
|
|
gimp_image_undo_push_fs_rigor (gimp_item_get_image (GIMP_ITEM (layer)),
|
|
|
|
NULL,
|
|
|
|
layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_relax (GimpLayer *layer,
|
2003-02-14 22:14:29 +08:00
|
|
|
gboolean push_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* restore the contents of drawable the floating layer is attached to */
|
|
|
|
if (layer->fs.initial == FALSE)
|
2000-01-26 07:06:12 +08:00
|
|
|
floating_sel_restore (layer,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->offset_x,
|
|
|
|
GIMP_ITEM (layer)->offset_y,
|
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
layer->fs.initial = TRUE;
|
|
|
|
|
2003-02-14 22:14:29 +08:00
|
|
|
if (push_undo)
|
|
|
|
gimp_image_undo_push_fs_relax (gimp_item_get_image (GIMP_ITEM (layer)),
|
|
|
|
NULL,
|
|
|
|
layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_composite (GimpLayer *layer,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h,
|
2003-02-14 22:14:29 +08:00
|
|
|
gboolean push_undo)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-01-29 07:25:25 +08:00
|
|
|
PixelRegion fsPR;
|
2001-03-08 10:01:52 +08:00
|
|
|
GimpImage *gimage;
|
2004-01-26 23:34:47 +08:00
|
|
|
GimpLayer *d_layer = NULL;
|
2001-01-29 07:25:25 +08:00
|
|
|
gint preserve_trans;
|
|
|
|
gint active[MAX_CHANNELS];
|
|
|
|
gint offx, offy;
|
|
|
|
gint x1, y1, x2, y2;
|
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2002-02-26 01:58:50 +08:00
|
|
|
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
|
1997-11-25 06:05:25 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* What this function does is composite the specified area of the
|
|
|
|
* drawble with the floating selection. We do this when the gimage
|
|
|
|
* is constructed, before any other composition takes place.
|
|
|
|
*/
|
|
|
|
|
2001-03-05 00:52:37 +08:00
|
|
|
/* If this isn't the first composite,
|
|
|
|
* restore the image underneath
|
|
|
|
*/
|
1997-11-25 06:05:25 +08:00
|
|
|
if (! layer->fs.initial)
|
|
|
|
floating_sel_restore (layer, x, y, w, h);
|
2003-09-12 03:52:29 +08:00
|
|
|
else if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
1997-11-25 06:05:25 +08:00
|
|
|
layer->fs.initial = FALSE;
|
|
|
|
|
2001-03-05 00:52:37 +08:00
|
|
|
/* First restore what's behind the image if necessary,
|
|
|
|
* then check for visibility
|
|
|
|
*/
|
2003-09-12 03:52:29 +08:00
|
|
|
if (gimp_item_get_visible (GIMP_ITEM (layer)))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
/* Find the minimum area we need to composite -- in gimage space */
|
2003-05-08 22:06:03 +08:00
|
|
|
gimp_item_offsets (GIMP_ITEM (layer->fs.drawable), &offx, &offy);
|
|
|
|
|
2003-05-08 19:52:31 +08:00
|
|
|
x1 = MAX (GIMP_ITEM (layer)->offset_x, offx);
|
|
|
|
y1 = MAX (GIMP_ITEM (layer)->offset_y, offy);
|
|
|
|
x2 = MIN (GIMP_ITEM (layer)->offset_x +
|
|
|
|
GIMP_ITEM (layer)->width,
|
2003-05-08 21:12:46 +08:00
|
|
|
offx + gimp_item_width (GIMP_ITEM (layer->fs.drawable)));
|
2003-05-08 19:52:31 +08:00
|
|
|
y2 = MIN (GIMP_ITEM (layer)->offset_y +
|
|
|
|
GIMP_ITEM (layer)->height,
|
2003-05-08 21:12:46 +08:00
|
|
|
offy + gimp_item_height (GIMP_ITEM (layer->fs.drawable)));
|
2000-01-26 07:06:12 +08:00
|
|
|
|
|
|
|
x1 = CLAMP (x, x1, x2);
|
|
|
|
y1 = CLAMP (y, y1, y2);
|
|
|
|
x2 = CLAMP (x + w, x1, x2);
|
|
|
|
y2 = CLAMP (y + h, y1, y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if ((x2 - x1) > 0 && (y2 - y1) > 0)
|
|
|
|
{
|
|
|
|
/* composite the area from the layer to the drawable */
|
2000-01-26 07:06:12 +08:00
|
|
|
pixel_region_init (&fsPR, GIMP_DRAWABLE (layer)->tiles,
|
2003-05-08 19:52:31 +08:00
|
|
|
(x1 - GIMP_ITEM (layer)->offset_x),
|
|
|
|
(y1 - GIMP_ITEM (layer)->offset_y),
|
1997-11-25 06:05:25 +08:00
|
|
|
(x2 - x1), (y2 - y1), FALSE);
|
|
|
|
|
|
|
|
/* a kludge here to prevent the case of the drawable
|
|
|
|
* underneath having preserve transparency on, and disallowing
|
|
|
|
* the composited floating selection from being shown
|
|
|
|
*/
|
1999-08-22 19:45:31 +08:00
|
|
|
if (GIMP_IS_LAYER (layer->fs.drawable))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-01-22 15:02:57 +08:00
|
|
|
d_layer = GIMP_LAYER (layer->fs.drawable);
|
2001-03-12 01:24:47 +08:00
|
|
|
if ((preserve_trans = gimp_layer_get_preserve_trans (d_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
|
|
|
gimp_layer_set_preserve_trans (d_layer, FALSE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
preserve_trans = FALSE;
|
|
|
|
|
|
|
|
/* We need to set all gimage channels to active to make sure that
|
|
|
|
* nothing strange happens while applying the floating selection.
|
|
|
|
* It wouldn't make sense for the floating selection to be affected
|
|
|
|
* by the active gimage channels.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < MAX_CHANNELS; i++)
|
|
|
|
{
|
|
|
|
active[i] = gimage->active[i];
|
|
|
|
gimage->active[i] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply the fs with the undo specified by the value
|
|
|
|
* passed to this function
|
|
|
|
*/
|
2003-10-06 22:40:12 +08:00
|
|
|
gimp_drawable_apply_region (layer->fs.drawable, &fsPR,
|
|
|
|
push_undo, NULL,
|
|
|
|
layer->opacity,
|
|
|
|
layer->mode,
|
|
|
|
NULL,
|
|
|
|
(x1 - offx), (y1 - offy));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* restore preserve transparency */
|
|
|
|
if (preserve_trans)
|
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
|
|
|
gimp_layer_set_preserve_trans (d_layer, TRUE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* restore gimage active channels */
|
|
|
|
for (i = 0; i < MAX_CHANNELS; i++)
|
|
|
|
gimage->active[i] = active[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-08-30 22:25:05 +08:00
|
|
|
const BoundSeg *
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_boundary (GimpLayer *layer,
|
2001-01-29 21:51:23 +08:00
|
|
|
gint *n_segs)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PixelRegion bPR;
|
2001-01-29 21:51:23 +08:00
|
|
|
gint i;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
|
|
|
|
g_return_val_if_fail (gimp_layer_is_floating_sel (layer), NULL);
|
|
|
|
g_return_val_if_fail (n_segs != NULL, NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (layer->fs.boundary_known == FALSE)
|
|
|
|
{
|
|
|
|
if (layer->fs.segs)
|
|
|
|
g_free (layer->fs.segs);
|
|
|
|
|
|
|
|
/* find the segments */
|
2000-01-26 07:06:12 +08:00
|
|
|
pixel_region_init (&bPR, GIMP_DRAWABLE (layer)->tiles,
|
|
|
|
0, 0,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->width,
|
|
|
|
GIMP_ITEM (layer)->height, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
layer->fs.segs = find_mask_boundary (&bPR, &layer->fs.num_segs,
|
|
|
|
WithinBounds, 0, 0,
|
2003-05-08 19:52:31 +08:00
|
|
|
GIMP_ITEM (layer)->width,
|
2003-07-10 19:59:38 +08:00
|
|
|
GIMP_ITEM (layer)->height,
|
|
|
|
HALF_WAY);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* offset the segments */
|
|
|
|
for (i = 0; i < layer->fs.num_segs; i++)
|
|
|
|
{
|
2003-05-08 19:52:31 +08:00
|
|
|
layer->fs.segs[i].x1 += GIMP_ITEM (layer)->offset_x;
|
|
|
|
layer->fs.segs[i].y1 += GIMP_ITEM (layer)->offset_y;
|
|
|
|
layer->fs.segs[i].x2 += GIMP_ITEM (layer)->offset_x;
|
|
|
|
layer->fs.segs[i].y2 += GIMP_ITEM (layer)->offset_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
layer->fs.boundary_known = TRUE;
|
|
|
|
}
|
|
|
|
|
2001-01-29 21:51:23 +08:00
|
|
|
*n_segs = layer->fs.num_segs;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
return layer->fs.segs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-01-29 07:25:25 +08:00
|
|
|
floating_sel_invalidate (GimpLayer *layer)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-01-26 23:34:47 +08:00
|
|
|
g_return_if_fail (GIMP_IS_LAYER (layer));
|
|
|
|
g_return_if_fail (gimp_layer_is_floating_sel (layer));
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* Invalidate the attached-to drawable's preview */
|
2001-02-05 06:10:54 +08:00
|
|
|
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (layer->fs.drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Invalidate the boundary */
|
|
|
|
layer->fs.boundary_known = FALSE;
|
|
|
|
}
|