mirror of https://github.com/GNOME/gimp.git
app: allow "Lock alpha" to be set on layer groups.
It can be argued that layer groups can't be painted on, and that's probably the original reason, but it's really just the same as "Lock pixels". It is interesting to be able to lock alpha channels on a layer group to simply lock all its contents alpha channels.
This commit is contained in:
parent
ed59344406
commit
2e64bfc61b
|
@ -568,9 +568,11 @@ static gboolean
|
|||
check_drawable_alpha (GimpDrawable *drawable,
|
||||
gpointer data)
|
||||
{
|
||||
GimpLayer *locked_layer = NULL;
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable) &&
|
||||
GIMP_IS_LAYER (drawable) &&
|
||||
gimp_layer_get_lock_alpha (GIMP_LAYER (drawable)))
|
||||
gimp_layer_is_alpha_locked (GIMP_LAYER (drawable), &locked_layer))
|
||||
{
|
||||
Gimp *gimp = action_data_get_gimp (data);
|
||||
GimpDisplay *display = action_data_get_display (data);
|
||||
|
@ -581,7 +583,7 @@ check_drawable_alpha (GimpDrawable *drawable,
|
|||
gimp, G_OBJECT (display), GIMP_MESSAGE_WARNING,
|
||||
_("A selected layer's alpha channel is locked."));
|
||||
|
||||
gimp_tools_blink_lock_box (gimp, GIMP_ITEM (drawable));
|
||||
gimp_tools_blink_lock_box (gimp, GIMP_ITEM (locked_layer));
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -220,6 +220,8 @@ static void gimp_layer_srgb_to_pixel (GimpPickable *pickable,
|
|||
const Babl *format,
|
||||
gpointer pixel);
|
||||
|
||||
static gboolean gimp_layer_real_is_alpha_locked (GimpLayer *layer,
|
||||
GimpLayer **locked_layer);
|
||||
static void gimp_layer_real_translate (GimpLayer *layer,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
@ -468,6 +470,7 @@ gimp_layer_class_init (GimpLayerClass *klass)
|
|||
klass->apply_mask_changed = NULL;
|
||||
klass->edit_mask_changed = NULL;
|
||||
klass->show_mask_changed = NULL;
|
||||
klass->is_alpha_locked = gimp_layer_real_is_alpha_locked;
|
||||
klass->translate = gimp_layer_real_translate;
|
||||
klass->scale = gimp_layer_real_scale;
|
||||
klass->resize = gimp_layer_real_resize;
|
||||
|
@ -1488,7 +1491,8 @@ gimp_layer_get_active_components (GimpDrawable *drawable,
|
|||
/* first copy the image active channels */
|
||||
gimp_image_get_active_array (image, active);
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable) && layer->lock_alpha)
|
||||
if (gimp_drawable_has_alpha (drawable) &&
|
||||
gimp_layer_is_alpha_locked (layer, NULL))
|
||||
active[babl_format_get_n_components (format) - 1] = FALSE;
|
||||
}
|
||||
|
||||
|
@ -1499,7 +1503,8 @@ gimp_layer_get_active_mask (GimpDrawable *drawable)
|
|||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
GimpComponentMask mask = gimp_image_get_active_mask (image);
|
||||
|
||||
if (gimp_drawable_has_alpha (drawable) && layer->lock_alpha)
|
||||
if (gimp_drawable_has_alpha (drawable) &&
|
||||
gimp_layer_is_alpha_locked (layer, NULL))
|
||||
mask &= ~GIMP_COMPONENT_MASK_ALPHA;
|
||||
|
||||
return mask;
|
||||
|
@ -1627,6 +1632,26 @@ gimp_layer_srgb_to_pixel (GimpPickable *pickable,
|
|||
gimp_pickable_srgb_to_pixel (GIMP_PICKABLE (image), color, format, pixel);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_layer_real_is_alpha_locked (GimpLayer *layer,
|
||||
GimpLayer **locked_layer)
|
||||
{
|
||||
GimpItem *parent = gimp_item_get_parent (GIMP_ITEM (layer));
|
||||
|
||||
if (layer->lock_alpha)
|
||||
{
|
||||
if (locked_layer)
|
||||
*locked_layer = layer;
|
||||
}
|
||||
else if (parent &&
|
||||
gimp_layer_is_alpha_locked (GIMP_LAYER (parent), locked_layer))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return layer->lock_alpha;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_layer_real_translate (GimpLayer *layer,
|
||||
gint offset_x,
|
||||
|
@ -2899,12 +2924,17 @@ gimp_layer_can_lock_alpha (GimpLayer *layer)
|
|||
{
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
||||
|
||||
if (gimp_viewable_get_children (GIMP_VIEWABLE (layer)))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gimp_layer_is_alpha_locked (GimpLayer *layer,
|
||||
GimpLayer **locked_layer)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE);
|
||||
|
||||
return GIMP_LAYER_GET_CLASS (layer)->is_alpha_locked (layer, locked_layer);
|
||||
}
|
||||
|
||||
/* protected functions */
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ struct _GimpLayerClass
|
|||
void (* show_mask_changed) (GimpLayer *layer);
|
||||
|
||||
/* virtual functions */
|
||||
gboolean (* is_alpha_locked) (GimpLayer *layer,
|
||||
GimpLayer **locked_layer);
|
||||
|
||||
void (* translate) (GimpLayer *layer,
|
||||
gint offset_x,
|
||||
gint offset_y);
|
||||
|
@ -237,6 +240,8 @@ void gimp_layer_set_lock_alpha (GimpLayer *layer,
|
|||
gboolean push_undo);
|
||||
gboolean gimp_layer_get_lock_alpha (GimpLayer *layer);
|
||||
gboolean gimp_layer_can_lock_alpha (GimpLayer *layer);
|
||||
gboolean gimp_layer_is_alpha_locked (GimpLayer *layer,
|
||||
GimpLayer **locked_layer);
|
||||
|
||||
|
||||
/* protected */
|
||||
|
|
|
@ -915,24 +915,27 @@ gimp_paint_tool_check_alpha (GimpPaintTool *paint_tool,
|
|||
|
||||
if (klass->is_alpha_only && klass->is_alpha_only (paint_tool, drawable))
|
||||
{
|
||||
GimpLayer *locked_layer = NULL;
|
||||
|
||||
if (! gimp_drawable_has_alpha (drawable))
|
||||
{
|
||||
g_set_error_literal (
|
||||
error, GIMP_ERROR, GIMP_FAILED,
|
||||
_("The active layer does not have an alpha channel."));
|
||||
_("The selected drawable does not have an alpha channel."));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (GIMP_IS_LAYER (drawable) &&
|
||||
gimp_layer_get_lock_alpha (GIMP_LAYER (drawable)))
|
||||
gimp_layer_is_alpha_locked (GIMP_LAYER (drawable),
|
||||
&locked_layer))
|
||||
{
|
||||
g_set_error_literal (
|
||||
error, GIMP_ERROR, GIMP_FAILED,
|
||||
_("The active layer's alpha channel is locked."));
|
||||
_("The selected layer's alpha channel is locked."));
|
||||
|
||||
if (error)
|
||||
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (drawable));
|
||||
gimp_tools_blink_lock_box (display->gimp, GIMP_ITEM (locked_layer));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue