diff options
author | 2022-02-16 15:44:50 +0700 | |
---|---|---|
committer | 2022-02-16 15:44:50 +0700 | |
commit | 35e9b75e415ef3b9124051696b60628ef56afe47 (patch) | |
tree | dc81a8bfa59634072d2e439d32bdf263dd4f610a /pure/src/widget/button.rs | |
parent | cff891833be68c0e2d4919d4475daf23da821f9b (diff) | |
download | iced-35e9b75e415ef3b9124051696b60628ef56afe47.tar.gz iced-35e9b75e415ef3b9124051696b60628ef56afe47.tar.bz2 iced-35e9b75e415ef3b9124051696b60628ef56afe47.zip |
Introduce `Tag` and `State` opaque types in `iced_pure::widget::tree`
Diffstat (limited to 'pure/src/widget/button.rs')
-rw-r--r-- | pure/src/widget/button.rs | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/pure/src/widget/button.rs b/pure/src/widget/button.rs index 6dc1016c..55cbf8b4 100644 --- a/pure/src/widget/button.rs +++ b/pure/src/widget/button.rs @@ -1,4 +1,5 @@ -use crate::widget::{Element, Tree, Widget}; +use crate::widget::tree::{self, Tree}; +use crate::widget::{Element, Widget}; use iced_native::event::{self, Event}; use iced_native::layout; @@ -10,8 +11,6 @@ use iced_native::{ }; use iced_style::button::StyleSheet; -use std::any::Any; - pub use button::State; pub struct Button<'a, Message, Renderer> { @@ -77,20 +76,20 @@ where Message: 'static + Clone, Renderer: 'static + iced_native::Renderer, { - fn tag(&self) -> std::any::TypeId { - std::any::TypeId::of::<State>() + fn tag(&self) -> tree::Tag { + tree::Tag::of::<State>() } - fn state(&self) -> Box<dyn Any> { - Box::new(State::new()) + fn state(&self) -> tree::State { + tree::State::new(State::new()) } - fn diff(&self, tree: &mut Tree) { - tree.diff_children(std::slice::from_ref(&self.content)) + fn children(&self) -> Vec<Tree> { + vec![Tree::new(&self.content)] } - fn children_state(&self) -> Vec<Tree> { - vec![Tree::new(&self.content)] + fn diff(&self, tree: &mut Tree) { + tree.diff_children(std::slice::from_ref(&self.content)) } fn width(&self) -> Length { |