pub struct WindowBackend<P: Presenter> { /* private fields */ }Expand description
A Backend built from a Presenter plus an input event queue.
Backend fuses input and output, which does not fit a window: some event
loop owns input, while a per-renderer surface owns output. WindowBackend
reunites the two so Terminal gets the full
Backend it needs, while renderer crates implement only Presenter:
event loop.push_event(e) ──> VecDeque<Event> ──> app.poll_event()
│
v
Terminal<WindowBackend<P>>
│
draw / flush / resize v
◄──────────────────── WindowBackend
│
v
P: Presenter (output)With the winit feature enabled, winit::run_windowed and
winit::run_app own the event loop, call push_event as winit events
are translated, and call Presenter::present once per frame; callers
never touch WindowBackend directly. With winit disabled,
retroglyph-window exports no event loop at all: a caller driving its
own loop (SDL2, tao, a custom driver) constructs
WindowBackend::new(presenter) itself, calls push_event for each
translated input event, and calls Terminal::present (which drives
Presenter::flush) plus presenter_mut().present() once per frame.
poll_event never blocks: frame timing is owned by
the event loop, not by input waits.
Implementations§
Source§impl<P: Presenter> WindowBackend<P>
impl<P: Presenter> WindowBackend<P>
Sourcepub const fn presenter_mut(&mut self) -> &mut P
pub const fn presenter_mut(&mut self) -> &mut P
The wrapped presenter, mutably.
Sourcepub fn into_presenter(self) -> P
pub fn into_presenter(self) -> P
Unwrap into the presenter, discarding queued events.
Trait Implementations§
Source§impl<P: Presenter> Backend for WindowBackend<P>
impl<P: Presenter> Backend for WindowBackend<P>
Source§fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
fn draw<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
Source§fn draw_layers<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
fn draw_layers<'a, I>(&mut self, content: I) -> Result<(), Self::Error>
Source§fn flush(&mut self) -> Result<(), Self::Error>
fn flush(&mut self) -> Result<(), Self::Error>
Source§fn needs_full_frame(&self) -> bool
fn needs_full_frame(&self) -> bool
true if the backend needs the entire frame (all cells on
all layers) on every call to draw_layers, rather
than just the changed cells. Read moreSource§fn composites_layers(&self) -> bool
fn composites_layers(&self) -> bool
draw_layers. Read moreSource§fn poll_event(&mut self, _timeout: Duration) -> Option<Event>
fn poll_event(&mut self, _timeout: Duration) -> Option<Event>
timeout.Source§fn push_event(&mut self, event: Event)
fn push_event(&mut self, event: Event)
Source§fn set_cursor_visible(&mut self, _visible: bool)
fn set_cursor_visible(&mut self, _visible: bool)
Source§fn set_cursor_position(&mut self, _position: Pos)
fn set_cursor_position(&mut self, _position: Pos)
Auto Trait Implementations§
impl<P> Freeze for WindowBackend<P>where
P: Freeze,
impl<P> RefUnwindSafe for WindowBackend<P>where
P: RefUnwindSafe,
impl<P> Send for WindowBackend<P>where
P: Send,
impl<P> Sync for WindowBackend<P>where
P: Sync,
impl<P> Unpin for WindowBackend<P>where
P: Unpin,
impl<P> UnsafeUnpin for WindowBackend<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for WindowBackend<P>where
P: UnwindSafe,
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.