Trait AppContext
pub trait AppContext {
// Required methods
fn central(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder));
fn set_theme(&mut self, theme: &UiTheme);
fn set_fonts(&mut self, pack: &FontPack);
fn screen_size(&self) -> [f32; 2];
fn request_repaint(&mut self);
// Provided methods
fn pixels_per_point(&self) -> f32 { ... }
fn request_close(&mut self) { ... }
}Expand description
Top-level app context — one per frame.
Required Methods§
fn central(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))
fn central(&mut self, f: &mut dyn FnMut(&mut dyn UiBuilder))
Open the central drawing region. The closure receives a
&mut dyn UiBuilder and lays out the frame’s content.
Equivalent to “the whole window minus any panels installed at the backend level”. For tools without OS-level panels (the hub) this is the only call needed per frame.
fn set_theme(&mut self, theme: &UiTheme)
fn set_theme(&mut self, theme: &UiTheme)
Apply a UiTheme to the underlying backend’s visual
configuration. Idempotent — call again to swap palettes at
runtime.
fn set_fonts(&mut self, pack: &FontPack)
fn set_fonts(&mut self, pack: &FontPack)
Install the fonts described by pack. Called once at startup
(or whenever fonts change).
fn screen_size(&self) -> [f32; 2]
fn screen_size(&self) -> [f32; 2]
Logical screen size in pixels — [width, height].
fn request_repaint(&mut self)
fn request_repaint(&mut self)
Ask the backend for another paint pass on the next available frame, even if no input event would normally trigger one. Use when an off-thread async task completes and the visible UI must update.
Provided Methods§
fn pixels_per_point(&self) -> f32
fn pixels_per_point(&self) -> f32
Pixels-per-point ratio (DPI scale). 1.0 on standard displays, 2.0 on Retina, etc.
fn request_close(&mut self)
fn request_close(&mut self)
Request the application window to close. The shutdown happens at the end of the current frame (or whenever the backend gets to it).