pub struct Embedded<A: App> { /* private fields */ }Expand description
A fenestra app embedded in a caller-owned wgpu world. See the module docs for the contract.
Implementations§
Source§impl<A: App> Embedded<A>
impl<A: App> Embedded<A>
Sourcepub fn new(
app: A,
theme: Theme,
device: &Device,
target_format: TextureFormat,
) -> Self
pub fn new( app: A, theme: Theme, device: &Device, target_format: TextureFormat, ) -> Self
Builds the renderer on your device. target_format is the
format of the views you will pass to Self::render (usually
your surface format).
§Panics
If vello’s shaders fail to compile on the device.
Sourcepub fn set_clear(&mut self, color: Color)
pub fn set_clear(&mut self, color: Color)
The base color behind the UI. Defaults to the theme background;
set Color::TRANSPARENT to composite over your own scene.
Sourcepub fn set_theme(&mut self, theme: Theme)
pub fn set_theme(&mut self, theme: Theme)
Replaces the theme (e.g. a light/dark toggle driven by your app).
Sourcepub fn app_mut(&mut self) -> &mut A
pub fn app_mut(&mut self) -> &mut A
Mutable app access (the next Self::render rebuilds).
Sourcepub fn pump(&mut self) -> bool
pub fn pump(&mut self) -> bool
Drains proxied messages (from App::init / threads) into the
app. Returns whether anything was applied — repaint if so.
Sourcepub fn input(&mut self, event: InputEvent) -> EventResponse
pub fn input(&mut self, event: InputEvent) -> EventResponse
Routes one raw input event into the UI. Prefer
Self::handle_window_event in winit apps; this is the
window-system-agnostic form (and what tests drive).
Sourcepub fn handle_window_event(
&mut self,
window: &Window,
event: &WindowEvent,
) -> EventResponse
pub fn handle_window_event( &mut self, window: &Window, event: &WindowEvent, ) -> EventResponse
Translates and routes one winit event (cursor, buttons, wheel, keyboard with the printable/shortcut split, IME commit/preedit, modifiers) — the same mapping the built-in runner uses.
Sourcepub fn animating(&self) -> bool
pub fn animating(&self) -> bool
Whether the last built frame is still animating (keep rendering).
Sourcepub fn render(
&mut self,
device: &Device,
queue: &Queue,
target: &TextureView,
physical: (u32, u32),
scale: f64,
)
pub fn render( &mut self, device: &Device, queue: &Queue, target: &TextureView, physical: (u32, u32), scale: f64, )
Builds the current frame and composites it onto target with
premultiplied-alpha blending. physical is the target size in
physical pixels; scale the DPI factor (logical = physical /
scale). Call after your own passes each frame.
§Panics
If vello fails to render (device loss).
Sourcepub fn frame(&self) -> Option<&Frame>
pub fn frame(&self) -> Option<&Frame>
The last built frame (after Self::render) — semantic queries
and inspector dumps work on it like anywhere else.
Sourcepub fn texture_view(&self) -> Option<&TextureView>
pub fn texture_view(&self) -> Option<&TextureView>
The internal premultiplied-alpha texture view from the last
Self::render — sample it in your own pipeline for custom
compositing instead of the built-in blit.
Auto Trait Implementations§
impl<A> !Freeze for Embedded<A>
impl<A> !RefUnwindSafe for Embedded<A>
impl<A> !Send for Embedded<A>
impl<A> !Sync for Embedded<A>
impl<A> !UnwindSafe for Embedded<A>
impl<A> Unpin for Embedded<A>
impl<A> UnsafeUnpin for Embedded<A>
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.