Skip to content

Commit

Permalink
Upgrade yoga-rs to v0.5.0
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Burns <[email protected]>
  • Loading branch information
nicoburns committed Jan 16, 2025
1 parent 80cc4a0 commit cdaddd3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 2 additions & 2 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ rand = { version = "0.8.5" }
rand_chacha = "0.3.1"
taffy = { path = ".." }
taffy_03 = { package = "taffy", version = "0.3", optional = true }
yoga = { version = "0.4.0", optional = true }
ordered-float = { version = "3.4.0", optional = true }
yoga = { version = "0.5.0", optional = true }
ordered-float = { version = "4", optional = true }
slotmap = { version = "1.0.6", optional = true }

[features]
Expand Down
16 changes: 11 additions & 5 deletions benches/src/yoga_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ fn create_yg_node(tree: &mut yg::YogaTree, style: &tf::Style, children: &[yg::De
let mut node = yg::Node::new();
apply_taffy_style(&mut node, &style);
for (i, child) in children.into_iter().enumerate() {
node.insert_child(&mut tree[*child], i as u32);
node.insert_child(&mut tree[*child], i);
}
tree.insert(node)
}

pub fn new_default_style_with_children(tree: &mut yg::YogaTree, children: &[yg::DefaultKey]) -> yg::DefaultKey {
let mut node = yg::Node::new();
for (i, child) in children.into_iter().enumerate() {
node.insert_child(&mut tree[*child], i as u32);
node.insert_child(&mut tree[*child], i);
}
tree.insert(node)
}
Expand All @@ -123,7 +123,7 @@ fn set_node_children(tree: &mut yg::YogaTree, node_id: yg::DefaultKey, children:
// TODO: clear existing children.
for (i, child_id) in children.into_iter().enumerate() {
let [node, child] = tree.get_disjoint_mut([node_id, *child_id]).unwrap();
node.insert_child(child, i as u32);
node.insert_child(child, i);
}
}

Expand Down Expand Up @@ -194,6 +194,12 @@ fn apply_taffy_style(node: &mut yg::Node, style: &tf::Style) {
tf::Display::Block => panic!("Yoga does not support CSS Block layout"),
});

// box_sizing
node.set_box_sizing(match style.box_sizing {
tf::BoxSizing::BorderBox => yg::BoxSizing::BorderBox,
tf::BoxSizing::ContentBox => yg::BoxSizing::ContentBox,
});

// position
node.set_position_type(match style.position {
tf::Position::Relative => yg::PositionType::Relative,
Expand Down Expand Up @@ -239,8 +245,8 @@ fn apply_taffy_style(node: &mut yg::Node, style: &tf::Style) {
node.set_justify_content(content_into_justify(style.justify_content));

// gap
node.set_column_gap(into_pixels(style.gap.width));
node.set_row_gap(into_pixels(style.gap.height));
node.set_column_gap(into_yg_units(style.gap.width));
node.set_row_gap(into_yg_units(style.gap.height));

// flex
node.set_flex_direction(match style.flex_direction {
Expand Down

0 comments on commit cdaddd3

Please sign in to comment.