[−][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<D::Draw> + 'static
The associated Window
implementation.
type DrawHandle: DrawHandle
The associated DrawHandle
implementation.
Required methods
fn init(&mut self, draw: &mut D)
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 load_font
.
The first font loaded (by any theme) becomes the default font.
fn new_window(&self, draw: &mut D::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 D::Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
&self,
draw: &mut D::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<D>, D: DrawShared> Theme<D> for Box<T>
[src]
type Window = <T as Theme<D>>::Window
type DrawHandle = <T as Theme<D>>::DrawHandle
fn init(&mut self, draw: &mut D)
[src]
fn new_window(&self, draw: &mut D::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 D::Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
[src]
&self,
draw: &mut D::Draw,
window: &mut Self::Window,
rect: Rect
) -> Self::DrawHandle
fn clear_colour(&self) -> Colour
[src]
Implementors
impl<D: DrawShared + 'static> Theme<D> for MultiTheme<D>
[src]
type Window = StackDst<dyn WindowDst<D::Draw>>
type DrawHandle = StackDst<dyn DrawHandle>
fn init(&mut self, draw: &mut D)
[src]
fn new_window(&self, draw: &mut D::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 D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> StackDst<dyn DrawHandle>
[src]
&'a self,
draw: &'a mut D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> StackDst<dyn DrawHandle>
fn clear_colour(&self) -> Colour
[src]
impl<D: DrawShared + DrawTextShared + 'static> Theme<D> for FlatTheme where
D::Draw: DrawRounded + DrawText,
[src]
D::Draw: DrawRounded + DrawText,
type Window = DimensionsWindow
type DrawHandle = DrawHandle<'static, D::Draw>
fn init(&mut self, draw: &mut D)
[src]
fn new_window(&self, _draw: &mut D::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 D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle
[src]
&'a self,
draw: &'a mut D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle
fn clear_colour(&self) -> Colour
[src]
impl<D: DrawShared + DrawTextShared + 'static> Theme<D> for ShadedTheme where
D::Draw: DrawRounded + DrawShaded + DrawText,
[src]
D::Draw: DrawRounded + DrawShaded + DrawText,
type Window = DimensionsWindow
type DrawHandle = DrawHandle<'static, D::Draw>
fn init(&mut self, draw: &mut D)
[src]
fn new_window(&self, _draw: &mut D::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 D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle
[src]
&'a self,
draw: &'a mut D::Draw,
window: &'a mut Self::Window,
rect: Rect
) -> Self::DrawHandle