[BUG][EDITOR] Zoom only preserves cursor position after LMB click [FIXED]

Started by WillLem, November 30, 2024, 03:19:37 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

WillLem

After fixing this bug in NL/SLX, I've begun investigating the same bug in the Editor.

Nepster implemented zooming-preserves-cursor behaviour in commit fa1ff40. I haven't test-built from that commit yet, but current Editor behaviour is that the cursor is only preserved if the level area is first clicked with the LMB.

Steps to reproduce:

1) Open the Editor
2) Place a large piece in the centre of the level (e.g. clump_01 from orig_crystal is good for testing this)
3) LMB-click the very top-left corner of the piece, keep the cursor there, and zoom in

Observation A: The zoom should focus towards the top-left corner of the piece, as expected.

4) Zoom back out
5) Without clicking, move the cursor towards the bottom-right corner, and zoom in

Observation B: The zoom should still focus towards the top-left corner of the piece.

6) Zoom back out
7) LMB-click the very bottom-right corner of the piece, keep the cursor there, and zoom in

Observation C: The zoom should now focus towards the bottom-right corner of the piece. Moving the cursor to another part of the piece, without clicking, should result in similar behaviour to that observed in Observation B; the zoom wants to focus on the last place that was actively clicked by the LMB, as opposed to the current cursor position.

Conclusion: The fix to the zoom works, but relies on actual mouse interaction as opposed to simply knowing the current position of the cursor.

I'll see if I can get this fixed in the next update.

WillLem

This has now been fixed (Commits 60ed316 and 14adada).

First commit: After a bit lot of trial and error, I discovered that it's necessary to reset the "isMouseWheelActive" bool to false after determining the mouse position; resetting the flag triggers this part of the mouse wheel event handler to re-read the mouse position again between each zoom. Previously, with the flag set to true, the code would skip straight to "ChangeZoom" with the original mouse position, which wouldn't get updated until the flag was set to false (i.e. by clicking the LMB somewhere else). This is enough to fix the bug, but I then wonder if the bool is needed at all...

Second commit: After further investigation, it indeed appears that the "isMouseWheelActive" bool isn't actually needed at all. Its only function was to prevent re-firing of the part of the mouse wheel event handler that reads the mouse position, but that's exactly what was causing the bug; we want it to re-fire. So, the bool is gone and the zoom anchor is both preserved between zooms and reset each time a new zoom is performed.