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() -> Scene
Sourcepub fn sense(self, sense: Sense) -> Scene
pub fn sense(self, sense: Sense) -> Scene
Specify what type of input the scene should respond to.
The default is Sense::click_and_drag().
Set this to Sense::hover() to disable panning via clicking and dragging.
Sourcepub fn zoom_range(self, zoom_range: impl Into<Rangef>) -> Scene
pub fn zoom_range(self, zoom_range: impl Into<Rangef>) -> Scene
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>) -> Scene
pub fn max_inner_size(self, max_inner_size: impl Into<Vec2>) -> Scene
Set the maximum size of the inner Ui that will be created.
Specify which pointer buttons can be used to pan by clicking and dragging.
By default, this is DragPanButtons::all().
Sourcepub fn scroll_zooms(self, scroll_zooms: bool) -> Scene
pub fn scroll_zooms(self, scroll_zooms: bool) -> Scene
Specify whether scrolling the mousewheel without a modifier pans or zooms the Scene. Touch input is not affected by this setting.
By default, this is false.
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.
Trait Implementations§
Auto Trait Implementations§
impl Forget for Scene
impl Freeze for Scene
impl Move for Scene
impl RefUnwindSafe for Scene
impl Send for Scene
impl Sync for Scene
impl Unpin for Scene
impl UnsafeUnpin for Scene
impl UnwindSafe for Scene
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more