diff --git a/app/actions/layers-actions.c b/app/actions/layers-actions.c index 0b4f9c12f5..f4e4c80905 100644 --- a/app/actions/layers-actions.c +++ b/app/actions/layers-actions.c @@ -24,6 +24,8 @@ #include "actions-types.h" +#include "operations/layer-modes/gimp-layer-modes.h" + #include "core/gimpchannel.h" #include "core/gimpimage.h" #include "core/gimplayer.h" @@ -342,11 +344,6 @@ static const GimpRadioActionEntry layers_blend_space_actions[] = { "layers-blend-space-rgb-perceptual", NULL, NC_("layers-action", "RGB (perceptual)"), NULL, NULL, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - NULL }, - - { "layers-blend-space-lab", NULL, - NC_("layers-action", "LAB"), NULL, NULL, - GIMP_LAYER_COLOR_SPACE_LAB, NULL } }; @@ -365,11 +362,6 @@ static const GimpRadioActionEntry layers_composite_space_actions[] = { "layers-composite-space-rgb-perceptual", NULL, NC_("layers-action", "RGB (perceptual)"), NULL, NULL, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL, - NULL }, - - { "layers-composite-space-lab", NULL, - NC_("layers-action", "LAB"), NULL, NULL, - GIMP_LAYER_COLOR_SPACE_LAB, NULL } }; @@ -751,6 +743,9 @@ layers_actions_update (GimpActionGroup *group, gboolean writable = FALSE; gboolean movable = FALSE; gboolean children = FALSE; + gboolean bs_mutable = FALSE; + gboolean cs_mutable = FALSE; + gboolean cm_mutable = FALSE; GList *next = NULL; GList *next_visible = NULL; GList *prev = NULL; @@ -766,9 +761,10 @@ layers_actions_update (GimpActionGroup *group, if (layer) { - const gchar *action = NULL; - GList *layer_list; - GList *list; + GimpLayerMode mode = gimp_layer_get_mode (layer); + const gchar *action = NULL; + GList *layer_list; + GList *list; switch (gimp_layer_get_blend_space (layer)) { @@ -778,11 +774,12 @@ layers_actions_update (GimpActionGroup *group, action = "layers-blend-space-rgb-linear"; break; case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: action = "layers-blend-space-rgb-perceptual"; break; - case GIMP_LAYER_COLOR_SPACE_LAB: - action = "layers-blend-space-lab"; break; + default: + action = NULL; break; /* can't happen */ } - gimp_action_group_set_action_active (group, action, TRUE); + if (action) + gimp_action_group_set_action_active (group, action, TRUE); switch (gimp_layer_get_composite_space (layer)) { @@ -792,11 +789,12 @@ layers_actions_update (GimpActionGroup *group, action = "layers-composite-space-rgb-linear"; break; case GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL: action = "layers-composite-space-rgb-perceptual"; break; - case GIMP_LAYER_COLOR_SPACE_LAB: - action = "layers-composite-space-lab"; break; + default: + action = NULL; break; /* can't happen */ } - gimp_action_group_set_action_active (group, action, TRUE); + if (action) + gimp_action_group_set_action_active (group, action, TRUE); switch (gimp_layer_get_composite_mode (layer)) { @@ -814,6 +812,10 @@ layers_actions_update (GimpActionGroup *group, gimp_action_group_set_action_active (group, action, TRUE); + bs_mutable = gimp_layer_mode_is_blend_space_mutable (mode); + cs_mutable = gimp_layer_mode_is_composite_space_mutable (mode); + cm_mutable = gimp_layer_mode_is_composite_mode_mutable (mode); + mask = gimp_layer_get_mask (layer); lock_alpha = gimp_layer_get_lock_alpha (layer); can_lock_alpha = gimp_layer_can_lock_alpha (layer); @@ -919,21 +921,19 @@ layers_actions_update (GimpActionGroup *group, SET_SENSITIVE ("layers-lock-alpha", can_lock_alpha); SET_ACTIVE ("layers-lock-alpha", lock_alpha); - SET_SENSITIVE ("layers-blend-space-auto", layer); - SET_SENSITIVE ("layers-blend-space-rgb-linear", layer); - SET_SENSITIVE ("layers-blend-space-rgb-perceptual", layer); - SET_SENSITIVE ("layers-blend-space-lab", layer); + SET_SENSITIVE ("layers-blend-space-auto", layer && bs_mutable); + SET_SENSITIVE ("layers-blend-space-rgb-linear", layer && bs_mutable); + SET_SENSITIVE ("layers-blend-space-rgb-perceptual", layer && bs_mutable); - SET_SENSITIVE ("layers-composite-space-auto", layer); - SET_SENSITIVE ("layers-composite-space-rgb-linear", layer); - SET_SENSITIVE ("layers-composite-space-rgb-perceptual", layer); - SET_SENSITIVE ("layers-composite-space-lab", layer); + SET_SENSITIVE ("layers-composite-space-auto", layer && cs_mutable); + SET_SENSITIVE ("layers-composite-space-rgb-linear", layer && cs_mutable); + SET_SENSITIVE ("layers-composite-space-rgb-perceptual", layer && cs_mutable); - SET_SENSITIVE ("layers-composite-mode-auto", layer); - SET_SENSITIVE ("layers-composite-mode-src-over", layer); - SET_SENSITIVE ("layers-composite-mode-src-atop", layer); - SET_SENSITIVE ("layers-composite-mode-src-in", layer); - SET_SENSITIVE ("layers-composite-mode-dst-atop", layer); + SET_SENSITIVE ("layers-composite-mode-auto", layer && cm_mutable); + SET_SENSITIVE ("layers-composite-mode-src-over", layer && cm_mutable); + SET_SENSITIVE ("layers-composite-mode-src-atop", layer && cm_mutable); + SET_SENSITIVE ("layers-composite-mode-src-in", layer && cm_mutable); + SET_SENSITIVE ("layers-composite-mode-dst-atop", layer && cm_mutable); SET_SENSITIVE ("layers-mask-add", layer && !fs && !ac && !mask && !children); SET_SENSITIVE ("layers-mask-add-button", layer && !fs && !ac && !children); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 7cb90096d0..9f1cf4b77b 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -31,6 +31,8 @@ #include "core-types.h" +#include "operations/layer-modes/gimp-layer-modes.h" + #include "gegl/gimp-babl.h" #include "gegl/gimp-gegl-apply-operation.h" #include "gegl/gimp-gegl-loops.h" @@ -2202,6 +2204,9 @@ gimp_layer_set_blend_space (GimpLayer *layer, { g_return_if_fail (GIMP_IS_LAYER (layer)); + if (! gimp_layer_mode_is_blend_space_mutable (layer->mode)) + return; + if (layer->blend_space != blend_space) { if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer))) @@ -2238,6 +2243,9 @@ gimp_layer_set_composite_space (GimpLayer *layer, { g_return_if_fail (GIMP_IS_LAYER (layer)); + if (! gimp_layer_mode_is_composite_space_mutable (layer->mode)) + return; + if (layer->composite_space != composite_space) { if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer))) @@ -2274,6 +2282,9 @@ gimp_layer_set_composite_mode (GimpLayer *layer, { g_return_if_fail (GIMP_IS_LAYER (layer)); + if (! gimp_layer_mode_is_composite_mode_mutable (layer->mode)) + return; + if (layer->composite_mode != composite_mode) { if (push_undo && gimp_item_is_attached (GIMP_ITEM (layer))) diff --git a/app/dialogs/layer-options-dialog.c b/app/dialogs/layer-options-dialog.c index a46b63368c..e92934b433 100644 --- a/app/dialogs/layer-options-dialog.c +++ b/app/dialogs/layer-options-dialog.c @@ -26,6 +26,8 @@ #include "dialogs-types.h" +#include "operations/layer-modes/gimp-layer-modes.h" + #include "core/gimpcontext.h" #include "core/gimpdrawable-filters.h" #include "core/gimpimage.h" @@ -62,6 +64,9 @@ struct _LayerOptionsDialog gpointer user_data; GtkWidget *mode_box; + GtkWidget *blend_space_combo; + GtkWidget *composite_space_combo; + GtkWidget *composite_mode_combo; GtkWidget *size_se; GtkWidget *offset_se; }; @@ -69,20 +74,23 @@ struct _LayerOptionsDialog /* local function prototypes */ -static void layer_options_dialog_free (LayerOptionsDialog *private); -static void layer_options_dialog_callback (GtkWidget *dialog, - GimpImage *image, - GimpItem *item, - GimpContext *context, - const gchar *item_name, - gboolean item_visible, - gboolean item_linked, - GimpColorTag item_color_tag, - gboolean item_lock_content, - gboolean item_lock_position, - gpointer user_data); -static void layer_options_dialog_toggle_rename (GtkWidget *widget, - LayerOptionsDialog *private); +static void layer_options_dialog_free (LayerOptionsDialog *private); +static void layer_options_dialog_callback (GtkWidget *dialog, + GimpImage *image, + GimpItem *item, + GimpContext *context, + const gchar *item_name, + gboolean item_visible, + gboolean item_linked, + GimpColorTag item_color_tag, + gboolean item_lock_content, + gboolean item_lock_position, + gpointer user_data); +static void layer_options_dialog_mode_notify (GtkWidget *widget, + const GParamSpec *pspec, + LayerOptionsDialog *private); +static void layer_options_dialog_rename_toggled (GtkWidget *widget, + LayerOptionsDialog *private); /* public functions */ @@ -116,6 +124,7 @@ layer_options_dialog_new (GimpImage *image, LayerOptionsDialog *private; GtkWidget *dialog; GtkWidget *table; + GtkListStore *space_model; GtkWidget *combo; GtkWidget *scale; GtkWidget *label; @@ -172,7 +181,17 @@ layer_options_dialog_new (GimpImage *image, gimp_layer_mode_box_set_mode (GIMP_LAYER_MODE_BOX (private->mode_box), private->mode); - combo = gimp_enum_combo_box_new (GIMP_TYPE_LAYER_COLOR_SPACE); + g_signal_connect (private->mode_box, "notify::layer-mode", + G_CALLBACK (layer_options_dialog_mode_notify), + private); + + space_model = + gimp_enum_store_new_with_range (GIMP_TYPE_LAYER_COLOR_SPACE, + GIMP_LAYER_COLOR_SPACE_AUTO, + GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL); + + private->blend_space_combo = combo = + gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (space_model)); item_options_dialog_add_widget (dialog, _("Blend space:"), combo); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-layer-color-space"); @@ -181,7 +200,8 @@ layer_options_dialog_new (GimpImage *image, G_CALLBACK (gimp_int_combo_box_get_active), &private->blend_space); - combo = gimp_enum_combo_box_new (GIMP_TYPE_LAYER_COLOR_SPACE); + private->composite_space_combo = combo = + gimp_enum_combo_box_new_with_model (GIMP_ENUM_STORE (space_model)); item_options_dialog_add_widget (dialog, _("Composite space:"), combo); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-layer-color-space"); @@ -190,7 +210,10 @@ layer_options_dialog_new (GimpImage *image, G_CALLBACK (gimp_int_combo_box_get_active), &private->composite_space); - combo = gimp_enum_combo_box_new (GIMP_TYPE_LAYER_COMPOSITE_MODE); + g_object_unref (space_model); + + private->composite_mode_combo = combo = + gimp_enum_combo_box_new (GIMP_TYPE_LAYER_COMPOSITE_MODE); item_options_dialog_add_widget (dialog, _("Composite mode:"), combo); gimp_enum_combo_box_set_icon_prefix (GIMP_ENUM_COMBO_BOX (combo), "gimp-layer-composite"); @@ -421,7 +444,7 @@ layer_options_dialog_new (GimpImage *image, &private->rename_text_layers); g_signal_connect (button, "toggled", - G_CALLBACK (layer_options_dialog_toggle_rename), + G_CALLBACK (layer_options_dialog_rename_toggled), private); } @@ -456,9 +479,6 @@ layer_options_dialog_callback (GtkWidget *dialog, gint offset_x; gint offset_y; - private->mode = - gimp_layer_mode_box_get_mode (GIMP_LAYER_MODE_BOX (private->mode_box)); - if (private->size_se) { width = @@ -502,8 +522,33 @@ layer_options_dialog_callback (GtkWidget *dialog, } static void -layer_options_dialog_toggle_rename (GtkWidget *widget, - LayerOptionsDialog *private) +layer_options_dialog_mode_notify (GtkWidget *widget, + const GParamSpec *pspec, + LayerOptionsDialog *private) +{ + gboolean mutable; + + private->mode = gimp_layer_mode_box_get_mode (GIMP_LAYER_MODE_BOX (widget)); + + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->blend_space_combo), + GIMP_LAYER_COLOR_SPACE_AUTO); + mutable = gimp_layer_mode_is_blend_space_mutable (private->mode); + gtk_widget_set_sensitive (private->blend_space_combo, mutable); + + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->composite_space_combo), + GIMP_LAYER_COLOR_SPACE_AUTO); + mutable = gimp_layer_mode_is_composite_space_mutable (private->mode); + gtk_widget_set_sensitive (private->composite_space_combo, mutable); + + gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (private->composite_mode_combo), + GIMP_LAYER_COMPOSITE_AUTO); + mutable = gimp_layer_mode_is_composite_mode_mutable (private->mode); + gtk_widget_set_sensitive (private->composite_mode_combo, mutable); +} + +static void +layer_options_dialog_rename_toggled (GtkWidget *widget, + LayerOptionsDialog *private) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) && gimp_item_is_text_layer (GIMP_ITEM (private->layer))) diff --git a/app/operations/layer-modes/gimp-layer-modes.c b/app/operations/layer-modes/gimp-layer-modes.c index 503eaab3b3..e6aae88200 100644 --- a/app/operations/layer-modes/gimp-layer-modes.c +++ b/app/operations/layer-modes/gimp-layer-modes.c @@ -65,115 +65,172 @@ static const GimpLayerModeInfo layer_mode_infos[]= { GIMP_LAYER_MODE_MULTIPLY_LEGACY, "gimp:multiply-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_SCREEN_LEGACY, "gimp:screen-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_OVERLAY_LEGACY, "gimp:overlay-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_DIFFERENCE_LEGACY, "gimp:difference-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_ADDITION_LEGACY, "gimp:addition-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_SUBTRACT_LEGACY, "gimp:subtract-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_DARKEN_ONLY_LEGACY, "gimp:darken-only-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_LIGHTEN_ONLY_LEGACY, "gimp:lighten-only-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_HSV_HUE_LEGACY, "gimp:hsv-hue-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_HSV_SATURATION_LEGACY, "gimp:hsv-saturation-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_HSV_COLOR_LEGACY, "gimp:hsv-color-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_HSV_VALUE_LEGACY, "gimp:hsv-value-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_DIVIDE_LEGACY, "gimp:divide-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_DODGE_LEGACY, "gimp:dodge-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_BURN_LEGACY, "gimp:burn-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_HARDLIGHT_LEGACY, "gimp:hardlight-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_SOFTLIGHT_LEGACY, "gimp:softlight-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_GRAIN_EXTRACT_LEGACY, "gimp:grain-extract-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, { GIMP_LAYER_MODE_GRAIN_MERGE_LEGACY, "gimp:grain-merge-legacy", - GIMP_LAYER_MODE_FLAG_LEGACY, + GIMP_LAYER_MODE_FLAG_LEGACY | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE | + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, }, @@ -193,7 +250,8 @@ static const GimpLayerModeInfo layer_mode_infos[]= { GIMP_LAYER_MODE_LCH_HUE, "gimp:layer-mode", - GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA, + GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, GIMP_LAYER_COLOR_SPACE_LAB @@ -201,7 +259,8 @@ static const GimpLayerModeInfo layer_mode_infos[]= { GIMP_LAYER_MODE_LCH_CHROMA, "gimp:layer-mode", - GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA, + GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, GIMP_LAYER_COLOR_SPACE_LAB @@ -209,7 +268,8 @@ static const GimpLayerModeInfo layer_mode_infos[]= { GIMP_LAYER_MODE_LCH_COLOR, "gimp:layer-mode", - GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA, + GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, GIMP_LAYER_COLOR_SPACE_LAB @@ -217,7 +277,8 @@ static const GimpLayerModeInfo layer_mode_infos[]= { GIMP_LAYER_MODE_LCH_LIGHTNESS, "gimp:layer-mode", - GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA, + GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA | + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE, GIMP_LAYER_COMPOSITE_SRC_ATOP, GIMP_LAYER_COLOR_SPACE_RGB_LINEAR, GIMP_LAYER_COLOR_SPACE_LAB @@ -1020,6 +1081,33 @@ gimp_layer_mode_wants_linear_data (GimpLayerMode mode) return (info->flags & GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA) != 0; } +gboolean +gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode) +{ + const GimpLayerModeInfo *info = gimp_layer_mode_info (mode); + if (!info) + return FALSE; + return (info->flags & GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE) == 0; +} + +gboolean +gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode) +{ + const GimpLayerModeInfo *info = gimp_layer_mode_info (mode); + if (!info) + return FALSE; + return (info->flags & GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE) == 0; +} + +gboolean +gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode) +{ + const GimpLayerModeInfo *info = gimp_layer_mode_info (mode); + if (!info) + return FALSE; + return (info->flags & GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE) == 0; +} + GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode) { diff --git a/app/operations/layer-modes/gimp-layer-modes.h b/app/operations/layer-modes/gimp-layer-modes.h index a22de5252f..bfe4ef16d9 100644 --- a/app/operations/layer-modes/gimp-layer-modes.h +++ b/app/operations/layer-modes/gimp-layer-modes.h @@ -28,6 +28,10 @@ void gimp_layer_modes_init (void); gboolean gimp_layer_mode_is_legacy (GimpLayerMode mode); gboolean gimp_layer_mode_wants_linear_data (GimpLayerMode mode); +gboolean gimp_layer_mode_is_blend_space_mutable (GimpLayerMode mode); +gboolean gimp_layer_mode_is_composite_space_mutable (GimpLayerMode mode); +gboolean gimp_layer_mode_is_composite_mode_mutable (GimpLayerMode mode); + GimpLayerColorSpace gimp_layer_mode_get_blend_space (GimpLayerMode mode); GimpLayerColorSpace gimp_layer_mode_get_composite_space (GimpLayerMode mode); GimpLayerCompositeMode gimp_layer_mode_get_composite_mode (GimpLayerMode mode); diff --git a/app/operations/operations-enums.h b/app/operations/operations-enums.h index 7d5eb9213d..364eb19200 100644 --- a/app/operations/operations-enums.h +++ b/app/operations/operations-enums.h @@ -170,8 +170,11 @@ typedef enum /*< pdb-skip, skip >*/ typedef enum /*< pdb-skip, skip >*/ { - GIMP_LAYER_MODE_FLAG_LEGACY = 1 << 0, - GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA = 1 << 1 + GIMP_LAYER_MODE_FLAG_LEGACY = 1 << 0, + GIMP_LAYER_MODE_FLAG_WANTS_LINEAR_DATA = 1 << 1, + GIMP_LAYER_MODE_FLAG_BLEND_SPACE_IMMUTABLE = 1 << 2, + GIMP_LAYER_MODE_FLAG_COMPOSITE_SPACE_IMMUTABLE = 1 << 3, + GIMP_LAYER_MODE_FLAG_COMPOSITE_MODE_IMMUTABLE = 1 << 4, } GimpLayerModeFlags; diff --git a/menus/layers-menu.xml b/menus/layers-menu.xml index 00759ab741..bf3dc269bc 100644 --- a/menus/layers-menu.xml +++ b/menus/layers-menu.xml @@ -9,13 +9,11 @@ -