mirror of https://github.com/GNOME/gimp.git
app: make layers-mask-add-last-values multi-selection aware.
This commit is contained in:
parent
b2c11f8e95
commit
b5c8a259c8
|
@ -259,9 +259,9 @@ static const GimpActionEntry layers_actions[] =
|
||||||
GIMP_HELP_LAYER_CROP },
|
GIMP_HELP_LAYER_CROP },
|
||||||
|
|
||||||
{ "layers-mask-add", GIMP_ICON_LAYER_MASK,
|
{ "layers-mask-add", GIMP_ICON_LAYER_MASK,
|
||||||
NC_("layers-action", "Add La_yer Mask..."), NULL,
|
NC_("layers-action", "Add La_yer Masks..."), NULL,
|
||||||
NC_("layers-action",
|
NC_("layers-action",
|
||||||
"Add a mask that allows non-destructive editing of transparency"),
|
"Add masks to selected layers that allows non-destructive editing of transparency"),
|
||||||
layers_mask_add_cmd_callback,
|
layers_mask_add_cmd_callback,
|
||||||
GIMP_HELP_LAYER_MASK_ADD },
|
GIMP_HELP_LAYER_MASK_ADD },
|
||||||
|
|
||||||
|
@ -269,16 +269,16 @@ static const GimpActionEntry layers_actions[] =
|
||||||
* there is a mask on the layer
|
* there is a mask on the layer
|
||||||
*/
|
*/
|
||||||
{ "layers-mask-add-button", GIMP_ICON_LAYER_MASK,
|
{ "layers-mask-add-button", GIMP_ICON_LAYER_MASK,
|
||||||
NC_("layers-action", "Add La_yer Mask..."), NULL,
|
NC_("layers-action", "Add La_yer Masks..."), NULL,
|
||||||
NC_("layers-action",
|
NC_("layers-action",
|
||||||
"Add a mask that allows non-destructive editing of transparency"),
|
"Add masks to selected layers that allows non-destructive editing of transparency"),
|
||||||
layers_mask_add_cmd_callback,
|
layers_mask_add_cmd_callback,
|
||||||
GIMP_HELP_LAYER_MASK_ADD },
|
GIMP_HELP_LAYER_MASK_ADD },
|
||||||
|
|
||||||
{ "layers-mask-add-last-values", GIMP_ICON_LAYER_MASK,
|
{ "layers-mask-add-last-values", GIMP_ICON_LAYER_MASK,
|
||||||
NC_("layers-action", "Add La_yer Mask"), NULL,
|
NC_("layers-action", "Add La_yer Masks"), NULL,
|
||||||
NC_("layers-action",
|
NC_("layers-action",
|
||||||
"Add a mask with last used values"),
|
"Add mask to selected layers with last used values"),
|
||||||
layers_mask_add_last_vals_cmd_callback,
|
layers_mask_add_last_vals_cmd_callback,
|
||||||
GIMP_HELP_LAYER_MASK_ADD },
|
GIMP_HELP_LAYER_MASK_ADD },
|
||||||
|
|
||||||
|
@ -763,6 +763,7 @@ layers_actions_update (GimpActionGroup *group,
|
||||||
{
|
{
|
||||||
GimpImage *image = action_data_get_image (data);
|
GimpImage *image = action_data_get_image (data);
|
||||||
GList *layers = NULL;
|
GList *layers = NULL;
|
||||||
|
GList *iter = NULL;
|
||||||
GimpLayer *layer = NULL;
|
GimpLayer *layer = NULL;
|
||||||
GimpLayerMask *mask = NULL; /* layer mask */
|
GimpLayerMask *mask = NULL; /* layer mask */
|
||||||
gboolean fs = FALSE; /* floating sel */
|
gboolean fs = FALSE; /* floating sel */
|
||||||
|
@ -785,6 +786,8 @@ layers_actions_update (GimpActionGroup *group,
|
||||||
GList *prev = NULL;
|
GList *prev = NULL;
|
||||||
gboolean next_mode = FALSE;
|
gboolean next_mode = FALSE;
|
||||||
gboolean prev_mode = FALSE;
|
gboolean prev_mode = FALSE;
|
||||||
|
gboolean have_masks = FALSE; /* At least 1 selected layer has a mask. */
|
||||||
|
gboolean have_no_masks = FALSE; /* At least 1 selected layer has no mask. */
|
||||||
gint n_layers = 0;
|
gint n_layers = 0;
|
||||||
|
|
||||||
if (image)
|
if (image)
|
||||||
|
@ -797,8 +800,24 @@ layers_actions_update (GimpActionGroup *group,
|
||||||
layers = gimp_image_get_selected_layers (image);
|
layers = gimp_image_get_selected_layers (image);
|
||||||
n_layers = g_list_length (layers);
|
n_layers = g_list_length (layers);
|
||||||
|
|
||||||
|
for (iter = layers; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
if (gimp_layer_get_mask (iter->data))
|
||||||
|
have_masks = TRUE;
|
||||||
|
else
|
||||||
|
have_no_masks = TRUE;
|
||||||
|
|
||||||
|
/* have_masks and have_no_masks are not opposite. 3 cases are
|
||||||
|
* possible: all layers have masks, none have masks, or some
|
||||||
|
* have masks, and some none.
|
||||||
|
*/
|
||||||
|
if (have_masks && have_no_masks)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (n_layers == 1)
|
if (n_layers == 1)
|
||||||
{
|
{
|
||||||
|
/* Special unique layer case. */
|
||||||
GimpLayerMode *modes;
|
GimpLayerMode *modes;
|
||||||
GimpLayerMode mode;
|
GimpLayerMode mode;
|
||||||
const gchar *action = NULL;
|
const gchar *action = NULL;
|
||||||
|
@ -998,16 +1017,16 @@ layers_actions_update (GimpActionGroup *group,
|
||||||
SET_SENSITIVE ("layers-composite-mode-clip-to-layer", layer && cm_mutable);
|
SET_SENSITIVE ("layers-composite-mode-clip-to-layer", layer && cm_mutable);
|
||||||
SET_SENSITIVE ("layers-composite-mode-intersection", layer && cm_mutable);
|
SET_SENSITIVE ("layers-composite-mode-intersection", layer && cm_mutable);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask);
|
SET_SENSITIVE ("layers-mask-add", n_layers > 0 && !fs && !ac && mask);
|
||||||
SET_SENSITIVE ("layers-mask-add-button", layer && !fs && !ac);
|
SET_SENSITIVE ("layers-mask-add-button", n_layers > 0 && !fs && !ac);
|
||||||
SET_SENSITIVE ("layers-mask-add-last-values", layer && !fs && !ac && !mask);
|
SET_SENSITIVE ("layers-mask-add-last-values", n_layers > 0 && !fs && !ac && have_no_masks);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-mask-apply", writable && !fs && !ac && mask && !children);
|
SET_SENSITIVE ("layers-mask-apply", writable && !fs && !ac && mask && !children);
|
||||||
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-delete", layer && !fs && !ac && mask);
|
||||||
|
|
||||||
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-edit", layer && !fs && !ac && mask);
|
||||||
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-show", layer && !fs && !ac && mask);
|
||||||
SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac && mask);
|
SET_SENSITIVE ("layers-mask-disable", layer && !fs && !ac && mask);
|
||||||
|
|
||||||
SET_ACTIVE ("layers-mask-edit", mask && gimp_layer_get_edit_mask (layer));
|
SET_ACTIVE ("layers-mask-edit", mask && gimp_layer_get_edit_mask (layer));
|
||||||
SET_ACTIVE ("layers-mask-show", mask && gimp_layer_get_show_mask (layer));
|
SET_ACTIVE ("layers-mask-show", mask && gimp_layer_get_show_mask (layer));
|
||||||
|
|
|
@ -1062,17 +1062,15 @@ layers_mask_add_last_vals_cmd_callback (GimpAction *action,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpImage *image;
|
GimpImage *image;
|
||||||
GimpLayer *layer;
|
GList *layers;
|
||||||
|
GList *iter;
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
GimpDialogConfig *config;
|
GimpDialogConfig *config;
|
||||||
GimpChannel *channel = NULL;
|
GimpChannel *channel = NULL;
|
||||||
GimpLayerMask *mask;
|
GimpLayerMask *mask;
|
||||||
return_if_no_layer (image, layer, data);
|
return_if_no_layers (image, layers, data);
|
||||||
return_if_no_widget (widget, data);
|
return_if_no_widget (widget, data);
|
||||||
|
|
||||||
if (gimp_layer_get_mask (layer))
|
|
||||||
return;
|
|
||||||
|
|
||||||
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||||
|
|
||||||
if (config->layer_add_mask_type == GIMP_ADD_MASK_CHANNEL)
|
if (config->layer_add_mask_type == GIMP_ADD_MASK_CHANNEL)
|
||||||
|
@ -1093,14 +1091,35 @@ layers_mask_add_last_vals_cmd_callback (GimpAction *action,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mask = gimp_layer_create_mask (layer,
|
for (iter = layers; iter; iter = iter->next)
|
||||||
config->layer_add_mask_type,
|
{
|
||||||
channel);
|
if (! gimp_layer_get_mask (iter->data))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (iter == NULL)
|
||||||
|
/* No layers or they all have masks already. */
|
||||||
|
return;
|
||||||
|
|
||||||
if (config->layer_add_mask_invert)
|
gimp_image_undo_group_start (image,
|
||||||
gimp_channel_invert (GIMP_CHANNEL (mask), FALSE);
|
GIMP_UNDO_GROUP_LAYER_ADD,
|
||||||
|
_("Add Layer Masks"));
|
||||||
|
for (iter = layers; iter; iter = iter->next)
|
||||||
|
{
|
||||||
|
if (gimp_layer_get_mask (iter->data))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
mask = gimp_layer_create_mask (iter->data,
|
||||||
|
config->layer_add_mask_type,
|
||||||
|
channel);
|
||||||
|
|
||||||
|
if (config->layer_add_mask_invert)
|
||||||
|
gimp_channel_invert (GIMP_CHANNEL (mask), FALSE);
|
||||||
|
|
||||||
|
gimp_layer_add_mask (iter->data, mask, TRUE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gimp_image_undo_group_end (image);
|
||||||
|
|
||||||
gimp_layer_add_mask (layer, mask, TRUE, NULL);
|
|
||||||
gimp_image_flush (image);
|
gimp_image_flush (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue