pub struct Scene { /* private fields */ }
Expand description
A container that allows you to zoom and pan.
This is similar to crate::ScrollArea
but:
- Supports zooming
- Has no scroll bars
- Has no limits on the scrolling
Implementations§
Source§impl Scene
impl Scene
pub fn new() -> Self
Sourcepub fn zoom_range(self, zoom_range: impl Into<Rangef>) -> Self
pub fn zoom_range(self, zoom_range: impl Into<Rangef>) -> Self
Set the allowed zoom range.
The default zoom range is 0.0..=1.0
,
which mean you zan make things arbitrarily small, but you cannot zoom in past a 1:1
ratio.
If you want to allow zooming in, you can set the zoom range to 0.0..=f32::INFINITY
.
Note that text rendering becomes blurry when you zoom in: https://github.com/emilk/egui/issues/4813.
Sourcepub fn max_inner_size(self, max_inner_size: impl Into<Vec2>) -> Self
pub fn max_inner_size(self, max_inner_size: impl Into<Vec2>) -> Self
Set the maximum size of the inner Ui
that will be created.
Sourcepub fn show<R>(
&self,
parent_ui: &mut Ui,
scene_rect: &mut Rect,
add_contents: impl FnOnce(&mut Ui) -> R,
) -> InnerResponse<R>
pub fn show<R>( &self, parent_ui: &mut Ui, scene_rect: &mut Rect, add_contents: impl FnOnce(&mut Ui) -> R, ) -> InnerResponse<R>
scene_rect
contains the view bounds of the inner Ui
.
scene_rect
will be mutated by any panning/zooming done by the user.
If scene_rect
is somehow invalid (e.g. Rect::ZERO
),
then it will be reset to the inner rect of the inner ui.
You need to store the scene_rect
in your state between frames.
Sourcepub fn register_pan_and_zoom(
&self,
ui: &Ui,
resp: &mut Response,
to_global: &mut TSTransform,
)
pub fn register_pan_and_zoom( &self, ui: &Ui, resp: &mut Response, to_global: &mut TSTransform, )
Helper function to handle pan and zoom interactions on a response.