Skip to content

Commit

Permalink
Fix for child-space issue (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
geom3trik committed Nov 8, 2023
1 parent a2da20d commit 001a24f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "morphorm"
version = "0.6.3"
version = "0.6.4"
edition = "2021"
author = "George Atkinson <geom3trik@vizia.dev>"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A mini ECS used for testing the morphorm crate."
license = "MIT"

[dependencies]
morphorm = {version = "0.6.3", path = "../"}
morphorm = {version = "0.6.4", path = "../"}
femtovg = {version = "0.7.1", default-features = false}
rand = "0.8.5"
slotmap = "1.0.6"
17 changes: 8 additions & 9 deletions src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,17 @@ where
let mut iter = node
.children(tree)
.filter(|child| child.visible(store))
.enumerate()
.filter(|(_, child)| child.position_type(store).unwrap_or_default() == PositionType::ParentDirected);
.filter(|child| child.position_type(store).unwrap_or_default() == PositionType::ParentDirected)
.enumerate();

let first = iter.next().map(|(index, _)| index);
let last = iter.last().map_or(first, |(index, _)| Some(index));

let mut node_children = node
.children(tree)
.filter(|child| child.visible(store))
.filter(|child| child.position_type(store).unwrap_or_default() == PositionType::ParentDirected)
.enumerate()
.filter(|(_, child)| child.position_type(store).unwrap_or_default() == PositionType::ParentDirected)
.peekable();

// Compute space and size of non-flexible parent-directed children.
Expand Down Expand Up @@ -353,9 +353,9 @@ where
// Compute flexible space and size on the cross-axis for parent-directed children.
for (index, child) in children
.iter_mut()
.filter(|child| child.node.position_type(store).unwrap_or_default() == PositionType::ParentDirected)
.filter(|child| !child.node.cross(store, layout_type).is_auto())
.enumerate()
.filter(|(_, child)| child.node.position_type(store).unwrap_or_default() == PositionType::ParentDirected)
.filter(|(_, child)| !child.node.cross(store, layout_type).is_auto())
{
let mut child_cross_before = child.node.cross_before(store, layout_type);
let child_cross = child.node.cross(store, layout_type);
Expand Down Expand Up @@ -570,8 +570,7 @@ where

// Compute stretch cross_before and stretch cross_after for auto cross children.
// TODO: I think this only needs to be done for parent-directed children...
for (index, child) in
children.iter_mut().enumerate().filter(|(_, child)| child.node.cross(store, layout_type).is_auto())
for (index, child) in children.iter_mut().filter(|child| child.node.cross(store, layout_type).is_auto()).enumerate()
{
let mut child_cross_before = child.node.cross_before(store, layout_type);
let mut child_cross_after = child.node.cross_after(store, layout_type);
Expand Down Expand Up @@ -782,8 +781,8 @@ where
// Compute flexible space and size on the cross-axis for self-directed nodes.
for (index, child) in children
.iter_mut()
.filter(|child| child.node.position_type(store).unwrap_or_default() == PositionType::SelfDirected)
.enumerate()
.filter(|(_, child)| child.node.position_type(store).unwrap_or_default() == PositionType::SelfDirected)
{
let mut child_cross_before = child.node.cross_before(store, layout_type);
let child_cross = child.node.cross(store, layout_type);
Expand Down Expand Up @@ -933,8 +932,8 @@ where
// Compute flexible space and size on the main-axis for self-directed nodes.
for (index, child) in children
.iter_mut()
.filter(|child| child.node.position_type(store).unwrap_or_default() == PositionType::SelfDirected)
.enumerate()
.filter(|(_, child)| child.node.position_type(store).unwrap_or_default() == PositionType::SelfDirected)
{
let mut child_main_before = child.node.main_before(store, layout_type);
let child_main = child.node.main(store, layout_type);
Expand Down

0 comments on commit 001a24f

Please sign in to comment.