Add background_color
to Settings
This commit is contained in:
parent
c7b170da6d
commit
f74ab463d4
@ -21,14 +21,15 @@
|
|||||||
//! [`checkbox::Renderer`]: ../widget/checkbox/trait.Renderer.html
|
//! [`checkbox::Renderer`]: ../widget/checkbox/trait.Renderer.html
|
||||||
|
|
||||||
mod debugger;
|
mod debugger;
|
||||||
#[cfg(debug_assertions)]
|
|
||||||
mod null;
|
|
||||||
mod windowed;
|
mod windowed;
|
||||||
|
|
||||||
pub use debugger::Debugger;
|
pub use debugger::Debugger;
|
||||||
|
pub use windowed::{Target, Windowed};
|
||||||
|
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
mod null;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub use null::Null;
|
pub use null::Null;
|
||||||
pub use windowed::{Target, Windowed};
|
|
||||||
|
|
||||||
use crate::{layout, Element};
|
use crate::{layout, Element};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::MouseCursor;
|
use crate::{Color, MouseCursor};
|
||||||
|
|
||||||
use raw_window_handle::HasRawWindowHandle;
|
use raw_window_handle::HasRawWindowHandle;
|
||||||
|
|
||||||
@ -19,6 +19,7 @@ pub trait Windowed: super::Renderer + Sized {
|
|||||||
/// top of the GUI on most scenarios.
|
/// top of the GUI on most scenarios.
|
||||||
fn draw<T: AsRef<str>>(
|
fn draw<T: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
clear_color: Color,
|
||||||
output: &Self::Output,
|
output: &Self::Output,
|
||||||
overlay: &[T],
|
overlay: &[T],
|
||||||
target: &mut Self::Target,
|
target: &mut Self::Target,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
//! Configure your application.
|
//! Configure your application.
|
||||||
|
use crate::Color;
|
||||||
|
|
||||||
/// The settings of an application.
|
/// The settings of an application.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
/// The [`Window`] settings.
|
/// The [`Window`] settings.
|
||||||
///
|
///
|
||||||
@ -9,6 +10,20 @@ pub struct Settings {
|
|||||||
///
|
///
|
||||||
/// [`Window`]: struct.Window.html
|
/// [`Window`]: struct.Window.html
|
||||||
pub window: Window,
|
pub window: Window,
|
||||||
|
|
||||||
|
/// The default background [`Color`] of the application
|
||||||
|
///
|
||||||
|
/// [`Color`]: ../struct.Color.html
|
||||||
|
pub background_color: Color,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Settings {
|
||||||
|
fn default() -> Settings {
|
||||||
|
Settings {
|
||||||
|
window: Window::default(),
|
||||||
|
background_color: Color::WHITE,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The window settings of an application.
|
/// The window settings of an application.
|
||||||
@ -44,6 +59,7 @@ impl From<Settings> for iced_winit::Settings {
|
|||||||
decorations: settings.window.decorations,
|
decorations: settings.window.decorations,
|
||||||
platform_specific: Default::default(),
|
platform_specific: Default::default(),
|
||||||
},
|
},
|
||||||
|
background_color: settings.background_color,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ impl Renderer {
|
|||||||
|
|
||||||
fn draw<T: AsRef<str>>(
|
fn draw<T: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
clear_color: Color,
|
||||||
(primitive, mouse_cursor): &(Primitive, MouseCursor),
|
(primitive, mouse_cursor): &(Primitive, MouseCursor),
|
||||||
overlay: &[T],
|
overlay: &[T],
|
||||||
target: &mut Target,
|
target: &mut Target,
|
||||||
@ -97,11 +98,15 @@ impl Renderer {
|
|||||||
resolve_target: None,
|
resolve_target: None,
|
||||||
load_op: wgpu::LoadOp::Clear,
|
load_op: wgpu::LoadOp::Clear,
|
||||||
store_op: wgpu::StoreOp::Store,
|
store_op: wgpu::StoreOp::Store,
|
||||||
clear_color: wgpu::Color {
|
clear_color: {
|
||||||
r: 1.0,
|
let [r, g, b, a] = clear_color.into_linear();
|
||||||
g: 1.0,
|
|
||||||
b: 1.0,
|
wgpu::Color {
|
||||||
a: 1.0,
|
r: f64::from(r),
|
||||||
|
g: f64::from(g),
|
||||||
|
b: f64::from(b),
|
||||||
|
a: f64::from(a),
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
depth_stencil_attachment: None,
|
depth_stencil_attachment: None,
|
||||||
@ -428,11 +433,12 @@ impl Windowed for Renderer {
|
|||||||
|
|
||||||
fn draw<T: AsRef<str>>(
|
fn draw<T: AsRef<str>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
clear_color: Color,
|
||||||
output: &Self::Output,
|
output: &Self::Output,
|
||||||
overlay: &[T],
|
overlay: &[T],
|
||||||
target: &mut Target,
|
target: &mut Target,
|
||||||
) -> MouseCursor {
|
) -> MouseCursor {
|
||||||
self.draw(output, overlay, target)
|
self.draw(clear_color, output, overlay, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,8 +279,12 @@ pub trait Application: Sized {
|
|||||||
resized = false;
|
resized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_mouse_cursor =
|
let new_mouse_cursor = renderer.draw(
|
||||||
renderer.draw(&primitive, &debug.overlay(), &mut target);
|
settings.background_color,
|
||||||
|
&primitive,
|
||||||
|
&debug.overlay(),
|
||||||
|
&mut target,
|
||||||
|
);
|
||||||
|
|
||||||
debug.render_finished();
|
debug.render_finished();
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//! Configure your application.
|
//! Configure your application.
|
||||||
|
use crate::Color;
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
#[path = "windows.rs"]
|
#[path = "windows.rs"]
|
||||||
@ -10,12 +11,24 @@ mod platform;
|
|||||||
pub use platform::PlatformSpecific;
|
pub use platform::PlatformSpecific;
|
||||||
|
|
||||||
/// The settings of an application.
|
/// The settings of an application.
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct Settings {
|
pub struct Settings {
|
||||||
/// The [`Window`] settings
|
/// The [`Window`] settings
|
||||||
///
|
///
|
||||||
/// [`Window`]: struct.Window.html
|
/// [`Window`]: struct.Window.html
|
||||||
pub window: Window,
|
pub window: Window,
|
||||||
|
|
||||||
|
/// The default background color of the application
|
||||||
|
pub background_color: Color,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Settings {
|
||||||
|
fn default() -> Settings {
|
||||||
|
Settings {
|
||||||
|
window: Window::default(),
|
||||||
|
background_color: Color::WHITE,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The window settings of an application.
|
/// The window settings of an application.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user