summaryrefslogtreecommitdiffstats
path: root/winit
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-12 22:12:15 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-12 22:12:15 +0200
commit4c0286e8acdf0792a9680f6f8212a534a51e3da0 (patch)
tree6d478a1074a33b1ab66d5758530bac548106ef94 /winit
parent2a516dfc4823feb16054e8d484637014e4eedcce (diff)
downloadiced-4c0286e8acdf0792a9680f6f8212a534a51e3da0.tar.gz
iced-4c0286e8acdf0792a9680f6f8212a534a51e3da0.tar.bz2
iced-4c0286e8acdf0792a9680f6f8212a534a51e3da0.zip
Add `background_color` to `Application` and `Sandbox`
Diffstat (limited to 'winit')
-rw-r--r--winit/src/application.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/winit/src/application.rs b/winit/src/application.rs
index a5d00407..ceca5645 100644
--- a/winit/src/application.rs
+++ b/winit/src/application.rs
@@ -1,6 +1,6 @@
//! Create interactive, native cross-platform applications.
use crate::{
- conversion, mouse, Clipboard, Command, Debug, Executor, Mode, Proxy,
+ conversion, mouse, Clipboard, Color, Command, Debug, Executor, Mode, Proxy,
Runtime, Settings, Size, Subscription,
};
use iced_graphics::window;
@@ -73,6 +73,17 @@ pub trait Application: Program {
fn mode(&self) -> Mode {
Mode::Windowed
}
+
+ /// Returns the background [`Color`] of the [`Application`].
+ ///
+ /// By default, it returns [`Color::WHITE`].
+ ///
+ /// [`Color`]: struct.Color.html
+ /// [`Application`]: trait.Application.html
+ /// [`Color::WHITE`]: struct.Color.html#const.WHITE
+ fn background_color(&self) -> Color {
+ Color::WHITE
+ }
}
/// Runs an [`Application`] with an executor, compositor, and the provided
@@ -112,6 +123,7 @@ pub fn run<A, E, C>(
let mut title = application.title();
let mut mode = application.mode();
+ let mut background_color = application.background_color();
let window = settings
.window
@@ -193,6 +205,9 @@ pub fn run<A, E, C>(
mode = new_mode;
}
+
+ // Update background color
+ background_color = program.background_color();
}
window.request_redraw();
@@ -219,6 +234,7 @@ pub fn run<A, E, C>(
&mut renderer,
&mut swap_chain,
&viewport,
+ background_color,
state.primitive(),
&debug.overlay(),
);