pub struct PlayerHost {
pub player: Player,
pub renderer: SceneRenderer,
pub view: ViewTransform,
pub playing: bool,
pub last_tick: Instant,
pub dirty_images: bool,
pub last_pointer: DVec2,
pub fit: FitState,
}Expand description
Per-surface state for one embedded player: the engine, the tessellator
(SceneRenderer), the viewport fit/zoom mapping, and playback control.
Fields§
§player: Player§renderer: SceneRenderer§view: ViewTransformScreen - world mapping for the embed surface.
playing: boolTrue while the widget keeps ticking playback each frame.
last_tick: Instant§dirty_images: boolSet when image assets changed. Uploaded to RenderContext on the next
draw. Constructors mark it dirty so a fresh renderer uploads once.
last_pointer: DVec2Most recent pointer position in surface px (wheel-zoom anchor).
fit: FitStateFit-state tracker: remembers the last fitted surface (+ artboard) and only refits on resize or explicit invalidation, so interactive zoom survives redraws.
Implementations§
Source§impl PlayerHost
impl PlayerHost
pub fn new(player: Player) -> PlayerHost
pub fn from_ren_str(text: &str) -> Result<PlayerHost, PlayerError>
pub fn from_ren_bytes(bytes: &[u8]) -> Result<PlayerHost, PlayerError>
Sourcepub fn mark_images_dirty(&mut self)
pub fn mark_images_dirty(&mut self)
Mark image assets dirty so the next draw re-uploads them to
RenderContext. Call after replacing the player’s project.
pub fn play(&mut self)
pub fn pause(&mut self)
pub fn toggle(&mut self)
Sourcepub fn tick_playback(&mut self) -> bool
pub fn tick_playback(&mut self) -> bool
Advance playback by the wall-clock delta since the last call. Returns true while playing so callers (or hosts with their own loop) can keep requesting frames. Zero-cost whenever paused.
Sourcepub fn tick_playback_fixed(&mut self, dt_secs: f64) -> bool
pub fn tick_playback_fixed(&mut self, dt_secs: f64) -> bool
Advance playback by a fixed dt_secs, for sim-driven embeds where
pause must freeze playback (no wall clock, no 50 ms clamp).
Returns true while playing so callers can keep requesting frames.
Zero-cost whenever paused.
Sourcepub fn fit(&mut self, surface: DVec2)
pub fn fit(&mut self, surface: DVec2)
Fit the artboard inside surface with a margin, centering it.
Records surface so zoom_at /
zoom_centered work after an explicit fit.
Sourcepub fn fit_exact(&mut self, surface: DVec2)
pub fn fit_exact(&mut self, surface: DVec2)
Exact-fit the artboard with no margin (presentational embeds):
records surface and centers, letterboxing on aspect mismatch.
pub fn zoom_centered(&mut self, factor: f64)
Sourcepub fn zoom_at(&mut self, screen_pos: DVec2, factor: f64)
pub fn zoom_at(&mut self, screen_pos: DVec2, factor: f64)
Zoom by factor keeping the world point under screen_pos anchored.
Sourcepub fn surface_size(&self) -> DVec2
pub fn surface_size(&self) -> DVec2
Last fitted surface size (zero before first layout).
Auto Trait Implementations§
impl Freeze for PlayerHost
impl RefUnwindSafe for PlayerHost
impl Send for PlayerHost
impl Sync for PlayerHost
impl Unpin for PlayerHost
impl UnsafeUnpin for PlayerHost
impl UnwindSafe for PlayerHost
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> 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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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.