Uranium icon indicating copy to clipboard operation
Uranium copied to clipboard

Fix "Zoom Toward Mouse Direction" #6775

Open seaniepie opened this issue 2 years ago • 8 comments

Zoom toward mouse always referenced the mouse position as half the actual position. Mainly due to calculations based on the viewport centre rather than the dimensions and native mouse positions. This patch fixes it by not referencing the centre of the viewport, but to the mouse position directly.

seaniepie avatar May 09 '22 12:05 seaniepie

This breaks zoom towards mouse direction on my machine (Ubuntu). The original code does work correctly on my device.

nallath avatar May 10 '22 07:05 nallath

@nallath, I think this latest commit allows for Mac/Win AND Linux in an elegant enough way. Do you have Win and Mac to test on also or only Linux?

seaniepie avatar May 10 '22 11:05 seaniepie

@nallath, I think this latest commit allows for Mac/Win AND Linux in an elegant enough way. Do you have Win and Mac to test on also or only Linux?

I will ask one of the other developers :)

nallath avatar May 10 '22 11:05 nallath

Hi, designated Windows dev here. I initially observed that, on my machine, our method works, but yours didn't.

I have a theory, however, based on some tests with changing the scaling the OS applies globally (you can set that in the 'Display Settings').

Our method seems to work fine when the scaling of the OS is set to 100%. In fact, on 100% ours works, and your change doesn't seem to, at least on my machine.

Both our method and yours break when I set it to (say) 175% scaling. Your method seems to work around 125%, 150%, which is recommended for some (laptop) screens, so Windows auto-selects that.

So I don't think this is the right way to fix this, especially since we don't even know if mac works or not (behaviour is closer to linux usually). Also, we have standardized methods for Win/Mac/Linux look for Platform.isLinux() for example.

rburema avatar May 10 '22 12:05 rburema

I think it must be down to the resolution (for a Mac laptop this is often 2x (ish) due to their 'retina' screens). This is probably not being accounted for but only seems to affect zoom scaling when it comes to dealing with the mouse position. Probably because it is only there that the code is specifically interested in the mouse position. I'll do a bit more digging and then close this pull request.

seaniepie avatar May 10 '22 19:05 seaniepie

Part of Qt seems to help with this using devicePixelRatio If we instead use a simple multiplier on the mouse position derived from the devicePixelRatio(), we should be able to fix for any platform, display and resolution scaling.

seaniepie avatar May 10 '22 20:05 seaniepie

@nallath @rburema, Latest commit makes use of devicePixelRatio. Can you test on your OSs too? Can an independent Mac dev also test for us? Preferably someone with a Retina display that can switch between pixelRatios.

seaniepie avatar May 10 '22 21:05 seaniepie

The latest version seems to work correctly for me (Ubuntu 21)

nallath avatar May 11 '22 11:05 nallath

Ah sorry, this one fell between the cracks it seems. Yes it works now!

rburema avatar Aug 26 '22 19:08 rburema

Yay. Thanks

seaniepie avatar Aug 27 '22 08:08 seaniepie