Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for child-space issue #32

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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