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

(cherry picked from commit a11ada4ce2)
This commit is contained in:
woob 2019-12-19 22:58:31 -05:00 committed by Michael Natterer
parent 3bab2e60fa
commit b419aa5d10
4 changed files with 58 additions and 8 deletions

View file

@ -954,6 +954,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,

View file

@ -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);

View file

@ -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);

View file

@ -401,7 +401,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);