diff options
author | 2024-01-21 17:56:01 +0100 | |
---|---|---|
committer | 2024-01-21 17:56:01 +0100 | |
commit | 7a50e9e8fbb8d37e53a42c1dd5936b97463ead53 (patch) | |
tree | c0960018f287bcb2043a1752ae85ad0d45e00f21 /src | |
parent | 545cc909c9f356dd733d273173694db9b8c28594 (diff) | |
download | iced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.tar.gz iced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.tar.bz2 iced-7a50e9e8fbb8d37e53a42c1dd5936b97463ead53.zip |
Convert `Renderer::Theme` to generic `Widget` type
Diffstat (limited to 'src')
-rw-r--r-- | src/application.rs | 9 | ||||
-rw-r--r-- | src/lib.rs | 20 | ||||
-rw-r--r-- | src/multi_window/application.rs | 9 |
3 files changed, 23 insertions, 15 deletions
diff --git a/src/application.rs b/src/application.rs index 9518b8c5..01b2032f 100644 --- a/src/application.rs +++ b/src/application.rs @@ -139,7 +139,7 @@ pub trait Application: Sized { /// Returns the widgets to display in the [`Application`]. /// /// These widgets can produce __messages__ based on user interaction. - fn view(&self) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>; + fn view(&self) -> Element<'_, Self::Message, Self::Theme, crate::Renderer>; /// Returns the current [`Theme`] of the [`Application`]. /// @@ -208,7 +208,7 @@ pub trait Application: Sized { Ok(crate::shell::application::run::< Instance<Self>, Self::Executor, - crate::renderer::Compositor<Self::Theme>, + crate::renderer::Compositor, >(settings.into(), renderer_settings)?) } } @@ -219,14 +219,15 @@ impl<A> crate::runtime::Program for Instance<A> where A: Application, { - type Renderer = crate::Renderer<A::Theme>; type Message = A::Message; + type Theme = A::Theme; + type Renderer = crate::Renderer; fn update(&mut self, message: Self::Message) -> Command<Self::Message> { self.0.update(message) } - fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { + fn view(&self) -> Element<'_, Self::Message, Self::Theme, Self::Renderer> { self.0.view() } } @@ -271,8 +271,12 @@ pub mod overlay { /// This is an alias of an [`overlay::Element`] with a default `Renderer`. /// /// [`overlay::Element`]: crate::core::overlay::Element - pub type Element<'a, Message, Renderer = crate::Renderer> = - crate::core::overlay::Element<'a, Message, Renderer>; + pub type Element< + 'a, + Message, + Theme = crate::Renderer, + Renderer = crate::Renderer, + > = crate::core::overlay::Element<'a, Message, Theme, Renderer>; pub use iced_widget::overlay::*; } @@ -302,19 +306,21 @@ pub use error::Error; pub use event::Event; pub use executor::Executor; pub use font::Font; +pub use renderer::Renderer; pub use sandbox::Sandbox; pub use settings::Settings; pub use subscription::Subscription; pub use theme::Theme; -/// The default renderer. -pub type Renderer<Theme = style::Theme> = renderer::Renderer<Theme>; - /// A generic widget. /// /// This is an alias of an `iced_native` element with a default `Renderer`. -pub type Element<'a, Message, Renderer = crate::Renderer> = - crate::core::Element<'a, Message, Renderer>; +pub type Element< + 'a, + Message, + Theme = crate::Theme, + Renderer = crate::Renderer, +> = crate::core::Element<'a, Message, Theme, Renderer>; /// The result of running an [`Application`]. /// diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index 4a91bdf4..ac625281 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -114,7 +114,7 @@ pub trait Application: Sized { fn view( &self, window: window::Id, - ) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>; + ) -> Element<'_, Self::Message, Self::Theme, crate::Renderer>; /// Returns the current [`Theme`] of the `window` of the [`Application`]. /// @@ -185,7 +185,7 @@ pub trait Application: Sized { Ok(crate::shell::multi_window::run::< Instance<Self>, Self::Executor, - crate::renderer::Compositor<Self::Theme>, + crate::renderer::Compositor, >(settings.into(), renderer_settings)?) } } @@ -196,8 +196,9 @@ impl<A> crate::runtime::multi_window::Program for Instance<A> where A: Application, { - type Renderer = crate::Renderer<A::Theme>; type Message = A::Message; + type Theme = A::Theme; + type Renderer = crate::Renderer; fn update(&mut self, message: Self::Message) -> Command<Self::Message> { self.0.update(message) @@ -206,7 +207,7 @@ where fn view( &self, window: window::Id, - ) -> Element<'_, Self::Message, Self::Renderer> { + ) -> Element<'_, Self::Message, Self::Theme, Self::Renderer> { self.0.view(window) } } |