diff options
author | 2022-05-14 01:47:55 +0200 | |
---|---|---|
committer | 2022-05-14 01:56:32 +0200 | |
commit | 664251f3f5c7b76f69a97683af1468094bba887f (patch) | |
tree | f43a495036ed117ce5dbb479c62652d872a6d273 /src/sandbox.rs | |
parent | 5de337f214530faab1d5fe47784afd7006c3f7f0 (diff) | |
download | iced-664251f3f5c7b76f69a97683af1468094bba887f.tar.gz iced-664251f3f5c7b76f69a97683af1468094bba887f.tar.bz2 iced-664251f3f5c7b76f69a97683af1468094bba887f.zip |
Draft first-class `Theme` support
RFC: https://github.com/iced-rs/rfcs/pull/6
Diffstat (limited to 'src/sandbox.rs')
-rw-r--r-- | src/sandbox.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/sandbox.rs b/src/sandbox.rs index e7e97920..16819569 100644 --- a/src/sandbox.rs +++ b/src/sandbox.rs @@ -1,5 +1,5 @@ use crate::{ - Application, Color, Command, Element, Error, Settings, Subscription, + Application, Color, Command, Element, Error, Settings, Subscription, Theme, }; /// A sandboxed [`Application`]. @@ -111,6 +111,16 @@ pub trait Sandbox { /// These widgets can produce __messages__ based on user interaction. fn view(&mut self) -> Element<'_, Self::Message>; + /// Returns the current [`Theme`] of the [`Sandbox`]. + /// + /// If you want to use your own custom theme type, you will have to use an + /// [`Application`]. + /// + /// By default, it returns [`Theme::default`]. + fn theme(&self) -> Theme { + Theme::default() + } + /// Returns the background color of the [`Sandbox`]. /// /// By default, it returns [`Color::WHITE`]. @@ -159,6 +169,7 @@ where type Executor = iced_futures::backend::null::Executor; type Flags = (); type Message = T::Message; + type Theme = Theme; fn new(_flags: ()) -> (Self, Command<T::Message>) { (T::new(), Command::none()) @@ -174,14 +185,18 @@ where Command::none() } - fn subscription(&self) -> Subscription<T::Message> { - Subscription::none() - } - fn view(&mut self) -> Element<'_, T::Message> { T::view(self) } + fn theme(&self) -> Self::Theme { + T::theme(self) + } + + fn subscription(&self) -> Subscription<T::Message> { + Subscription::none() + } + fn background_color(&self) -> Color { T::background_color(self) } |