Make Element aliases in iced compatible with iced_native and iced_pure
This commit is contained in:
parent
48bc505cb6
commit
4407385fbe
4 changed files with 15 additions and 9 deletions
|
|
@ -139,7 +139,9 @@ pub trait Application: Sized {
|
||||||
/// Returns the widgets to display in the [`Application`].
|
/// Returns the widgets to display in the [`Application`].
|
||||||
///
|
///
|
||||||
/// These widgets can produce __messages__ based on user interaction.
|
/// These widgets can produce __messages__ based on user interaction.
|
||||||
fn view(&mut self) -> Element<'_, Self::Message, Self::Theme>;
|
fn view(
|
||||||
|
&mut self,
|
||||||
|
) -> Element<'_, Self::Message, crate::Renderer<Self::Theme>>;
|
||||||
|
|
||||||
/// Returns the current [`Theme`] of the [`Application`].
|
/// Returns the current [`Theme`] of the [`Application`].
|
||||||
///
|
///
|
||||||
|
|
@ -239,14 +241,14 @@ impl<A> iced_winit::Program for Instance<A>
|
||||||
where
|
where
|
||||||
A: Application,
|
A: Application,
|
||||||
{
|
{
|
||||||
type Renderer = crate::renderer::Renderer<A::Theme>;
|
type Renderer = crate::Renderer<A::Theme>;
|
||||||
type Message = A::Message;
|
type Message = A::Message;
|
||||||
|
|
||||||
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
|
fn update(&mut self, message: Self::Message) -> Command<Self::Message> {
|
||||||
self.0.update(message)
|
self.0.update(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&mut self) -> Element<'_, Self::Message, A::Theme> {
|
fn view(&mut self) -> Element<'_, Self::Message, Self::Renderer> {
|
||||||
self.0.view()
|
self.0.view()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/// A generic widget.
|
/// A generic widget.
|
||||||
///
|
///
|
||||||
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
/// This is an alias of an `iced_native` element with a default `Renderer`.
|
||||||
pub type Element<'a, Message, Theme = iced_native::Theme> =
|
pub type Element<'a, Message, Renderer = crate::Renderer<crate::Theme>> =
|
||||||
crate::runtime::Element<'a, Message, crate::Renderer<Theme>>;
|
crate::runtime::Element<'a, Message, Renderer>;
|
||||||
|
|
|
||||||
|
|
@ -108,5 +108,5 @@ pub use iced_pure::Widget;
|
||||||
pub use iced_pure::{Pure, State};
|
pub use iced_pure::{Pure, State};
|
||||||
|
|
||||||
/// A generic, pure [`Widget`].
|
/// A generic, pure [`Widget`].
|
||||||
pub type Element<'a, Message, Theme = crate::Theme> =
|
pub type Element<'a, Message, Renderer = crate::Renderer<crate::Theme>> =
|
||||||
iced_pure::Element<'a, Message, crate::Renderer<Theme>>;
|
iced_pure::Element<'a, Message, Renderer>;
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@ pub trait Application: Sized {
|
||||||
/// Returns the widgets to display in the [`Application`].
|
/// Returns the widgets to display in the [`Application`].
|
||||||
///
|
///
|
||||||
/// These widgets can produce __messages__ based on user interaction.
|
/// These widgets can produce __messages__ based on user interaction.
|
||||||
fn view(&self) -> pure::Element<'_, Self::Message, Self::Theme>;
|
fn view(
|
||||||
|
&self,
|
||||||
|
) -> pure::Element<'_, Self::Message, crate::Renderer<Self::Theme>>;
|
||||||
|
|
||||||
/// Returns the current [`Theme`] of the [`Application`].
|
/// Returns the current [`Theme`] of the [`Application`].
|
||||||
fn theme(&self) -> Self::Theme {
|
fn theme(&self) -> Self::Theme {
|
||||||
|
|
@ -167,7 +169,9 @@ where
|
||||||
A::subscription(&self.application)
|
A::subscription(&self.application)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn view(&mut self) -> crate::Element<'_, Self::Message, Self::Theme> {
|
fn view(
|
||||||
|
&mut self,
|
||||||
|
) -> crate::Element<'_, Self::Message, crate::Renderer<Self::Theme>> {
|
||||||
let content = A::view(&self.application);
|
let content = A::view(&self.application);
|
||||||
|
|
||||||
Pure::new(&mut self.state, content).into()
|
Pure::new(&mut self.state, content).into()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue