Related bug: https://bugs.kde.org/show_bug.cgi?id=421752
The Problem
Different tools use opacity settings, and they use it in a bit different ways. E.g. Brush Tool paints with the opacity, stored in the brush preset. But Gradient and FloodFill Tools use opacity just to render the gradient/filling.
But in Krita, we store the opacity in the brush preset all the time. We don't have a separate storage for opacity intended for the tools that don't use brushes. It means that when you use Gradient Tool with 50% opacity, this opacity will be written to the brush preset and the preset will be marked as "dirty".
What is more, right now, we have a temporary workaround for that in Krita, which makes things even worse. Every time a tool is deactivated/activated, it saves/restores the opacity saved specifically for this tool. And during this save-restore operation the paintop preset is modified and marked as dirty.
One can reproduce this bug with the following steps:
- Activate Gradient Tool
- Set opacity to 50%
- Switch back to Brush Tool
- Select a clean preset
- Switch to Gradient Tool and back to Brush Tool
BUG: the brush preset is marked as dirty
Proposed solution
- There should be two kinds of opacities: brush opacity and external opacity
- Brush opacity is stored in in the brush preset itself
- External opacity is stored in Krita's resource server (in a global or per-tool manner, see "Question 1")
- Every tool can declare what opacity it would like to use, external or brush one. It can be done by declaring a special flag, like we do that in KisTool::flags(). E.g. Brush Tool would request brush opacity, Gradient Tool would request external opacity (see "Question 3")
- On activation of the tool, the resource server (or tool manager?) would reroute all the requests to opacity to the corresponding storage (preset or something local). It would also handle all the "opacity-changed" signals delivery.
- The same strategy would also apply to other resources that are stored in a brush: Blending Mode, Eraser Mode, Flow, Size, Alpha Lock. All of them should have their own flags.
Questions
- Should every tool have its own external opacity setting or there should be only two opacities: one in the preset and another one for "all the other tools", like Gradient and Fill? In other words, should Gradient and Fill tools share the opacity setting?
- Should the extrenal opacity be saved in Krita config file? In other words, should Gradient Tool restore last-used opacity when restarting Krita or it should always start from 100% opacity?
- Should Rectangle and Ellipse tools use opacity from the brush preset or use the external one?