blackjack icon indicating copy to clipboard operation
blackjack copied to clipboard

Zoom speed on MacOS

Open setzer22 opened this issue 2 years ago • 7 comments

Just a small improvement would be to reduce the speed of the zoom speed, it is very difficult to be precise as it is very fast to zoom and unzoom.

Originally posted by @Kerollmops in https://github.com/setzer22/blackjack/issues/7#issuecomment-1025198179

setzer22 avatar Jan 30 '22 18:01 setzer22

@Kerollmops Zoom speed looks fine on my end. This is probably caused by mouse events behaving slightly different on MacOS. I added a few debug prints on a new branch fix/zoom_speed_macos (https://github.com/setzer22/blackjack/tree/fix/zoom_speed_macos). If you have time, could you run that and tell me what kind of output you're getting when scrolling on both the viewport and node editor?

For reference, it looks like this on my end after scrolling a few times up and down on one viewport, then the other:

PS: Many thanks for helping me debug all these issues :smile:

[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, 1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[3d viewport] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, -1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)
[Node Editor] LineDelta(0.0, 1.0)

setzer22 avatar Jan 30 '22 18:01 setzer22

Here are the debug logs I get when I just barely move my fingers on my trackpad i.e. no more than a distance of 0.5 cm.

[Node Editor] PixelDelta(PhysicalPosition { x: -0.0, y: 0.0 })
[Node Editor] PixelDelta(PhysicalPosition { x: -0.0, y: 0.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 0.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 4.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -2.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -2.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -4.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 2.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 2.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 2.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 4.0, y: 4.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 2.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: 2.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: -2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -2.0, y: 0.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -2.0, y: 0.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 4.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 2.0 })
[3d viewport] PixelDelta(PhysicalPosition { x: -0.0, y: 0.0 })

BTW importing files on this specific branch makes the program crash with:

thread 'main' panicked at 'Error executing action: missing field `shown_inline`', src/application.rs:196:18

Kerollmops avatar Jan 30 '22 19:01 Kerollmops

Here are the debug logs I get when I just barely move my fingers on my trackpad i.e. no more than a distance of 0.5 cm

Thanks! I can start working with that :)

BTW importing files on this specific branch makes the program crash with:

Oops, I messed up and pushed to the wrong branch. The panic happens because I added a new property to the graph struct. In general, don't expect file compatibility between versions just yet. It's too soon for that since I'm still figuring out exactly what I need to store.

But for this particular case, I think I can serde::default my way out of it :smile:

setzer22 avatar Jan 30 '22 19:01 setzer22

For the record, the panic on deserialization has been fixed in db97e62, since keeping compatibility was easy enough for the new fields I added.

setzer22 avatar Jan 30 '22 20:01 setzer22

Thank you, that is a nice project I would like it to go further 😃

Just for correctness, I was not even moving 0.5cm with my fingers on my trackpad but not moving them at all, just rolling them a little bit. That's probably just 0.05 cm.

Kerollmops avatar Jan 30 '22 20:01 Kerollmops

As a drive-by suggestion, in the hopes it might be a helpful pointer:

This issue has the appearance of a common issue with cross-platform "scroll-wheel" behaviour which occurs due to the difference in use of trackpad vs mouse-wheel for scrolling and the unit of the values returned.

It can be seen in the debug logs where the first log shows LineDelta (as generally reported by scroll-wheels) & while the second log shows PixelDelta (as generally reported by trackpad scrolling)--what is possibly happening is that the pixel-delta is being used as a line-delta which effectively multiplies the speed of the zoom.

The issue can also appear when an application is deployed natively vs when deployed in a web browser (and across browser engines).

I know egui has run into this (& other scrolling) issue before so it might be informative to take a look at the related issues/patches:

  • https://github.com/emilk/egui/issues/159#issuecomment-776593734 (Lol, apparently I wrote a bunch more detail there. :D )
  • https://github.com/emilk/egui/issues/461
  • https://github.com/emilk/egui/issues/356
  • https://github.com/emilk/egui/issues/401

Hope this is helpful.


Aside: Discovered Blackjack via your recent Rust GameDev Meetup talk which was enjoyable. I particularly liked how you doubled-down on the carrots in response. :D

follower avatar Feb 13 '22 12:02 follower

Hope this is helpful.

It certainly is! Many thanks :smile:

Aside: Discovered Blackjack via your recent Rust GameDev Meetup talk which was enjoyable. I particularly liked how you doubled-down on the carrots in response. :D

Haha, I'm glad you enjoyed it! Extra carrots is always a safe bet :carrot:

setzer22 avatar Feb 14 '22 12:02 setzer22