Add background_color to Application and Sandbox
This commit is contained in:
parent
2a516dfc48
commit
4c0286e8ac
11 changed files with 81 additions and 17 deletions
|
|
@ -1,4 +1,6 @@
|
|||
use crate::{window, Command, Element, Executor, Settings, Subscription};
|
||||
use crate::{
|
||||
window, Color, Command, Element, Executor, Settings, Subscription,
|
||||
};
|
||||
|
||||
/// An interactive cross-platform application.
|
||||
///
|
||||
|
|
@ -174,6 +176,16 @@ pub trait Application: Sized {
|
|||
window::Mode::Windowed
|
||||
}
|
||||
|
||||
/// Returns the background color of the [`Application`].
|
||||
///
|
||||
/// 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 [`Application`].
|
||||
///
|
||||
/// On native platforms, this method will take control of the current thread
|
||||
|
|
@ -256,6 +268,10 @@ where
|
|||
fn subscription(&self) -> Subscription<Self::Message> {
|
||||
self.0.subscription()
|
||||
}
|
||||
|
||||
fn background_color(&self) -> Color {
|
||||
self.0.background_color()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue