Remove background from Settings

This commit is contained in:
Héctor Ramón Jiménez 2020-01-05 18:11:54 +01:00
parent 5af4159848
commit 8d6f86b317
5 changed files with 9 additions and 34 deletions

View File

@ -1,4 +1,4 @@
use crate::{Color, MouseCursor}; use crate::MouseCursor;
use raw_window_handle::HasRawWindowHandle; use raw_window_handle::HasRawWindowHandle;
@ -21,7 +21,6 @@ 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,

View File

@ -1,5 +1,4 @@
//! Configure your application. //! Configure your application.
use crate::Color;
/// The settings of an application. /// The settings of an application.
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
@ -11,11 +10,6 @@ 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,
// TODO: Add `name` for web compatibility // TODO: Add `name` for web compatibility
pub default_font: Option<&'static [u8]>, pub default_font: Option<&'static [u8]>,
} }
@ -24,7 +18,6 @@ impl Default for Settings {
fn default() -> Settings { fn default() -> Settings {
Settings { Settings {
window: Window::default(), window: Window::default(),
background: Color::WHITE,
default_font: None, default_font: None,
} }
} }
@ -63,7 +56,6 @@ impl From<Settings> for iced_winit::Settings {
decorations: settings.window.decorations, decorations: settings.window.decorations,
platform_specific: Default::default(), platform_specific: Default::default(),
}, },
background: settings.background,
} }
} }
} }

View File

@ -80,7 +80,6 @@ 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,
@ -102,15 +101,11 @@ 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: { clear_color: wgpu::Color {
let [r, g, b, a] = clear_color.into_linear(); r: 1.0,
g: 1.0,
wgpu::Color { b: 1.0,
r: f64::from(r), a: 1.0,
g: f64::from(g),
b: f64::from(b),
a: f64::from(a),
}
}, },
}], }],
depth_stencil_attachment: None, depth_stencil_attachment: None,
@ -443,12 +438,11 @@ 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(clear_color, output, overlay, target) self.draw(output, overlay, target)
} }
} }

View File

@ -281,12 +281,8 @@ pub trait Application: Sized {
resized = false; resized = false;
} }
let new_mouse_cursor = renderer.draw( let new_mouse_cursor =
settings.background, renderer.draw(&primitive, &debug.overlay(), &mut target);
&primitive,
&debug.overlay(),
&mut target,
);
debug.render_finished(); debug.render_finished();

View File

@ -1,6 +1,4 @@
//! Configure your application. //! Configure your application.
use crate::Color;
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
#[path = "windows.rs"] #[path = "windows.rs"]
mod platform; mod platform;
@ -17,16 +15,12 @@ pub struct 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,
} }
impl Default for Settings { impl Default for Settings {
fn default() -> Settings { fn default() -> Settings {
Settings { Settings {
window: Window::default(), window: Window::default(),
background: Color::WHITE,
} }
} }
} }