From 1af18140814d1668d80193afc3509a14a32038f5 Mon Sep 17 00:00:00 2001 From: genusistimelord Date: Tue, 7 Nov 2023 14:34:04 -0500 Subject: [PATCH] Fixed wrap --- Cargo.toml | 4 ++-- src/native/wrap.rs | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 581ea0fc..fc379ac9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ default = [ "tab_bar", "tabs", "time_picker", - #"wrap", + "wrap", #"selection_list", #"split", #"menu", @@ -96,7 +96,7 @@ members = [ "examples/tab_bar", "examples/tabs", "examples/time_picker", - #"examples/wrap", + "examples/wrap", "examples/number_input", #"examples/selection_list", #"examples/split", diff --git a/src/native/wrap.rs b/src/native/wrap.rs index e80a4e75..43003122 100644 --- a/src/native/wrap.rs +++ b/src/native/wrap.rs @@ -176,8 +176,8 @@ where self.height } - fn layout(&self, renderer: &Renderer, limits: &Limits) -> Node { - self.inner_layout(renderer, limits) + fn layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node { + self.inner_layout(tree, renderer, limits) } fn on_event( @@ -337,7 +337,7 @@ where Renderer: core::Renderer, { /// A inner layout of the [`Wrap`]. - fn inner_layout(&self, renderer: &Renderer, limits: &Limits) -> Node; + fn inner_layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node; } impl<'a, Message, Renderer> WrapLayout @@ -347,7 +347,7 @@ where { #[allow(clippy::inline_always)] #[inline(always)] - fn inner_layout(&self, renderer: &Renderer, limits: &Limits) -> Node { + fn inner_layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node { let padding = Padding::from(self.padding); let spacing = self.spacing; let line_spacing = self.line_spacing; @@ -361,6 +361,7 @@ where .max_height(self.max_height); let max_width = limits.max().width; + let mut children = tree.children.iter_mut(); let mut curse = padding.left; let mut deep_curse = padding.left; let mut current_line_height = line_minimal_length; @@ -376,7 +377,9 @@ where Size::new(limits.min().width, line_minimal_length), limits.max(), ); - let mut node = elem.as_widget().layout(renderer, &node_limit); + let mut node = + elem.as_widget() + .layout(&mut children.next().unwrap(), renderer, &node_limit); let size = node.size(); @@ -429,7 +432,7 @@ where { #[allow(clippy::inline_always)] #[inline(always)] - fn inner_layout(&self, renderer: &Renderer, limits: &Limits) -> Node { + fn inner_layout(&self, tree: &mut Tree, renderer: &Renderer, limits: &Limits) -> Node { let padding = Padding::from(self.padding); let spacing = self.spacing; let line_spacing = self.line_spacing; @@ -443,6 +446,7 @@ where .max_height(self.max_height); let max_height = limits.max().height; + let mut children = tree.children.iter_mut(); let mut curse = padding.left; let mut wide_curse = padding.left; let mut current_line_width = line_minimal_length; @@ -458,7 +462,9 @@ where Size::new(line_minimal_length, limits.min().height), limits.max(), ); - let mut node = elem.as_widget().layout(renderer, &node_limit); + let mut node = + elem.as_widget() + .layout(&mut children.next().unwrap(), renderer, &node_limit); let size = node.size();