pub struct ThemeSwitcher<'a> { /* private fields */ }Expand description
A drop-in picker for the four built-in elegance themes.
Renders a small Select of the four built-in themes
and — by default — installs the chosen theme into the context each
frame. Bind it to a BuiltInTheme held anywhere in your app state.
let mut theme = BuiltInTheme::Slate;
ui.add(ThemeSwitcher::new(&mut theme));§Installation
By default the widget calls Theme::install on
the selected theme on every frame. If your app already installs a
theme elsewhere (for instance from a larger preference store), call
ThemeSwitcher::auto_install(false) to suppress that.
Implementations§
Source§impl<'a> ThemeSwitcher<'a>
impl<'a> ThemeSwitcher<'a>
Sourcepub fn new(current: &'a mut BuiltInTheme) -> Self
pub fn new(current: &'a mut BuiltInTheme) -> Self
Create a switcher bound to a mutable BuiltInTheme slot.
Sourcepub fn id_salt(self, id_salt: impl Hash) -> Self
pub fn id_salt(self, id_salt: impl Hash) -> Self
Override the id salt. Only needed if multiple switchers coexist in the same UI.
Sourcepub fn auto_install(self, auto_install: bool) -> Self
pub fn auto_install(self, auto_install: bool) -> Self
Whether to call Theme::install on the
selected theme every frame. Default: true.
Set to false if the caller installs a theme elsewhere and just
wants the picker UI.