Skip to content

fix: fix wx scrolling#190

Open
tlambert03 wants to merge 1 commit intopygfx:mainfrom
tlambert03:fix-windows-wheel
Open

fix: fix wx scrolling#190
tlambert03 wants to merge 1 commit intopygfx:mainfrom
tlambert03:fix-windows-wheel

Conversation

@tlambert03
Copy link
Contributor

hey @almarklein

this is a fix for scrolling on windows in wx, which is currently broken (see pyapp-kit/ndv#116), but it will also slightly change the behavior on macos.

I tried to figure out what the "proper" fix is here, but the docs weren't super helpful. So the numbers I came to here are a bit empirical ... after testing on both mac and windows, to match the experience of the qt backend.

The one thing I'm confident about is that the previous code of dy = delta * rotation is definitely wrong. It worked ok on macos because you get numbers like delta=10, rotation=1, but on windows you get delta=120, rotation=120 and that leads to the "galaxy far away" phenotype described in the issue above (one step on the wheel and you're absolutely gone).

So, I'm confident that it needs to be scaled by rotation / delta. But that leads to an extremely slow scroll. So I'm adding a gain. the 120 (on windows) exactly matches the Qt single wheel behavior, and on windows, scrolling the wheel faster simply emits more events at exactly the same rotation size. On macos, however, faster scrolling leads to dramatically different rotation sizes (which is nice for UX: you get fine control at small speed and big change at high speed).

Anyway, I know the magic number doesn't feel great here. So feel free to test/research however you like. But I'm confident that things are fully broken on main for windows + wx.

@almarklein
Copy link
Member

Thanks for this! Wheel events are somewhat notorious to get 'right'; empirical numbers are fine :)

MacOS indeed does wheel events somewhat funny, scaling much harder if you yank the wheel harder. I guess this is a good thing, because it means people will very naturally adjust to whatever gain we put in 🤷

I looked into the wx wheel props, and I think we should just ignore the delta altogether. Then the gain is simply 1 for Windows. For MacOS a gain of 1 feels too slpw, but a gain of about 2 makes it more similar to qt.

Have you tried on Linux? I could have a look tomorrow.

@almarklein
Copy link
Member

BTW: do people still use wx nowadays?

@tlambert03
Copy link
Contributor Author

I don't :) however... a well-used application in the bioimage community is cell-profiler: https://cellprofiler.org/ (https://github.com/CellProfiler/CellProfiler) ... and they have been working on integrating ndv specifically because it supports wx. (i believe it's for licensing reasons). So, it remains an important target for ndv

@tlambert03
Copy link
Contributor Author

Have you tried on Linux? I could have a look tomorrow.

i have not!

@almarklein
Copy link
Member

I could have a look tomorrow.

Oh, there don't seem to be binary wheels for wx for Linux; they expect you to built it yourself, but I don't feel like going into that rabbit hole right now, so I'm just going to assume the behavior for Linux and Windows are similar.

Could you just drop the delta, and use a small gain for if sys.platform == 'darwin'?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants