pub struct SceneTransform {
pub zoom: f64,
pub offset: Point,
}Expand description
Translation + uniform scale mapping scene space to Scene-local screen space.
Fields§
§zoom: f64Screen pixels per scene unit. Always > 0.
offset: PointScene→screen translation, applied after scaling (Scene-local Y-up px).
Implementations§
Source§impl SceneTransform
impl SceneTransform
pub fn new(zoom: f64, offset: Point) -> Self
Sourcepub fn scene_to_screen(&self, p: Point) -> Point
pub fn scene_to_screen(&self, p: Point) -> Point
Map a scene-space point to Scene-local screen space.
Sourcepub fn to_affine(&self) -> TransAffine
pub fn to_affine(&self) -> TransAffine
This transform as a crate::TransAffine mapping scene (child) space to
Scene-local screen space, i.e. screen = zoom * scene + offset.
This is what Scene returns from
Widget::child_transform so
the framework’s paint / hit-test / dispatch / inspector traversals all
map coordinates through the same pan/zoom the content is drawn under.
Sourcepub fn screen_to_scene(&self, p: Point) -> Point
pub fn screen_to_scene(&self, p: Point) -> Point
Map a Scene-local screen point back to scene space.
Sourcepub fn visible_scene_rect(&self, size: Size) -> Rect
pub fn visible_scene_rect(&self, size: Size) -> Rect
The region of scene space currently visible in a container of size
(the Scene widget’s bounds), expressed in scene coordinates.
This is what the caller reads back as the “scene rect”.
Sourcepub fn pan(&mut self, delta_screen: Point)
pub fn pan(&mut self, delta_screen: Point)
Translate the view by a screen-space delta (drag-to-pan). Content follows the cursor: dragging right moves the scene content right.
Sourcepub fn zoom_at(
&mut self,
cursor_screen: Point,
new_zoom: f64,
range: (f64, f64),
)
pub fn zoom_at( &mut self, cursor_screen: Point, new_zoom: f64, range: (f64, f64), )
Change the zoom to new_zoom (clamped to range) while keeping the
scene point currently under cursor_screen fixed on screen.
This is the invariant that makes wheel-zoom feel anchored to the cursor rather than to the origin.
Trait Implementations§
Source§impl Clone for SceneTransform
impl Clone for SceneTransform
Source§fn clone(&self) -> SceneTransform
fn clone(&self) -> SceneTransform
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SceneTransform
Source§impl Debug for SceneTransform
impl Debug for SceneTransform
Source§impl Default for SceneTransform
impl Default for SceneTransform
Source§impl PartialEq for SceneTransform
impl PartialEq for SceneTransform
impl StructuralPartialEq for SceneTransform
Auto Trait Implementations§
impl Freeze for SceneTransform
impl RefUnwindSafe for SceneTransform
impl Send for SceneTransform
impl Sync for SceneTransform
impl Unpin for SceneTransform
impl UnsafeUnpin for SceneTransform
impl UnwindSafe for SceneTransform
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().