Add support for egui built-in ctrl+/- and other zoom behaviours #437
+204
−14
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.
Egui provides some built-in zoom factor manipulation.
Egui includes:
zoom_menu_buttons(ui);When using the
ui.rsexample before applying this change, when using the built-in egui scaling hotkeys, the UI flickers for one frame but there is no resulting scale change.These proposed changes add support for changes to egui zoom_factor being propagated back to the bevy_egui scale_factor.
The changes include adding
ctrl+[andctrl+]hotkeys to theui.rsexample to demonstrate that both egui and bevy_egui can harmoniously adjust the zoom factor with no one-frame problems.To experience the changes, run the ui.rs example and use the
ctrl+[,ctrl+],ctrl+'+',ctrl+'-'hotkeys to observe scale changes being initiated from both egui and bevy_egui.It's a bit fiddly to make sure that the values are synced properly while allowing either to initiate a change with no flickering lol
My understanding is that the bevy_egui scale factor was introduced before egui had its own scale factor, so there's future opportunity to remove the bevy_egui scale factor entirely, but until then this should be a good middle ground.
related: #244