summaryrefslogtreecommitdiffstats
path: root/src/sandbox.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2020-06-14 18:10:14 +0200
committerLibravatar GitHub <noreply@github.com>2020-06-14 18:10:14 +0200
commit50c37ff3d7f0cafb203d659b9c4bebf8f11d9b9d (patch)
tree6cb1e2cfa8e2933b8edf4cc05e9fb60724903904 /src/sandbox.rs
parentf131969c47bb4a32d60d5be4c2bece0688b0a418 (diff)
parent4c0286e8acdf0792a9680f6f8212a534a51e3da0 (diff)
downloadiced-50c37ff3d7f0cafb203d659b9c4bebf8f11d9b9d.tar.gz
iced-50c37ff3d7f0cafb203d659b9c4bebf8f11d9b9d.tar.bz2
iced-50c37ff3d7f0cafb203d659b9c4bebf8f11d9b9d.zip
Merge pull request #406 from hecrj/feature/background-color
Add `background_color` to `Application` and `Sandbox`
Diffstat (limited to 'src/sandbox.rs')
-rw-r--r--src/sandbox.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/sandbox.rs b/src/sandbox.rs
index c6fa45d0..729d9103 100644
--- a/src/sandbox.rs
+++ b/src/sandbox.rs
@@ -1,4 +1,6 @@
-use crate::{executor, Application, Command, Element, Settings, Subscription};
+use crate::{
+ executor, Application, Color, Command, Element, Settings, Subscription,
+};
/// A sandboxed [`Application`].
///
@@ -124,6 +126,16 @@ pub trait Sandbox {
/// [`Sandbox`]: trait.Sandbox.html
fn view(&mut self) -> Element<'_, Self::Message>;
+ /// Returns the background color of the [`Sandbox`].
+ ///
+ /// By default, it returns [`Color::WHITE`].
+ ///
+ /// [`Application`]: trait.Application.html
+ /// [`Color::WHITE`]: struct.Color.html#const.WHITE
+ fn background_color(&self) -> Color {
+ Color::WHITE
+ }
+
/// Runs the [`Sandbox`].
///
/// On native platforms, this method will take control of the current thread
@@ -169,4 +181,8 @@ where
fn view(&mut self) -> Element<'_, T::Message> {
T::view(self)
}
+
+ fn background_color(&self) -> Color {
+ T::background_color(self)
+ }
}