From f74ab463d44dd0bb025b0cea466d2861576253dd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 12:29:47 +0100 Subject: Add `background_color` to `Settings` --- winit/src/application.rs | 8 ++++++-- winit/src/settings/mod.rs | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index a8612b1a..50060b11 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -279,8 +279,12 @@ pub trait Application: Sized { resized = false; } - let new_mouse_cursor = - renderer.draw(&primitive, &debug.overlay(), &mut target); + let new_mouse_cursor = renderer.draw( + settings.background_color, + &primitive, + &debug.overlay(), + &mut target, + ); debug.render_finished(); diff --git a/winit/src/settings/mod.rs b/winit/src/settings/mod.rs index 58e3d879..1f9f1502 100644 --- a/winit/src/settings/mod.rs +++ b/winit/src/settings/mod.rs @@ -1,4 +1,5 @@ //! Configure your application. +use crate::Color; #[cfg(target_os = "windows")] #[path = "windows.rs"] @@ -10,12 +11,24 @@ mod platform; pub use platform::PlatformSpecific; /// The settings of an application. -#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Settings { /// The [`Window`] settings /// /// [`Window`]: struct.Window.html 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. -- cgit From 89a6b8a9a173e767753ec777fd83c912c1be5ea3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 29 Dec 2019 12:31:47 +0100 Subject: Rename `Settings::background_color` to `background` --- winit/src/application.rs | 2 +- winit/src/settings/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 50060b11..56f17573 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -280,7 +280,7 @@ pub trait Application: Sized { } let new_mouse_cursor = renderer.draw( - settings.background_color, + settings.background, &primitive, &debug.overlay(), &mut target, diff --git a/winit/src/settings/mod.rs b/winit/src/settings/mod.rs index 1f9f1502..0384df32 100644 --- a/winit/src/settings/mod.rs +++ b/winit/src/settings/mod.rs @@ -19,14 +19,14 @@ pub struct Settings { pub window: Window, /// The default background color of the application - pub background_color: Color, + pub background: Color, } impl Default for Settings { fn default() -> Settings { Settings { window: Window::default(), - background_color: Color::WHITE, + background: Color::WHITE, } } } -- cgit From fb9cc0262b30a953e8188897b74abb5106ea1fd8 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 31 Dec 2019 11:36:54 +0100 Subject: Draft basic styling for `Container` --- winit/src/application.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 56f17573..02fa3780 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -1,5 +1,5 @@ use crate::{ - conversion, + container, conversion, input::{keyboard, mouse}, renderer::{Target, Windowed}, subscription, Cache, Clipboard, Command, Container, Debug, Element, Event, @@ -18,7 +18,7 @@ pub trait Application: Sized { /// The renderer to use to draw the [`Application`]. /// /// [`Application`]: trait.Application.html - type Renderer: Windowed; + type Renderer: Windowed + container::Renderer; /// The type of __messages__ your [`Application`] will produce. /// -- cgit From d96ced8e2da703117a43399110ef2b8fa21a7546 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 1 Jan 2020 17:49:48 +0100 Subject: Allow configuration of default font --- winit/src/application.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index 02fa3780..d16c209c 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -81,8 +81,10 @@ pub trait Application: Sized { /// It should probably be that last thing you call in your `main` function. /// /// [`Application`]: trait.Application.html - fn run(settings: Settings) - where + fn run( + settings: Settings, + renderer_settings: ::Settings, + ) where Self: 'static, { use winit::{ @@ -140,7 +142,7 @@ pub trait Application: Sized { let mut resized = false; let clipboard = Clipboard::new(&window); - let mut renderer = Self::Renderer::new(); + let mut renderer = Self::Renderer::new(renderer_settings); let mut target = { let (width, height) = to_physical(size, dpi); -- cgit From 8d6f86b317303c06a0daf1ca3ce91c29670dd674 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 5 Jan 2020 18:11:54 +0100 Subject: Remove `background` from `Settings` --- winit/src/application.rs | 8 ++------ winit/src/settings/mod.rs | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index d16c209c..da943660 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -281,12 +281,8 @@ pub trait Application: Sized { resized = false; } - let new_mouse_cursor = renderer.draw( - settings.background, - &primitive, - &debug.overlay(), - &mut target, - ); + let new_mouse_cursor = + renderer.draw(&primitive, &debug.overlay(), &mut target); debug.render_finished(); diff --git a/winit/src/settings/mod.rs b/winit/src/settings/mod.rs index 0384df32..b2290b46 100644 --- a/winit/src/settings/mod.rs +++ b/winit/src/settings/mod.rs @@ -1,6 +1,4 @@ //! Configure your application. -use crate::Color; - #[cfg(target_os = "windows")] #[path = "windows.rs"] mod platform; @@ -17,16 +15,12 @@ pub struct Settings { /// /// [`Window`]: struct.Window.html pub window: Window, - - /// The default background color of the application - pub background: Color, } impl Default for Settings { fn default() -> Settings { Settings { window: Window::default(), - background: Color::WHITE, } } } -- cgit From d15d1156bd0c7fa111d1c59bea11fd58b9cc63b1 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 10 Jan 2020 01:34:41 +0100 Subject: Produce `window::Event::Resized` in `iced_winit` --- winit/src/application.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index da943660..8529c99c 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -2,8 +2,8 @@ use crate::{ container, conversion, input::{keyboard, mouse}, renderer::{Target, Windowed}, - subscription, Cache, Clipboard, Command, Container, Debug, Element, Event, - Length, MouseCursor, Settings, Subscription, UserInterface, + subscription, window, Cache, Clipboard, Command, Container, Debug, Element, + Event, Length, MouseCursor, Settings, Subscription, UserInterface, }; /// An interactive, native cross-platform application. @@ -373,10 +373,13 @@ pub trait Application: Sized { *control_flow = ControlFlow::Exit; } WindowEvent::Resized(new_size) => { + events.push(Event::Window(window::Event::Resized { + width: new_size.width.round() as u32, + height: new_size.height.round() as u32, + })); + size = new_size; resized = true; - - log::debug!("Resized: {:?}", new_size); } _ => {} }, -- cgit