diff options
author | 2022-05-26 19:02:15 +0200 | |
---|---|---|
committer | 2022-05-26 19:02:15 +0200 | |
commit | 7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3 (patch) | |
tree | fb616dc39053d3249829c8a31976a1fd569153e5 | |
parent | 3e8f4cdd138d3f927ce8a3ea451cbfcca52af0d9 (diff) | |
download | iced-7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3.tar.gz iced-7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3.tar.bz2 iced-7f3b7075db68a215f4331b4bfba1c8ddd1c4d7f3.zip |
Rename `theme::Definition` to `application::StyleSheet`
Diffstat (limited to '')
-rw-r--r-- | glutin/src/application.rs | 6 | ||||
-rw-r--r-- | native/src/lib.rs | 1 | ||||
-rw-r--r-- | native/src/program/state.rs | 6 | ||||
-rw-r--r-- | native/src/user_interface.rs | 9 | ||||
-rw-r--r-- | src/application.rs | 5 | ||||
-rw-r--r-- | src/lib.rs | 4 | ||||
-rw-r--r-- | src/pure.rs | 2 | ||||
-rw-r--r-- | src/pure/application.rs | 5 | ||||
-rw-r--r-- | style/src/application.rs | 7 | ||||
-rw-r--r-- | style/src/lib.rs | 1 | ||||
-rw-r--r-- | style/src/theme.rs | 9 | ||||
-rw-r--r-- | winit/src/application.rs | 9 |
12 files changed, 37 insertions, 27 deletions
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<Renderer = A::Renderer> + 'static, - <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, + <A::Renderer as iced_native::Renderer>::Theme: StyleSheet, { use futures::task; use futures::Future; @@ -205,7 +205,7 @@ async fn run_instance<A, E, C>( A: Application + 'static, E: Executor + 'static, C: window::GLCompositor<Renderer = A::Renderer> + 'static, - <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, + <A::Renderer as iced_native::Renderer>::Theme: StyleSheet, { use glutin::event; use iced_winit::futures::stream::StreamExt; diff --git a/native/src/lib.rs b/native/src/lib.rs index 948fdff0..2d0dd6ec 100644 --- a/native/src/lib.rs +++ b/native/src/lib.rs @@ -76,6 +76,7 @@ pub use iced_core::{ Rectangle, Size, Vector, }; pub use iced_futures::{executor, futures}; +pub use iced_style::application; pub use iced_style::theme; #[doc(no_inline)] diff --git a/native/src/program/state.rs b/native/src/program/state.rs index 0c133484..c881a64f 100644 --- a/native/src/program/state.rs +++ b/native/src/program/state.rs @@ -1,5 +1,5 @@ +use crate::application; use crate::mouse; -use crate::theme; use crate::user_interface::{self, UserInterface}; use crate::{Clipboard, Command, Debug, Event, Point, Program, Size}; @@ -20,7 +20,7 @@ where impl<P> State<P> where P: Program + 'static, - <P::Renderer as crate::Renderer>::Theme: theme::Definition, + <P::Renderer as crate::Renderer>::Theme: application::StyleSheet, { /// Creates a new [`State`] with the provided [`Program`], initializing its /// primitive with the given logical bounds and renderer. @@ -168,7 +168,7 @@ fn build_user_interface<'a, P: Program>( debug: &mut Debug, ) -> UserInterface<'a, P::Message, P::Renderer> where - <P::Renderer as crate::Renderer>::Theme: theme::Definition, + <P::Renderer as crate::Renderer>::Theme: application::StyleSheet, { debug.view_started(); let view = program.view(); diff --git a/native/src/user_interface.rs b/native/src/user_interface.rs index c8496112..26850f0a 100644 --- a/native/src/user_interface.rs +++ b/native/src/user_interface.rs @@ -1,9 +1,9 @@ //! Implement your own event loop to drive a user interface. +use crate::application; use crate::event::{self, Event}; use crate::layout; use crate::mouse; use crate::renderer; -use crate::theme::{self, Definition as _}; use crate::{Clipboard, Element, Layout, Point, Rectangle, Shell, Size}; /// A set of interactive graphical elements with a specific [`Layout`]. @@ -29,7 +29,7 @@ pub struct UserInterface<'a, Message, Renderer> { impl<'a, Message, Renderer> UserInterface<'a, Message, Renderer> where Renderer: crate::Renderer, - Renderer::Theme: theme::Definition, + Renderer::Theme: application::StyleSheet, { /// Builds a user interface for an [`Element`]. /// @@ -373,7 +373,10 @@ where renderer, theme, &renderer::Style { - text_color: theme.text_color(), + text_color: { + use application::StyleSheet; + theme.text_color() + }, }, Layout::new(&self.base), base_cursor, diff --git a/src/application.rs b/src/application.rs index 01571b56..b7c8cf9f 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,7 +1,8 @@ -use crate::theme; use crate::window; use crate::{Command, Element, Executor, Settings, Subscription}; +pub use iced_native::application::StyleSheet; + /// An interactive cross-platform application. /// /// This trait is the main entrypoint of Iced. Once implemented, you can run @@ -102,7 +103,7 @@ pub trait Application: Sized { type Message: std::fmt::Debug + Send; /// The theme of your [`Application`]. - type Theme: Default + theme::Definition; + type Theme: Default + StyleSheet; /// The data needed to initialize your [`Application`]. type Flags; @@ -174,18 +174,18 @@ #![doc( html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg" )] -#![deny(missing_docs)] +//#![deny(missing_docs)] #![deny(missing_debug_implementations)] #![deny(unused_results)] #![forbid(unsafe_code)] #![forbid(rust_2018_idioms)] #![cfg_attr(docsrs, feature(doc_cfg))] -mod application; mod element; mod error; mod result; mod sandbox; +pub mod application; pub mod clipboard; pub mod executor; pub mod keyboard; diff --git a/src/pure.rs b/src/pure.rs index b2b3ade7..1efacdf4 100644 --- a/src/pure.rs +++ b/src/pure.rs @@ -95,9 +95,9 @@ //! [the original widgets]: crate::widget //! [`button::State`]: crate::widget::button::State //! [impure `Application`]: crate::Application +pub mod application; pub mod widget; -mod application; mod sandbox; pub use application::Application; diff --git a/src/pure/application.rs b/src/pure/application.rs index 1306ab6c..4a7df13e 100644 --- a/src/pure/application.rs +++ b/src/pure/application.rs @@ -1,8 +1,9 @@ use crate::pure::{self, Pure}; -use crate::theme; use crate::window; use crate::{Command, Executor, Settings, Subscription}; +pub use iced_native::application::StyleSheet; + /// A pure version of [`Application`]. /// /// Unlike the impure version, the `view` method of this trait takes an @@ -23,7 +24,7 @@ pub trait Application: Sized { type Message: std::fmt::Debug + Send; /// The theme of your [`Application`]. - type Theme: Default + theme::Definition; + type Theme: Default + StyleSheet; /// The data needed to initialize your [`Application`]. type Flags; diff --git a/style/src/application.rs b/style/src/application.rs new file mode 100644 index 00000000..4aa950fb --- /dev/null +++ b/style/src/application.rs @@ -0,0 +1,7 @@ +use iced_core::Color; + +pub trait StyleSheet { + fn background_color(&self) -> Color; + + fn text_color(&self) -> Color; +} diff --git a/style/src/lib.rs b/style/src/lib.rs index d9c3259e..4a0a6a14 100644 --- a/style/src/lib.rs +++ b/style/src/lib.rs @@ -9,6 +9,7 @@ )] pub use iced_core::{Background, Color}; +pub mod application; pub mod button; pub mod checkbox; pub mod container; diff --git a/style/src/theme.rs b/style/src/theme.rs index cf939824..9cfbd1d5 100644 --- a/style/src/theme.rs +++ b/style/src/theme.rs @@ -2,6 +2,7 @@ mod palette; pub use self::palette::Palette; +use crate::application; use crate::button; use crate::slider; @@ -35,13 +36,7 @@ impl Default for Theme { } } -pub trait Definition { - fn background_color(&self) -> Color; - - fn text_color(&self) -> Color; -} - -impl Definition for Theme { +impl application::StyleSheet for Theme { fn background_color(&self) -> Color { let palette = self.extended_palette(); diff --git a/winit/src/application.rs b/winit/src/application.rs index 12279bbb..c7905c60 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -6,7 +6,6 @@ pub use state::State; use crate::clipboard::{self, Clipboard}; use crate::conversion; use crate::mouse; -use crate::theme::{self, Definition as _}; use crate::{ Command, Debug, Error, Executor, Mode, Proxy, Runtime, Settings, Size, Subscription, @@ -19,6 +18,8 @@ use iced_graphics::window; use iced_native::program::Program; use iced_native::user_interface::{self, UserInterface}; +pub use iced_native::application::StyleSheet; + use std::mem::ManuallyDrop; /// An interactive, native cross-platform application. @@ -109,7 +110,7 @@ where A: Application + 'static, E: Executor + 'static, C: window::Compositor<Renderer = A::Renderer> + 'static, - <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, + <A::Renderer as iced_native::Renderer>::Theme: StyleSheet, { use futures::task; use futures::Future; @@ -245,7 +246,7 @@ async fn run_instance<A, E, C>( A: Application + 'static, E: Executor + 'static, C: window::Compositor<Renderer = A::Renderer> + 'static, - <A::Renderer as iced_native::Renderer>::Theme: theme::Definition, + <A::Renderer as iced_native::Renderer>::Theme: StyleSheet, { use iced_futures::futures::stream::StreamExt; use winit::event; @@ -506,7 +507,7 @@ pub fn build_user_interface<'a, A: Application>( debug: &mut Debug, ) -> UserInterface<'a, A::Message, A::Renderer> where - <A::Renderer as crate::Renderer>::Theme: theme::Definition, + <A::Renderer as crate::Renderer>::Theme: StyleSheet, { debug.view_started(); let view = application.view(); |