Commit 8bfd02fa authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added a boolean "push_undo" parameter.

2002-06-06  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpchannel.[ch] (gimp_channel_invert): added a boolean
	"push_undo" parameter.

	* app/core/gimpimage-mask.c
	* app/core/gimpimage-qmask.c: pass push_undo == TRUE.

	* app/core/gimplayer.c (gimp_layer_create_mask): call
	gimp_channel_invert(), not gimp_drawable_invert() because the
	latter takes the current selection into accout (reported by Jimmac
	on #gimp). Added g_return_if_fail() stuff to all public functions.
	Cleanup.
parent 8c3f15b4
2002-06-06 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.[ch] (gimp_channel_invert): added a boolean
"push_undo" parameter.
* app/core/gimpimage-mask.c
* app/core/gimpimage-qmask.c: pass push_undo == TRUE.
* app/core/gimplayer.c (gimp_layer_create_mask): call
gimp_channel_invert(), not gimp_drawable_invert() because the
latter takes the current selection into accout (reported by Jimmac
on #gimp). Added g_return_if_fail() stuff to all public functions.
Cleanup.
2002-06-06 Michael Natterer <mitch@gimp.org>
* app/core/gimpcontainer.c (gimp_container_get_child_by_index):
......
......@@ -1322,15 +1322,16 @@ gimp_channel_all (GimpChannel *mask)
}
void
gimp_channel_invert (GimpChannel *mask)
gimp_channel_invert (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
GimpLut *lut;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
......@@ -1339,8 +1340,9 @@ gimp_channel_invert (GimpChannel *mask)
lut = invert_lut_new (1);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline,
lut, 1, &maskPR);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, lut,
1, &maskPR);
gimp_lut_free (lut);
mask->bounds_known = FALSE;
}
......
......@@ -160,7 +160,8 @@ void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask);
void gimp_channel_all (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
......
......@@ -1322,15 +1322,16 @@ gimp_channel_all (GimpChannel *mask)
}
void
gimp_channel_invert (GimpChannel *mask)
gimp_channel_invert (GimpChannel *mask,
gboolean push_undo)
{
PixelRegion maskPR;
GimpLut *lut;
g_return_if_fail (GIMP_IS_CHANNEL (mask));
/* push the current channel onto the undo stack */
gimp_channel_push_undo (mask);
if (push_undo)
gimp_channel_push_undo (mask);
pixel_region_init (&maskPR, GIMP_DRAWABLE (mask)->tiles,
0, 0,
......@@ -1339,8 +1340,9 @@ gimp_channel_invert (GimpChannel *mask)
lut = invert_lut_new (1);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline,
lut, 1, &maskPR);
pixel_regions_process_parallel ((p_func) gimp_lut_process_inline, lut,
1, &maskPR);
gimp_lut_free (lut);
mask->bounds_known = FALSE;
}
......
......@@ -160,7 +160,8 @@ void gimp_channel_push_undo (GimpChannel *mask);
void gimp_channel_clear (GimpChannel *mask);
void gimp_channel_all (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask);
void gimp_channel_invert (GimpChannel *mask,
gboolean push_undo);
void gimp_channel_border (GimpChannel *mask,
gint radius_x,
......
......@@ -436,7 +436,7 @@ gimp_image_mask_undo (GimpImage *gimage)
void
gimp_image_mask_invert (GimpImage *gimage)
{
gimp_channel_invert (gimp_image_get_mask (gimage));
gimp_channel_invert (gimp_image_get_mask (gimage), TRUE);
}
......
......@@ -104,7 +104,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
}
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_channel_invert (mask, TRUE);
undo_push_image_qmask (gimage);
......@@ -131,7 +131,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
undo_push_image_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_channel_invert (mask, TRUE);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
......@@ -167,7 +167,7 @@ gimp_image_qmask_invert (GimpImage *gimage)
if (qmask)
{
gimp_channel_invert (qmask);
gimp_channel_invert (qmask, TRUE);
gimp_drawable_update (GIMP_DRAWABLE (qmask),
0, 0,
......
......@@ -104,7 +104,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
}
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_channel_invert (mask, TRUE);
undo_push_image_qmask (gimage);
......@@ -131,7 +131,7 @@ gimp_image_set_qmask_state (GimpImage *gimage,
undo_push_image_qmask (gimage);
if (gimage->qmask_inverted)
gimp_channel_invert (mask);
gimp_channel_invert (mask, TRUE);
gimp_image_mask_load (gimage, mask);
gimp_image_remove_channel (gimage, mask);
......@@ -167,7 +167,7 @@ gimp_image_qmask_invert (GimpImage *gimage)
if (qmask)
{
gimp_channel_invert (qmask);
gimp_channel_invert (qmask, TRUE);
gimp_drawable_update (GIMP_DRAWABLE (qmask),
0, 0,
......
/* TODO: make sure has_alpha gets set */
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
......@@ -175,20 +173,23 @@ gimp_layer_class_init (GimpLayerClass *klass)
viewable_class->invalidate_preview = gimp_layer_invalidate_preview;
klass->opacity_changed = NULL;
klass->mode_changed = NULL;
klass->preserve_trans_changed = NULL;
klass->linked_changed = NULL;
klass->mask_changed = NULL;
}
static void
gimp_layer_init (GimpLayer *layer)
{
layer->linked = FALSE;
layer->opacity = GIMP_OPACITY_OPAQUE;
layer->mode = GIMP_NORMAL_MODE;
layer->preserve_trans = FALSE;
layer->linked = FALSE;
layer->mask = NULL;
layer->opacity = GIMP_OPACITY_OPAQUE;
layer->mode = GIMP_NORMAL_MODE;
/* floating selection */
layer->fs.backing_store = NULL;
layer->fs.drawable = NULL;
......@@ -253,11 +254,11 @@ gimp_layer_invalidate_preview (GimpViewable *viewable)
{
GimpLayer *layer;
layer = GIMP_LAYER (viewable);
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
layer = GIMP_LAYER (viewable);
if (gimp_layer_is_floating_sel (layer))
floating_sel_invalidate (layer);
}
......@@ -615,6 +616,8 @@ gimp_layer_create_mask (const GimpLayer *layer,
gchar *mask_name;
GimpRGB black = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
gimage = gimp_item_get_image (GIMP_ITEM (layer));
mask_name = g_strdup_printf (_("%s mask"),
......@@ -734,7 +737,7 @@ gimp_layer_create_mask (const GimpLayer *layer,
case GIMP_ADD_INVERSE_SELECTION_MASK:
case GIMP_ADD_INVERSE_COPY_MASK:
gimp_drawable_invert (GIMP_DRAWABLE (mask));
gimp_channel_invert (GIMP_CHANNEL (mask), FALSE);
break;
}
......@@ -840,6 +843,8 @@ gimp_layer_translate (GimpLayer *layer,
gint off_x,
gint off_y)
{
g_return_if_fail (GIMP_IS_LAYER (layer));
/* the undo call goes here */
undo_push_layer_displace (gimp_item_get_image (GIMP_ITEM (layer)), layer);
......@@ -880,6 +885,8 @@ gimp_layer_add_alpha (GimpLayer *layer)
GimpImageType type;
GimpImage *gimage;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
return;
......@@ -1022,6 +1029,8 @@ gimp_layer_check_scaling (const GimpLayer *layer,
gint new_layer_width;
gint new_layer_height;
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
gimage = gimp_item_get_image (GIMP_ITEM (layer));
img_scale_w = (gdouble) new_width / (gdouble) gimage->width;
img_scale_h = (gdouble) new_height / (gdouble) gimage->height;
......@@ -1070,6 +1079,8 @@ gimp_layer_scale_by_factors (GimpLayer *layer,
gint new_width, new_height;
gint new_offset_x, new_offset_y;
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
if (w_factor == 0.0 || h_factor == 0.0)
{
g_message ("gimp_layer_scale_by_factors: Error. Requested width or height scale equals zero.");
......@@ -1129,6 +1140,8 @@ gimp_layer_scale (GimpLayer *layer,
{
gint new_offset_x, new_offset_y;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (new_width == 0 || new_height == 0)
{
g_message ("gimp_layer_scale: Error. Requested width or height equals zero.");
......@@ -1172,6 +1185,8 @@ gimp_layer_resize (GimpLayer *layer,
gint w, h;
gint x1, y1, x2, y2;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (new_width < 1 || new_height < 1)
return;
......@@ -1286,6 +1301,8 @@ gimp_layer_resize_to_image (GimpLayer *layer)
gint offset_x;
gint offset_y;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
return;
......@@ -1309,6 +1326,8 @@ gimp_layer_boundary (GimpLayer *layer,
{
BoundSeg *new_segs;
g_return_val_if_fail (GIMP_IS_LAYER (layer), NULL);
/* Create the four boundary segments that encompass this
* layer's boundary.
*/
......@@ -1367,6 +1386,8 @@ gimp_layer_invalidate_boundary (GimpLayer *layer)
GimpImage *gimage;
GimpChannel *mask;
g_return_if_fail (GIMP_IS_LAYER (layer));
if (! (gimage = gimp_item_get_image (GIMP_ITEM (layer))))
return;
......@@ -1399,6 +1420,8 @@ gimp_layer_pick_correlate (GimpLayer *layer,
Tile *mask_tile;
gint val;
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
/* Is the point inside the layer?
* First transform the point to layer coordinates...
*/
......@@ -1492,7 +1515,7 @@ gimp_layer_get_opacity (const GimpLayer *layer)
{
g_return_val_if_fail (GIMP_IS_LAYER (layer), GIMP_OPACITY_OPAQUE);
return (gdouble) layer->opacity;
return layer->opacity;
}
void
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment