[gimp] app: expand functionality of merge-down button



commit a11ada4ce2fa47d7e0a5e617abaff48d5cea06f3
Author: woob <thetoastcaper gmail com>
Date:   Thu Dec 19 22:58:31 2019 -0500

    app: expand functionality of merge-down button
    
    Adds a number of modifier keys to the layer dockable's new "Merge Down"
    button to access further functions, and adds among them a new action to
    merge visible layers using the dialog's last values, akin to those
    accompanying the New Layer and Add Layer Mask dialogs.
    
    Modifier keys are bound as follows:
      Shift -> Merge layer group
      Ctrl -> Merge visible layers
      Ctrl + Shift -> Merge visible layers from last used values
    
    The Merge Down button is kept sensitive even when the current layer
    can't be merged down to allow access to these functions

 app/actions/image-commands.c    | 22 ++++++++++++++++++++++
 app/actions/image-commands.h    |  3 +++
 app/actions/layers-actions.c    | 31 ++++++++++++++++++++++++-------
 app/widgets/gimplayertreeview.c | 10 +++++++++-
 4 files changed, 58 insertions(+), 8 deletions(-)
---
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index dd8f90d7a3..585ae6c1ff 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -951,6 +951,28 @@ image_merge_layers_cmd_callback (GimpAction *action,
   gtk_window_present (GTK_WINDOW (dialog));
 }
 
+void
+image_merge_layers_last_vals_cmd_callback (GimpAction *action,
+                                           GVariant   *value,
+                                           gpointer    data)
+{
+  GimpImage        *image;
+  GimpDisplay      *display;
+  GimpDialogConfig *config;
+  return_if_no_image (image, data);
+  return_if_no_display (display, data);
+
+  config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
+  image_merge_layers_callback (NULL,
+                               image,
+                               action_data_get_context (data),
+                               config->layer_merge_type,
+                               config->layer_merge_active_group_only,
+                               config->layer_merge_discard_invisible,
+                               display);
+}
+
 void
 image_flatten_image_cmd_callback (GimpAction *action,
                                   GVariant   *value,
diff --git a/app/actions/image-commands.h b/app/actions/image-commands.h
index f645f2f635..964ffb2ec5 100644
--- a/app/actions/image-commands.h
+++ b/app/actions/image-commands.h
@@ -83,6 +83,9 @@ void   image_crop_to_content_cmd_callback          (GimpAction *action,
 void   image_merge_layers_cmd_callback             (GimpAction *action,
                                                     GVariant   *value,
                                                     gpointer    data);
+void   image_merge_layers_last_vals_cmd_callback   (GimpAction *action,
+                                                    GVariant   *value,
+                                                    gpointer    data);
 void   image_flatten_image_cmd_callback            (GimpAction *action,
                                                     GVariant   *value,
                                                     gpointer    data);
diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c
index 86a3c7c18b..2100696b17 100644
--- a/app/actions/layers-actions.c
+++ b/app/actions/layers-actions.c
@@ -177,6 +177,15 @@ static const GimpActionEntry layers_actions[] =
     layers_merge_down_cmd_callback,
     GIMP_HELP_LAYER_MERGE_DOWN },
 
+  /* this is the same as layers-merge-down, except it's sensitive even if
+   * the layer can't be merged down
+   */
+  { "layers-merge-down-button", GIMP_ICON_LAYER_MERGE_DOWN,
+    NC_("layers-action", "Merge Do_wn"), NULL,
+    NC_("layers-action", "Merge this layer with the first visible layer below it"),
+    layers_merge_down_cmd_callback,
+    GIMP_HELP_LAYER_MERGE_DOWN },
+
   { "layers-merge-group", NULL,
     NC_("layers-action", "Merge Layer Group"), NULL,
     NC_("layers-action", "Merge the layer group's layers into one normal layer"),
@@ -189,6 +198,12 @@ static const GimpActionEntry layers_actions[] =
     image_merge_layers_cmd_callback,
     GIMP_HELP_IMAGE_MERGE_LAYERS },
 
+  { "layers-merge-layers-last-values", NULL,
+    NC_("layers-action", "Merge _Visible Layers"), NULL,
+    NC_("layers-action", "Merge all visible layers with last used values"),
+    image_merge_layers_last_vals_cmd_callback,
+    GIMP_HELP_IMAGE_MERGE_LAYERS },
+
   { "layers-flatten-image", NULL,
     NC_("layers-action", "_Flatten Image"), NULL,
     NC_("layers-action", "Merge all layers into one and remove transparency"),
@@ -937,13 +952,15 @@ layers_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("layers-lower",            layer && !fs && !ac && next);
   SET_SENSITIVE ("layers-lower-to-bottom",  layer && !fs && !ac && next);
 
-  SET_VISIBLE   ("layers-anchor",           layer &&  fs && !ac);
-  SET_VISIBLE   ("layers-merge-down",       !fs);
-  SET_SENSITIVE ("layers-merge-down",       layer && !fs && !ac && visible && next_visible);
-  SET_VISIBLE   ("layers-merge-group",      children);
-  SET_SENSITIVE ("layers-merge-group",      layer && !fs && !ac && children);
-  SET_SENSITIVE ("layers-merge-layers",     layer && !fs && !ac);
-  SET_SENSITIVE ("layers-flatten-image",    layer && !fs && !ac);
+  SET_VISIBLE   ("layers-anchor",            layer &&  fs && !ac);
+  SET_VISIBLE   ("layers-merge-down",        !fs);
+  SET_SENSITIVE ("layers-merge-down",        layer && !fs && !ac && visible && next_visible);
+  SET_VISIBLE   ("layers-merge-down-button", !fs);
+  SET_SENSITIVE ("layers-merge-down-button", layer && !fs && !ac);
+  SET_VISIBLE   ("layers-merge-group",       children);
+  SET_SENSITIVE ("layers-merge-group",       layer && !fs && !ac && children);
+  SET_SENSITIVE ("layers-merge-layers",      layer && !fs && !ac);
+  SET_SENSITIVE ("layers-flatten-image",     layer && !fs && !ac);
 
   SET_VISIBLE   ("layers-text-discard",       text_layer && !ac);
   SET_VISIBLE   ("layers-text-to-vectors",    text_layer && !ac);
diff --git a/app/widgets/gimplayertreeview.c b/app/widgets/gimplayertreeview.c
index 45f5c4fa1c..d2dbd5367b 100644
--- a/app/widgets/gimplayertreeview.c
+++ b/app/widgets/gimplayertreeview.c
@@ -389,7 +389,15 @@ gimp_layer_tree_view_constructed (GObject *object)
                          button, 5);
 
   button = gimp_editor_add_action_button (GIMP_EDITOR (layer_view), "layers",
-                                          "layers-merge-down", NULL);
+                                          "layers-merge-down-button",
+                                          "layers-merge-group",
+                                          GDK_SHIFT_MASK,
+                                          "layers-merge-layers",
+                                          GDK_CONTROL_MASK,
+                                          "layers-merge-layers-last-values",
+                                          GDK_CONTROL_MASK |
+                                          GDK_SHIFT_MASK,
+                                          NULL);
   gimp_container_view_enable_dnd (GIMP_CONTAINER_VIEW (layer_view),
                                   GTK_BUTTON (button),
                                   GIMP_TYPE_LAYER);


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