I made an extension that enables you to assign a keyboard shortcut to toggle the visibility of a reference layer

Hey!

When I’m drawing my cleanline and shade on top of my sketch i find i run into the problem that if I set the layer to be transparent I it becomes very difficult to follow along with my shading, and to see which lines I’ve drawn. So I made a plugin that lets you set a keyboard shortcut to hide and show a layer named “reference”

here it is: https://drive.google.com/file/d/11O8FiejleajsT_uHd4Q4VBrCrYX9Rh5v/view?usp=sharing

Let me know if you have any feedback, I have set the default keyboard shortcut as ctrl+alt+shift+L but you can change it to whatever you like.

5 Likes

It works :slight_smile: Thank you :slight_smile:
If I name two layers as ‘reference’ there is some confusion and I can’t work out the logic of what happens but that’s the sort of thing I like to do - don’t worry about it.

2 Likes

Well for me so far it’s actually been using the most lately named layer but I might have just been lucky. What would you like to happen? That it hides/reveals all layers named reference?

1 Like

I’m not asking for changes as such, it was just an observation. I also figured out (forehead slap) that it can toggle an entire group if the group layer is called ‘reference’.
Thinking more about it, there could be a situation where you want those layers to be distributed among the working layers, for whatever reason, so having it turn off every layer called ‘reference’ or even ‘reference…’ would be useful.
If you could make it do that then it would be even more flexible. It’s up to you and thank you again.

I have updated it.

It actually gave me an interesting challenge because you might have nested layers indefinitely called reference. so praised be pythons ability to call a function within itself since this allowed my to indefinitely just continue recursively looking through layers.

as an added bonus/consequence of this way of doing it the last visibility state is remebered, so if a reference layer is manually toggled and you press the button you will have oposing visibilites

2 Likes

Thanks for +1 useful feature in Krita! Is it possible to make toggling by color layer (that applying by right-click menu)? For example, pressing shortcut hide/reveal layer/s marked with red color.

1 Like

I’ve just downloaded and used it and it works very well.
You can use the ‘added bonus’ behaviour to toggle between two sets of reference images, or two sets of groups of references, or a mixture of the two.
You have to use it to see how useful it can be.

1 Like

Sure you can.
You will need to change the line that checks the name:

if node.name() == node_name:

to something that checks the color label

if node.colorLabel() == 6:

0 is for transparent label, 1 for green and so on. Red one would be 6 then.

2 Likes

Thanks, @wojtryb. It works.

1 Like

Interesting thing: if there are any visible layer with filter mask, even if layer are totally covered with other image/paint, there are delay in reaction to on/off reference layer. In 2800x3900 document is about 2-3 seconds.

Hmm I’m working in a document about that size and it’s nearly instant for me. How long does it take to manually toggle visibility by clicking the eye icon?

Manual switching and in-system shortcut hide/show layer work fast. Only if filter mask is visible, for example color balance, on a visible layer than there is a delay in switching any other marked as “reference” layer with the plugin. (And instead of “reference” I use color label by @wojtryb modification)

Anyway I rarely use filter masks, so this issue is not so issuable thing.