diff options
author | 2024-02-10 00:32:03 +0100 | |
---|---|---|
committer | 2024-02-10 00:32:03 +0100 | |
commit | 81bed94148dfdc60997d14db603a4c7f2d13bb51 (patch) | |
tree | 5a1ad65b9de2d543c24f0b6ca42bf03c14330dd8 /style | |
parent | 712c8e53f2385ed425173cab327e06a214248579 (diff) | |
download | iced-81bed94148dfdc60997d14db603a4c7f2d13bb51.tar.gz iced-81bed94148dfdc60997d14db603a4c7f2d13bb51.tar.bz2 iced-81bed94148dfdc60997d14db603a4c7f2d13bb51.zip |
Use custom `Application::style` to enable transparency
Diffstat (limited to 'style')
-rw-r--r-- | style/src/theme.rs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/style/src/theme.rs b/style/src/theme.rs index afb4d027..235aecbd 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -172,6 +172,15 @@ pub enum Application { Custom(Box<dyn application::StyleSheet<Style = Theme>>), } +impl Application { + /// Creates a custom [`Application`] style. + pub fn custom( + custom: impl application::StyleSheet<Style = Theme> + 'static, + ) -> Self { + Self::Custom(Box::new(custom)) + } +} + impl application::StyleSheet for Theme { type Style = Application; @@ -196,14 +205,6 @@ impl<T: Fn(&Theme) -> application::Appearance> application::StyleSheet for T { } } -impl<T: Fn(&Theme) -> application::Appearance + 'static> From<T> - for Application -{ - fn from(f: T) -> Self { - Self::Custom(Box::new(f)) - } -} - /// The style of a button. #[derive(Default)] pub enum Button { |