pub trait ThemeControl {
    // Required methods
    fn set_font_size(&mut self, pt_size: f32) -> Action;
    fn active_scheme(&self) -> &str;
    fn list_schemes(&self) -> Vec<&str>;
    fn get_scheme(&self, name: &str) -> Option<&ColorsSrgb>;
    fn get_colors(&self) -> &ColorsLinear;
    fn set_colors(&mut self, name: String, scheme: ColorsLinear) -> Action;

    // Provided methods
    fn set_scheme(&mut self, name: &str) -> Action { ... }
    fn set_theme(&mut self, _theme: &str) -> Action { ... }
}
Expand description

Interface through which a theme can be adjusted at run-time

All methods return a Action to enable correct action when a theme is updated via EventCx::adjust_theme. When adjusting a theme before the UI is started, this return value can be safely ignored.

Required Methods§

source

fn set_font_size(&mut self, pt_size: f32) -> Action

Set font size

Units: Points per Em (standard unit of font size)

source

fn active_scheme(&self) -> &str

Get the name of the active color scheme

source

fn list_schemes(&self) -> Vec<&str>

List available color schemes

source

fn get_scheme(&self, name: &str) -> Option<&ColorsSrgb>

Get colors of a named scheme

source

fn get_colors(&self) -> &ColorsLinear

Access the in-use color scheme

source

fn set_colors(&mut self, name: String, scheme: ColorsLinear) -> Action

Set colors directly

This may be used to provide a custom color scheme. The name is compulsary (and returned by Self::active_scheme). The name is also used when saving config, though the custom colors are not currently saved in this config.

Provided Methods§

source

fn set_scheme(&mut self, name: &str) -> Action

Change the color scheme

If no scheme by this name is found the scheme is left unchanged.

source

fn set_theme(&mut self, _theme: &str) -> Action

Switch the theme

Most themes do not react to this method; super::MultiTheme uses it to switch themes.

Implementations on Foreign Types§

source§

impl<T: ThemeControl + ?Sized> ThemeControl for &mut T

source§

fn set_font_size(&mut self, pt_size: f32) -> Action

source§

fn active_scheme(&self) -> &str

source§

fn list_schemes(&self) -> Vec<&str>

source§

fn get_scheme(&self, name: &str) -> Option<&ColorsSrgb>

source§

fn get_colors(&self) -> &ColorsLinear

source§

fn set_colors(&mut self, name: String, scheme: ColorsLinear) -> Action

source§

fn set_scheme(&mut self, name: &str) -> Action

source§

fn set_theme(&mut self, _theme: &str) -> Action

source§

impl<T: ThemeControl + ?Sized> ThemeControl for Box<T>

source§

fn set_font_size(&mut self, pt_size: f32) -> Action

source§

fn active_scheme(&self) -> &str

source§

fn list_schemes(&self) -> Vec<&str>

source§

fn get_scheme(&self, name: &str) -> Option<&ColorsSrgb>

source§

fn get_colors(&self) -> &ColorsLinear

source§

fn set_colors(&mut self, name: String, scheme: ColorsLinear) -> Action

source§

fn set_scheme(&mut self, name: &str) -> Action

source§

fn set_theme(&mut self, _theme: &str) -> Action

Implementors§