Skip to content

Conversation

@Tristan117
Copy link

@Tristan117 Tristan117 commented Oct 26, 2025

This feature allows building image viewers and similar applications using a Scene container where the desired mouse wheel input without a modifier is to zoom rather than scroll/pan.

Alternatives considered:

  1. Swap zoom and scroll variables used in Scene.rs
  • Would cause touch input zoom to scroll/pan instead which would be inconsistent with standard user interface interaction
  • This also means there is no simple way to swap zoom and vertical scroll modifiers for this use case e.g. ctrl+mousewheel pans vertically while mousewheel alone zooms. What is implemented results in ctrl-mousewheel and mousewheel only being identical inputs.
  1. Modify ctx.option.zoom_modifier
  • Doesn't work because Modifiers:NONE never matches to anything (and therefore disables mouse wheel zoom globally.

  • Refactoring this to provide a different option per container is a large amount of work and does not seem to be a use case that is likely to be used outside of Scene

  • The logic used inside Scene to achieve this is fairly simple and only adds one extra dependency on input_options.scroll_zoom_speed to ensure that the zoom speed setting change is consistent across the application

  • tested as part of my application

  • run ./scripts/check.sh

Tristan117 and others added 10 commits October 26, 2025 08:31
Added feature to allow mousewheel scroll input to zoom a scene rather than pan it (i.e. for an image viewer or other application). This addresses Issue emilk#7650
Fixed compilation errors.
Fixed compiler error
Adding horizontal and vertical scroll
Included scroll zoom speed
@github-actions
Copy link

Preview is being built...

Preview will be available at https://egui-pr-preview.github.io/pr/7666-patch-1

View snapshot changes at kitdiff

@Tristan117 Tristan117 marked this pull request as ready for review October 27, 2025 10:28
@Tristan117 Tristan117 changed the title Add option scrolling_zooms for mouse wheel to zoom instead of scroll inside a Scene container Add option scrolling_zooms for mouse wheel to zoom instead of scroll inside a Scene container Oct 27, 2025
@Tristan117 Tristan117 changed the title Add option scrolling_zooms for mouse wheel to zoom instead of scroll inside a Scene container Add option scrolling_zooms for mouse wheel to zoom instead of scroll inside a Scene container Oct 27, 2025
@Tristan117
Copy link
Author

All tests passing. Took a number of additional setup steps (install pngcrush, set options.threshold(OsThreshold::new(0.0).windows(2.1)) for the Bézier Curve demo) to get them working in Windows.

Tristan117 and others added 6 commits October 27, 2025 23:01
Fixed compilation errors.
Update scene.rs

Fixed compiler error
Update scene.rs

Adding horizontal and vertical scroll
Included scroll zoom speed
trying to fix scroll_zoom_speed

Trying to fix scroll_zoom_speed

This should fix it
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.

Scroll to zoom without ctrl in egui::Scene

1 participant