Commit 9860ad1b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/Makefile.am app/apptypes.h new widget derived from

2001-03-04  Michael Natterer  <mitch@gimp.org>

	* app/Makefile.am
	* app/apptypes.h
	* app/gimplayerlistitem.[ch]: new widget derived from
	GimpDrawableListItem (additionally displays the layer mask),

	* app/gimplistitem.[ch]: added the preview_size to the struct so
	subclasses can create previews at arbitrary times. Removed the
	"preview_size" parameter from "set_viewable".

	* app/gimpimage.[ch]: removed the layer mask functions because
	they belong to GimpLayer.

	* app/gimplayer.[ch]: folded the layer mask code from GimpImage
	into GimpLayer's layer mask functions. Added a "mask_changed"
	signal which is emitted when a mask is added/removed. Added
	"push_undo" parameters to the functions so we can use them from
	the undo system.

	* app/undo.c: instead of badly poking the GimpLayer struct, use
	the accessors with push_undo = FALSE.

	* app/gimage_mask.c
	* app/gimpdrawablelistitem.c
	* app/layers_dialog.c
	* app/xcf.c
	* app/pdb/image_cmds.c
	* tools/pdbgen/pdb/image.pdb: changed accordingly.
parent ed06832a
2001-03-04 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/apptypes.h
* app/gimplayerlistitem.[ch]: new widget derived from
GimpDrawableListItem (additionally displays the layer mask),
* app/gimplistitem.[ch]: added the preview_size to the struct so
subclasses can create previews at arbitrary times. Removed the
"preview_size" parameter from "set_viewable".
* app/gimpimage.[ch]: removed the layer mask functions because
they belong to GimpLayer.
* app/gimplayer.[ch]: folded the layer mask code from GimpImage
into GimpLayer's layer mask functions. Added a "mask_changed"
signal which is emitted when a mask is added/removed. Added
"push_undo" parameters to the functions so we can use them from
the undo system.
* app/undo.c: instead of badly poking the GimpLayer struct, use
the accessors with push_undo = FALSE.
* app/gimage_mask.c
* app/gimpdrawablelistitem.c
* app/layers_dialog.c
* app/xcf.c
* app/pdb/image_cmds.c
* tools/pdbgen/pdb/image.pdb: changed accordingly.
2001-03-04 Michael Natterer <mitch@gimp.org>
* app/gimpdrawable.[ch]: new function gimp_drawable_set_visible().
......
......@@ -303,6 +303,8 @@ gimp_SOURCES = \
gimpgradientpreview.c \
gimpimagepreview.h \
gimpimagepreview.c \
gimplayerlistitem.h \
gimplayerlistitem.c \
gimplistitem.h \
gimplistitem.c \
gimppalettepreview.h \
......
......@@ -101,6 +101,7 @@ typedef struct _GimpDrawableListView GimpDrawableListView;
typedef struct _GimpListItem GimpListItem;
typedef struct _GimpDrawableListItem GimpDrawableListItem;
typedef struct _GimpLayerListItem GimpLayerListItem;
typedef struct _HistogramWidget HistogramWidget;
......
......@@ -3306,113 +3306,6 @@ gimp_image_remove_layer (GimpImage *gimage,
gdisplays_update_full (gimage);
}
GimpLayerMask *
gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask)
{
LayerMaskUndo *lmu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
if (layer->mask != NULL)
{
g_message(_("Unable to add a layer mask since\nthe layer already has one."));
return (NULL);
}
if (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)))
{
g_message(_("Unable to add a layer mask to a\nlayer in an indexed image."));
return (NULL);
}
if (! gimp_layer_has_alpha (layer))
{
g_message (_("Cannot add layer mask to a layer\nwith no alpha channel."));
return (NULL);
}
if ((gimp_drawable_width (GIMP_DRAWABLE (layer)) !=
gimp_drawable_width (GIMP_DRAWABLE (mask))) ||
(gimp_drawable_height (GIMP_DRAWABLE (layer)) !=
gimp_drawable_height (GIMP_DRAWABLE (mask))))
{
g_message(_("Cannot add layer mask of different dimensions than specified layer."));
return NULL;
}
gimp_layer_add_mask (layer, mask);
/* Prepare a layer undo and push it */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = mask;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO, lmu);
return mask;
}
GimpChannel *
gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode)
{
LayerMaskUndo *lmu;
gint off_x;
gint off_y;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
if (!layer || !layer->mask)
return NULL;
/* Start an undo group */
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO);
/* Prepare a layer mask undo--push it below */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = layer->mask;
lmu->mode = mode;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
gimp_layer_apply_mask (layer, mode);
/* Push the undo--Important to do it here, AFTER the call
* to layer_apply_mask, in case the undo push fails and the
* mask is deleted
*/
undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu);
/* end the undo group */
undo_push_group_end (gimage);
/* If applying actually changed the view */
if ((mode == APPLY && (!lmu->apply_mask || lmu->show_mask)) ||
(mode == DISCARD && ( lmu->apply_mask || lmu->show_mask)))
{
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
off_x, off_y,
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)));
}
return NULL;
}
gboolean
gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel)
......
......@@ -354,12 +354,6 @@ gboolean gimp_image_add_layer (GimpImage *gimage,
gint position);
void gimp_image_remove_layer (GimpImage *gimage,
GimpLayer *layer);
GimpLayerMask * gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
GimpChannel * gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode);
gboolean gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_lower_channel (GimpImage *gimage,
......
......@@ -334,9 +334,8 @@ gimage_mask_extract (GImage *gimage,
}
else if (cut_gimage && GIMP_IS_LAYER_MASK (drawable))
{
gimp_image_remove_layer_mask (gimage,
gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)),
DISCARD);
gimp_layer_apply_mask (gimp_layer_mask_get_layer (GIMP_LAYER_MASK (drawable)),
DISCARD, TRUE);
}
else if (cut_gimage && GIMP_IS_CHANNEL (drawable))
gimp_image_remove_channel (gimage, GIMP_CHANNEL (drawable));
......
......@@ -3306,113 +3306,6 @@ gimp_image_remove_layer (GimpImage *gimage,
gdisplays_update_full (gimage);
}
GimpLayerMask *
gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask)
{
LayerMaskUndo *lmu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
if (layer->mask != NULL)
{
g_message(_("Unable to add a layer mask since\nthe layer already has one."));
return (NULL);
}
if (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)))
{
g_message(_("Unable to add a layer mask to a\nlayer in an indexed image."));
return (NULL);
}
if (! gimp_layer_has_alpha (layer))
{
g_message (_("Cannot add layer mask to a layer\nwith no alpha channel."));
return (NULL);
}
if ((gimp_drawable_width (GIMP_DRAWABLE (layer)) !=
gimp_drawable_width (GIMP_DRAWABLE (mask))) ||
(gimp_drawable_height (GIMP_DRAWABLE (layer)) !=
gimp_drawable_height (GIMP_DRAWABLE (mask))))
{
g_message(_("Cannot add layer mask of different dimensions than specified layer."));
return NULL;
}
gimp_layer_add_mask (layer, mask);
/* Prepare a layer undo and push it */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = mask;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO, lmu);
return mask;
}
GimpChannel *
gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode)
{
LayerMaskUndo *lmu;
gint off_x;
gint off_y;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
if (!layer || !layer->mask)
return NULL;
/* Start an undo group */
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO);
/* Prepare a layer mask undo--push it below */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = layer->mask;
lmu->mode = mode;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
gimp_layer_apply_mask (layer, mode);
/* Push the undo--Important to do it here, AFTER the call
* to layer_apply_mask, in case the undo push fails and the
* mask is deleted
*/
undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu);
/* end the undo group */
undo_push_group_end (gimage);
/* If applying actually changed the view */
if ((mode == APPLY && (!lmu->apply_mask || lmu->show_mask)) ||
(mode == DISCARD && ( lmu->apply_mask || lmu->show_mask)))
{
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
off_x, off_y,
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)));
}
return NULL;
}
gboolean
gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel)
......
......@@ -354,12 +354,6 @@ gboolean gimp_image_add_layer (GimpImage *gimage,
gint position);
void gimp_image_remove_layer (GimpImage *gimage,
GimpLayer *layer);
GimpLayerMask * gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
GimpChannel * gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode);
gboolean gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_lower_channel (GimpImage *gimage,
......
......@@ -3306,113 +3306,6 @@ gimp_image_remove_layer (GimpImage *gimage,
gdisplays_update_full (gimage);
}
GimpLayerMask *
gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask)
{
LayerMaskUndo *lmu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
if (layer->mask != NULL)
{
g_message(_("Unable to add a layer mask since\nthe layer already has one."));
return (NULL);
}
if (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)))
{
g_message(_("Unable to add a layer mask to a\nlayer in an indexed image."));
return (NULL);
}
if (! gimp_layer_has_alpha (layer))
{
g_message (_("Cannot add layer mask to a layer\nwith no alpha channel."));
return (NULL);
}
if ((gimp_drawable_width (GIMP_DRAWABLE (layer)) !=
gimp_drawable_width (GIMP_DRAWABLE (mask))) ||
(gimp_drawable_height (GIMP_DRAWABLE (layer)) !=
gimp_drawable_height (GIMP_DRAWABLE (mask))))
{
g_message(_("Cannot add layer mask of different dimensions than specified layer."));
return NULL;
}
gimp_layer_add_mask (layer, mask);
/* Prepare a layer undo and push it */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = mask;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO, lmu);
return mask;
}
GimpChannel *
gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode)
{
LayerMaskUndo *lmu;
gint off_x;
gint off_y;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
if (!layer || !layer->mask)
return NULL;
/* Start an undo group */
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO);
/* Prepare a layer mask undo--push it below */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = layer->mask;
lmu->mode = mode;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
gimp_layer_apply_mask (layer, mode);
/* Push the undo--Important to do it here, AFTER the call
* to layer_apply_mask, in case the undo push fails and the
* mask is deleted
*/
undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu);
/* end the undo group */
undo_push_group_end (gimage);
/* If applying actually changed the view */
if ((mode == APPLY && (!lmu->apply_mask || lmu->show_mask)) ||
(mode == DISCARD && ( lmu->apply_mask || lmu->show_mask)))
{
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
off_x, off_y,
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)));
}
return NULL;
}
gboolean
gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel)
......
......@@ -354,12 +354,6 @@ gboolean gimp_image_add_layer (GimpImage *gimage,
gint position);
void gimp_image_remove_layer (GimpImage *gimage,
GimpLayer *layer);
GimpLayerMask * gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
GimpChannel * gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode);
gboolean gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_lower_channel (GimpImage *gimage,
......
......@@ -3306,113 +3306,6 @@ gimp_image_remove_layer (GimpImage *gimage,
gdisplays_update_full (gimage);
}
GimpLayerMask *
gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask)
{
LayerMaskUndo *lmu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
if (layer->mask != NULL)
{
g_message(_("Unable to add a layer mask since\nthe layer already has one."));
return (NULL);
}
if (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)))
{
g_message(_("Unable to add a layer mask to a\nlayer in an indexed image."));
return (NULL);
}
if (! gimp_layer_has_alpha (layer))
{
g_message (_("Cannot add layer mask to a layer\nwith no alpha channel."));
return (NULL);
}
if ((gimp_drawable_width (GIMP_DRAWABLE (layer)) !=
gimp_drawable_width (GIMP_DRAWABLE (mask))) ||
(gimp_drawable_height (GIMP_DRAWABLE (layer)) !=
gimp_drawable_height (GIMP_DRAWABLE (mask))))
{
g_message(_("Cannot add layer mask of different dimensions than specified layer."));
return NULL;
}
gimp_layer_add_mask (layer, mask);
/* Prepare a layer undo and push it */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = mask;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
undo_push_layer_mask (gimage, LAYER_MASK_ADD_UNDO, lmu);
return mask;
}
GimpChannel *
gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode)
{
LayerMaskUndo *lmu;
gint off_x;
gint off_y;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
if (!layer || !layer->mask)
return NULL;
/* Start an undo group */
undo_push_group_start (gimage, LAYER_APPLY_MASK_UNDO);
/* Prepare a layer mask undo--push it below */
lmu = g_new (LayerMaskUndo, 1);
lmu->layer = layer;
lmu->mask = layer->mask;
lmu->mode = mode;
lmu->apply_mask = layer->apply_mask;
lmu->edit_mask = layer->edit_mask;
lmu->show_mask = layer->show_mask;
gimp_layer_apply_mask (layer, mode);
/* Push the undo--Important to do it here, AFTER the call
* to layer_apply_mask, in case the undo push fails and the
* mask is deleted
*/
undo_push_layer_mask (gimage, LAYER_MASK_REMOVE_UNDO, lmu);
/* end the undo group */
undo_push_group_end (gimage);
/* If applying actually changed the view */
if ((mode == APPLY && (!lmu->apply_mask || lmu->show_mask)) ||
(mode == DISCARD && ( lmu->apply_mask || lmu->show_mask)))
{
gimp_viewable_invalidate_preview (GIMP_VIEWABLE (gimage));
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &off_x, &off_y);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[REPAINT],
off_x, off_y,
gimp_drawable_width (GIMP_DRAWABLE (layer)),
gimp_drawable_height (GIMP_DRAWABLE (layer)));
}
return NULL;
}
gboolean
gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel)
......
......@@ -354,12 +354,6 @@ gboolean gimp_image_add_layer (GimpImage *gimage,
gint position);
void gimp_image_remove_layer (GimpImage *gimage,
GimpLayer *layer);
GimpLayerMask * gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask);
GimpChannel * gimp_image_remove_layer_mask (GimpImage *gimage,
GimpLayer *layer,
MaskApplyMode mode);
gboolean gimp_image_raise_channel (GimpImage *gimage,
GimpChannel *channel);
gboolean gimp_image_lower_channel (GimpImage *gimage,
......
......@@ -3306,113 +3306,6 @@ gimp_image_remove_layer (GimpImage *gimage,
gdisplays_update_full (gimage);
}
GimpLayerMask *
gimp_image_add_layer_mask (GimpImage *gimage,
GimpLayer *layer,
GimpLayerMask *mask)
{
LayerMaskUndo *lmu;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
g_return_val_if_fail (GIMP_IS_LAYER_MASK (mask), NULL);
if (layer->mask != NULL)
{
g_message(_("Unable to add a layer mask since\nthe layer already has one."));
return (NULL);
}
if (gimp_drawable_is_indexed (GIMP_DRAWABLE (layer)))
{
g_message(_("Unable to add a layer mask to a\nlayer in an indexed image."));
return (NULL);
}
if (! gimp_layer_has_alpha (layer))
{