pencil
pencil copied to clipboard
New canvas cursor and quick cursor implementation
Here's a proposal for a new canvas and quick cursor implementation. The PR also introduces an arguably better way to interrupt a pointer events without potentially screwing up all our tools. We do this through a new method called interruptPointerEvent in BaseTool and currently use it in StrokeTool.
https://github.com/pencil2d/pencil/assets/1045397/dbd753e3-9c3d-4dfb-8b6b-eaf4d45f1364
Canvas cursor
The design of the canvas cursor has been tweaked, mostly in order to avoid cosmetic misalignment once the cursor becomes too small.
Old | New |
---|---|
Quick cursor
When enabling quick cursor using the shortcut, the canvas cursor will be offset so that the respective circle outline aligns with the cursor position. if you adjust the width it will offset based on the outer circle and otherwise the inner circle
I initially wanted to just fix the Quick cursor implementation but ended up re-doing the entire canvas cursor implementation. The rework allowed me to also move the canvas cursor logic out of ScribbleArea.
Bugs fixed:
- Canvas Cursor and Quick cursor would be cut in some cases while moving on the canvas
- Cursor would be shown for some tools even though it didn't make sense
- Quick cursor painting didn't work properly with the tiled painter
- Feather circle wasn't taking in the factor of width properly
Changes:
- Feather circle is only drawn when it can be modified
- Quick cursor is no longer restricted to adjustments from certain position, it can be done from any angle and and place where you can see the cursor.
- Bucket tool fill tolerance is no longer a quick cursor setting
- Only a tool that inherits StrokeTool can display the cursor, as such preventing bugs where the canvas cursor would be shown when it shouldn't.
- Canvas cursor is no longer drawn using two circles and dotted lines but instead use a raster operation composition mode to make sure it can always be seen.
PR is ready to be reviewed again.
After disabling the dotted cursor in the preferences, it continues to linger on the canvas.
This should be fixed now, although it required a bit more logic but overall it's better I think. The quick sizing visualization does not linger anymore either.
When the program is started with dotted cursor disabled, the quick sizing visualisation lingers after using quick sizing.
This should be fixed now
(also, now that i think about it, maybe we should rename the dotted cursor setting now that the cursor is no longer dotted. maybe “preview stroke width and feather” or something like that)
I've made a proposal for that for now, "Canvas cursor" is fine i think.
Canvas cursor doesn’t seem to work correctly for vector bucket tool, though quick sizing works fine
Hmm I'm in doubt about this one... I don't think it should have a cursor, because it doesn't draw on the canvas with a width size as such, we use it as a stroke tool to allow filling across multiple areas but the width does not matter. Either I should add the cursor again for the vector layer or we should remove the quick sizing property for this tool. Does it even make sense to have it? What do you think?
Also thanks for reviewing 🙏
I took the liberty of changing the config file key back since it’s not directly user-facing but messes with users’ settings when switching between versions. I’m fine with “Canvas Cursor” as the name in the preferences dialog and the code constants.
Fair enough, although i think the change is somewhat valid, even if it isn't directly user facing, it does make more sense that our keys are aligned with implementation or generic enough that we don't have to change it between versions. You do however have a point in that if you come back to the old version, then the setting should still be used.
Lastly, I did notice a strange glitch when leaving and re-entering the canvas with the cursor after having made at least one stroke:
Hmm it's not something I can reproduce on Mac OS, I don't see how that interpolation should happen either, so maybe it's a platform specific thing?
But it does? Width = 1: That said you’re right that canvas cursor / quick sizing usefulness is limited here. I’m fine with either solution.
Correct but i don't consider that a "stroke" as such, I personally don't think it should be on the bucket tool thing at all. Alright, in that case, I'll remove the logic.
I just realised there was an error in my tool event handling suggestion as I’d gotten some stuff mixed up while reading through the Qt documentation. I’ve just committed what I now believe to be the intended way to handle such things.