Bug 388464

Summary: Impossible to set layer blending modes individually
Product: [Applications] krita Reporter: Matthew Trescott <matthewtrescott>
Component: GeneralAssignee: Halla Rempt <halla>
Status: RESOLVED FIXED    
Severity: normal CC: halla
Priority: NOR    
Version First Reported In: 4.0 pre-alpha   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Matthew Trescott 2018-01-02 19:59:19 UTC
I tried to follow this tutorial: https://docs.krita.org/Channels

When I try to set the blending mode for the layers individually through the drop-down menu at the top, it gets applied to all the layers. If I try to set the blending mode via the layer properties dialog, the "Copy Red", "Copy Green", and "Copy Blue" options are disabled. This problem also shows up when I use Krita from the Arch repositories (v3.3.2.1).
Comment 1 Halla Rempt 2018-01-03 13:19:20 UTC
Weirdly enough, this bug seems to have been around for ages. What works is selecting the layer by clicking on it with the mouse and then selecting the blending mode in the combobox at the top of the layerbox. Moving along the layers with pgup and pgdn or using the properties dialog doesn't work.
Comment 2 Halla Rempt 2018-01-03 13:26:56 UTC
Okay, so:

There is a discrepancy between the when the layer is selected by pgup/pgdn and the settings dialog on the one hand, or by clicking in the layerbox on the other hand. 

In the first case, all the composite ops that are not in the layer's colormodel are disabled. 

In the second case, they are enabled. So, after selecting a grayscale layer with pgup in the layerbox, the warning label is shown. If you'd click anywhere in the layerbox, the warning label disappears.

I would think that, if only in order to make that tutorial work, we should check the image's color model, not the layer's.
Comment 3 Halla Rempt 2018-01-03 13:29:36 UTC
More notes: void KisCompositeOpComboBox::validate(const KoColorSpace *cs)  was written to validate the composite ops for painting, not those in the layerbox. Validate is only called here:

void KisPaintopBox::slotColorSpaceChanged(const KoColorSpace* colorSpace)
{
    m_cmbCompositeOp->validate(colorSpace);
}
Comment 4 Halla Rempt 2018-01-03 13:51:29 UTC
Changing a layer with pgup causes three KisLayerBox::updateUI calls, and 3 KisPaintopBox::slotColorSpaceChanged calls:

Validate KisCompositeOpComboBox(0x986fa30) "Grayscale/Alpha (8-bit integer/channel)"
Validate KisCompositeOpComboBox(0x986fa30) "Grayscale/Alpha (8-bit integer/channel)"
Validate KisCompositeOpComboBox(0xb836b90, name="cmbComposite") "RGB/Alpha (8-bit integer/channel)"
Validate KisCompositeOpComboBox(0xb836b90, name="cmbComposite") "RGB/Alpha (8-bit integer/channel)"
Validate KisCompositeOpComboBox(0xb836b90, name="cmbComposite") "RGB/Alpha (8-bit integer/channel)"
Validate KisCompositeOpComboBox(0x986fa30) "Grayscale/Alpha (8-bit integer/channel)"

The weird thing is that even if change KisLayerBox::updateUi to always call validate() with the image colorspace, the model is still filtered with the layer's colorspace.
Comment 5 Halla Rempt 2018-01-03 13:53:51 UTC
Selecting a layer with the mouse only gives one call:

Validate KisCompositeOpComboBox(0xb836b90, name="cmbComposite") "RGB/Alpha (8-bit integer/channel)"

And doesn't cause anything to be validated in the paintopbox's composite op combobox, which then, of course isn't validated for the current layer's colorspace.

So, are these models shared among instances of kis_cmb_compositeop?
Comment 6 Halla Rempt 2018-01-03 13:55:32 UTC
Yes, they are. Sylvio, what were you thinking!
Comment 7 Halla Rempt 2018-01-03 14:51:43 UTC
Git commit 01294ad178d6e7fac321579f182880f58c5a5d0b by Boudewijn Rempt.
Committed on 03/01/2018 at 14:51.
Pushed by rempt into branch 'master'.

Do not share composite op models among composite op comboboxes

It is perfectly valid for one composte op combobox to show
a different set of valid composite ops than another, for instance
if the image is rgb but the layer grayscale; a grayscale layer can
be composited with rgb composite ops because it's converted to rgb
beforehand.

M  +1    -1    libs/libqml/plugins/kritasketchplugin/models/CompositeOpModel.cpp
M  +19   -19   libs/ui/kis_composite_ops_model.cc
M  +13   -2    libs/ui/kis_composite_ops_model.h
M  +1    -11   plugins/dockers/defaultdockers/kis_layer_box.cpp
M  +0    -1    plugins/dockers/defaultdockers/kis_layer_box.h

https://commits.kde.org/krita/01294ad178d6e7fac321579f182880f58c5a5d0b
Comment 8 Halla Rempt 2018-01-03 14:52:06 UTC
Git commit 2172482f76979ae3c09b1eaf0734bb1918c677cb by Boudewijn Rempt.
Committed on 03/01/2018 at 14:51.
Pushed by rempt into branch 'krita/3.3'.

Do not share composite op models among composite op comboboxes

It is perfectly valid for one composte op combobox to show
a different set of valid composite ops than another, for instance
if the image is rgb but the layer grayscale; a grayscale layer can
be composited with rgb composite ops because it's converted to rgb
beforehand.

M  +19   -19   libs/ui/kis_composite_ops_model.cc
M  +13   -2    libs/ui/kis_composite_ops_model.h
M  +1    -11   plugins/dockers/defaultdockers/kis_layer_box.cpp
M  +0    -1    plugins/dockers/defaultdockers/kis_layer_box.h

https://commits.kde.org/krita/2172482f76979ae3c09b1eaf0734bb1918c677cb