diff options
author | 2022-03-23 17:11:14 +0700 | |
---|---|---|
committer | 2022-03-23 17:11:14 +0700 | |
commit | 0eef527fa5b04be74141c75b076677473320e321 (patch) | |
tree | 5062a9ce2c370632de87a01471526da1176e0a60 /lazy/src/pure.rs | |
parent | 4aece6b77617f4a37af8208d8ddb1618bf9052d3 (diff) | |
parent | ef4c79ea23e86fec9a8ad0fb27463296c14400e5 (diff) | |
download | iced-0eef527fa5b04be74141c75b076677473320e321.tar.gz iced-0eef527fa5b04be74141c75b076677473320e321.tar.bz2 iced-0eef527fa5b04be74141c75b076677473320e321.zip |
Merge pull request #1284 from iced-rs/virtual-widgets
Stateless widgets
Diffstat (limited to 'lazy/src/pure.rs')
-rw-r--r-- | lazy/src/pure.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lazy/src/pure.rs b/lazy/src/pure.rs new file mode 100644 index 00000000..dc500e5e --- /dev/null +++ b/lazy/src/pure.rs @@ -0,0 +1,31 @@ +mod component; +mod responsive; + +pub use component::Component; +pub use responsive::Responsive; + +use iced_native::Size; +use iced_pure::Element; + +/// Turns an implementor of [`Component`] into an [`Element`] that can be +/// embedded in any application. +pub fn component<'a, C, Message, Renderer>( + component: C, +) -> Element<'a, Message, Renderer> +where + C: Component<Message, Renderer> + 'a, + C::State: 'static, + Message: 'a, + Renderer: iced_native::Renderer + 'a, +{ + component::view(component) +} + +pub fn responsive<'a, Message, Renderer>( + f: impl Fn(Size) -> Element<'a, Message, Renderer> + 'a, +) -> Responsive<'a, Message, Renderer> +where + Renderer: iced_native::Renderer, +{ + Responsive::new(f) +} |