Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New canvas cursor and quick cursor implementation #1806

Merged
merged 25 commits into from
Mar 7, 2024

Conversation

MrStevns
Copy link
Member

@MrStevns MrStevns commented Jan 9, 2024

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.

Screen.Recording.2024-01-09.at.19.45.33.mp4

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
image image

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
cursor-test

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.

@J5lx J5lx self-assigned this Feb 25, 2024
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found two small issues in this PR:

  • After disabling the dotted cursor in the preferences, it continues to linger on the canvas. When the program is started with dotted cursor disabled, the quick sizing visualisation lingers after using quick sizing. (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)
  • Canvas cursor doesn’t seem to work correctly for vector bucket tool, though quick sizing works fine

In my experience, this PR also noticeably improves quick sizing performance, so I’m marking it as closing #1694. Well done!

core_lib/src/util/mathutils.h Outdated Show resolved Hide resolved
core_lib/src/tool/brushtool.cpp Outdated Show resolved Hide resolved
core_lib/src/tool/stroketool.cpp Outdated Show resolved Hide resolved
core_lib/src/tool/stroketool.cpp Outdated Show resolved Hide resolved
core_lib/src/interface/scribblearea.cpp Outdated Show resolved Hide resolved
@J5lx J5lx linked an issue Feb 25, 2024 that may be closed by this pull request
@J5lx J5lx added this to the v0.6.7 milestone Feb 25, 2024
@MrStevns
Copy link
Member Author

MrStevns commented Mar 2, 2024

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 🙏

@MrStevns MrStevns requested a review from J5lx March 2, 2024 19:43
Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking pretty good now. 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.

the width does not matter

But it does? Width = 1:

Screenshot_20240305_215325

Width = 100:

Screenshot_20240305_215353

That said you’re right that canvas cursor / quick sizing usefulness is limited here. I’m fine with either solution.

Lastly, I did notice a strange glitch when leaving and re-entering the canvas with the cursor after having made at least one stroke:

Screencast_20240305_214239.webm

(Edit: I just realised the recording also shows the cursor icon being wrong outside the ScribbleArea, but that is a bug in the Plasma 6 RC I'm using as far as I can tell and not the glitch I’m talking about)

Doesn’t seem to have any serious consequences though so I don’t think it’s strictly necessary to fix it, but I wanted to mention it at least.

Anyway, thanks for your work on this 👍

core_lib/src/interface/scribblearea.cpp Outdated Show resolved Hide resolved
core_lib/src/tool/penciltool.cpp Show resolved Hide resolved
@MrStevns
Copy link
Member Author

MrStevns commented Mar 6, 2024

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.

Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see how that interpolation should happen either

I just tested again and it is in fact interpolation. I didn’t figure that out at first because you have to make a stroke after changing the interpolation setting for it to take effect, and that’s probably also why you weren’t able to reproduce it. That said, I also noticed it happens on master, too – I just never noticed it because due to the way the canvas cursor is drawn on master it doesn’t stand out as much. So, sorry for the false alarm!

With that, I’d say this PR is good to go as soon as the vector bucket tool is taken care of.

core_lib/src/tool/penciltool.cpp Show resolved Hide resolved
@J5lx
Copy link
Member

J5lx commented Mar 6, 2024

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.

Copy link
Member

@J5lx J5lx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@J5lx J5lx merged commit 758a1a1 into pencil2d:master Mar 7, 2024
8 checks passed
@MrStevns MrStevns deleted the new-canvas-cursor-impl branch March 7, 2024 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Review
Development

Successfully merging this pull request may close these issues.

Using shift modifier+stylus to change brush size can cause lag and crash
2 participants