Skip to main content

fret_ui_kit/declarative/
theme_access.rs

1use fret_ui::{ElementContext, Theme, ThemeSnapshot, UiHost};
2
3pub trait ElementContextThemeExt {
4    fn with_theme<R>(&mut self, f: impl FnOnce(&Theme) -> R) -> R;
5
6    fn theme_snapshot(&mut self) -> ThemeSnapshot;
7}
8
9impl<H: UiHost> ElementContextThemeExt for ElementContext<'_, H> {
10    fn with_theme<R>(&mut self, f: impl FnOnce(&Theme) -> R) -> R {
11        f(self.theme())
12    }
13
14    fn theme_snapshot(&mut self) -> ThemeSnapshot {
15        self.theme().snapshot()
16    }
17}