[−][src]Trait kas_theme::Theme
A theme provides widget sizing and drawing implementations.
The theme is generic over some Draw type.
Objects of this type are copied within each window's data structure. For large resources (e.g. fonts and icons) consider using external storage.
Associated Types
type Window: Window<Draw> + 'static
The associated Window implementation.
type DrawHandle: DrawHandle
The associated DrawHandle implementation.
Required methods
fn init(&mut self, draw: &mut Draw)
Theme initialisation
The toolkit must call this method before Theme::new_window
to allow initialisation specific to the Draw device.
At a minimum, a theme must load a font via DrawText::load_font.
The first font loaded (by any theme) becomes the default font.
fn new_window(&self, draw: &mut Draw, dpi_factor: f32) -> Self::Window
Construct per-window storage
On "standard" monitors, the dpi_factor is 1. High-DPI screens may
have a factor of 2 or higher. The factor may not be an integer; e.g.
9/8 = 1.125 works well with many 1440p screens. It is recommended to
round dimensions to the nearest integer, and cache the result:
self.margin = (MARGIN * factor).round() as u32;
A reference to the draw backend is provided allowing configuration.
fn update_window(&self, window: &mut Self::Window, dpi_factor: f32)
Update a window created by Theme::new_window
This is called when the DPI factor changes or theme dimensions change.
unsafe fn draw_handle(
&self,
draw: &mut Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
&self,
draw: &mut Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
Construct a DrawHandle object
Drawing via this DrawHandle is restricted to the specified rect.
The window is guaranteed to be one created by a call to
Theme::new_window on self, and the draw reference is guaranteed
to be identical to the one passed to Theme::new_window.
fn clear_colour(&self) -> Colour
Background colour
Implementations on Foreign Types
impl<T: Theme<Draw>, Draw> Theme<Draw> for Box<T>[src]
type Window = <T as Theme<Draw>>::Window
type DrawHandle = <T as Theme<Draw>>::DrawHandle
fn init(&mut self, draw: &mut Draw)[src]
fn new_window(&self, draw: &mut Draw, dpi_factor: f32) -> Self::Window[src]
fn update_window(&self, window: &mut Self::Window, dpi_factor: f32)[src]
unsafe fn draw_handle(
&self,
draw: &mut Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle[src]
&self,
draw: &mut Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
fn clear_colour(&self) -> Colour[src]
Implementors
impl<D> Theme<D> for ShadedTheme where
D: Draw + DrawRounded + DrawShaded + DrawText + 'static, [src]
D: Draw + DrawRounded + DrawShaded + DrawText + 'static,
type Window = DimensionsWindow
type DrawHandle = DrawHandle<'static, D>
fn init(&mut self, draw: &mut D)[src]
fn new_window(&self, _draw: &mut D, dpi_factor: f32) -> Self::Window[src]
fn update_window(&self, window: &mut Self::Window, dpi_factor: f32)[src]
unsafe fn draw_handle<'a>(
&'a self,
draw: &'a mut D,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle[src]
&'a self,
draw: &'a mut D,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle
fn clear_colour(&self) -> Colour[src]
impl<D: Draw + DrawRounded + DrawText + 'static> Theme<D> for FlatTheme[src]
type Window = DimensionsWindow
type DrawHandle = DrawHandle<'static, D>
fn init(&mut self, draw: &mut D)[src]
fn new_window(&self, _draw: &mut D, dpi_factor: f32) -> Self::Window[src]
fn update_window(&self, window: &mut Self::Window, dpi_factor: f32)[src]
unsafe fn draw_handle<'a>(
&'a self,
draw: &'a mut D,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle[src]
&'a self,
draw: &'a mut D,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle
fn clear_colour(&self) -> Colour[src]
impl<Draw: 'static> Theme<Draw> for MultiTheme<Draw>[src]
type Window = StackDst<dyn WindowDst<Draw>>
type DrawHandle = StackDst<dyn DrawHandle>
fn init(&mut self, draw: &mut Draw)[src]
fn new_window(&self, draw: &mut Draw, dpi_factor: f32) -> Self::Window[src]
fn update_window(&self, window: &mut Self::Window, dpi_factor: f32)[src]
unsafe fn draw_handle<'a>(
&'a self,
draw: &'a mut Draw,
window: &'a mut Self::Window,
rect: Rect
) -> StackDst<dyn DrawHandle>[src]
&'a self,
draw: &'a mut Draw,
window: &'a mut Self::Window,
rect: Rect
) -> StackDst<dyn DrawHandle>