Commit 3c7bb378 authored by CDT 1998  Larry Ewing's avatar CDT 1998 Larry Ewing Committed by Larry Ewing
Browse files

app/gimpimage.[ch] app/gimage_cmds.[ch] Added merge down procedure, I'm

Mon Aug 31 16:33:11 CDT 1998  Larry Ewing  <lewing@gimp.org>

 	* app/gimpimage.[ch]
	* app/gimage_cmds.[ch]
	* app/layers_dialog.c: Added merge down procedure, I'm not really
	sure if this behaves the way people expect it to, so please send
	me any comments on what it actually should do.  It also needs a
	little testing, especially the pdb call.

	* app/gimpimage.c: cleaned up Seth's merge commit a little. Also
	changed the mode of a merged layer to normal, as this seems to be
	the proper thing.  Discussion is welcome here as well.
parent eeca444b
Mon Aug 31 16:33:11 CDT 1998 Larry Ewing <lewing@gimp.org>
* app/gimpimage.[ch]
* app/gimage_cmds.[ch]
* app/layers_dialog.c: Added merge down procedure, I'm not really
sure if this behaves the way people expect it to, so please send
me any comments on what it actually should do. It also needs a
little testing, especially the pdb call.
* app/gimpimage.c: cleaned up Seth's merge commit a little. Also
changed the mode of a merged layer to normal, as this seems to be
the proper thing. Discussion is welcome here as well.
Mon Aug 31 19:16:36 BST 1998 Adam D. Moss <adam@gimp.org>
* app/gimpimage.c: I'm pleased to say that lewing doesn't
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
layer_list = g_slist_next (layer_list);
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
}
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
g_slist_free (merge_list);
return layer;
}
else
{
g_message ("There are not enough visible layers for a merge down.");
g_slist_free (merge_list);
return NULL;
}
}
Layer *
gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_type)
......@@ -2495,14 +2542,17 @@ gimp_image_merge_layers (GimpImage *gimage, GSList *merge_list, MergeType merge_
}
else
{
/* The final merged layer inherits the attributes of the bottomost layer,
* with a notable exception: The resulting layer has an alpha channel
/* The final merged layer inherits the name of the bottom most layer
* and the resulting layer has an alpha channel
* whether or not the original did
* Opacity is set to 100% and the MODE is set to normal
*/
merge_layer = layer_new (gimage, (x2 - x1), (y2 - y1),
drawable_type_with_alpha (GIMP_DRAWABLE(layer)),
drawable_name (GIMP_DRAWABLE(layer)),
layer->opacity, layer->mode);
OPAQUE_OPACITY, NORMAL_MODE);
if (!merge_layer) {
g_message ("gimp_image_merge_layers: could not allocate merge layer");
......
......@@ -147,6 +147,7 @@ void gimp_image_set_layer_mask_show (GimpImage *, int);
Layer * gimp_image_raise_layer (GimpImage *, Layer *);
Layer * gimp_image_lower_layer (GimpImage *, Layer *);
Layer * gimp_image_merge_visible_layers (GimpImage *, MergeType);
Layer * gimp_image_merge_down (GimpImage *, Layer *, MergeType);
Layer * gimp_image_flatten (GimpImage *);
Layer * gimp_image_merge_layers (GimpImage *, GSList *, MergeType);
Layer * gimp_image_add_layer (GimpImage *, Layer *, int);
......
......@@ -2334,7 +2334,6 @@ gimp_image_merge_visible_layers (GimpImage *gimage, MergeType merge_type)
if (merge_list && merge_list->next)
{
layer = gimp_image_merge_layers (gimage, merge_list, merge_type);
layer->opacity = 255;
g_slist_free (merge_list);
return layer;
}
......@@ -2369,6 +2368,54 @@ gimp_image_flatten (GimpImage *gimage)
return layer;
}
Layer *
gimp_image_merge_down (GimpImage *gimage,
Layer *current_layer,
MergeType merge_type)
{
GSList *layer_list;
GSList *merge_list= NULL;
Layer *layer = NULL;
layer_list = gimage->layers;
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
layer = (Layer *) layer_list->data;
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);