pub trait Backend {
Show 16 methods
// Required methods
fn cache_policy(&self) -> CachePolicy;
fn window_size(&self) -> Size;
fn resize_window(&mut self, size: Size);
fn set_event_mask(&mut self, mask: EventMask);
fn set_text_input(&mut self, active: bool);
fn poll_events(&mut self, wait: Option<Duration>) -> Vec<InputEvent>;
fn waker(&self) -> Option<Waker>;
fn paint_widget(
&mut self,
id: WidgetId,
size: Size,
paint: &mut dyn FnMut(&mut dyn Painter),
);
fn begin_frame(&mut self, clear: Color);
fn draw_widget(&mut self, id: WidgetId, bounds: Rect);
fn present(&mut self);
fn take_notices(&mut self) -> Vec<EngineEvent>;
fn clipboard_text(&mut self) -> Option<String>;
fn set_clipboard_text(&mut self, text: &str);
fn open_url(&mut self, url: &str) -> Result<(), String>;
// Provided method
fn now(&self) -> Instant { ... }
}Expand description
The services a windowing system provides to the engine.
A backend owns the window and one texture per Widget. The engine asks it to paint a
Widget only when that Widget is invalidated, then composes each frame by drawing the
cached textures. Window creation happens when the backend is built (each backend has its own
settings); Backend::resize_window changes it afterward.
Required Methods§
Sourcefn cache_policy(&self) -> CachePolicy
fn cache_policy(&self) -> CachePolicy
Sourcefn window_size(&self) -> Size
fn window_size(&self) -> Size
Sourcefn resize_window(&mut self, size: Size)
fn resize_window(&mut self, size: Size)
Sourcefn set_event_mask(&mut self, mask: EventMask)
fn set_event_mask(&mut self, mask: EventMask)
Tells the backend which input classes the application wants, so it can stop delivering the rest. A backend may ignore this; the engine filters as well.
§Arguments
mask- The run loop’s event mask.
Sourcefn set_text_input(&mut self, active: bool)
fn set_text_input(&mut self, active: bool)
Starts or stops text input to match the focused Widget.
§Arguments
active-truewhile a text editor has focus.
Sourcefn poll_events(&mut self, wait: Option<Duration>) -> Vec<InputEvent>
fn poll_events(&mut self, wait: Option<Duration>) -> Vec<InputEvent>
Sourcefn waker(&self) -> Option<Waker>
fn waker(&self) -> Option<Waker>
Returns a function other threads call to end a Backend::poll_events wait early; the
next poll then yields InputEvent::Wake.
§Returns
The waker, or None if the backend cannot be woken (the loop then notices posted events
within a frame).
Sourcefn paint_widget(
&mut self,
id: WidgetId,
size: Size,
paint: &mut dyn FnMut(&mut dyn Painter),
)
fn paint_widget( &mut self, id: WidgetId, size: Size, paint: &mut dyn FnMut(&mut dyn Painter), )
Sourcefn begin_frame(&mut self, clear: Color)
fn begin_frame(&mut self, clear: Color)
Sourcefn draw_widget(&mut self, id: WidgetId, bounds: Rect)
fn draw_widget(&mut self, id: WidgetId, bounds: Rect)
Copies a Widget’s cached texture into the frame; nothing happens if it has none.
§Arguments
id- TheWidgetto draw.bounds- Where to draw it, in window coordinates.
Sourcefn take_notices(&mut self) -> Vec<EngineEvent>
fn take_notices(&mut self) -> Vec<EngineEvent>
Returns the engine events the backend produced since the last call (fonts loaded, glyph atlas pages added).
§Returns
The events, in order.
Sourcefn clipboard_text(&mut self) -> Option<String>
fn clipboard_text(&mut self) -> Option<String>
Sourcefn set_clipboard_text(&mut self, text: &str)
fn set_clipboard_text(&mut self, text: &str)
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".