From 664251f3f5c7b76f69a97683af1468094bba887f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 14 May 2022 01:47:55 +0200 Subject: Draft first-class `Theme` support RFC: https://github.com/iced-rs/rfcs/pull/6 --- glutin/src/application.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index dbc9b580..d93059e5 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -209,6 +209,8 @@ async fn run_instance( let mut state = application::State::new(&application, context.window()); let mut viewport_version = state.viewport_version(); + let theme = application.theme(); + let mut user_interface = ManuallyDrop::new(application::build_user_interface( &mut application, @@ -288,8 +290,11 @@ async fn run_instance( } debug.draw_started(); - let new_mouse_interaction = - user_interface.draw(&mut renderer, state.cursor_position()); + let new_mouse_interaction = user_interface.draw( + &mut renderer, + &theme, + state.cursor_position(), + ); debug.draw_finished(); if new_mouse_interaction != mouse_interaction { @@ -341,8 +346,11 @@ async fn run_instance( debug.layout_finished(); debug.draw_started(); - let new_mouse_interaction = user_interface - .draw(&mut renderer, state.cursor_position()); + let new_mouse_interaction = user_interface.draw( + &mut renderer, + &theme, + state.cursor_position(), + ); debug.draw_finished(); if new_mouse_interaction != mouse_interaction { -- cgit From 03eda9b162012c503ead649e5ccb95b7ef1d10ed Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 25 May 2022 05:01:18 +0200 Subject: Let a `Theme` control the background color of an application ... and remove `Application::background_color` --- glutin/src/application.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index d93059e5..7a5d78ea 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -9,6 +9,7 @@ use iced_winit::application; use iced_winit::conversion; use iced_winit::futures; use iced_winit::futures::channel::mpsc; +use iced_winit::theme::{self, Definition as _}; use iced_winit::user_interface; use iced_winit::{Clipboard, Debug, Proxy, Settings}; @@ -25,6 +26,7 @@ where A: Application + 'static, E: Executor + 'static, C: window::GLCompositor + 'static, + ::Theme: theme::Definition, { use futures::task; use futures::Future; @@ -203,6 +205,7 @@ async fn run_instance( A: Application + 'static, E: Executor + 'static, C: window::GLCompositor + 'static, + ::Theme: theme::Definition, { use glutin::event; use iced_winit::futures::stream::StreamExt; @@ -376,7 +379,7 @@ async fn run_instance( compositor.present( &mut renderer, state.viewport(), - state.background_color(), + theme.background_color(), &debug.overlay(), ); -- cgit From 7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 26 May 2022 19:02:15 +0200 Subject: Rename `theme::Definition` to `application::StyleSheet` --- glutin/src/application.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 7a5d78ea..5fce58be 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -2,6 +2,7 @@ use crate::mouse; use crate::{Error, Executor, Runtime}; +pub use iced_winit::application::StyleSheet; pub use iced_winit::Application; use iced_graphics::window; @@ -9,7 +10,6 @@ use iced_winit::application; use iced_winit::conversion; use iced_winit::futures; use iced_winit::futures::channel::mpsc; -use iced_winit::theme::{self, Definition as _}; use iced_winit::user_interface; use iced_winit::{Clipboard, Debug, Proxy, Settings}; @@ -26,7 +26,7 @@ where A: Application + 'static, E: Executor + 'static, C: window::GLCompositor + 'static, - ::Theme: theme::Definition, + ::Theme: StyleSheet, { use futures::task; use futures::Future; @@ -205,7 +205,7 @@ async fn run_instance( A: Application + 'static, E: Executor + 'static, C: window::GLCompositor + 'static, - ::Theme: theme::Definition, + ::Theme: StyleSheet, { use glutin::event; use iced_winit::futures::stream::StreamExt; -- cgit From c807abdfd70c49b0c93868c12f142a2fb4c08036 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 25 Jun 2022 05:30:48 +0200 Subject: Fix `Theme` not being refreshed in `iced_glutin` --- glutin/src/application.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index 5fce58be..a222036a 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -212,7 +212,7 @@ async fn run_instance( let mut state = application::State::new(&application, context.window()); let mut viewport_version = state.viewport_version(); - let theme = application.theme(); + let mut theme = application.theme(); let mut user_interface = ManuallyDrop::new(application::build_user_interface( @@ -278,6 +278,7 @@ async fn run_instance( let should_exit = application.should_exit(); + theme = application.theme(); user_interface = ManuallyDrop::new(application::build_user_interface( &mut application, -- cgit From bb07d017e8c8e43ac74f66bf649643bebdc5f71d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 8 Jul 2022 20:07:33 +0200 Subject: Add `Style` variant support to `application::StyleSheet` --- glutin/src/application.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'glutin/src/application.rs') diff --git a/glutin/src/application.rs b/glutin/src/application.rs index a222036a..dddf0067 100644 --- a/glutin/src/application.rs +++ b/glutin/src/application.rs @@ -10,6 +10,7 @@ use iced_winit::application; use iced_winit::conversion; use iced_winit::futures; use iced_winit::futures::channel::mpsc; +use iced_winit::renderer; use iced_winit::user_interface; use iced_winit::{Clipboard, Debug, Proxy, Settings}; @@ -212,7 +213,6 @@ async fn run_instance( let mut state = application::State::new(&application, context.window()); let mut viewport_version = state.viewport_version(); - let mut theme = application.theme(); let mut user_interface = ManuallyDrop::new(application::build_user_interface( @@ -278,7 +278,6 @@ async fn run_instance( let should_exit = application.should_exit(); - theme = application.theme(); user_interface = ManuallyDrop::new(application::build_user_interface( &mut application, @@ -296,7 +295,10 @@ async fn run_instance( debug.draw_started(); let new_mouse_interaction = user_interface.draw( &mut renderer, - &theme, + state.theme(), + &renderer::Style { + text_color: state.text_color(), + }, state.cursor_position(), ); debug.draw_finished(); @@ -352,7 +354,10 @@ async fn run_instance( debug.draw_started(); let new_mouse_interaction = user_interface.draw( &mut renderer, - &theme, + state.theme(), + &renderer::Style { + text_color: state.text_color(), + }, state.cursor_position(), ); debug.draw_finished(); @@ -380,7 +385,7 @@ async fn run_instance( compositor.present( &mut renderer, state.viewport(), - theme.background_color(), + state.background_color(), &debug.overlay(), ); -- cgit