Commit 62eedd41 authored by Jehan's avatar Jehan

app: layers-alpha-add|remove multi-layer aware.

parent da9284b7
Pipeline #200396 passed with stages
in 23 minutes and 45 seconds
......@@ -769,14 +769,12 @@ layers_actions_update (GimpActionGroup *group,
gboolean fs = FALSE; /* floating sel */
gboolean ac = FALSE; /* active channel */
gboolean sel = FALSE;
gboolean alpha = FALSE; /* alpha channel present */
gboolean indexed = FALSE; /* is indexed */
gboolean lock_alpha = TRUE;
gboolean can_lock_alpha = FALSE;
gboolean text_layer = FALSE;
gboolean writable = FALSE;
gboolean movable = FALSE;
gboolean children = FALSE;
gboolean bs_mutable = FALSE; /* At least 1 selected layers' blend space is mutable. */
gboolean cs_mutable = FALSE; /* At least 1 selected layers' composite space is mutable. */
gboolean cm_mutable = FALSE; /* At least 1 selected layers' composite mode is mutable. */
......@@ -792,6 +790,8 @@ layers_actions_update (GimpActionGroup *group,
gboolean have_writable = FALSE; /* At least 1 selected layer has no contents lock. */
gboolean have_prev = FALSE; /* At least 1 selected layer has a previous sibling. */
gboolean have_next = FALSE; /* At least 1 selected layer has a next sibling. */
gboolean have_alpha = FALSE; /* At least 1 selected layer has an alpha channel. */
gboolean have_no_alpha = FALSE; /* At least 1 selected layer has no alpha channel. */
gboolean all_visible = TRUE;
gboolean all_next_visible = TRUE;
......@@ -918,6 +918,11 @@ layers_actions_update (GimpActionGroup *group,
if (! gimp_item_get_visible (iter->data))
all_visible = FALSE;
if (gimp_drawable_has_alpha (iter->data))
have_alpha = TRUE;
else
have_no_alpha = TRUE;
if (have_masks && have_no_masks &&
have_groups && have_no_groups &&
have_writable && ! all_writable &&
......@@ -928,7 +933,8 @@ layers_actions_update (GimpActionGroup *group,
! prev_mode && ! next_mode &&
have_prev && have_next &&
bs_mutable && cs_mutable && cm_mutable &&
! all_visible && ! all_next_visible)
! all_visible && ! all_next_visible &&
have_alpha && have_no_alpha)
break;
}
......@@ -985,13 +991,9 @@ layers_actions_update (GimpActionGroup *group,
gimp_action_group_set_action_active (group, action, TRUE);
mask = gimp_layer_get_mask (layer);
alpha = gimp_drawable_has_alpha (GIMP_DRAWABLE (layer));
writable = ! gimp_item_is_content_locked (GIMP_ITEM (layer));
movable = ! gimp_item_is_position_locked (GIMP_ITEM (layer));
if (gimp_viewable_get_children (GIMP_VIEWABLE (layer)))
children = TRUE;
text_layer = gimp_item_is_text_layer (GIMP_ITEM (layer));
}
}
......@@ -1064,8 +1066,8 @@ layers_actions_update (GimpActionGroup *group,
SET_SENSITIVE ("layers-crop-to-selection", all_writable && all_movable && sel);
SET_SENSITIVE ("layers-crop-to-content", all_writable && all_movable);
SET_SENSITIVE ("layers-alpha-add", writable && !children && !fs && !alpha);
SET_SENSITIVE ("layers-alpha-remove", writable && !children && !fs && alpha);
SET_SENSITIVE ("layers-alpha-add", all_writable && have_no_groups && !fs && have_no_alpha);
SET_SENSITIVE ("layers-alpha-remove", all_writable && have_no_groups && !fs && have_alpha);
SET_SENSITIVE ("layers-lock-alpha", can_lock_alpha);
SET_ACTIVE ("layers-lock-alpha", lock_alpha);
......
......@@ -1651,14 +1651,19 @@ layers_alpha_add_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
GimpLayer *layer;
return_if_no_layer (image, layer, data);
GList *layers;
GList *iter;
return_if_no_layers (image, layers, data);
if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
{
gimp_layer_add_alpha (layer);
gimp_image_flush (image);
}
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_LAYER_ADD_ALPHA,
_("Add Alpha Channel"));
for (iter = layers; iter; iter = iter->next)
if (! gimp_drawable_has_alpha (iter->data))
gimp_layer_add_alpha (iter->data);
gimp_image_undo_group_end (image);
gimp_image_flush (image);
}
void
......@@ -1667,14 +1672,19 @@ layers_alpha_remove_cmd_callback (GimpAction *action,
gpointer data)
{
GimpImage *image;
GimpLayer *layer;
return_if_no_layer (image, layer, data);
GList *layers;
GList *iter;
return_if_no_layers (image, layers, data);
if (gimp_drawable_has_alpha (GIMP_DRAWABLE (layer)))
{
gimp_layer_remove_alpha (layer, action_data_get_context (data));
gimp_image_flush (image);
}
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_LAYER_ADD_ALPHA,
_("Remove Alpha Channel"));
for (iter = layers; iter; iter = iter->next)
if (gimp_drawable_has_alpha (iter->data))
gimp_layer_remove_alpha (iter->data, action_data_get_context (data));
gimp_image_undo_group_end (image);
gimp_image_flush (image);
}
void
......
......@@ -526,8 +526,10 @@ typedef enum /*< pdb-skip >*/
GIMP_UNDO_GROUP_ITEM_SCALE, /*< desc="Scale item" >*/
GIMP_UNDO_GROUP_ITEM_RESIZE, /*< desc="Resize item" >*/
GIMP_UNDO_GROUP_LAYER_ADD, /*< desc="Add layer" >*/
GIMP_UNDO_GROUP_LAYER_ADD_ALPHA, /*< desc="Add alpha channel" >*/
GIMP_UNDO_GROUP_LAYER_ADD_MASK, /*< desc="Add layer mask" >*/
GIMP_UNDO_GROUP_LAYER_APPLY_MASK, /*< desc="Apply layer mask" >*/
GIMP_UNDO_GROUP_LAYER_REMOVE_ALPHA, /*< desc="Remove alpha channel" >*/
GIMP_UNDO_GROUP_LAYER_LOCK_ALPHA, /*< desc="Lock/Unlock alpha channels" >*/
GIMP_UNDO_GROUP_LAYER_OPACITY, /*< desc="Set layers opacity" >*/
GIMP_UNDO_GROUP_LAYER_MODE, /*< desc="Set layers mode" >*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment