limiting scene scrolling boundries to content size
- Dominant language
- Rust
- Stars
- 30.6k
- Forks
- 2.1k
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 72
Description
**Is your feature request related to a problem? Please describe.**
I would like to have a scene, that can be zoomed infinitely, but a max of 1.0 ratio. The panning should be limited to the content inside, so that when the content is at the 1.0 ratio, the scene should not pan at all. Similarly, when zoomed and at the image border, it should not scroll past the content.
The usecase is specifically for an image viewer, where you can zoom but it doesn't need to pan past the image borders (and some padding).
**Describe the solution you'd like**
An api on the scene builder that allows declaring a maximum boundary size at the 1.0 ratio.
```rs
Scene::new().with_boundary(Align2::CENTER, Vec2::splat(400.0)).show(...)
```
A side thought about an edge case: zooming out past 1.0 ratio, boundary size might have to limit the zoom range as well if we reach it fully in either direction.
**Describe alternatives you've considered**
Maybe more specifically just a high level toggle to set the panning boundary to the content size would be nice. It might be easy to also implement in tandem with the more granular boundary api described above.
```rs
Scene::new().zoom_range(1.0..=f32::INFINITY).with_content_limit(true).show(...)
```
Contributor guide
Research direction
Start by locating the Scene::new API and existing zoom or panning boundary handling in egui. Define how a boundary at the 1.0 ratio affects panning, zooming below 1.0, alignment, and padding; done means the scene cannot scroll beyond the declared content boundary while preserving the requested zoom behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100