Skip to content

Commit

Permalink
Fixed wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
genusistimelord committed Nov 7, 2023
1 parent 34ab848 commit 1af1814
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ default = [
"tab_bar",
"tabs",
"time_picker",
#"wrap",
"wrap",
#"selection_list",
#"split",
#"menu",
Expand Down Expand Up @@ -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",
Expand Down
20 changes: 13 additions & 7 deletions src/native/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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<Renderer>
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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();

Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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();

Expand Down

0 comments on commit 1af1814

Please sign in to comment.