Skip to content
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

Zoom steps #9327

Merged
merged 2 commits into from
Mar 8, 2024
Merged

Zoom steps #9327

merged 2 commits into from
Mar 8, 2024

Conversation

kazcw
Copy link
Contributor

@kazcw kazcw commented Mar 7, 2024

Pull Request Description

When zooming with Ctrl+wheel, used fixed-factor steps instead of scroll wheel rate information.

Screen.Recording.2024-03-07.at.13.09.54.mov

Fixes #9177.

Important Notes

  • Wheel events are distinguished from trackpad gestures, so that OS X pinch-zoom still works nicely.
  • When zooming with the mouse wheel, scale factor is rounded (geometrically) to the nearest power of √2, and then stepped up or down by the same factor; this ensures that round values like 100% are never skipped over.
  • Added directed-clamping logic, so that if the zoom is moved outside the clamping range of a zoom-method, it can be stepped back into range without jumping.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@kazcw kazcw added CI: No changelog needed Do not require a changelog entry for this PR. -gui labels Mar 7, 2024
@kazcw kazcw self-assigned this Mar 7, 2024
Comment on lines +210 to +228
let ctrlPressed = false
useEvent(
window,
'keydown',
(event) => {
if (event.key === 'Control') ctrlPressed = true
return false
},
{ capture: true },
)
useEvent(
window,
'keyup',
(event) => {
if (event.key === 'Control') ctrlPressed = false
return false
},
{ capture: true },
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always concerned in cases where the entire window loses focus when pressed ctrl - we then could likely be stuck with control pressed what is not easily discoverable by the user.

But as it's only for gestures... maybe it's not as big issue here. But let also clear the flag if received event without ctrlKey.

@farmaazon
Copy link
Contributor

Also, I'd like to have +- buttons in "zoom" menu entry behave the same way.

@kazcw kazcw merged commit 614a5a6 into develop Mar 8, 2024
32 of 35 checks passed
@kazcw kazcw deleted the wip/kw/zoom-steps branch March 8, 2024 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-gui CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zoom steps when ctrl+wheeling are impractical
2 participants