pub struct Windowed<B> { /* private fields */ }winit only.Expand description
Pairs a windowed backend’s PresenterBuilder with the window title Launch needs to
open one.
PresenterBuilder (retroglyph#1192) describes renderer configuration only (grid, scale,
font, tileset): a window title isn’t part of that surface, and adding one would mean
retroglyph-software’s headless pixel-test path (which never opens a window) carries a field
it has no use for. This wrapper is the seam that adds it back for the one call site that
does need it, Launch::launch, without touching PresenterBuilder itself.
Generic over B: PresenterBuilder rather than duplicated per backend crate: Launch is
implemented here, once, for any Windowed<B>, so retroglyph-software, retroglyph-gl, and
retroglyph-wgpu need no impl (and no dependency on this crate’s winit feature beyond what
they already carry) of their own to be launchable this way.
§Examples
use retroglyph_core::app::{App, Flow, Frame, Launch, RunOptions};
use retroglyph_core::backend::Backend;
use retroglyph_core::terminal::Terminal;
use retroglyph_window::PresenterBuilder;
use retroglyph_window::winit::Windowed;
struct MyGame;
impl<B: Backend> App<B> for MyGame {
fn update(&mut self, _term: &mut Terminal<B>, _frame: &Frame) -> Flow {
Flow::Exit
}
}
// Opens a real window, so this example is `no_run`.
Windowed::new(builder, "demo").launch(MyGame, RunOptions::animated(60))?;Implementations§
Trait Implementations§
Source§impl<B> Launch for Windowed<B>where
B: PresenterBuilder,
impl<B> Launch for Windowed<B>where
B: PresenterBuilder,
Source§fn launch<A>(self, app: A, options: RunOptions) -> Result<(), Self::Error>
fn launch<A>(self, app: A, options: RunOptions) -> Result<(), Self::Error>
Builds self’s presenter, opens a window sized to fit it (paced by options), and
drives app on it until it returns Flow::Exit.
RunOptions::idle_wake has no windowed
meaning and is ignored; see WindowConfig::with_run_options for why.
§Errors
Returns WindowedLaunchError::Build if the presenter builder’s configuration is
invalid, or WindowedLaunchError::EventLoop if the event loop cannot be created or
fails while running.
Source§type Backend = WindowBackend<<B as PresenterBuilder>::Presenter>
type Backend = WindowBackend<<B as PresenterBuilder>::Presenter>
App on.Source§type Error = WindowedLaunchError<<B as PresenterBuilder>::Error>
type Error = WindowedLaunchError<<B as PresenterBuilder>::Error>
launch can fail with; each backend surfaces its
own, unwrapped (see this trait’s docs for why there is no unified error here).Auto Trait Implementations§
impl<B> Freeze for Windowed<B>where
B: Freeze,
impl<B> RefUnwindSafe for Windowed<B>where
B: RefUnwindSafe,
impl<B> Send for Windowed<B>where
B: Send,
impl<B> Sync for Windowed<B>where
B: Sync,
impl<B> Unpin for Windowed<B>where
B: Unpin,
impl<B> UnsafeUnpin for Windowed<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for Windowed<B>where
B: 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> 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>. 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.