-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
Prevent canvas micro-panning on point add #5742
Conversation
On the other hand, the current behavior is pretty sweet on a trackpad where click is click and pan is a drag gesture. |
Codecov Report
@@ Coverage Diff @@
## main #5742 +/- ##
==========================================
+ Coverage 89.86% 89.87% +0.01%
==========================================
Files 610 610
Lines 52121 52133 +12
==========================================
+ Hits 46837 46856 +19
+ Misses 5284 5277 -7
... and 7 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Yeah... what we really need is for the threshold to also apply to vispy camera events :/
How would this solve the problem? Or are you saying that we could differentiate the two cases and disable panning only if it's qtabletevents and not normal mouse events? |
I assume proper handling of the actual tablet/stylus would help resolve the issue because the tap event would be handled as that and not as a click-slight drag. Basically, I'm assuming at the moment everything is just being treated as mouse events—same with my trackpad, only the gestures that the OS translates to mouse events work. |
This was added in #2148. Space to pan is good but it is much less ergonomic than just using the mouse — there's a reason why that PR was made. So I don't want to "just" revert that change.
I'm pro-this. 😂 You might not need a complete refactoring, as shown by the recent PRs for keeping mouse zoom working in all modes. #5701 #5726 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I thought this was an issue not a PR 😂
Ok, I found another solution using the Unfortunately it required some changes to the The basic idea is: mark event as Note that this works because the order of callbacks is set up so that vispy acts last. |
34d5bf1
to
640d212
Compare
This reverts commit 1e25701.
These tests are so annoying :/ They are failing claiming that a point is added when it shouldn't even though that doesn't happen when actually using napari. I think it's because all the @kevinyamauchi it seems you touched these tests before; maybe you have some suggestions? |
@jni the changes should satisfy you now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice - tested manually and all working as expected from my side, could you add a test? With a test I think this is ready to go!
# Simulate click | ||
event = ReadOnlyWrapper( | ||
Event(type='mouse_press', position=known_non_point) | ||
event = read_only_event( | ||
type='mouse_press', position=known_non_point, pos=np.array([0, 0]) | ||
) | ||
mouse_press_callbacks(layer, event) | ||
|
||
known_non_point_end = [40, 60] | ||
|
||
# Simulate drag end | ||
event = ReadOnlyWrapper( | ||
Event( | ||
type='mouse_move', is_dragging=True, position=known_non_point_end | ||
) | ||
event = read_only_event( | ||
type='mouse_move', | ||
is_dragging=True, | ||
position=known_non_point_end, | ||
pos=np.array([4, 4]), | ||
) | ||
mouse_move_callbacks(layer, event) | ||
|
||
# Simulate release | ||
event = ReadOnlyWrapper( | ||
Event( | ||
type='mouse_release', | ||
position=known_non_point_end, | ||
pos=np.array([4, 4]), | ||
) | ||
event = read_only_event( | ||
type='mouse_release', | ||
position=known_non_point_end, | ||
pos=np.array([4, 4]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The add/not-add-point behaviour is already tested here. Testing whether the camera moves is quite a bit harder cause we need a fully working vispy canvas, and I don't seem to be able to get that to work. I'm using make_napari_viewer
and then checking if viewer.window.qt_viewer.camera.center
changes before and after the callback. For some reason, this never changes, despite the fact that when I'm actually testing manually, this value is changed as appropriate. Any suggestions? Otherwise I suggest we get this in without adding an extra test, since it's a small bug fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy for this to go in if main behaviour is already covered in tests!
Currently, when adding points interactively the vispy camera is still getting moved by mouse events. This is not a problem with a mouse - since normally you don't move the mouse while clicking - but it's pretty frustrating with a tablet, since the cursor moves slightly every time you press down or release the stylus. This results on the canvas moving around a tiny bit every time you click. This was a know issue, since there is a mouse-movement threshold in place beyond which a point doesn't get added; however this does not prevent the canvas from moving even within that threshold. This PR prevents the vispy camera from receiving the event if this threshold is not yet surpassed. <!-- Please delete options that are not relevant. --> - [x] Bug-ix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
Currently, when adding points interactively the vispy camera is still getting moved by mouse events. This is not a problem with a mouse - since normally you don't move the mouse while clicking - but it's pretty frustrating with a tablet, since the cursor moves slightly every time you press down or release the stylus. This results on the canvas moving around a tiny bit every time you click. This was a know issue, since there is a mouse-movement threshold in place beyond which a point doesn't get added; however this does not prevent the canvas from moving even within that threshold. This PR prevents the vispy camera from receiving the event if this threshold is not yet surpassed. <!-- Please delete options that are not relevant. --> - [x] Bug-ix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
Currently, when adding points interactively the vispy camera is still getting moved by mouse events. This is not a problem with a mouse - since normally you don't move the mouse while clicking - but it's pretty frustrating with a tablet, since the cursor moves slightly every time you press down or release the stylus. This results on the canvas moving around a tiny bit every time you click. This was a know issue, since there is a mouse-movement threshold in place beyond which a point doesn't get added; however this does not prevent the canvas from moving even within that threshold. This PR prevents the vispy camera from receiving the event if this threshold is not yet surpassed. <!-- Please delete options that are not relevant. --> - [x] Bug-ix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
Currently, when adding points interactively the vispy camera is still getting moved by mouse events. This is not a problem with a mouse - since normally you don't move the mouse while clicking - but it's pretty frustrating with a tablet, since the cursor moves slightly every time you press down or release the stylus. This results on the canvas moving around a tiny bit every time you click. This was a know issue, since there is a mouse-movement threshold in place beyond which a point doesn't get added; however this does not prevent the canvas from moving even within that threshold. This PR prevents the vispy camera from receiving the event if this threshold is not yet surpassed. <!-- Please delete options that are not relevant. --> - [x] Bug-ix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update
I ran into this -- I think -- recently in a workshop. |
As a quick check, try setting the DRAG_DIST_THRESHOLD to like 10 and see if it still happens! |
Thanks, that helps, but, I need to set to at least 20 to mostly prevent the effect when labeling and 50 still feels better. |
With the current value on main, I can go as fast as I can and Istill never move the canvas ^^' Either you're very fast, or I'm very slow, or something else is afoot, probably the hidpi. But so HI as to require a whopping 50 pixels? |
@brisvag What kind of mouse do you have? |
I have a logitech B100 according to the sticker, should be a generic office mouse afaik ^^' |
@psobolewskiPhD could you somehow log what are mean movement of your mouse movement? |
like a screen recording? |
|
||
while event.type != 'mouse_release': | ||
while event.type == 'mouse_move': | ||
dist = np.linalg.norm(start_pos - event.pos) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like print this dist
and test how it behaves when you perform long and short moves.
When I go slow, I get 0.0 and 1.0 basically exclusively.
The values appear to be in screen pixels?
|
Basically I have to be very careful to ensure the full release of the mouse button before moving. Very deliberate. |
Description
Currently, when adding points interactively the vispy camera is still getting moved by mouse events.
This is not a problem with a mouse - since normally you don't move the mouse while clicking - but it's pretty frustrating with a tablet, since the cursor moves slightly every time you press down or release the stylus. This results on the canvas moving around a tiny bit every time you click.
This was a know issue, since there is a mouse-movement threshold in place beyond which a point doesn't get added; however this does not prevent the canvas from moving even within that threshold.
This PR prevents the vispy camera from receiving the event if this threshold is not yet surpassed.
Type of change