gimp/app/core/gimplayermask.c
Michael Natterer 7a6a8d9dbb Moved the undo step implementations to the core and pass around lots of
2003-02-14  Michael Natterer  <mitch@gimp.org>

	Moved the undo step implementations to the core and pass around
	lots of "const gchar *undo_desc". Fixes bug #104367.

	* app/Makefile.am
	* app/undo.[ch]: removed...

	* app/core/Makefile.am
	* app/core/gimpimage-undo-push.[ch]: ...and added here.

	* app/paint/Makefile.am
	* app/tools/Makefile.am
	* app/paint/gimppaintcore-undo.[ch]
	* app/tools/gimptransformtool-undo.[ch]: new files for the
	paint and transform undos.

	* app/core/gimppaintinfo.[ch]: added a blurb.

	* app/paint/gimpairbrush.c
	* app/paint/gimpclone.c
	* app/paint/gimpconvolve.c
	* app/paint/gimpdodgeburn.c
	* app/paint/gimperaser.c
	* app/paint/gimppaintbrush.c
	* app/paint/gimppaintcore.c
	* app/paint/gimppencil.c
	* app/paint/gimpsmudge.c
	* app/paint/paint-types.h
	* app/paint/paint.c: pass the blurb when registering the core.

	* app/core/gimpdrawable.[ch]
	* app/core/gimpimage.[ch]
	* app/core/gimpimage-mask-select.[ch]
	* app/core/gimpimage-mask.[ch]
	* app/core/gimpimagemap.[ch]
	* app/core/gimplayer-floating-sel.[ch]: added "undo_desc" parameters
	to all undo pushing helper functions.

	* app/undo_history.c
	* app/core/gimpchannel.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable-bucket-fill.c
	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpdrawable-equalize.c
	* app/core/gimpdrawable-invert.c
	* app/core/gimpdrawable-offset.c
	* app/core/gimpdrawable-transform.c
	* app/core/gimpedit.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage-crop.c
	* app/core/gimpimage-guides.c
	* app/core/gimpimage-merge.c
	* app/core/gimpimage-qmask.c
	* app/core/gimpimage-resize.c
	* app/core/gimpimage-scale.c
	* app/core/gimpimage-undo.c
	* app/core/gimpitem.c
	* app/core/gimplayer.c
	* app/core/gimplayermask.c
	* app/display/gimpdisplayshell-dnd.c
	* app/file/file-open.c
	* app/file/file-save.c
	* app/gui/channels-commands.c
	* app/gui/file-commands.c
	* app/gui/file-open-dialog.c
	* app/gui/image-commands.c
	* app/gui/layers-commands.c
	* app/gui/paths-dialog.c
	* app/gui/select-commands.c
	* app/gui/vectors-commands.c
	* app/text/gimptext-compat.c
	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpbucketfilltool.c
	* app/tools/gimpeditselectiontool.c
	* app/tools/gimpfreeselecttool.c
	* app/tools/gimpfuzzyselecttool.c
	* app/tools/gimpimagemaptool.c
	* app/tools/gimpinktool.c
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimpmovetool.c
	* app/tools/gimppainttool.c
	* app/tools/gimprectselecttool.c
	* app/tools/gimptexttool.c
	* app/tools/gimptransformtool.c
	* app/widgets/gimpchannellistview.c
	* app/widgets/gimpdrawablelistview.c
	* app/widgets/gimpselectioneditor.c
	* tools/pdbgen/pdb/color.pdb
	* tools/pdbgen/pdb/drawable.pdb
	* tools/pdbgen/pdb/guides.pdb
	* tools/pdbgen/pdb/layer.pdb
	* tools/pdbgen/pdb/selection.pdb
	* tools/pdbgen/pdb/selection_tools.pdb: changed accordingly: pass
	"undo_desc" strings, changed includes or simply removed inclusion
	of "undo.h". Some random cleanups.

	* tools/pdbgen/pdb/guides.pdb: cleaned up a lot. Fixed
	gimp_image_find_next_guide() to not return guides with
	position < 0 (and made it shorter and readable).

	* app/pdb/color_cmds.c
	* app/pdb/drawable_cmds.c
	* app/pdb/guides_cmds.c
	* app/pdb/layer_cmds.c
	* app/pdb/selection_cmds.c
	* app/pdb/selection_tools_cmds.c: regenerated.
2003-02-14 14:14:29 +00:00

297 lines
7.3 KiB
C

/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
#include "core-types.h"
#include "gimplayer.h"
#include "gimplayermask.h"
#include "gimpmarshal.h"
#include "libgimp/gimpintl.h"
enum
{
APPLY_CHANGED,
EDIT_CHANGED,
SHOW_CHANGED,
LAST_SIGNAL
};
static void gimp_layer_mask_class_init (GimpLayerMaskClass *klass);
static void gimp_layer_mask_init (GimpLayerMask *layer_mask);
static GimpItem * gimp_layer_mask_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha);
static guint layer_mask_signals[LAST_SIGNAL] = { 0 };
static GimpChannelClass *parent_class = NULL;
GType
gimp_layer_mask_get_type (void)
{
static GType layer_mask_type = 0;
if (! layer_mask_type)
{
static const GTypeInfo layer_mask_info =
{
sizeof (GimpLayerMaskClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) gimp_layer_mask_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GimpLayerMask),
0, /* n_preallocs */
(GInstanceInitFunc) gimp_layer_mask_init,
};
layer_mask_type = g_type_register_static (GIMP_TYPE_CHANNEL,
"GimpLayerMask",
&layer_mask_info, 0);
}
return layer_mask_type;
}
static void
gimp_layer_mask_class_init (GimpLayerMaskClass *klass)
{
GimpItemClass *item_class;
item_class = GIMP_ITEM_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
layer_mask_signals[APPLY_CHANGED] =
g_signal_new ("apply_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, apply_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_mask_signals[EDIT_CHANGED] =
g_signal_new ("edit_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, edit_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
layer_mask_signals[SHOW_CHANGED] =
g_signal_new ("show_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GimpLayerMaskClass, show_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
item_class->duplicate = gimp_layer_mask_duplicate;
}
static void
gimp_layer_mask_init (GimpLayerMask *layer_mask)
{
layer_mask->layer = NULL;
layer_mask->apply_mask = TRUE;
layer_mask->edit_mask = TRUE;
layer_mask->show_mask = FALSE;
}
static GimpItem *
gimp_layer_mask_duplicate (GimpItem *item,
GType new_type,
gboolean add_alpha)
{
GimpLayerMask *layer_mask;
GimpItem *new_item;
GimpLayerMask *new_layer_mask;
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);
if (! GIMP_IS_LAYER_MASK (new_item))
return new_item;
layer_mask = GIMP_LAYER_MASK (item);
new_layer_mask = GIMP_LAYER_MASK (new_item);
new_layer_mask->apply_mask = layer_mask->apply_mask;
new_layer_mask->edit_mask = layer_mask->edit_mask;
new_layer_mask->show_mask = layer_mask->show_mask;
return new_item;
}
GimpLayerMask *
gimp_layer_mask_new (GimpImage *gimage,
gint width,
gint height,
const gchar *name,
const GimpRGB *color)
{
GimpLayerMask *layer_mask;
layer_mask = g_object_new (GIMP_TYPE_LAYER_MASK, NULL);
gimp_drawable_configure (GIMP_DRAWABLE (layer_mask),
gimage,
0, 0, width, height,
GIMP_GRAY_IMAGE, name);
/* set the layer_mask color and opacity */
GIMP_CHANNEL (layer_mask)->color = *color;
GIMP_CHANNEL (layer_mask)->show_masked = TRUE;
/* selection mask variables */
GIMP_CHANNEL (layer_mask)->x2 = width;
GIMP_CHANNEL (layer_mask)->y2 = height;
return layer_mask;
}
void
gimp_layer_mask_set_layer (GimpLayerMask *layer_mask,
GimpLayer *layer)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
g_return_if_fail (! layer || GIMP_IS_LAYER (layer));
layer_mask->layer = layer;
}
GimpLayer *
gimp_layer_mask_get_layer (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), NULL);
return layer_mask->layer;
}
void
gimp_layer_mask_set_apply (GimpLayerMask *layer_mask,
gboolean apply)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->apply_mask != apply)
{
layer_mask->apply_mask = apply ? TRUE : FALSE;
if (layer_mask->layer)
{
GimpDrawable *drawable;
drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
}
g_signal_emit (layer_mask, layer_mask_signals[APPLY_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_apply (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->apply_mask;
}
void
gimp_layer_mask_set_edit (GimpLayerMask *layer_mask,
gboolean edit)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->edit_mask != edit)
{
layer_mask->edit_mask = edit ? TRUE : FALSE;
g_signal_emit (layer_mask, layer_mask_signals[EDIT_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_edit (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->edit_mask;
}
void
gimp_layer_mask_set_show (GimpLayerMask *layer_mask,
gboolean show)
{
g_return_if_fail (GIMP_IS_LAYER_MASK (layer_mask));
if (layer_mask->show_mask != show)
{
layer_mask->show_mask = show ? TRUE : FALSE;
if (layer_mask->layer)
{
GimpDrawable *drawable;
drawable = GIMP_DRAWABLE (layer_mask->layer);
gimp_drawable_update (drawable,
0, 0,
gimp_drawable_width (drawable),
gimp_drawable_height (drawable));
}
g_signal_emit (layer_mask, layer_mask_signals[SHOW_CHANGED], 0);
}
}
gboolean
gimp_layer_mask_get_show (const GimpLayerMask *layer_mask)
{
g_return_val_if_fail (GIMP_IS_LAYER_MASK (layer_mask), FALSE);
return layer_mask->show_mask;
}