Introduce global zoom_factor - #3608
Merged
Merged
Conversation
emilk
force-pushed
the
emilk/zoom_factor
branch
from
November 22, 2023 16:16
3ce14e2 to
12da7c3
Compare
emilk
force-pushed
the
emilk/zoom_factor
branch
from
November 22, 2023 16:39
7fe5deb to
a206f0b
Compare
emilk
marked this pull request as ready for review
November 22, 2023 17:46
Contributor
|
I really feel that this should not be enabled by default. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zoom_factor#3602You can now zoom any egui app by pressing Cmd+Plus, Cmd+Minus or Cmd+0, just like in a browser. This will change the current
zoom_factor(default 1.0) which is persisted in the egui memory, and is the same for all viewports.You can turn off the keyboard shortcuts with
ctx.options_mut(|o| o.zoom_with_keyboard = false);zoom_factorcan also be explicitly read/written withctx.zoom_factor()andctx.set_zoom_factor().This redefines
pixels_per_pointaszoom_factor * native_pixels_per_point, wherenative_pixels_per_pointis whatever is the native scale factor for the monitor that the current viewport is in.This adds some complexity to the interaction with winit, since we need to know the current
zoom_factorin a lot of places, because all egui IO is done in ui points. I'm pretty sure this PR fixes a bunch of subtle bugs though that used to be in this code.egui::gui_zoom::zoom_with_keyboard_shortcutsis now gone, and is no longer needed, as this is now the default behavior.Context::set_pixels_per_pointis still there, but it is recommended you useContext::set_zoom_factorinstead.