From 1aeb317f2dbfb63215e6226073e67878ffa6503b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 6 Dec 2024 04:06:41 +0100 Subject: Add image and hash snapshot-based testing to `iced_test` --- winit/src/program/state.rs | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'winit/src/program/state.rs') diff --git a/winit/src/program/state.rs b/winit/src/program/state.rs index b8a58960..e883d04a 100644 --- a/winit/src/program/state.rs +++ b/winit/src/program/state.rs @@ -1,17 +1,18 @@ use crate::conversion; -use crate::core::{mouse, window}; +use crate::core::{mouse, theme, window}; use crate::core::{Color, Size}; use crate::graphics::Viewport; -use crate::program::{self, Program}; -use std::fmt::{Debug, Formatter}; +use crate::program::Program; use winit::event::{Touch, WindowEvent}; use winit::window::Window; +use std::fmt::{Debug, Formatter}; + /// The state of a multi-windowed [`Program`]. pub struct State where - P::Theme: program::DefaultStyle, + P::Theme: theme::Base, { title: String, scale_factor: f64, @@ -20,12 +21,12 @@ where cursor_position: Option>, modifiers: winit::keyboard::ModifiersState, theme: P::Theme, - appearance: program::Appearance, + style: theme::Style, } impl Debug for State

where - P::Theme: program::DefaultStyle, + P::Theme: theme::Base, { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { f.debug_struct("multi_window::State") @@ -34,14 +35,14 @@ where .field("viewport", &self.viewport) .field("viewport_version", &self.viewport_version) .field("cursor_position", &self.cursor_position) - .field("appearance", &self.appearance) + .field("style", &self.style) .finish() } } impl State

where - P::Theme: program::DefaultStyle, + P::Theme: theme::Base, { /// Creates a new [`State`] for the provided [`Program`]'s `window`. pub fn new( @@ -52,7 +53,7 @@ where let title = application.title(window_id); let scale_factor = application.scale_factor(window_id); let theme = application.theme(window_id); - let appearance = application.style(&theme); + let style = application.style(&theme); let viewport = { let physical_size = window.inner_size(); @@ -71,7 +72,7 @@ where cursor_position: None, modifiers: winit::keyboard::ModifiersState::default(), theme, - appearance, + style, } } @@ -127,12 +128,12 @@ where /// Returns the current background [`Color`] of the [`State`]. pub fn background_color(&self) -> Color { - self.appearance.background_color + self.style.background_color } /// Returns the current text [`Color`] of the [`State`]. pub fn text_color(&self) -> Color { - self.appearance.text_color + self.style.text_color } /// Processes the provided window event and updates the [`State`] accordingly. @@ -237,6 +238,6 @@ where // Update theme and appearance self.theme = application.theme(window_id); - self.appearance = application.style(&self.theme); + self.style = application.style(&self.theme); } } -- cgit