pub struct FitState {
pub pending: bool,
/* private fields */
}Expand description
Fit-state tracker shared by the editor viewport and the player embed: remembers the last fitted surface (+ artboard) and only refits on resize or explicit invalidation, so interactive zoom survives redraws.
Fields§
§pending: boolImplementations§
Source§impl FitState
impl FitState
pub fn new() -> Self
Sourcepub fn with_surface(surface: DVec2) -> Self
pub fn with_surface(surface: DVec2) -> Self
Pre-seed the surface record (e.g. after an explicit fit call) so
zoom anchors work even when the artboard was degenerate.
Sourcepub fn ensure(
&mut self,
view: &mut ViewTransform,
surface: DVec2,
artboard: DVec2,
refit_on_resize: bool,
) -> bool
pub fn ensure( &mut self, view: &mut ViewTransform, surface: DVec2, artboard: DVec2, refit_on_resize: bool, ) -> bool
Refit view when the surface/artboard changed beyond 0.5 px or a
fit was requested via FitState::request. Returns true when a
refit ran. Pan gestures opt out by skipping this call.
refit_on_resize: the player embed refits on window resize
(true); the editor viewport keeps the user’s zoom on resize
(false) and only refits on first layout, artboard change, or
explicit request.
Sourcepub fn request(&mut self)
pub fn request(&mut self)
Request a refit on the next FitState::ensure call
(e.g. after a zoom-to-fit shortcut).
pub fn surface_size(&self) -> DVec2
Sourcepub fn zoom_centered(&self, view: &mut ViewTransform, factor: f64)
pub fn zoom_centered(&self, view: &mut ViewTransform, factor: f64)
Zoom about the surface center; no-op before the first layout.
Sourcepub fn zoom_at(&self, view: &mut ViewTransform, screen_pos: DVec2, factor: f64)
pub fn zoom_at(&self, view: &mut ViewTransform, screen_pos: DVec2, factor: f64)
Zoom about screen_pos; no-op before the first layout.