[gimp] app: do not forbid merging down floating layers, instead anchor them.



commit 40bc5307dcac2ad47f78a4caed0d564d5c21e836
Author: Jehan <jehan girinstud io>
Date:   Sun Dec 31 00:17:23 2017 +0100

    app: do not forbid merging down floating layers, instead anchor them.
    
    Anchoring a floating layer is basically equivalent to merge down. This
    is already what we do in other merging actions (flatten image and merge
    visible layers).

 app/core/gimpimage-merge.c |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)
---
diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c
index 138845e..41dcc14 100644
--- a/app/core/gimpimage-merge.c
+++ b/app/core/gimpimage-merge.c
@@ -239,13 +239,6 @@ gimp_image_merge_down (GimpImage      *image,
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (error == NULL || *error == NULL, NULL);
 
-  if (gimp_layer_is_floating_sel (current_layer))
-    {
-      g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED,
-                           _("Cannot merge down a floating selection."));
-      return NULL;
-    }
-
   for (list = gimp_item_get_container_iter (GIMP_ITEM (current_layer));
        list;
        list = g_list_next (list))
@@ -298,9 +291,22 @@ gimp_image_merge_down (GimpImage      *image,
                                GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE,
                                C_("undo-type", "Merge Down"));
 
-  layer = gimp_image_merge_layers (image,
-                                   gimp_item_get_container (GIMP_ITEM (current_layer)),
-                                   merge_list, context, merge_type);
+  if (gimp_layer_is_floating_sel (current_layer))
+    {
+      /* Merging down a floating selection is basically equivalent to
+       * anchoring it.
+       */
+      floating_sel_anchor (current_layer);
+      /* layer is already set to the right layer below the floating
+       * selection, on which we anchored. This will be the return value.
+       */
+    }
+  else
+    {
+      layer = gimp_image_merge_layers (image,
+                                       gimp_item_get_container (GIMP_ITEM (current_layer)),
+                                       merge_list, context, merge_type);
+    }
   g_slist_free (merge_list);
 
   gimp_image_undo_group_end (image);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]