diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 000000000..7e669f119 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[alias] +gentest = "run --package gentest --" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67c864941..837145200 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,6 +52,36 @@ jobs: command: test args: --no-default-features --features alloc + test-features-default-with-grid: + name: "Test Suite [Features: default + experimental_grid]" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + args: --features experimental_grid + + test-features-alloc-with-grid: + name: "Test Suite [Features: alloc + experimental_grid]" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: test + args: --no-default-features --features alloc,experimental_grid + fmt: name: Rustfmt runs-on: ubuntu-latest @@ -82,7 +112,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: clippy - args: --workspace -- -D warnings + args: --workspace --features experimental_grid -- -D warnings markdownlint: name: Markdown Lint diff --git a/.gitignore b/.gitignore index 5188ccbf6..d70fe4b5f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ Cargo.lock .DS_Store .vscode + +*-test-names.txt \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5f1827413..f618073f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,7 +32,7 @@ If you are Ubuntu, you will have to install `openssl` first, and then can follow [these instructions](https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu/). Be sure that your Chrome vesion matches the downloaded `chromedriver` version! -Once you have chromedriver installed and available in `PATH` you can re-generate all tests by running `cargo run --package gentest`. You should not manually update the tests in `tests/generated`. Instead, fix the script in `scripts/gentest/` and re-generate them. This can happen after a refactor. It can be helpful to commit the updated tests in a dedicated commit so that they can be easier to ignore during review. +Once you have chromedriver installed and available in `PATH` you can re-generate all tests by running `cargo gentest`. You should not manually update the tests in `tests/generated`. Instead, fix the script in `scripts/gentest/` and re-generate them. This can happen after a refactor. It can be helpful to commit the updated tests in a dedicated commit so that they can be easier to ignore during review. To add a new test case add another HTML file to `/test_fixtures` following the current tests as a template for new tests. diff --git a/Cargo.toml b/Cargo.toml index 0b3179542..31a2b417a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,9 +19,11 @@ num-traits = { version = "0.2", default-features = false } rand = { version = "0.8.5", optional = true } serde = { version = "1.0", optional = true, features = ["serde_derive"] } slotmap = "1.0.6" +grid = { version = "0.7.0", optional = true } [features] default = ["std"] +experimental_grid = ["dep:grid"] alloc = [] std = ["num-traits/std"] serde = ["dep:serde"] diff --git a/RELEASES.md b/RELEASES.md index 6b3a3a7b3..a5e1a0b7e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,9 +1,150 @@ # Release Notes -## 0.3.0 (Unreleased) +## 0.3.0-alpha1 (Unreleased) + +This is the first in a series of planned alpha releases to allow users of Taffy to try out the new CSS Grid layout mode in advance of a stable release. We hope that by marking this is alpha release we are clearly communicating that this a pre-release and that the implementation is not yet of production quality. But we never-the-less encourage you to try it out. Feedback is welcome, and bug reports for the Grid implementation are being accepted as of this release. + +**Note: CSS Grid support must be enabled using the `experimental_grid` feature. For the time being this feature is not enabled by default.** + +### New Feature: CSS Grid (Experimental) + +We very excited to report that we have an initial version of the CSS Grid layout available. This is in addition to the existing Flexbox layout support, and the two modes interoperate (although this interaction has not been extensively tested). You can set a node to use Grid layout by setting the `display` property to `Display::Grid`. + +#### Learning Resources + +Taffy implements the CSS Grid specification faithfully, so documentation designed for the web should translate cleanly to Taffy's implementation. If you are interested in learning how to use CSS Grid, we would recommend the following resources: + +- [CSS Grid Garden](https://cssgridgarden.com/). This is an interactive tutorial/game that allows you to learn the essential parts of CSS Grid in a fun engaging way. +- [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comphrehensive written explanation of the different Grid propertie and how they work. + +#### Supported Features & Properties + +In addition to the usual sizing/spacing proerties (size, min_size, padding, margin, etc), the following Grid style properties are supported on Grid Containers: + +| Property | Explanation | +| --- | --- | +| [`grid-template-columns`] | The track sizing functions of the grid's explicit columns | +| [`grid-template-rows`] | The track sizing functions of the grid's explicit rows | +| [`grid-template-areas`] | Defines named grid areas | +| [`grid-auto-rows`] | Track sizing functions for the grid's implicitly generated rows | +| [`grid-auto-columns`] | Track sizing functions for the grid's implicitly generated columns | +| [`grid-auto-flow`] | Whether auto-placed items are placed row-wise or column-wise. And sparsely or densely. | +| [`gap`] | The size of the vertical and horizontal gaps between grid rows/columns | +| [`align-content`] | Align grid tracks within the container in the inline (horizontal) axis | +| [`justify-content`] | Align grid tracks within the container in the block (vertical) axis | +| [`align-items`] | Align the child items within their grid areas in the inline (horizontal) axis | +| [`justify-items`] | Align the child items within their grid areas in the block (vertical) axis | + +And the following Grid style properties are supported on Grid Items (children): + +| Property | Explanation | +| --- | --- | +| [`grid-row`] | The (row) grid line the item starts at (or a span) | +| [`grid-column`] | The (column) grid line the item end at (or a span) | +| [`align-self`] | Align the item within it's grid area in the inline (horizontal) axis. Overrides `align-items`. | +| [`justify-self`] | Align the item within it's grid area in the block (vertical) axis. Overrides `justify-items`. | + +[`grid-template-columns`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns +[`grid-template-rows`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-rows +[`grid-template-areas`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas +[`grid-auto-rows`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows +[`grid-auto-columns`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns +[`grid-auto-flow`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow +[`gap`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/gap +[`align-content`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/align_content +[`justify-content`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/justify_content +[`align-items`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/align-items +[`justify-items`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/justify-items +[`grid-row`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-row +[`grid-column`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/grid-column +[`align-self`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/align-self +[`justify-self`]: https:://developer.mozilla.org/en-US/docs/Web/CSS/justify-self + +The following properties and features are not yet supported, but are planned for the near future: + +- Baseline alignment +- `fit-content()` with a percentage argument. +- `repeat()` with integer repetition (but users of Taffy can just expand these definition manually) + +The following properties and features are not supported, and there are no immediate plans to implement them: + +- Subgrids +- Named grid lines +- Named areas: `grid-template-areas` and `grid-area` +- `grid-template` or `grid` shorthand + +#### Example + +See [examples/grid_holy_grail.rs](https://github.com/DioxusLabs/taffy/blob/main/examples/grid_holy_grail.rs) for an example using Taffy to implement the so-called [Holy Grail Layout](https://en.wikipedia.org/wiki/Holy_grail_(web_design)). If you want to run this example, the don't forget the enable the CSS Grid cargo feature: + +```bash +cargo run --example grid_holy_grail --features experimental_grid +``` + +### New Feature: Style Helpers + +Ten new helper functions have added to the taffy prelude. These helper functions have short, intuitive names, and have generic return types which allow them to magically return the correct type depending on context. They make defining styles much easier, and means you won't typically need to use types like `Dimension` or `TrackSizingFunction` directly. + +For example, instead of: + +```rust +let size : Size = Size { width: Dimension::Points(100.0), height: Dimension::Percent(50.0) }; +``` + +you can now write + +```rust +let size : Size = Size { width: points(100.0), height: percent(50.0) }; +``` + +And that same helper function will work other types like `LengthPercentage` and `MinTrackSizingFunction` that also have a `Points` variant. There are also generic impl's for `Size`, `Rect` and `Line` which means if your node is the same size in all dimensions you can even write + +```rust +let size : Size = points(100.0); +``` + +The following functions work for `Dimension`, `LengthPercentageAuto`, `LengthPercentage`, `AvailableSpace` and for Grid track sizing functions + +- `points(f32)` - Generates a `Points` variant with the specified value +- `zero()` - Generates a `Points` variant with the value `0.0`. + +The following functions work for `Dimension`, `LengthPercentageAuto`, `LengthPercentage` and for Grid track sizing functions + +- `percent(f32)` - Generates a `Percent` value +- `auto()` - Generates an `Auto` variant + +The following functions work for `AvailableSpace` and grid track sizing functions: + +- `min_content()` - Generates an `MinContent` variant +- `max_content()` - Generates an `MaxContent` variant + +The following functions currently work only for grid track sizing functions: + +- `flex(f32)` - Genrates a `Flex` variant with the specified flex fraction +- `fit_content(LengthPercentage)` - Generates a `FitContent` variant with the specified limit. Nest `points` or `percent` inside this function to specified the limit. +- `minmax(MinTrackSizingFunction, MaxTrackSizingFunction)` - Generates a track sizing function with different min and max sizing functions. Nest `points`, `percent`, `auto`, `min_content`, `max_content`, or `flex` to specify the min and max functions. +- `repeat(GridTrackRepetition, Vec)` - Genereate an auto-repeating track definition. ### Breaking API changes +#### Changes to alignment style types + +- `AlignContent` and `JustifyContent` has been merged. + - `JustifyContent` is now an alias of `AlignContent` and contains the `Stretch` variant. + - This variant will be *ignored* (falling back to `Start`) when applied Flexbox containers. It is valid value for Grid containers. +- `AlignItems` and `AlignSelf` have been merged. + - The `Auto` variant of `AlignSelf` has been removed. You should now use `Option::None` if you wish to specify `AlignSelf::Auto`. + - `AlignSelf` is now an alias of `AlignItems`. + - `JustifyItems` and `JustifySelf` aliases have been added. These properties have no affect on Flexbox containers, but apply to Grid containers. +- `Default` impls have been removed from all alignment types. This is because the correct default varies by property, and the types are now shared between multiple properties. The `Style` struct still has a default for each alignment property, so this is considered unlikely to affect you in practice. + +#### Strict style types + +- New types `LengthPercentage` and `LengthPercentageAuto` have been added. + - `LengthPercentage` is like `Dimension` but only contains the `Points` and `Percent` variants, which allows us to increase type safety for properties that don't support the `Auto` value. + - `LengthPercentageAuto` is currently identical to `Dimension` but will allow us to expand dimension in future to support values like `MinContent`, `MaxContent` and `FitContent`. +- Some style properties have been updated to use either `LengthPercentage` or `LengthPercentageAuto` instead of `Dimension`. You will need to update your code, but it is recommended that you use the new style helpers (see above) rather than using the new types directly (although you certainly can use them directly if you want to). + #### Changes to `LayoutTree` - Added generic associated type to `LayoutTree` for a `ChildIter`, an iterator on the children of a given node. @@ -11,6 +152,10 @@ - Added `child_count` method to `LayoutTree` for querying the number of children of a node. Required because the `children` method now returns an iterator instead of an array. - Added `is_childless` method to `LayoutTree` for querying whether a node has no children. +#### `AvailableSpace` has been moved + +The `AvailableSpace` enum has been moved from the `layout` module to the `style` module. If you are importing it via the prelude then you will unaffected by the change. + ### Fixes - Fix case where column-gap style could be used in place of row-gap style (when using a percentage gap with an indefinite container size) diff --git a/benches/big_tree.rs b/benches/big_tree.rs index fda359e75..1f7d2a523 100644 --- a/benches/big_tree.rs +++ b/benches/big_tree.rs @@ -73,9 +73,9 @@ fn build_yoga_deep_hierarchy(taffy: &mut Taffy, node_count: u32, branching_facto flex_grow: 1.0, ..Default::default() }; - let mut build_leaf_node = |taffy: &mut Taffy| taffy.new_leaf(style).unwrap(); + let mut build_leaf_node = |taffy: &mut Taffy| taffy.new_leaf(style.clone()).unwrap(); let mut build_flex_node = - |taffy: &mut Taffy, children: Vec| taffy.new_with_children(style, &children).unwrap(); + |taffy: &mut Taffy, children: Vec| taffy.new_with_children(style.clone(), &children).unwrap(); let tree = build_deep_tree(taffy, node_count, branching_factor, &mut build_leaf_node, &mut build_flex_node); diff --git a/benches/complex.rs b/benches/complex.rs index ad7493b14..cba4a0b7a 100644 --- a/benches/complex.rs +++ b/benches/complex.rs @@ -1,4 +1,5 @@ use criterion::{criterion_group, criterion_main, Criterion}; +use taffy::style_helpers::*; use taffy::tree::LayoutTree; fn build_deep_hierarchy(taffy: &mut taffy::node::Taffy) -> taffy::node::Node { diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center.rs index ca0e219b1..a6b327999 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_center.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center.rs @@ -3,28 +3,23 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs index 242e323e2..b9e2ca44c 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -3,32 +3,29 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs index 2c6d7ec03..75381e88e 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -3,32 +3,29 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: auto(), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs index 978a31491..e6b93e783 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -3,32 +3,29 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(5f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs index 1ada06afd..5738428e1 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -3,32 +3,29 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs b/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs index 0b23cd809..6530506e9 100644 --- a/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs +++ b/benches/generated/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -3,28 +3,23 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, - justify_content: taffy::style::JustifyContent::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_center.rs b/benches/generated/absolute_layout_align_items_center.rs index db9f4f27a..c3dac43b4 100644 --- a/benches/generated/absolute_layout_align_items_center.rs +++ b/benches/generated/absolute_layout_align_items_center.rs @@ -3,27 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_align_items_center_on_child_only.rs b/benches/generated/absolute_layout_align_items_center_on_child_only.rs index 0d3b0802b..0fc82fbfe 100644 --- a/benches/generated/absolute_layout_align_items_center_on_child_only.rs +++ b/benches/generated/absolute_layout_align_items_center_on_child_only.rs @@ -3,19 +3,15 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::Center, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_child_order.rs b/benches/generated/absolute_layout_child_order.rs index b7c80ad35..b5d8ad49d 100644 --- a/benches/generated/absolute_layout_child_order.rs +++ b/benches/generated/absolute_layout_child_order.rs @@ -3,54 +3,41 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs b/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs index 8c77b85c6..a7ea7a908 100644 --- a/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs +++ b/benches/generated/absolute_layout_in_wrap_reverse_column_container.rs @@ -3,18 +3,14 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs index eae4f47f2..c4c0b8379 100644 --- a/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs +++ b/benches/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -3,19 +3,15 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -25,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs b/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs index 72dcea73b..dde1ab337 100644 --- a/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs +++ b/benches/generated/absolute_layout_in_wrap_reverse_row_container.rs @@ -3,18 +3,14 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs index df41760ba..b71612d1a 100644 --- a/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs +++ b/benches/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -3,19 +3,15 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_justify_content_center.rs b/benches/generated/absolute_layout_justify_content_center.rs index 61dfeaa5f..484389241 100644 --- a/benches/generated/absolute_layout_justify_content_center.rs +++ b/benches/generated/absolute_layout_justify_content_center.rs @@ -3,27 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_no_size.rs b/benches/generated/absolute_layout_no_size.rs index aa115adc9..c00ddab66 100644 --- a/benches/generated/absolute_layout_no_size.rs +++ b/benches/generated/absolute_layout_no_size.rs @@ -3,10 +3,7 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { position_type: taffy::style::PositionType::Absolute, ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { position_type: taffy::style::PositionType::Absolute, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -14,7 +11,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs b/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs index 4d2e80540..a12500b6b 100644 --- a/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/benches/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -3,55 +3,49 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.5f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -59,7 +53,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_start_top_end_bottom.rs b/benches/generated/absolute_layout_start_top_end_bottom.rs index 27d290fae..fe9225836 100644 --- a/benches/generated/absolute_layout_start_top_end_bottom.rs +++ b/benches/generated/absolute_layout_start_top_end_bottom.rs @@ -3,20 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_width_height_end_bottom.rs b/benches/generated/absolute_layout_width_height_end_bottom.rs index a7df966c1..9cebb3da4 100644 --- a/benches/generated/absolute_layout_width_height_end_bottom.rs +++ b/benches/generated/absolute_layout_width_height_end_bottom.rs @@ -3,23 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_width_height_start_top.rs b/benches/generated/absolute_layout_width_height_start_top.rs index b0716ed08..e6f4e4dd7 100644 --- a/benches/generated/absolute_layout_width_height_start_top.rs +++ b/benches/generated/absolute_layout_width_height_start_top.rs @@ -3,23 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs b/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs index 99e948759..a16258537 100644 --- a/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs +++ b/benches/generated/absolute_layout_width_height_start_top_end_bottom.rs @@ -3,25 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -29,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/absolute_layout_within_border.rs b/benches/generated/absolute_layout_within_border.rs index ff72a32c4..873186dbf 100644 --- a/benches/generated/absolute_layout_within_border.rs +++ b/benches/generated/absolute_layout_within_border.rs @@ -3,94 +3,80 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(0f32), - top: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(0f32), - bottom: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(0f32), - top: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(0f32), - bottom: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -98,21 +84,18 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/align_baseline.rs b/benches/generated/align_baseline.rs index 845e65740..f88ea6eb2 100644 --- a/benches/generated/align_baseline.rs +++ b/benches/generated/align_baseline.rs @@ -3,39 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_baseline_child_multiline.rs b/benches/generated/align_baseline_child_multiline.rs index f4d42e66c..c602e6ffc 100644 --- a/benches/generated/align_baseline_child_multiline.rs +++ b/benches/generated/align_baseline_child_multiline.rs @@ -3,75 +3,55 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node11 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node12 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node13 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, ..Default::default() }, &[node10, node11, node12, node13], @@ -80,8 +60,8 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/align_baseline_nested_child.rs b/benches/generated/align_baseline_nested_child.rs index fb1bbc055..f8e870c7e 100644 --- a/benches/generated/align_baseline_nested_child.rs +++ b/benches/generated/align_baseline_nested_child.rs @@ -3,30 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -35,7 +27,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(20f32), - ..Size::auto() }, ..Default::default() }, @@ -45,11 +36,10 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_center_should_size_based_on_content.rs b/benches/generated/align_center_should_size_based_on_content.rs index 4974830b4..184984bb6 100644 --- a/benches/generated/align_center_should_size_based_on_content.rs +++ b/benches/generated/align_center_should_size_based_on_content.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) @@ -21,7 +17,7 @@ pub fn compute() { let node0 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, ..Default::default() @@ -32,11 +28,10 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_around_single_line.rs b/benches/generated/align_content_space_around_single_line.rs index a07a64d33..4eb1c4c95 100644 --- a/benches/generated/align_content_space_around_single_line.rs +++ b/benches/generated/align_content_space_around_single_line.rs @@ -3,91 +3,66 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_around_wrapped.rs b/benches/generated/align_content_space_around_wrapped.rs index 8d27e756a..634965984 100644 --- a/benches/generated/align_content_space_around_wrapped.rs +++ b/benches/generated/align_content_space_around_wrapped.rs @@ -3,92 +3,67 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_between_single_line.rs b/benches/generated/align_content_space_between_single_line.rs index 765d776c9..aa69f67a5 100644 --- a/benches/generated/align_content_space_between_single_line.rs +++ b/benches/generated/align_content_space_between_single_line.rs @@ -3,91 +3,66 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_between_wrapped.rs b/benches/generated/align_content_space_between_wrapped.rs index b036aa563..bd457d9e0 100644 --- a/benches/generated/align_content_space_between_wrapped.rs +++ b/benches/generated/align_content_space_between_wrapped.rs @@ -3,92 +3,67 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_evenly_single_line.rs b/benches/generated/align_content_space_evenly_single_line.rs index db0c13d66..05b54116a 100644 --- a/benches/generated/align_content_space_evenly_single_line.rs +++ b/benches/generated/align_content_space_evenly_single_line.rs @@ -3,91 +3,66 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceEvenly, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_content_space_evenly_wrapped.rs b/benches/generated/align_content_space_evenly_wrapped.rs index 7a48300eb..6cfbb8821 100644 --- a/benches/generated/align_content_space_evenly_wrapped.rs +++ b/benches/generated/align_content_space_evenly_wrapped.rs @@ -3,92 +3,67 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceEvenly, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_flex_start_with_shrinking_children.rs b/benches/generated/align_flex_start_with_shrinking_children.rs index c6778d88b..9e78cd987 100644 --- a/benches/generated/align_flex_start_with_shrinking_children.rs +++ b/benches/generated/align_flex_start_with_shrinking_children.rs @@ -2,15 +2,14 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); @@ -20,7 +19,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs b/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs index c6778d88b..321e383a4 100644 --- a/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs +++ b/benches/generated/align_flex_start_with_shrinking_children_with_stretch.rs @@ -2,15 +2,22 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); @@ -20,7 +27,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_flex_start_with_stretching_children.rs b/benches/generated/align_flex_start_with_stretching_children.rs index c41468475..f7a9ce6cb 100644 --- a/benches/generated/align_flex_start_with_stretching_children.rs +++ b/benches/generated/align_flex_start_with_stretching_children.rs @@ -2,9 +2,8 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) .unwrap(); @@ -15,7 +14,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_center.rs b/benches/generated/align_items_center.rs index f2688d958..2521c24ca 100644 --- a/benches/generated/align_items_center.rs +++ b/benches/generated/align_items_center.rs @@ -3,26 +3,21 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs b/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs index 3d171d12e..ccd683790 100644 --- a/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs +++ b/benches/generated/align_items_center_child_with_margin_bigger_than_parent.rs @@ -3,38 +3,34 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs b/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs index 9831a591c..00b805b0f 100644 --- a/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs +++ b/benches/generated/align_items_center_child_without_margin_bigger_than_parent.rs @@ -3,33 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(70f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_center_with_child_margin.rs b/benches/generated/align_items_center_with_child_margin.rs index e4f066671..c3fdcb1f1 100644 --- a/benches/generated/align_items_center_with_child_margin.rs +++ b/benches/generated/align_items_center_with_child_margin.rs @@ -3,30 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_center_with_child_top.rs b/benches/generated/align_items_center_with_child_top.rs index 29d4affc5..518f4dadd 100644 --- a/benches/generated/align_items_center_with_child_top.rs +++ b/benches/generated/align_items_center_with_child_top.rs @@ -3,30 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_flex_end.rs b/benches/generated/align_items_flex_end.rs index bbbc822d9..78490a348 100644 --- a/benches/generated/align_items_flex_end.rs +++ b/benches/generated/align_items_flex_end.rs @@ -3,26 +3,21 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs index 16681f367..5689535be 100644 --- a/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs +++ b/benches/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -3,38 +3,34 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::End), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs index 0933a3175..67cc7c22a 100644 --- a/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs +++ b/benches/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -3,33 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(70f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::End), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_flex_start.rs b/benches/generated/align_items_flex_start.rs index 5a9f4b2d0..89f8ce282 100644 --- a/benches/generated/align_items_flex_start.rs +++ b/benches/generated/align_items_flex_start.rs @@ -3,26 +3,21 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_items_min_max.rs b/benches/generated/align_items_min_max.rs index 4724afb61..0092e0b48 100644 --- a/benches/generated/align_items_min_max.rs +++ b/benches/generated/align_items_min_max.rs @@ -3,26 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/align_items_stretch.rs b/benches/generated/align_items_stretch.rs index 45a26a677..41922018f 100644 --- a/benches/generated/align_items_stretch.rs +++ b/benches/generated/align_items_stretch.rs @@ -3,13 +3,10 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -17,7 +14,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_self_baseline.rs b/benches/generated/align_self_baseline.rs index 71b46a913..015be5273 100644 --- a/benches/generated/align_self_baseline.rs +++ b/benches/generated/align_self_baseline.rs @@ -3,40 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::Baseline, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { - align_self: taffy::style::AlignSelf::Baseline, + align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(20f32), - ..Size::auto() }, ..Default::default() }, @@ -49,7 +40,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_self_center.rs b/benches/generated/align_self_center.rs index 77ed1e9e4..96fe87b63 100644 --- a/benches/generated/align_self_center.rs +++ b/benches/generated/align_self_center.rs @@ -3,18 +3,14 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::Center, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +18,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_self_flex_end.rs b/benches/generated/align_self_flex_end.rs index 99dd5efc1..8a3da7d63 100644 --- a/benches/generated/align_self_flex_end.rs +++ b/benches/generated/align_self_flex_end.rs @@ -3,18 +3,14 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +18,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_self_flex_end_override_flex_start.rs b/benches/generated/align_self_flex_end_override_flex_start.rs index f2dbce164..290024b31 100644 --- a/benches/generated/align_self_flex_end_override_flex_start.rs +++ b/benches/generated/align_self_flex_end_override_flex_start.rs @@ -3,27 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_self_flex_start.rs b/benches/generated/align_self_flex_start.rs index 781de261a..010ed390b 100644 --- a/benches/generated/align_self_flex_start.rs +++ b/benches/generated/align_self_flex_start.rs @@ -3,18 +3,14 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexStart, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +18,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/align_strech_should_size_based_on_parent.rs b/benches/generated/align_strech_should_size_based_on_parent.rs index 6f3df07d6..bf166f107 100644 --- a/benches/generated/align_strech_should_size_based_on_parent.rs +++ b/benches/generated/align_strech_should_size_based_on_parent.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) @@ -21,7 +17,7 @@ pub fn compute() { let node0 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, ..Default::default() @@ -35,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/border_center_child.rs b/benches/generated/border_center_child.rs index 10388128f..603a483d7 100644 --- a/benches/generated/border_center_child.rs +++ b/benches/generated/border_center_child.rs @@ -3,32 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { + left: zero(), + right: zero(), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/border_flex_child.rs b/benches/generated/border_flex_child.rs index 7c4680eee..656d9edbf 100644 --- a/benches/generated/border_flex_child.rs +++ b/benches/generated/border_flex_child.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,14 +15,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/border_no_child.rs b/benches/generated/border_no_child.rs index 7ab4e70c8..f335eb24c 100644 --- a/benches/generated/border_no_child.rs +++ b/benches/generated/border_no_child.rs @@ -3,19 +3,15 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(10f32), - right: taffy::style::LengthPercentage::Points(10f32), - top: taffy::style::LengthPercentage::Points(10f32), - bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/border_stretch_child.rs b/benches/generated/border_stretch_child.rs index e4811cc17..d828e3fe7 100644 --- a/benches/generated/border_stretch_child.rs +++ b/benches/generated/border_stretch_child.rs @@ -3,13 +3,10 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -17,14 +14,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/child_min_max_width_flexing.rs b/benches/generated/child_min_max_width_flexing.rs index f3fa1dde4..c238edc93 100644 --- a/benches/generated/child_min_max_width_flexing.rs +++ b/benches/generated/child_min_max_width_flexing.rs @@ -3,36 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(0f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/container_with_unsized_child.rs b/benches/generated/container_with_unsized_child.rs index 58961fd3f..e3b02d1e5 100644 --- a/benches/generated/container_with_unsized_child.rs +++ b/benches/generated/container_with_unsized_child.rs @@ -2,14 +2,13 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/display_none.rs b/benches/generated/display_none.rs index c7f901009..557f2bfaf 100644 --- a/benches/generated/display_none.rs +++ b/benches/generated/display_none.rs @@ -2,12 +2,9 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -15,7 +12,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/display_none_fixed_size.rs b/benches/generated/display_none_fixed_size.rs index c224eeb06..13eebc8c7 100644 --- a/benches/generated/display_none_fixed_size.rs +++ b/benches/generated/display_none_fixed_size.rs @@ -2,20 +2,16 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/display_none_with_child.rs b/benches/generated/display_none_with_child.rs index 910530d32..187a0c84f 100644 --- a/benches/generated/display_none_with_child.rs +++ b/benches/generated/display_none_with_child.rs @@ -3,27 +3,21 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -39,15 +33,12 @@ pub fn compute() { ) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -55,7 +46,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/display_none_with_margin.rs b/benches/generated/display_none_with_margin.rs index 394f611b2..8d78d7e81 100644 --- a/benches/generated/display_none_with_margin.rs +++ b/benches/generated/display_none_with_margin.rs @@ -3,34 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/display_none_with_position.rs b/benches/generated/display_none_with_position.rs index 2621891d4..30e0f29dd 100644 --- a/benches/generated/display_none_with_position.rs +++ b/benches/generated/display_none_with_position.rs @@ -2,20 +2,19 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - flex_grow: 1f32, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + flex_grow: 1f32, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +22,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs b/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs index 475456be4..c48feab39 100644 --- a/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs +++ b/benches/generated/flex_basis_and_main_dimen_set_when_flexing.rs @@ -3,39 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(0f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(0f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_basis_flex_grow_column.rs b/benches/generated/flex_basis_flex_grow_column.rs index f8e1a1510..b4072b481 100644 --- a/benches/generated/flex_basis_flex_grow_column.rs +++ b/benches/generated/flex_basis_flex_grow_column.rs @@ -3,16 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -20,7 +17,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_flex_grow_row.rs b/benches/generated/flex_basis_flex_grow_row.rs index ebc426faa..f65e00c25 100644 --- a/benches/generated/flex_basis_flex_grow_row.rs +++ b/benches/generated/flex_basis_flex_grow_row.rs @@ -3,23 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_flex_shrink_column.rs b/benches/generated/flex_basis_flex_shrink_column.rs index ad0bf67ca..2dd14a539 100644 --- a/benches/generated/flex_basis_flex_shrink_column.rs +++ b/benches/generated/flex_basis_flex_shrink_column.rs @@ -3,16 +3,10 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -21,7 +15,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_flex_shrink_row.rs b/benches/generated/flex_basis_flex_shrink_row.rs index 0054681be..a8ef618dc 100644 --- a/benches/generated/flex_basis_flex_shrink_row.rs +++ b/benches/generated/flex_basis_flex_shrink_row.rs @@ -3,16 +3,10 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -20,7 +14,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_larger_than_content_column.rs b/benches/generated/flex_basis_larger_than_content_column.rs index 60dbcc38d..d2518830f 100644 --- a/benches/generated/flex_basis_larger_than_content_column.rs +++ b/benches/generated/flex_basis_larger_than_content_column.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -29,7 +25,7 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_larger_than_content_row.rs b/benches/generated/flex_basis_larger_than_content_row.rs index 53fc13d86..75f58a1b9 100644 --- a/benches/generated/flex_basis_larger_than_content_row.rs +++ b/benches/generated/flex_basis_larger_than_content_row.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,7 +24,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_overrides_main_size.rs b/benches/generated/flex_basis_overrides_main_size.rs index 4b63488b8..504855549 100644 --- a/benches/generated/flex_basis_overrides_main_size.rs +++ b/benches/generated/flex_basis_overrides_main_size.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -39,7 +30,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs index fc74e331e..de4b2dce5 100644 --- a/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs +++ b/benches/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,17 +23,13 @@ pub fn compute() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_basis_smaller_than_content_column.rs b/benches/generated/flex_basis_smaller_than_content_column.rs index 877effff7..b25f19f70 100644 --- a/benches/generated/flex_basis_smaller_than_content_column.rs +++ b/benches/generated/flex_basis_smaller_than_content_column.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -29,7 +25,7 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_smaller_than_content_row.rs b/benches/generated/flex_basis_smaller_than_content_row.rs index acbe83da6..1bc964a27 100644 --- a/benches/generated/flex_basis_smaller_than_content_row.rs +++ b/benches/generated/flex_basis_smaller_than_content_row.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,7 +24,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_smaller_than_main_dimen_column.rs b/benches/generated/flex_basis_smaller_than_main_dimen_column.rs index 69dd2246c..092b269c1 100644 --- a/benches/generated/flex_basis_smaller_than_main_dimen_column.rs +++ b/benches/generated/flex_basis_smaller_than_main_dimen_column.rs @@ -3,24 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_smaller_than_main_dimen_row.rs b/benches/generated/flex_basis_smaller_than_main_dimen_row.rs index b98d01c35..9eed6373c 100644 --- a/benches/generated/flex_basis_smaller_than_main_dimen_row.rs +++ b/benches/generated/flex_basis_smaller_than_main_dimen_row.rs @@ -3,23 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs index be29c6254..df3bd13bb 100644 --- a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,17 +23,13 @@ pub fn compute() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs index 02ab0b740..3297fe3d6 100644 --- a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,17 +23,13 @@ pub fn compute() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs index 8824cf95b..86359a187 100644 --- a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,17 +23,13 @@ pub fn compute() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( diff --git a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs index 1a7747fce..774ae93f1 100644 --- a/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/benches/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,17 +23,13 @@ pub fn compute() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_basis_unconstraint_column.rs b/benches/generated/flex_basis_unconstraint_column.rs index 41fc0c7cc..53c26b671 100644 --- a/benches/generated/flex_basis_unconstraint_column.rs +++ b/benches/generated/flex_basis_unconstraint_column.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/benches/generated/flex_basis_unconstraint_row.rs b/benches/generated/flex_basis_unconstraint_row.rs index f3f2ffa1b..a0d1d48ca 100644 --- a/benches/generated/flex_basis_unconstraint_row.rs +++ b/benches/generated/flex_basis_unconstraint_row.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/flex_direction_column.rs b/benches/generated/flex_direction_column.rs index 115e63c0d..35feaa913 100644 --- a/benches/generated/flex_direction_column.rs +++ b/benches/generated/flex_direction_column.rs @@ -3,31 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -36,7 +27,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_direction_column_no_height.rs b/benches/generated/flex_direction_column_no_height.rs index c75739194..9aedbb90e 100644 --- a/benches/generated/flex_direction_column_no_height.rs +++ b/benches/generated/flex_direction_column_no_height.rs @@ -3,37 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/flex_direction_column_reverse.rs b/benches/generated/flex_direction_column_reverse.rs index 3b626ad15..eb8139564 100644 --- a/benches/generated/flex_direction_column_reverse.rs +++ b/benches/generated/flex_direction_column_reverse.rs @@ -3,31 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -36,7 +27,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_direction_row.rs b/benches/generated/flex_direction_row.rs index 3c41844d6..225fd5d56 100644 --- a/benches/generated/flex_direction_row.rs +++ b/benches/generated/flex_direction_row.rs @@ -3,31 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -35,7 +26,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_direction_row_no_width.rs b/benches/generated/flex_direction_row_no_width.rs index 9411ad6f0..63d7500d3 100644 --- a/benches/generated/flex_direction_row_no_width.rs +++ b/benches/generated/flex_direction_row_no_width.rs @@ -3,36 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/flex_direction_row_reverse.rs b/benches/generated/flex_direction_row_reverse.rs index da474e792..4e78cbb2e 100644 --- a/benches/generated/flex_direction_row_reverse.rs +++ b/benches/generated/flex_direction_row_reverse.rs @@ -3,31 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -36,7 +27,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_child.rs b/benches/generated/flex_grow_child.rs index 11488ebd9..fb5f57294 100644 --- a/benches/generated/flex_grow_child.rs +++ b/benches/generated/flex_grow_child.rs @@ -3,15 +3,12 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/flex_grow_flex_basis_percent_min_max.rs b/benches/generated/flex_grow_flex_basis_percent_min_max.rs index 86c5ae916..691fb98ba 100644 --- a/benches/generated/flex_grow_flex_basis_percent_min_max.rs +++ b/benches/generated/flex_grow_flex_basis_percent_min_max.rs @@ -3,39 +3,32 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(0f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_height_maximized.rs b/benches/generated/flex_grow_height_maximized.rs index 9401edd4a..aa933842f 100644 --- a/benches/generated/flex_grow_height_maximized.rs +++ b/benches/generated/flex_grow_height_maximized.rs @@ -3,31 +3,25 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node00, node01], @@ -40,7 +34,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_in_at_most_container.rs b/benches/generated/flex_grow_in_at_most_container.rs index 34b9d2d2f..9647a8720 100644 --- a/benches/generated/flex_grow_in_at_most_container.rs +++ b/benches/generated/flex_grow_in_at_most_container.rs @@ -3,24 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_less_than_factor_one.rs b/benches/generated/flex_grow_less_than_factor_one.rs index c9e88d66a..7c469295a 100644 --- a/benches/generated/flex_grow_less_than_factor_one.rs +++ b/benches/generated/flex_grow_less_than_factor_one.rs @@ -3,29 +3,23 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0.2f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(40f32), - ..Default::default() - }, - &[], - ) - .unwrap(); - let node1 = taffy - .new_with_children(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }, &[]) - .unwrap(); - let node2 = taffy - .new_with_children(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }, &[]) + .new_leaf(taffy::style::Style { + flex_grow: 0.2f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(40f32), + ..Default::default() + }) .unwrap(); + let node1 = + taffy.new_leaf(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); + let node2 = + taffy.new_leaf(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_root_minimized.rs b/benches/generated/flex_grow_root_minimized.rs index c6e343858..d35ef8600 100644 --- a/benches/generated/flex_grow_root_minimized.rs +++ b/benches/generated/flex_grow_root_minimized.rs @@ -3,31 +3,25 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node00, node01], @@ -37,9 +31,9 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_grow_shrink_at_most.rs b/benches/generated/flex_grow_shrink_at_most.rs index a4f73236c..18b8af1dd 100644 --- a/benches/generated/flex_grow_shrink_at_most.rs +++ b/benches/generated/flex_grow_shrink_at_most.rs @@ -2,9 +2,8 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node00 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy .new_with_children( @@ -12,7 +11,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_to_min.rs b/benches/generated/flex_grow_to_min.rs index 7ba2d5ca2..1698e5e24 100644 --- a/benches/generated/flex_grow_to_min.rs +++ b/benches/generated/flex_grow_to_min.rs @@ -2,25 +2,21 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node0 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_within_constrained_max_column.rs b/benches/generated/flex_grow_within_constrained_max_column.rs index 2e23e9bf6..3eb85ae37 100644 --- a/benches/generated/flex_grow_within_constrained_max_column.rs +++ b/benches/generated/flex_grow_within_constrained_max_column.rs @@ -3,30 +3,24 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_within_constrained_max_row.rs b/benches/generated/flex_grow_within_constrained_max_row.rs index f23bcc39b..3e1f96900 100644 --- a/benches/generated/flex_grow_within_constrained_max_row.rs +++ b/benches/generated/flex_grow_within_constrained_max_row.rs @@ -3,29 +3,23 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -35,7 +29,7 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_grow_within_constrained_max_width.rs b/benches/generated/flex_grow_within_constrained_max_width.rs index a334d5984..9fab6e933 100644 --- a/benches/generated/flex_grow_within_constrained_max_width.rs +++ b/benches/generated/flex_grow_within_constrained_max_width.rs @@ -3,19 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Size::auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: auto() }, ..Default::default() }, &[node00], @@ -28,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_grow_within_constrained_min_column.rs b/benches/generated/flex_grow_within_constrained_min_column.rs index 2dff2e324..a38862426 100644 --- a/benches/generated/flex_grow_within_constrained_min_column.rs +++ b/benches/generated/flex_grow_within_constrained_min_column.rs @@ -2,21 +2,18 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_within_constrained_min_max_column.rs b/benches/generated/flex_grow_within_constrained_min_max_column.rs index 7dd1054d3..08f988706 100644 --- a/benches/generated/flex_grow_within_constrained_min_max_column.rs +++ b/benches/generated/flex_grow_within_constrained_min_max_column.rs @@ -2,20 +2,17 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_within_constrained_min_row.rs b/benches/generated/flex_grow_within_constrained_min_row.rs index 1b50b663f..3b8169ded 100644 --- a/benches/generated/flex_grow_within_constrained_min_row.rs +++ b/benches/generated/flex_grow_within_constrained_min_row.rs @@ -2,21 +2,18 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_grow_within_max_width.rs b/benches/generated/flex_grow_within_max_width.rs index 59399d195..20a3d1074 100644 --- a/benches/generated/flex_grow_within_max_width.rs +++ b/benches/generated/flex_grow_within_max_width.rs @@ -3,19 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00], @@ -28,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_root_ignored.rs b/benches/generated/flex_root_ignored.rs index aadf1ca75..b8b43f556 100644 --- a/benches/generated/flex_root_ignored.rs +++ b/benches/generated/flex_root_ignored.rs @@ -3,31 +3,25 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs b/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs index df405b196..e49e7aa2c 100644 --- a/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs +++ b/benches/generated/flex_shrink_by_outer_margin_with_max_size.rs @@ -3,28 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(100f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(100f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(80f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs index ed95a8a64..02d301997 100644 --- a/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs +++ b/benches/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -3,34 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -38,7 +30,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_shrink_flex_grow_row.rs b/benches/generated/flex_shrink_flex_grow_row.rs index d99350bbe..36a2c2357 100644 --- a/benches/generated/flex_shrink_flex_grow_row.rs +++ b/benches/generated/flex_shrink_flex_grow_row.rs @@ -3,34 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -38,7 +30,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_shrink_to_zero.rs b/benches/generated/flex_shrink_to_zero.rs index 2c8dd88ff..345616dc6 100644 --- a/benches/generated/flex_shrink_to_zero.rs +++ b/benches/generated/flex_shrink_to_zero.rs @@ -3,51 +3,39 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/flex_wrap_align_stretch_fits_one_row.rs b/benches/generated/flex_wrap_align_stretch_fits_one_row.rs index c193be688..a2d70026f 100644 --- a/benches/generated/flex_wrap_align_stretch_fits_one_row.rs +++ b/benches/generated/flex_wrap_align_stretch_fits_one_row.rs @@ -3,22 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(150f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs index f8e340e8a..e13fe9201 100644 --- a/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs +++ b/benches/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -3,32 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/flex_wrap_wrap_to_child_height.rs b/benches/generated/flex_wrap_wrap_to_child_height.rs index 5787b97a3..90fbdc41c 100644 --- a/benches/generated/flex_wrap_wrap_to_child_height.rs +++ b/benches/generated/flex_wrap_wrap_to_child_height.rs @@ -3,23 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node000], @@ -29,24 +25,20 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/benches/generated/gap_column_gap_child_margins.rs b/benches/generated/gap_column_gap_child_margins.rs index 04cad1d12..09a650d25 100644 --- a/benches/generated/gap_column_gap_child_margins.rs +++ b/benches/generated/gap_column_gap_child_margins.rs @@ -3,61 +3,54 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(2f32), - right: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(2f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(15f32), - right: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(15f32), + right: taffy::style::LengthPercentageAuto::Points(15f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_determines_parent_width.rs b/benches/generated/gap_column_gap_determines_parent_width.rs index 7f66a30d0..c36f9689d 100644 --- a/benches/generated/gap_column_gap_determines_parent_width.rs +++ b/benches/generated/gap_column_gap_determines_parent_width.rs @@ -3,37 +3,29 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_flexible.rs b/benches/generated/gap_column_gap_flexible.rs index 01b186144..e18337611 100644 --- a/benches/generated/gap_column_gap_flexible.rs +++ b/benches/generated/gap_column_gap_flexible.rs @@ -3,37 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,12 +32,10 @@ pub fn compute() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_flexible_undefined_parent.rs b/benches/generated/gap_column_gap_flexible_undefined_parent.rs index 0cee6a76b..2512a6b6d 100644 --- a/benches/generated/gap_column_gap_flexible_undefined_parent.rs +++ b/benches/generated/gap_column_gap_flexible_undefined_parent.rs @@ -3,37 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,9 +32,8 @@ pub fn compute() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_inflexible.rs b/benches/generated/gap_column_gap_inflexible.rs index 178dfc34a..1828e19cf 100644 --- a/benches/generated/gap_column_gap_inflexible.rs +++ b/benches/generated/gap_column_gap_inflexible.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_inflexible_undefined_parent.rs b/benches/generated/gap_column_gap_inflexible_undefined_parent.rs index 818e8d01c..4ae9524d5 100644 --- a/benches/generated/gap_column_gap_inflexible_undefined_parent.rs +++ b/benches/generated/gap_column_gap_inflexible_undefined_parent.rs @@ -3,37 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_justify_center.rs b/benches/generated/gap_column_gap_justify_center.rs index 0539c3d17..54858ecd5 100644 --- a/benches/generated/gap_column_gap_justify_center.rs +++ b/benches/generated/gap_column_gap_justify_center.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::Center), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_justify_flex_end.rs b/benches/generated/gap_column_gap_justify_flex_end.rs index 7771d4545..2ed7a8958 100644 --- a/benches/generated/gap_column_gap_justify_flex_end.rs +++ b/benches/generated/gap_column_gap_justify_flex_end.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::End), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_justify_flex_start.rs b/benches/generated/gap_column_gap_justify_flex_start.rs index 96bfa87cc..ade4b61ab 100644 --- a/benches/generated/gap_column_gap_justify_flex_start.rs +++ b/benches/generated/gap_column_gap_justify_flex_start.rs @@ -3,40 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::Start), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_justify_space_around.rs b/benches/generated/gap_column_gap_justify_space_around.rs index e9187b73a..10cb04f26 100644 --- a/benches/generated/gap_column_gap_justify_space_around.rs +++ b/benches/generated/gap_column_gap_justify_space_around.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceAround, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_justify_space_between.rs b/benches/generated/gap_column_gap_justify_space_between.rs index bfc398ee0..cec0588d1 100644 --- a/benches/generated/gap_column_gap_justify_space_between.rs +++ b/benches/generated/gap_column_gap_justify_space_between.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceBetween, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_justify_space_evenly.rs b/benches/generated/gap_column_gap_justify_space_evenly.rs index 44307938a..5500d43c9 100644 --- a/benches/generated/gap_column_gap_justify_space_evenly.rs +++ b/benches/generated/gap_column_gap_justify_space_evenly.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceEvenly, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_mixed_flexible.rs b/benches/generated/gap_column_gap_mixed_flexible.rs index 432b1008e..b6b68e997 100644 --- a/benches/generated/gap_column_gap_mixed_flexible.rs +++ b/benches/generated/gap_column_gap_mixed_flexible.rs @@ -3,42 +3,32 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs b/benches/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs index bd04e7b98..213617351 100644 --- a/benches/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs +++ b/benches/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs @@ -3,50 +3,38 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_percentage_cyclic_shrinkable.rs b/benches/generated/gap_column_gap_percentage_cyclic_shrinkable.rs index 9902ef769..735242c2f 100644 --- a/benches/generated/gap_column_gap_percentage_cyclic_shrinkable.rs +++ b/benches/generated/gap_column_gap_percentage_cyclic_shrinkable.rs @@ -3,48 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs b/benches/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs index f6351c91e..f109e93c7 100644 --- a/benches/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs +++ b/benches/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs @@ -3,51 +3,39 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_column_gap_percentage_flexible.rs b/benches/generated/gap_column_gap_percentage_flexible.rs index 23af8ac22..d043c82ad 100644 --- a/benches/generated/gap_column_gap_percentage_flexible.rs +++ b/benches/generated/gap_column_gap_percentage_flexible.rs @@ -3,37 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,12 +32,10 @@ pub fn compute() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.1f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_percentage_inflexible.rs b/benches/generated/gap_column_gap_percentage_inflexible.rs index 60a7e3d69..fcef9ceef 100644 --- a/benches/generated/gap_column_gap_percentage_inflexible.rs +++ b/benches/generated/gap_column_gap_percentage_inflexible.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_center.rs b/benches/generated/gap_column_gap_wrap_align_center.rs index dc2a53c2a..36af202b5 100644 --- a/benches/generated/gap_column_gap_wrap_align_center.rs +++ b/benches/generated/gap_column_gap_wrap_align_center.rs @@ -3,97 +3,71 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::Center, + align_content: Some(taffy::style::AlignContent::Center), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_flex_end.rs b/benches/generated/gap_column_gap_wrap_align_flex_end.rs index 3fc6b091d..ac0599277 100644 --- a/benches/generated/gap_column_gap_wrap_align_flex_end.rs +++ b/benches/generated/gap_column_gap_wrap_align_flex_end.rs @@ -3,97 +3,71 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::FlexEnd, + align_content: Some(taffy::style::AlignContent::End), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_flex_start.rs b/benches/generated/gap_column_gap_wrap_align_flex_start.rs index 0332525b4..e186810ba 100644 --- a/benches/generated/gap_column_gap_wrap_align_flex_start.rs +++ b/benches/generated/gap_column_gap_wrap_align_flex_start.rs @@ -3,97 +3,71 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::FlexStart, + align_content: Some(taffy::style::AlignContent::Start), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_space_around.rs b/benches/generated/gap_column_gap_wrap_align_space_around.rs index 3e357b555..2b420544f 100644 --- a/benches/generated/gap_column_gap_wrap_align_space_around.rs +++ b/benches/generated/gap_column_gap_wrap_align_space_around.rs @@ -3,97 +3,71 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_space_between.rs b/benches/generated/gap_column_gap_wrap_align_space_between.rs index 79f809b89..466ad7d00 100644 --- a/benches/generated/gap_column_gap_wrap_align_space_between.rs +++ b/benches/generated/gap_column_gap_wrap_align_space_between.rs @@ -3,97 +3,71 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_gap_wrap_align_stretch.rs b/benches/generated/gap_column_gap_wrap_align_stretch.rs index fb9740739..ea5cb7f6d 100644 --- a/benches/generated/gap_column_gap_wrap_align_stretch.rs +++ b/benches/generated/gap_column_gap_wrap_align_stretch.rs @@ -3,64 +3,49 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(5f32), ..Size::zero() }, + align_content: Some(taffy::style::AlignContent::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(5f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: taffy::style::Dimension::Points(300f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_column_row_gap_wrapping.rs b/benches/generated/gap_column_row_gap_wrapping.rs index 13dee628a..62845199f 100644 --- a/benches/generated/gap_column_row_gap_wrapping.rs +++ b/benches/generated/gap_column_row_gap_wrapping.rs @@ -3,121 +3,85 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -126,9 +90,8 @@ pub fn compute() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4, node5, node6, node7, node8], diff --git a/benches/generated/gap_percentage_row_gap_wrapping.rs b/benches/generated/gap_percentage_row_gap_wrapping.rs index 30d77ca54..985860af1 100644 --- a/benches/generated/gap_percentage_row_gap_wrapping.rs +++ b/benches/generated/gap_percentage_row_gap_wrapping.rs @@ -3,121 +3,85 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -126,9 +90,8 @@ pub fn compute() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Percent(0.1f32), - ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4, node5, node6, node7, node8], diff --git a/benches/generated/gap_row_gap_align_items_end.rs b/benches/generated/gap_row_gap_align_items_end.rs index 7587b9eb8..99fbe129a 100644 --- a/benches/generated/gap_row_gap_align_items_end.rs +++ b/benches/generated/gap_row_gap_align_items_end.rs @@ -3,73 +3,53 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_row_gap_align_items_stretch.rs b/benches/generated/gap_row_gap_align_items_stretch.rs index 9916d4dec..71904e814 100644 --- a/benches/generated/gap_row_gap_align_items_stretch.rs +++ b/benches/generated/gap_row_gap_align_items_stretch.rs @@ -3,72 +3,54 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Stretch), + align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_row_gap_column_child_margins.rs b/benches/generated/gap_row_gap_column_child_margins.rs index ca89e0290..30801fe38 100644 --- a/benches/generated/gap_row_gap_column_child_margins.rs +++ b/benches/generated/gap_row_gap_column_child_margins.rs @@ -3,62 +3,55 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(2f32), - bottom: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - bottom: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/gap_row_gap_determines_parent_height.rs b/benches/generated/gap_row_gap_determines_parent_height.rs index 10eb4fd03..c84a16d07 100644 --- a/benches/generated/gap_row_gap_determines_parent_height.rs +++ b/benches/generated/gap_row_gap_determines_parent_height.rs @@ -3,38 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(30f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(30f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/gap_row_gap_row_wrap_child_margins.rs b/benches/generated/gap_row_gap_row_wrap_child_margins.rs index c2fd6ffc8..9a2804abf 100644 --- a/benches/generated/gap_row_gap_row_wrap_child_margins.rs +++ b/benches/generated/gap_row_gap_row_wrap_child_margins.rs @@ -3,56 +3,49 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(2f32), - bottom: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - bottom: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/grid_absolute_align_self_sized_all.rs b/benches/generated/grid_absolute_align_self_sized_all.rs new file mode 100644 index 000000000..c5be4bfd8 --- /dev/null +++ b/benches/generated/grid_absolute_align_self_sized_all.rs @@ -0,0 +1,109 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_column_end.rs b/benches/generated/grid_absolute_column_end.rs new file mode 100644 index 000000000..67c9ee37c --- /dev/null +++ b/benches/generated/grid_absolute_column_end.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Auto, + end: taffy::style::GridPlacement::Line(1i16), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_column_start.rs b/benches/generated/grid_absolute_column_start.rs new file mode 100644 index 000000000..f842a051b --- /dev/null +++ b/benches/generated/grid_absolute_column_start.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_bottom_left.rs b/benches/generated/grid_absolute_container_bottom_left.rs new file mode 100644 index 000000000..7c4672e3e --- /dev/null +++ b/benches/generated/grid_absolute_container_bottom_left.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_bottom_left_margin.rs b/benches/generated/grid_absolute_container_bottom_left_margin.rs new file mode 100644 index 000000000..1630749f5 --- /dev/null +++ b/benches/generated/grid_absolute_container_bottom_left_margin.rs @@ -0,0 +1,53 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_left_overrides_right.rs b/benches/generated/grid_absolute_container_left_overrides_right.rs new file mode 100644 index 000000000..3eda452ed --- /dev/null +++ b/benches/generated/grid_absolute_container_left_overrides_right.rs @@ -0,0 +1,44 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_left_right.rs b/benches/generated/grid_absolute_container_left_right.rs new file mode 100644 index 000000000..03c6a9f0b --- /dev/null +++ b/benches/generated/grid_absolute_container_left_right.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_left_right_margin.rs b/benches/generated/grid_absolute_container_left_right_margin.rs new file mode 100644 index 000000000..03c6a9f0b --- /dev/null +++ b/benches/generated/grid_absolute_container_left_right_margin.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_negative_position.rs b/benches/generated/grid_absolute_container_negative_position.rs new file mode 100644 index 000000000..2db22f678 --- /dev/null +++ b/benches/generated/grid_absolute_container_negative_position.rs @@ -0,0 +1,54 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(-15f32), + top: taffy::style::LengthPercentageAuto::Points(-5f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(-25f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_negative_position_margin.rs b/benches/generated/grid_absolute_container_negative_position_margin.rs new file mode 100644 index 000000000..2db22f678 --- /dev/null +++ b/benches/generated/grid_absolute_container_negative_position_margin.rs @@ -0,0 +1,54 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(-15f32), + top: taffy::style::LengthPercentageAuto::Points(-5f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(-25f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_top_bottom.rs b/benches/generated/grid_absolute_container_top_bottom.rs new file mode 100644 index 000000000..c80171396 --- /dev/null +++ b/benches/generated/grid_absolute_container_top_bottom.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_top_bottom_margin.rs b/benches/generated/grid_absolute_container_top_bottom_margin.rs new file mode 100644 index 000000000..c80171396 --- /dev/null +++ b/benches/generated/grid_absolute_container_top_bottom_margin.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_top_right.rs b/benches/generated/grid_absolute_container_top_right.rs new file mode 100644 index 000000000..cea1e206c --- /dev/null +++ b/benches/generated/grid_absolute_container_top_right.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_container_top_right_margin.rs b/benches/generated/grid_absolute_container_top_right_margin.rs new file mode 100644 index 000000000..cea1e206c --- /dev/null +++ b/benches/generated/grid_absolute_container_top_right_margin.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_justify_self_sized_all.rs b/benches/generated/grid_absolute_justify_self_sized_all.rs new file mode 100644 index 000000000..c71003ec2 --- /dev/null +++ b/benches/generated/grid_absolute_justify_self_sized_all.rs @@ -0,0 +1,109 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_row_end.rs b/benches/generated/grid_absolute_row_end.rs new file mode 100644 index 000000000..b809e5461 --- /dev/null +++ b/benches/generated/grid_absolute_row_end.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Auto, + end: taffy::style::GridPlacement::Line(1i16), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_row_start.rs b/benches/generated/grid_absolute_row_start.rs new file mode 100644 index 000000000..66ceeea1f --- /dev/null +++ b/benches/generated/grid_absolute_row_start.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_top_overrides_bottom.rs b/benches/generated/grid_absolute_top_overrides_bottom.rs new file mode 100644 index 000000000..19fd778dd --- /dev/null +++ b/benches/generated/grid_absolute_top_overrides_bottom.rs @@ -0,0 +1,44 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_with_padding.rs b/benches/generated/grid_absolute_with_padding.rs new file mode 100644 index 000000000..878192ee9 --- /dev/null +++ b/benches/generated/grid_absolute_with_padding.rs @@ -0,0 +1,54 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_absolute_with_padding_and_margin.rs b/benches/generated/grid_absolute_with_padding_and_margin.rs new file mode 100644 index 000000000..878192ee9 --- /dev/null +++ b/benches/generated/grid_absolute_with_padding_and_margin.rs @@ -0,0 +1,54 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_center.rs b/benches/generated/grid_align_content_center.rs new file mode 100644 index 000000000..2791e45c2 --- /dev/null +++ b/benches/generated/grid_align_content_center.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_end.rs b/benches/generated/grid_align_content_end.rs new file mode 100644 index 000000000..75323e523 --- /dev/null +++ b/benches/generated/grid_align_content_end.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_end_with_padding_border.rs b/benches/generated/grid_align_content_end_with_padding_border.rs new file mode 100644 index 000000000..ebc4ec438 --- /dev/null +++ b/benches/generated/grid_align_content_end_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_around.rs b/benches/generated/grid_align_content_space_around.rs new file mode 100644 index 000000000..019d57c21 --- /dev/null +++ b/benches/generated/grid_align_content_space_around.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_around_with_padding_border.rs b/benches/generated/grid_align_content_space_around_with_padding_border.rs new file mode 100644 index 000000000..bcc75aa1b --- /dev/null +++ b/benches/generated/grid_align_content_space_around_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_between.rs b/benches/generated/grid_align_content_space_between.rs new file mode 100644 index 000000000..29576b5f8 --- /dev/null +++ b/benches/generated/grid_align_content_space_between.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_between_with_padding_border.rs b/benches/generated/grid_align_content_space_between_with_padding_border.rs new file mode 100644 index 000000000..1f5d8cf3b --- /dev/null +++ b/benches/generated/grid_align_content_space_between_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_evenly.rs b/benches/generated/grid_align_content_space_evenly.rs new file mode 100644 index 000000000..c11c604ad --- /dev/null +++ b/benches/generated/grid_align_content_space_evenly.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_space_evenly_with_padding_border.rs b/benches/generated/grid_align_content_space_evenly_with_padding_border.rs new file mode 100644 index 000000000..843fb6754 --- /dev/null +++ b/benches/generated/grid_align_content_space_evenly_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_start.rs b/benches/generated/grid_align_content_start.rs new file mode 100644 index 000000000..99d6f7ca0 --- /dev/null +++ b/benches/generated/grid_align_content_start.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_content_start_with_padding_border.rs b/benches/generated/grid_align_content_start_with_padding_border.rs new file mode 100644 index 000000000..370c42c6f --- /dev/null +++ b/benches/generated/grid_align_content_start_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_items_sized_center.rs b/benches/generated/grid_align_items_sized_center.rs new file mode 100644 index 000000000..67f4c5d78 --- /dev/null +++ b/benches/generated/grid_align_items_sized_center.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_items_sized_end.rs b/benches/generated/grid_align_items_sized_end.rs new file mode 100644 index 000000000..6ec0a4abc --- /dev/null +++ b/benches/generated/grid_align_items_sized_end.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_items_sized_start.rs b/benches/generated/grid_align_items_sized_start.rs new file mode 100644 index 000000000..16d9f0588 --- /dev/null +++ b/benches/generated/grid_align_items_sized_start.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_items_sized_stretch.rs b/benches/generated/grid_align_items_sized_stretch.rs new file mode 100644 index 000000000..349562e6a --- /dev/null +++ b/benches/generated/grid_align_items_sized_stretch.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Stretch), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_align_self_sized_all.rs b/benches/generated/grid_align_self_sized_all.rs new file mode 100644 index 000000000..839511e5c --- /dev/null +++ b/benches/generated/grid_align_self_sized_all.rs @@ -0,0 +1,101 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_columns_fixed_width.rs b/benches/generated/grid_auto_columns_fixed_width.rs new file mode 100644 index 000000000..eba65e1e8 --- /dev/null +++ b/benches/generated/grid_auto_columns_fixed_width.rs @@ -0,0 +1,40 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node14 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node15 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), auto(), points(40f32), auto()], + grid_template_columns: vec![points(40f32), auto(), points(40f32), auto()], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, + ], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_fill_fixed_size.rs b/benches/generated/grid_auto_fill_fixed_size.rs new file mode 100644 index 000000000..c472eaeeb --- /dev/null +++ b/benches/generated/grid_auto_fill_fixed_size.rs @@ -0,0 +1,30 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), repeat(GridTrackRepetition::AutoFill, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_fill_with_empty_auto_track.rs b/benches/generated/grid_auto_fill_with_empty_auto_track.rs new file mode 100644 index 000000000..5d868c4e6 --- /dev/null +++ b/benches/generated/grid_auto_fill_with_empty_auto_track.rs @@ -0,0 +1,24 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFill, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_fit_with_empty_auto_track.rs b/benches/generated/grid_auto_fit_with_empty_auto_track.rs new file mode 100644 index 000000000..c01cf8562 --- /dev/null +++ b/benches/generated/grid_auto_fit_with_empty_auto_track.rs @@ -0,0 +1,24 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFit, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_single_item.rs b/benches/generated/grid_auto_single_item.rs new file mode 100644 index 000000000..d0e2321a1 --- /dev/null +++ b/benches/generated/grid_auto_single_item.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_single_item_fixed_width.rs b/benches/generated/grid_auto_single_item_fixed_width.rs new file mode 100644 index 000000000..3b5e0250a --- /dev/null +++ b/benches/generated/grid_auto_single_item_fixed_width.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_auto_single_item_fixed_width_with_definite_width.rs b/benches/generated/grid_auto_single_item_fixed_width_with_definite_width.rs new file mode 100644 index 000000000..282fef9da --- /dev/null +++ b/benches/generated/grid_auto_single_item_fixed_width_with_definite_width.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_basic.rs b/benches/generated/grid_basic.rs new file mode 100644 index 000000000..0b57432c3 --- /dev/null +++ b/benches/generated/grid_basic.rs @@ -0,0 +1,30 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_basic_implicit_tracks.rs b/benches/generated/grid_basic_implicit_tracks.rs new file mode 100644 index 000000000..86e6473e8 --- /dev/null +++ b/benches/generated/grid_basic_implicit_tracks.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(35f32), + height: taffy::style::Dimension::Points(35f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32)], + grid_template_columns: vec![points(40f32)], + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_basic_with_overflow.rs b/benches/generated/grid_basic_with_overflow.rs new file mode 100644 index 000000000..25484c2a4 --- /dev/null +++ b/benches/generated/grid_basic_with_overflow.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_basic_with_padding.rs b/benches/generated/grid_basic_with_padding.rs new file mode 100644 index 000000000..724a95ed2 --- /dev/null +++ b/benches/generated/grid_basic_with_padding.rs @@ -0,0 +1,32 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fit_content_points_argument.rs b/benches/generated/grid_fit_content_points_argument.rs new file mode 100644 index 000000000..82f60f1cd --- /dev/null +++ b/benches/generated/grid_fit_content_points_argument.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fit_content_points_max_content.rs b/benches/generated/grid_fit_content_points_max_content.rs new file mode 100644 index 000000000..157bc5db1 --- /dev/null +++ b/benches/generated/grid_fit_content_points_max_content.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fit_content_points_min_content.rs b/benches/generated/grid_fit_content_points_min_content.rs new file mode 100644 index 000000000..0be082768 --- /dev/null +++ b/benches/generated/grid_fit_content_points_min_content.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fr_auto_no_sized_items.rs b/benches/generated/grid_fr_auto_no_sized_items.rs new file mode 100644 index 000000000..674c1b9b8 --- /dev/null +++ b/benches/generated/grid_fr_auto_no_sized_items.rs @@ -0,0 +1,30 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Auto, + height: taffy::style::Dimension::Auto, + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fr_auto_single_item.rs b/benches/generated/grid_fr_auto_single_item.rs new file mode 100644 index 000000000..b38466906 --- /dev/null +++ b/benches/generated/grid_fr_auto_single_item.rs @@ -0,0 +1,35 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Auto, + height: taffy::style::Dimension::Auto, + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fr_fixed_size_no_content.rs b/benches/generated/grid_fr_fixed_size_no_content.rs new file mode 100644 index 000000000..fdeb5703a --- /dev/null +++ b/benches/generated/grid_fr_fixed_size_no_content.rs @@ -0,0 +1,30 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_fr_fixed_size_single_item.rs b/benches/generated/grid_fr_fixed_size_single_item.rs new file mode 100644 index 000000000..02dcd46b9 --- /dev/null +++ b/benches/generated/grid_fr_fixed_size_single_item.rs @@ -0,0 +1,35 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_gap.rs b/benches/generated/grid_gap.rs new file mode 100644 index 000000000..ec3fa0393 --- /dev/null +++ b/benches/generated/grid_gap.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Points(40f32), + height: taffy::style::LengthPercentage::Points(40f32), + }, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_hidden.rs b/benches/generated/grid_hidden.rs new file mode 100644 index 000000000..c25c6e275 --- /dev/null +++ b/benches/generated/grid_hidden.rs @@ -0,0 +1,33 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_center.rs b/benches/generated/grid_justify_content_center.rs new file mode 100644 index 000000000..0f0d2a434 --- /dev/null +++ b/benches/generated/grid_justify_content_center.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_center_with_padding_border.rs b/benches/generated/grid_justify_content_center_with_padding_border.rs new file mode 100644 index 000000000..44c9666b5 --- /dev/null +++ b/benches/generated/grid_justify_content_center_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_end.rs b/benches/generated/grid_justify_content_end.rs new file mode 100644 index 000000000..16b7a6677 --- /dev/null +++ b/benches/generated/grid_justify_content_end.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_end_with_padding_border.rs b/benches/generated/grid_justify_content_end_with_padding_border.rs new file mode 100644 index 000000000..743cf478d --- /dev/null +++ b/benches/generated/grid_justify_content_end_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_around.rs b/benches/generated/grid_justify_content_space_around.rs new file mode 100644 index 000000000..1ee28f902 --- /dev/null +++ b/benches/generated/grid_justify_content_space_around.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_around_with_padding_border.rs b/benches/generated/grid_justify_content_space_around_with_padding_border.rs new file mode 100644 index 000000000..449055952 --- /dev/null +++ b/benches/generated/grid_justify_content_space_around_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_between.rs b/benches/generated/grid_justify_content_space_between.rs new file mode 100644 index 000000000..f21cd0e93 --- /dev/null +++ b/benches/generated/grid_justify_content_space_between.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_between_with_padding_border.rs b/benches/generated/grid_justify_content_space_between_with_padding_border.rs new file mode 100644 index 000000000..1f5f66776 --- /dev/null +++ b/benches/generated/grid_justify_content_space_between_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_evenly.rs b/benches/generated/grid_justify_content_space_evenly.rs new file mode 100644 index 000000000..a6813640d --- /dev/null +++ b/benches/generated/grid_justify_content_space_evenly.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_space_evenly_with_padding_border.rs b/benches/generated/grid_justify_content_space_evenly_with_padding_border.rs new file mode 100644 index 000000000..79679dd3d --- /dev/null +++ b/benches/generated/grid_justify_content_space_evenly_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_start.rs b/benches/generated/grid_justify_content_start.rs new file mode 100644 index 000000000..9d859133e --- /dev/null +++ b/benches/generated/grid_justify_content_start.rs @@ -0,0 +1,31 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_content_start_with_padding_border.rs b/benches/generated/grid_justify_content_start_with_padding_border.rs new file mode 100644 index 000000000..a18d3bfce --- /dev/null +++ b/benches/generated/grid_justify_content_start_with_padding_border.rs @@ -0,0 +1,43 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_items_sized_center.rs b/benches/generated/grid_justify_items_sized_center.rs new file mode 100644 index 000000000..1fa28e5f6 --- /dev/null +++ b/benches/generated/grid_justify_items_sized_center.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_items_sized_end.rs b/benches/generated/grid_justify_items_sized_end.rs new file mode 100644 index 000000000..836b4ca2b --- /dev/null +++ b/benches/generated/grid_justify_items_sized_end.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_items_sized_start.rs b/benches/generated/grid_justify_items_sized_start.rs new file mode 100644 index 000000000..4b6ee18f5 --- /dev/null +++ b/benches/generated/grid_justify_items_sized_start.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_items_sized_stretch.rs b/benches/generated/grid_justify_items_sized_stretch.rs new file mode 100644 index 000000000..6a8b3feaa --- /dev/null +++ b/benches/generated/grid_justify_items_sized_stretch.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Stretch), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_justify_self_sized_all.rs b/benches/generated/grid_justify_self_sized_all.rs new file mode 100644 index 000000000..a74954b3d --- /dev/null +++ b/benches/generated/grid_justify_self_sized_all.rs @@ -0,0 +1,101 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_auto_margins.rs b/benches/generated/grid_margins_auto_margins.rs new file mode 100644 index 000000000..edd881624 --- /dev/null +++ b/benches/generated/grid_margins_auto_margins.rs @@ -0,0 +1,72 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_auto_margins_override_stretch.rs b/benches/generated/grid_margins_auto_margins_override_stretch.rs new file mode 100644 index 000000000..27d86be67 --- /dev/null +++ b/benches/generated/grid_margins_auto_margins_override_stretch.rs @@ -0,0 +1,50 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_fixed_center.rs b/benches/generated/grid_margins_fixed_center.rs new file mode 100644 index 000000000..0de5a2967 --- /dev/null +++ b/benches/generated/grid_margins_fixed_center.rs @@ -0,0 +1,45 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(8f32), + right: taffy::style::LengthPercentageAuto::Points(4f32), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(6f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_fixed_end.rs b/benches/generated/grid_margins_fixed_end.rs new file mode 100644 index 000000000..c119fa8f1 --- /dev/null +++ b/benches/generated/grid_margins_fixed_end.rs @@ -0,0 +1,45 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_fixed_start.rs b/benches/generated/grid_margins_fixed_start.rs new file mode 100644 index 000000000..8840bdb63 --- /dev/null +++ b/benches/generated/grid_margins_fixed_start.rs @@ -0,0 +1,45 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_fixed_stretch.rs b/benches/generated/grid_margins_fixed_stretch.rs new file mode 100644 index 000000000..012ad7a2d --- /dev/null +++ b/benches/generated/grid_margins_fixed_stretch.rs @@ -0,0 +1,45 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_percent_center.rs b/benches/generated/grid_margins_percent_center.rs new file mode 100644 index 000000000..124cc6786 --- /dev/null +++ b/benches/generated/grid_margins_percent_center.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_percent_end.rs b/benches/generated/grid_margins_percent_end.rs new file mode 100644 index 000000000..910222c3e --- /dev/null +++ b/benches/generated/grid_margins_percent_end.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_percent_start.rs b/benches/generated/grid_margins_percent_start.rs new file mode 100644 index 000000000..dc7ae0a2c --- /dev/null +++ b/benches/generated/grid_margins_percent_start.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_margins_percent_stretch.rs b/benches/generated/grid_margins_percent_stretch.rs new file mode 100644 index 000000000..bd8657553 --- /dev/null +++ b/benches/generated/grid_margins_percent_stretch.rs @@ -0,0 +1,39 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_max_content_maximum_single_item.rs b/benches/generated/grid_max_content_maximum_single_item.rs new file mode 100644 index 000000000..e2c157228 --- /dev/null +++ b/benches/generated/grid_max_content_maximum_single_item.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(0f32), max_content()), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_max_content_single_item.rs b/benches/generated/grid_max_content_single_item.rs new file mode 100644 index 000000000..66a376a4e --- /dev/null +++ b/benches/generated/grid_max_content_single_item.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_max_content_single_item_margin_auto.rs b/benches/generated/grid_max_content_single_item_margin_auto.rs new file mode 100644 index 000000000..2cfb28972 --- /dev/null +++ b/benches/generated/grid_max_content_single_item_margin_auto.rs @@ -0,0 +1,42 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_max_content_single_item_margin_fixed.rs b/benches/generated/grid_max_content_single_item_margin_fixed.rs new file mode 100644 index 000000000..4ee074d4b --- /dev/null +++ b/benches/generated/grid_max_content_single_item_margin_fixed.rs @@ -0,0 +1,42 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_max_content_single_item_margin_percent.rs b/benches/generated/grid_max_content_single_item_margin_percent.rs new file mode 100644 index 000000000..7267cb88f --- /dev/null +++ b/benches/generated/grid_max_content_single_item_margin_percent.rs @@ -0,0 +1,42 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_flex_single_item.rs b/benches/generated/grid_min_content_flex_single_item.rs new file mode 100644 index 000000000..39d1a6339 --- /dev/null +++ b/benches/generated/grid_min_content_flex_single_item.rs @@ -0,0 +1,44 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_flex_single_item_margin_auto.rs b/benches/generated/grid_min_content_flex_single_item_margin_auto.rs new file mode 100644 index 000000000..0245c6745 --- /dev/null +++ b/benches/generated/grid_min_content_flex_single_item_margin_auto.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs b/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs new file mode 100644 index 000000000..7f0b542ac --- /dev/null +++ b/benches/generated/grid_min_content_flex_single_item_margin_fixed.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_flex_single_item_margin_percent.rs b/benches/generated/grid_min_content_flex_single_item_margin_percent.rs new file mode 100644 index 000000000..cc9b038f7 --- /dev/null +++ b/benches/generated/grid_min_content_flex_single_item_margin_percent.rs @@ -0,0 +1,56 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_maximum_single_item.rs b/benches/generated/grid_min_content_maximum_single_item.rs new file mode 100644 index 000000000..7aaf5742d --- /dev/null +++ b/benches/generated/grid_min_content_maximum_single_item.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(0f32), min_content()), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_content_single_item.rs b/benches/generated/grid_min_content_single_item.rs new file mode 100644 index 000000000..fd3734a0c --- /dev/null +++ b/benches/generated/grid_min_content_single_item.rs @@ -0,0 +1,34 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_max_column_auto.rs b/benches/generated/grid_min_max_column_auto.rs new file mode 100644 index 000000000..75617468c --- /dev/null +++ b/benches/generated/grid_min_max_column_auto.rs @@ -0,0 +1,26 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_max_column_fixed_width_above_range.rs b/benches/generated/grid_min_max_column_fixed_width_above_range.rs new file mode 100644 index 000000000..37752a176 --- /dev/null +++ b/benches/generated/grid_min_max_column_fixed_width_above_range.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(140f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_max_column_fixed_width_below_range.rs b/benches/generated/grid_min_max_column_fixed_width_below_range.rs new file mode 100644 index 000000000..bbde5550d --- /dev/null +++ b/benches/generated/grid_min_max_column_fixed_width_below_range.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(90f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_min_max_column_fixed_width_within_range.rs b/benches/generated/grid_min_max_column_fixed_width_within_range.rs new file mode 100644 index 000000000..4d9b5c99d --- /dev/null +++ b/benches/generated/grid_min_max_column_fixed_width_within_range.rs @@ -0,0 +1,27 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_out_of_order_items.rs b/benches/generated/grid_out_of_order_items.rs new file mode 100644 index 000000000..cbb487bfc --- /dev/null +++ b/benches/generated/grid_out_of_order_items.rs @@ -0,0 +1,71 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(35f32), + height: taffy::style::Dimension::Points(35f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + grid_auto_flow: taffy::style::GridAutoFlow::RowDense, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/grid_size_child_fixed_tracks.rs b/benches/generated/grid_size_child_fixed_tracks.rs new file mode 100644 index 000000000..f6d265efb --- /dev/null +++ b/benches/generated/grid_size_child_fixed_tracks.rs @@ -0,0 +1,88 @@ +pub fn compute() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHH\u{200b}HHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node3 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), height: auto() }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); +} diff --git a/benches/generated/justify_content_column_center.rs b/benches/generated/justify_content_column_center.rs index dd4d4a7a5..676e8e6b7 100644 --- a/benches/generated/justify_content_column_center.rs +++ b/benches/generated/justify_content_column_center.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_column_flex_end.rs b/benches/generated/justify_content_column_flex_end.rs index f7bf0b1f6..77af338d6 100644 --- a/benches/generated/justify_content_column_flex_end.rs +++ b/benches/generated/justify_content_column_flex_end.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_column_flex_start.rs b/benches/generated/justify_content_column_flex_start.rs index 115e63c0d..e331790b2 100644 --- a/benches/generated/justify_content_column_flex_start.rs +++ b/benches/generated/justify_content_column_flex_start.rs @@ -3,40 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_column_min_height_and_margin_bottom.rs b/benches/generated/justify_content_column_min_height_and_margin_bottom.rs index b96f0f6ad..80f0b9073 100644 --- a/benches/generated/justify_content_column_min_height_and_margin_bottom.rs +++ b/benches/generated/justify_content_column_min_height_and_margin_bottom.rs @@ -3,28 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/justify_content_column_min_height_and_margin_top.rs b/benches/generated/justify_content_column_min_height_and_margin_top.rs index cbcb384e9..35d8e3beb 100644 --- a/benches/generated/justify_content_column_min_height_and_margin_top.rs +++ b/benches/generated/justify_content_column_min_height_and_margin_top.rs @@ -3,28 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/justify_content_column_space_around.rs b/benches/generated/justify_content_column_space_around.rs index 4aa425250..3bf9cd841 100644 --- a/benches/generated/justify_content_column_space_around.rs +++ b/benches/generated/justify_content_column_space_around.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceAround, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_column_space_between.rs b/benches/generated/justify_content_column_space_between.rs index 90ad834c6..75df97b00 100644 --- a/benches/generated/justify_content_column_space_between.rs +++ b/benches/generated/justify_content_column_space_between.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceBetween, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_column_space_evenly.rs b/benches/generated/justify_content_column_space_evenly.rs index 5edc9c866..afd260571 100644 --- a/benches/generated/justify_content_column_space_evenly.rs +++ b/benches/generated/justify_content_column_space_evenly.rs @@ -3,41 +3,31 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceEvenly, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_min_max.rs b/benches/generated/justify_content_min_max.rs index 597b09111..e97392252 100644 --- a/benches/generated/justify_content_min_max.rs +++ b/benches/generated/justify_content_min_max.rs @@ -3,26 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, ..Default::default() }, &[node0], diff --git a/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs index 05323da84..667e7fee2 100644 --- a/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs +++ b/benches/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -3,42 +3,46 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(300f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(100f32), right: taffy::style::LengthPercentage::Points(100f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, &[node000], ) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(1000f32), height: taffy::style::Dimension::Points(1584f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs index 7da926ae4..07cdef966 100644 --- a/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs +++ b/benches/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -3,42 +3,46 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(199f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(199f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(100f32), right: taffy::style::LengthPercentage::Points(100f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, &[node000], ) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(1080f32), height: taffy::style::Dimension::Points(1584f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_overflow_min_max.rs b/benches/generated/justify_content_overflow_min_max.rs index 7827ffced..9f03c94b2 100644 --- a/benches/generated/justify_content_overflow_min_max.rs +++ b/benches/generated/justify_content_overflow_min_max.rs @@ -3,54 +3,42 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(110f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(110f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/benches/generated/justify_content_row_center.rs b/benches/generated/justify_content_row_center.rs index 56b6c6e58..68fc9e6ae 100644 --- a/benches/generated/justify_content_row_center.rs +++ b/benches/generated/justify_content_row_center.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_row_flex_end.rs b/benches/generated/justify_content_row_flex_end.rs index 60caa6909..5301bbee6 100644 --- a/benches/generated/justify_content_row_flex_end.rs +++ b/benches/generated/justify_content_row_flex_end.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_row_flex_start.rs b/benches/generated/justify_content_row_flex_start.rs index 3c41844d6..d3f67a445 100644 --- a/benches/generated/justify_content_row_flex_start.rs +++ b/benches/generated/justify_content_row_flex_start.rs @@ -3,39 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_row_max_width_and_margin.rs b/benches/generated/justify_content_row_max_width_and_margin.rs index d7dfd8a19..96a0fc48d 100644 --- a/benches/generated/justify_content_row_max_width_and_margin.rs +++ b/benches/generated/justify_content_row_max_width_and_margin.rs @@ -3,28 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(100f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(100f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/justify_content_row_min_width_and_margin.rs b/benches/generated/justify_content_row_min_width_and_margin.rs index e6fb775ba..1a6ef4c88 100644 --- a/benches/generated/justify_content_row_min_width_and_margin.rs +++ b/benches/generated/justify_content_row_min_width_and_margin.rs @@ -3,27 +3,25 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/justify_content_row_space_around.rs b/benches/generated/justify_content_row_space_around.rs index 8be9f4b8a..0f02d5787 100644 --- a/benches/generated/justify_content_row_space_around.rs +++ b/benches/generated/justify_content_row_space_around.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceAround, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_row_space_between.rs b/benches/generated/justify_content_row_space_between.rs index 896f83000..d4b9970a8 100644 --- a/benches/generated/justify_content_row_space_between.rs +++ b/benches/generated/justify_content_row_space_between.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceBetween, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/justify_content_row_space_evenly.rs b/benches/generated/justify_content_row_space_evenly.rs index 84ffb89ef..e024c19c9 100644 --- a/benches/generated/justify_content_row_space_evenly.rs +++ b/benches/generated/justify_content_row_space_evenly.rs @@ -3,40 +3,30 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceEvenly, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_and_flex_column.rs b/benches/generated/margin_and_flex_column.rs index 7ad5a445d..7ce2bbd73 100644 --- a/benches/generated/margin_and_flex_column.rs +++ b/benches/generated/margin_and_flex_column.rs @@ -3,18 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_and_flex_row.rs b/benches/generated/margin_and_flex_row.rs index 762c84acd..78c3819ce 100644 --- a/benches/generated/margin_and_flex_row.rs +++ b/benches/generated/margin_and_flex_row.rs @@ -3,18 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_and_stretch_column.rs b/benches/generated/margin_and_stretch_column.rs index ae9d8ca7c..ac28a8216 100644 --- a/benches/generated/margin_and_stretch_column.rs +++ b/benches/generated/margin_and_stretch_column.rs @@ -3,18 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_and_stretch_row.rs b/benches/generated/margin_and_stretch_row.rs index eb9b22bd3..d5d2d3875 100644 --- a/benches/generated/margin_and_stretch_row.rs +++ b/benches/generated/margin_and_stretch_row.rs @@ -3,18 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_bottom.rs b/benches/generated/margin_auto_bottom.rs index 62eed17ff..84e31d51c 100644 --- a/benches/generated/margin_auto_bottom.rs +++ b/benches/generated/margin_auto_bottom.rs @@ -3,40 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { bottom: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_bottom_and_top.rs b/benches/generated/margin_auto_bottom_and_top.rs index e873ad1b0..81c5d79b2 100644 --- a/benches/generated/margin_auto_bottom_and_top.rs +++ b/benches/generated/margin_auto_bottom_and_top.rs @@ -3,44 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_bottom_and_top_justify_center.rs b/benches/generated/margin_auto_bottom_and_top_justify_center.rs index 9ca934c2d..8f41d80a3 100644 --- a/benches/generated/margin_auto_bottom_and_top_justify_center.rs +++ b/benches/generated/margin_auto_bottom_and_top_justify_center.rs @@ -3,44 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left.rs b/benches/generated/margin_auto_left.rs index 9c154d85d..226b8bf14 100644 --- a/benches/generated/margin_auto_left.rs +++ b/benches/generated/margin_auto_left.rs @@ -3,40 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_and_right.rs b/benches/generated/margin_auto_left_and_right.rs index 13fbccd69..c39c7b531 100644 --- a/benches/generated/margin_auto_left_and_right.rs +++ b/benches/generated/margin_auto_left_and_right.rs @@ -3,35 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -39,7 +32,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_and_right_column.rs b/benches/generated/margin_auto_left_and_right_column.rs index ccd1598fa..2c26bd22f 100644 --- a/benches/generated/margin_auto_left_and_right_column.rs +++ b/benches/generated/margin_auto_left_and_right_column.rs @@ -3,44 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_and_right_column_and_center.rs b/benches/generated/margin_auto_left_and_right_column_and_center.rs index ccd1598fa..2c26bd22f 100644 --- a/benches/generated/margin_auto_left_and_right_column_and_center.rs +++ b/benches/generated/margin_auto_left_and_right_column_and_center.rs @@ -3,44 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_and_right_strech.rs b/benches/generated/margin_auto_left_and_right_strech.rs index 13fbccd69..dceb7b941 100644 --- a/benches/generated/margin_auto_left_and_right_strech.rs +++ b/benches/generated/margin_auto_left_and_right_strech.rs @@ -3,43 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_child_bigger_than_parent.rs index dc4e6785f..2709882a9 100644 --- a/benches/generated/margin_auto_left_child_bigger_than_parent.rs +++ b/benches/generated/margin_auto_left_child_bigger_than_parent.rs @@ -3,27 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs index be7f449e4..51b8b495e 100644 --- a/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/benches/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -3,31 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs b/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs index 51d18b133..72bad6e3b 100644 --- a/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs +++ b/benches/generated/margin_auto_left_right_child_bigger_than_parent.rs @@ -3,31 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_left_stretching_child.rs b/benches/generated/margin_auto_left_stretching_child.rs index d0abd6732..42f74a625 100644 --- a/benches/generated/margin_auto_left_stretching_child.rs +++ b/benches/generated/margin_auto_left_stretching_child.rs @@ -3,38 +3,35 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_mutiple_children_column.rs b/benches/generated/margin_auto_mutiple_children_column.rs index 16f6b1695..9ebbab403 100644 --- a/benches/generated/margin_auto_mutiple_children_column.rs +++ b/benches/generated/margin_auto_mutiple_children_column.rs @@ -3,55 +3,52 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_mutiple_children_row.rs b/benches/generated/margin_auto_mutiple_children_row.rs index eee2c64c2..853bfb5dc 100644 --- a/benches/generated/margin_auto_mutiple_children_row.rs +++ b/benches/generated/margin_auto_mutiple_children_row.rs @@ -3,54 +3,51 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_right.rs b/benches/generated/margin_auto_right.rs index 700e9beae..ba7047a0f 100644 --- a/benches/generated/margin_auto_right.rs +++ b/benches/generated/margin_auto_right.rs @@ -3,40 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_top.rs b/benches/generated/margin_auto_top.rs index 3aaa1c5f5..6621e5a81 100644 --- a/benches/generated/margin_auto_top.rs +++ b/benches/generated/margin_auto_top.rs @@ -3,40 +3,36 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_top_and_bottom_strech.rs b/benches/generated/margin_auto_top_and_bottom_strech.rs index 542e38b16..0baafb697 100644 --- a/benches/generated/margin_auto_top_and_bottom_strech.rs +++ b/benches/generated/margin_auto_top_and_bottom_strech.rs @@ -3,44 +3,37 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_auto_top_stretching_child.rs b/benches/generated/margin_auto_top_stretching_child.rs index fabfaaa8c..70c0a17be 100644 --- a/benches/generated/margin_auto_top_stretching_child.rs +++ b/benches/generated/margin_auto_top_stretching_child.rs @@ -3,38 +3,35 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_bottom.rs b/benches/generated/margin_bottom.rs index 2633fe434..2b51e5cfa 100644 --- a/benches/generated/margin_bottom.rs +++ b/benches/generated/margin_bottom.rs @@ -3,27 +3,25 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs b/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs index ecac0fd78..680041c07 100644 --- a/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs +++ b/benches/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -3,31 +3,27 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_left.rs b/benches/generated/margin_left.rs index f1416709a..8ad8cd3b7 100644 --- a/benches/generated/margin_left.rs +++ b/benches/generated/margin_left.rs @@ -3,17 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -21,7 +20,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_right.rs b/benches/generated/margin_right.rs index c51447ae6..603fb355a 100644 --- a/benches/generated/margin_right.rs +++ b/benches/generated/margin_right.rs @@ -3,26 +3,24 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_should_not_be_part_of_max_height.rs b/benches/generated/margin_should_not_be_part_of_max_height.rs index dc6585ca3..03e2c73f9 100644 --- a/benches/generated/margin_should_not_be_part_of_max_height.rs +++ b/benches/generated/margin_should_not_be_part_of_max_height.rs @@ -3,22 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -26,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(250f32), height: taffy::style::Dimension::Points(250f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_should_not_be_part_of_max_width.rs b/benches/generated/margin_should_not_be_part_of_max_width.rs index 70f6c41a5..f1338de88 100644 --- a/benches/generated/margin_should_not_be_part_of_max_width.rs +++ b/benches/generated/margin_should_not_be_part_of_max_width.rs @@ -3,22 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -26,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(250f32), height: taffy::style::Dimension::Points(250f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_top.rs b/benches/generated/margin_top.rs index 38341f6e2..cc7fd5b2d 100644 --- a/benches/generated/margin_top.rs +++ b/benches/generated/margin_top.rs @@ -3,17 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_with_sibling_column.rs b/benches/generated/margin_with_sibling_column.rs index 8a69575af..9d8bc5514 100644 --- a/benches/generated/margin_with_sibling_column.rs +++ b/benches/generated/margin_with_sibling_column.rs @@ -3,19 +3,18 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -23,7 +22,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/margin_with_sibling_row.rs b/benches/generated/margin_with_sibling_row.rs index 8d0f58272..3e3c66c0f 100644 --- a/benches/generated/margin_with_sibling_row.rs +++ b/benches/generated/margin_with_sibling_row.rs @@ -3,26 +3,24 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/max_height.rs b/benches/generated/max_height.rs index 773156720..fa17a38cf 100644 --- a/benches/generated/max_height.rs +++ b/benches/generated/max_height.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,7 +15,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/max_height_overrides_height.rs b/benches/generated/max_height_overrides_height.rs index 9952c7809..6d81313c0 100644 --- a/benches/generated/max_height_overrides_height.rs +++ b/benches/generated/max_height_overrides_height.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/max_height_overrides_height_on_root.rs b/benches/generated/max_height_overrides_height_on_root.rs index 89f212b79..f0401d606 100644 --- a/benches/generated/max_height_overrides_height_on_root.rs +++ b/benches/generated/max_height_overrides_height_on_root.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/max_width.rs b/benches/generated/max_width.rs index cd060c923..07f16f495 100644 --- a/benches/generated/max_width.rs +++ b/benches/generated/max_width.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -19,7 +16,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/max_width_overrides_width.rs b/benches/generated/max_width_overrides_width.rs index 0df2095d7..4d9f169ab 100644 --- a/benches/generated/max_width_overrides_width.rs +++ b/benches/generated/max_width_overrides_width.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/max_width_overrides_width_on_root.rs b/benches/generated/max_width_overrides_width_on_root.rs index a7924f7ed..02e5f710c 100644 --- a/benches/generated/max_width_overrides_width_on_root.rs +++ b/benches/generated/max_width_overrides_width_on_root.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/min_height.rs b/benches/generated/min_height.rs index a22e8b223..c7e1930b5 100644 --- a/benches/generated/min_height.rs +++ b/benches/generated/min_height.rs @@ -3,16 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(60f32) }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -20,7 +17,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/min_height_overrides_height.rs b/benches/generated/min_height_overrides_height.rs index 863e0c541..b7c7cf701 100644 --- a/benches/generated/min_height_overrides_height.rs +++ b/benches/generated/min_height_overrides_height.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/min_height_overrides_height_on_root.rs b/benches/generated/min_height_overrides_height_on_root.rs index 910535216..b2f724f80 100644 --- a/benches/generated/min_height_overrides_height_on_root.rs +++ b/benches/generated/min_height_overrides_height_on_root.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/min_height_overrides_max_height.rs b/benches/generated/min_height_overrides_max_height.rs index 786461a85..9133207d4 100644 --- a/benches/generated/min_height_overrides_max_height.rs +++ b/benches/generated/min_height_overrides_max_height.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/min_max_percent_no_width_height.rs b/benches/generated/min_max_percent_no_width_height.rs index 92a49aa09..e2a35368a 100644 --- a/benches/generated/min_max_percent_no_width_height.rs +++ b/benches/generated/min_max_percent_no_width_height.rs @@ -3,32 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), }, - &[], - ) + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/min_width.rs b/benches/generated/min_width.rs index 42354f82d..8624deb5c 100644 --- a/benches/generated/min_width.rs +++ b/benches/generated/min_width.rs @@ -3,23 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/min_width_overrides_max_width.rs b/benches/generated/min_width_overrides_max_width.rs index 5851ad48d..62ce4f6de 100644 --- a/benches/generated/min_width_overrides_max_width.rs +++ b/benches/generated/min_width_overrides_max_width.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/min_width_overrides_width.rs b/benches/generated/min_width_overrides_width.rs index a876f459b..e27fa9c0c 100644 --- a/benches/generated/min_width_overrides_width.rs +++ b/benches/generated/min_width_overrides_width.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/min_width_overrides_width_on_root.rs b/benches/generated/min_width_overrides_width_on_root.rs index 88751e18f..98bcccf3b 100644 --- a/benches/generated/min_width_overrides_width_on_root.rs +++ b/benches/generated/min_width_overrides_width_on_root.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/mod.rs b/benches/generated/mod.rs index 7985a324b..f887159a4 100644 --- a/benches/generated/mod.rs +++ b/benches/generated/mod.rs @@ -1,4 +1,46 @@ use criterion::{criterion_group, criterion_main, Criterion}; +#[allow(dead_code)] +fn measure_standard_text( + known_dimensions: taffy::geometry::Size>, + available_space: taffy::geometry::Size, + text_content: &str, +) -> taffy::geometry::Size { + use taffy::prelude::*; + const ZWS: char = '\u{200B}'; + const H_WIDTH: f32 = 10.0; + const H_HEIGHT: f32 = 10.0; + if let Size { width: Some(width), height: Some(height) } = known_dimensions { + return Size { width, height }; + } + let lines: Vec<&str> = text_content.split(ZWS).collect(); + if lines.is_empty() { + return Size::ZERO; + } + let min_line_length: usize = lines.iter().map(|line| line.len()).max().unwrap_or(0); + let max_line_length: usize = lines.iter().map(|line| line.len()).sum(); + let width = known_dimensions.width.unwrap_or_else(|| match available_space.width { + AvailableSpace::MinContent => min_line_length as f32 * H_WIDTH, + AvailableSpace::MaxContent => max_line_length as f32 * H_WIDTH, + AvailableSpace::Definite(width) => { + width.min(max_line_length as f32 * H_WIDTH).max(min_line_length as f32 * H_WIDTH) + } + }); + let height = known_dimensions.height.unwrap_or_else(|| { + let width_line_length = (width / H_WIDTH).floor() as usize; + let mut line_count = 1; + let mut current_line_length = 0; + for line in &lines { + if current_line_length + line.len() > width_line_length { + line_count += 1; + current_line_length = line.len(); + } else { + current_line_length += line.len(); + }; + } + (line_count as f32) * H_HEIGHT + }); + Size { width, height } +} mod absolute_layout_align_items_and_justify_content_center; mod absolute_layout_align_items_and_justify_content_center_and_bottom_position; mod absolute_layout_align_items_and_justify_content_center_and_left_position; @@ -140,6 +182,206 @@ mod gap_row_gap_align_items_stretch; mod gap_row_gap_column_child_margins; mod gap_row_gap_determines_parent_height; mod gap_row_gap_row_wrap_child_margins; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_align_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_column_end; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_column_start; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_bottom_left; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_bottom_left_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_overrides_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_right_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_negative_position; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_negative_position_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_bottom; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_bottom_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_right_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_justify_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_row_end; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_row_start; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_top_overrides_bottom; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_with_padding; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_with_padding_and_margin; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_center; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_end; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_end_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_around; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_around_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_between; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_between_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_evenly; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_evenly_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_start; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_start_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_center; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_end; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_start; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_align_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_auto_columns_fixed_width; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fill_fixed_size; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fill_with_empty_auto_track; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fit_with_empty_auto_track; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item_fixed_width; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item_fixed_width_with_definite_width; +#[cfg(feature = "experimental_grid")] +mod grid_basic; +#[cfg(feature = "experimental_grid")] +mod grid_basic_implicit_tracks; +#[cfg(feature = "experimental_grid")] +mod grid_basic_with_overflow; +#[cfg(feature = "experimental_grid")] +mod grid_basic_with_padding; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_argument; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_max_content; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_min_content; +#[cfg(feature = "experimental_grid")] +mod grid_fr_auto_no_sized_items; +#[cfg(feature = "experimental_grid")] +mod grid_fr_auto_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_fr_fixed_size_no_content; +#[cfg(feature = "experimental_grid")] +mod grid_fr_fixed_size_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_gap; +#[cfg(feature = "experimental_grid")] +mod grid_hidden; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_center; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_center_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_end; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_end_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_around; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_around_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_between; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_between_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_evenly; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_evenly_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_start; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_start_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_center; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_end; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_start; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_justify_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_margins_auto_margins; +#[cfg(feature = "experimental_grid")] +mod grid_margins_auto_margins_override_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_center; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_end; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_start; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_center; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_end; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_start; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_maximum_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_auto; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_fixed; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_percent; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_auto; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_fixed; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_percent; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_maximum_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_auto; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_above_range; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_below_range; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_within_range; +#[cfg(feature = "experimental_grid")] +mod grid_out_of_order_items; +#[cfg(feature = "experimental_grid")] +mod grid_size_child_fixed_tracks; mod justify_content_column_center; mod justify_content_column_flex_end; mod justify_content_column_flex_start; @@ -420,6 +662,206 @@ fn benchmark(c: &mut Criterion) { gap_row_gap_column_child_margins::compute(); gap_row_gap_determines_parent_height::compute(); gap_row_gap_row_wrap_child_margins::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_align_self_sized_all::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_column_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_column_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_bottom_left::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_bottom_left_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_left_overrides_right::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_left_right::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_left_right_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_negative_position::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_negative_position_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_top_bottom::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_top_bottom_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_top_right::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_container_top_right_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_justify_self_sized_all::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_row_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_row_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_top_overrides_bottom::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_with_padding::compute(); + #[cfg(feature = "experimental_grid")] + grid_absolute_with_padding_and_margin::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_end_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_around::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_around_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_between::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_between_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_evenly::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_space_evenly_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_content_start_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_items_sized_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_items_sized_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_items_sized_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_items_sized_stretch::compute(); + #[cfg(feature = "experimental_grid")] + grid_align_self_sized_all::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_columns_fixed_width::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_fill_fixed_size::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_fill_with_empty_auto_track::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_fit_with_empty_auto_track::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_single_item_fixed_width::compute(); + #[cfg(feature = "experimental_grid")] + grid_auto_single_item_fixed_width_with_definite_width::compute(); + #[cfg(feature = "experimental_grid")] + grid_basic::compute(); + #[cfg(feature = "experimental_grid")] + grid_basic_implicit_tracks::compute(); + #[cfg(feature = "experimental_grid")] + grid_basic_with_overflow::compute(); + #[cfg(feature = "experimental_grid")] + grid_basic_with_padding::compute(); + #[cfg(feature = "experimental_grid")] + grid_fit_content_points_argument::compute(); + #[cfg(feature = "experimental_grid")] + grid_fit_content_points_max_content::compute(); + #[cfg(feature = "experimental_grid")] + grid_fit_content_points_min_content::compute(); + #[cfg(feature = "experimental_grid")] + grid_fr_auto_no_sized_items::compute(); + #[cfg(feature = "experimental_grid")] + grid_fr_auto_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_fr_fixed_size_no_content::compute(); + #[cfg(feature = "experimental_grid")] + grid_fr_fixed_size_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_gap::compute(); + #[cfg(feature = "experimental_grid")] + grid_hidden::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_center_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_end_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_around::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_around_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_between::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_between_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_evenly::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_space_evenly_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_content_start_with_padding_border::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_items_sized_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_items_sized_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_items_sized_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_items_sized_stretch::compute(); + #[cfg(feature = "experimental_grid")] + grid_justify_self_sized_all::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_auto_margins::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_auto_margins_override_stretch::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_fixed_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_fixed_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_fixed_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_fixed_stretch::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_percent_center::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_percent_end::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_percent_start::compute(); + #[cfg(feature = "experimental_grid")] + grid_margins_percent_stretch::compute(); + #[cfg(feature = "experimental_grid")] + grid_max_content_maximum_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_max_content_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_max_content_single_item_margin_auto::compute(); + #[cfg(feature = "experimental_grid")] + grid_max_content_single_item_margin_fixed::compute(); + #[cfg(feature = "experimental_grid")] + grid_max_content_single_item_margin_percent::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_flex_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_flex_single_item_margin_auto::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_flex_single_item_margin_fixed::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_flex_single_item_margin_percent::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_maximum_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_content_single_item::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_max_column_auto::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_max_column_fixed_width_above_range::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_max_column_fixed_width_below_range::compute(); + #[cfg(feature = "experimental_grid")] + grid_min_max_column_fixed_width_within_range::compute(); + #[cfg(feature = "experimental_grid")] + grid_out_of_order_items::compute(); + #[cfg(feature = "experimental_grid")] + grid_size_child_fixed_tracks::compute(); justify_content_column_center::compute(); justify_content_column_flex_end::compute(); justify_content_column_flex_start::compute(); diff --git a/benches/generated/nested_overflowing_child.rs b/benches/generated/nested_overflowing_child.rs index cd4492620..957f3941a 100644 --- a/benches/generated/nested_overflowing_child.rs +++ b/benches/generated/nested_overflowing_child.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy @@ -22,7 +18,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/nested_overflowing_child_in_constraint_parent.rs b/benches/generated/nested_overflowing_child_in_constraint_parent.rs index 12ef5db0e..2e7411a1e 100644 --- a/benches/generated/nested_overflowing_child_in_constraint_parent.rs +++ b/benches/generated/nested_overflowing_child_in_constraint_parent.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -21,7 +17,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, @@ -34,7 +29,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/overflow_cross_axis.rs b/benches/generated/overflow_cross_axis.rs index 2be73d813..ff19cf25f 100644 --- a/benches/generated/overflow_cross_axis.rs +++ b/benches/generated/overflow_cross_axis.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -21,7 +17,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/overflow_main_axis.rs b/benches/generated/overflow_main_axis.rs index 066ffbcaa..ad00c6fbf 100644 --- a/benches/generated/overflow_main_axis.rs +++ b/benches/generated/overflow_main_axis.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,7 +15,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/padding_align_end_child.rs b/benches/generated/padding_align_end_child.rs index 75958abd0..74e291bb4 100644 --- a/benches/generated/padding_align_end_child.rs +++ b/benches/generated/padding_align_end_child.rs @@ -3,34 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(20f32), - right: taffy::style::LengthPercentage::Points(20f32), - top: taffy::style::LengthPercentage::Points(20f32), - bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(20f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(20f32), + bottom: taffy::style::LengthPercentage::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, - justify_content: taffy::style::JustifyContent::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/padding_center_child.rs b/benches/generated/padding_center_child.rs index 36d471538..025438271 100644 --- a/benches/generated/padding_center_child.rs +++ b/benches/generated/padding_center_child.rs @@ -3,34 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(20f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/padding_flex_child.rs b/benches/generated/padding_flex_child.rs index 31f523dff..d65330896 100644 --- a/benches/generated/padding_flex_child.rs +++ b/benches/generated/padding_flex_child.rs @@ -3,14 +3,11 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,14 +15,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/padding_no_child.rs b/benches/generated/padding_no_child.rs index 5ebde112f..da5de1074 100644 --- a/benches/generated/padding_no_child.rs +++ b/benches/generated/padding_no_child.rs @@ -3,19 +3,15 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(10f32), - right: taffy::style::LengthPercentage::Points(10f32), - top: taffy::style::LengthPercentage::Points(10f32), - bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); } diff --git a/benches/generated/padding_stretch_child.rs b/benches/generated/padding_stretch_child.rs index a18ac244c..5b2dd30bb 100644 --- a/benches/generated/padding_stretch_child.rs +++ b/benches/generated/padding_stretch_child.rs @@ -3,13 +3,10 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -17,14 +14,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/parent_wrap_child_size_overflowing_parent.rs b/benches/generated/parent_wrap_child_size_overflowing_parent.rs index 18582e8ae..a525f89f8 100644 --- a/benches/generated/parent_wrap_child_size_overflowing_parent.rs +++ b/benches/generated/parent_wrap_child_size_overflowing_parent.rs @@ -3,22 +3,18 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00], @@ -30,7 +26,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percent_absolute_position.rs b/benches/generated/percent_absolute_position.rs index aee9ba17e..e0cc8ba4f 100644 --- a/benches/generated/percent_absolute_position.rs +++ b/benches/generated/percent_absolute_position.rs @@ -3,22 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -27,11 +21,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, position: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() + right: auto(), + top: auto(), + bottom: auto(), }, ..Default::default() }, @@ -45,7 +40,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percent_within_flex_grow.rs b/benches/generated/percent_within_flex_grow.rs index 38266fed8..00ca44df6 100644 --- a/benches/generated/percent_within_flex_grow.rs +++ b/benches/generated/percent_within_flex_grow.rs @@ -3,22 +3,16 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -31,13 +25,10 @@ pub fn compute() { ) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -45,7 +36,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(350f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_absolute_position.rs b/benches/generated/percentage_absolute_position.rs index b710729e5..de8ecad4e 100644 --- a/benches/generated/percentage_absolute_position.rs +++ b/benches/generated/percentage_absolute_position.rs @@ -3,23 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.3f32), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.3f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -28,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_container_in_wrapping_container.rs b/benches/generated/percentage_container_in_wrapping_container.rs index 1f6731e66..0678cba5e 100644 --- a/benches/generated/percentage_container_in_wrapping_container.rs +++ b/benches/generated/percentage_container_in_wrapping_container.rs @@ -3,36 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node001 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, ..Default::default() }, &[node000, node001], @@ -48,12 +40,11 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis.rs b/benches/generated/percentage_flex_basis.rs index 3c056d815..1f99d92d9 100644 --- a/benches/generated/percentage_flex_basis.rs +++ b/benches/generated/percentage_flex_basis.rs @@ -3,24 +3,18 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -28,7 +22,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_cross.rs b/benches/generated/percentage_flex_basis_cross.rs index 89a31ffc9..f462458cf 100644 --- a/benches/generated/percentage_flex_basis_cross.rs +++ b/benches/generated/percentage_flex_basis_cross.rs @@ -3,24 +3,18 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -29,7 +23,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_cross_max_height.rs b/benches/generated/percentage_flex_basis_cross_max_height.rs index 3e9d30abd..76ea47a79 100644 --- a/benches/generated/percentage_flex_basis_cross_max_height.rs +++ b/benches/generated/percentage_flex_basis_cross_max_height.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_cross_max_width.rs b/benches/generated/percentage_flex_basis_cross_max_width.rs index c2d1d0b42..144a8625b 100644 --- a/benches/generated/percentage_flex_basis_cross_max_width.rs +++ b/benches/generated/percentage_flex_basis_cross_max_width.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_cross_min_height.rs b/benches/generated/percentage_flex_basis_cross_min_height.rs index 939303373..1d5425af8 100644 --- a/benches/generated/percentage_flex_basis_cross_min_height.rs +++ b/benches/generated/percentage_flex_basis_cross_min_height.rs @@ -3,24 +3,18 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 2f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 2f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -29,7 +23,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_cross_min_width.rs b/benches/generated/percentage_flex_basis_cross_min_width.rs index dfd14e842..153c8f538 100644 --- a/benches/generated/percentage_flex_basis_cross_min_width.rs +++ b/benches/generated/percentage_flex_basis_cross_min_width.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_main_max_height.rs b/benches/generated/percentage_flex_basis_main_max_height.rs index 78dd58ca4..6fea7dad3 100644 --- a/benches/generated/percentage_flex_basis_main_max_height.rs +++ b/benches/generated/percentage_flex_basis_main_max_height.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_main_max_width.rs b/benches/generated/percentage_flex_basis_main_max_width.rs index dc334f3ab..7a7274f19 100644 --- a/benches/generated/percentage_flex_basis_main_max_width.rs +++ b/benches/generated/percentage_flex_basis_main_max_width.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_flex_basis_main_min_width.rs b/benches/generated/percentage_flex_basis_main_min_width.rs index a985f260d..90bc3ad32 100644 --- a/benches/generated/percentage_flex_basis_main_min_width.rs +++ b/benches/generated/percentage_flex_basis_main_min_width.rs @@ -3,26 +3,20 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +24,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs b/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs index a8ca06634..7883cf52f 100644 --- a/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs +++ b/benches/generated/percentage_margin_should_calculate_based_only_on_width.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -25,7 +21,6 @@ pub fn compute() { right: taffy::style::LengthPercentageAuto::Percent(0.1f32), top: taffy::style::LengthPercentageAuto::Percent(0.1f32), bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::zero() }, ..Default::default() }, @@ -39,7 +34,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs index a2edc9f2e..e18b62835 100644 --- a/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs +++ b/benches/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -3,46 +3,39 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - ..Rect::zero() - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(3f32), - right: taffy::style::LengthPercentage::Points(3f32), - top: taffy::style::LengthPercentage::Points(3f32), - bottom: taffy::style::LengthPercentage::Points(3f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), }, - &[], - ) + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(3f32), + right: taffy::style::LengthPercentage::Points(3f32), + top: taffy::style::LengthPercentage::Points(3f32), + bottom: taffy::style::LengthPercentage::Points(3f32), + }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Points(5f32), right: taffy::style::LengthPercentageAuto::Points(5f32), top: taffy::style::LengthPercentageAuto::Points(5f32), bottom: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::zero() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Percent(0.03f32), right: taffy::style::LengthPercentage::Percent(0.03f32), top: taffy::style::LengthPercentage::Percent(0.03f32), bottom: taffy::style::LengthPercentage::Percent(0.03f32), - ..Rect::zero() }, ..Default::default() }, @@ -55,20 +48,18 @@ pub fn compute() { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Points(5f32), right: taffy::style::LengthPercentageAuto::Points(5f32), top: taffy::style::LengthPercentageAuto::Points(5f32), bottom: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::zero() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(3f32), right: taffy::style::LengthPercentage::Points(3f32), top: taffy::style::LengthPercentage::Points(3f32), bottom: taffy::style::LengthPercentage::Points(3f32), - ..Rect::zero() }, ..Default::default() }, @@ -76,15 +67,12 @@ pub fn compute() { ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -93,7 +81,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs b/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs index 6118a51f7..181230433 100644 --- a/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs +++ b/benches/generated/percentage_padding_should_calculate_based_only_on_width.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -25,7 +21,6 @@ pub fn compute() { right: taffy::style::LengthPercentage::Percent(0.1f32), top: taffy::style::LengthPercentage::Percent(0.1f32), bottom: taffy::style::LengthPercentage::Percent(0.1f32), - ..Rect::zero() }, ..Default::default() }, @@ -39,7 +34,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_position_bottom_right.rs b/benches/generated/percentage_position_bottom_right.rs index 9c70838de..c9451234e 100644 --- a/benches/generated/percentage_position_bottom_right.rs +++ b/benches/generated/percentage_position_bottom_right.rs @@ -3,22 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.55f32), - height: taffy::style::Dimension::Percent(0.15f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Percent(0.2f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.55f32), + height: taffy::style::Dimension::Percent(0.15f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Percent(0.2f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -26,7 +23,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_position_left_top.rs b/benches/generated/percentage_position_left_top.rs index 723c19956..2a1a2ce0c 100644 --- a/benches/generated/percentage_position_left_top.rs +++ b/benches/generated/percentage_position_left_top.rs @@ -3,22 +3,19 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.45f32), - height: taffy::style::Dimension::Percent(0.55f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.2f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.45f32), + height: taffy::style::Dimension::Percent(0.55f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.2f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -26,7 +23,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_size_based_on_parent_inner_size.rs b/benches/generated/percentage_size_based_on_parent_inner_size.rs index 41702cab4..7b58a22b3 100644 --- a/benches/generated/percentage_size_based_on_parent_inner_size.rs +++ b/benches/generated/percentage_size_based_on_parent_inner_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,14 +18,12 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(20f32), right: taffy::style::LengthPercentage::Points(20f32), top: taffy::style::LengthPercentage::Points(20f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/percentage_size_of_flex_basis.rs b/benches/generated/percentage_size_of_flex_basis.rs index be582e167..2df9df3af 100644 --- a/benches/generated/percentage_size_of_flex_basis.rs +++ b/benches/generated/percentage_size_of_flex_basis.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -24,7 +20,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/benches/generated/percentage_width_height.rs b/benches/generated/percentage_width_height.rs index ffcacb882..a674b251d 100644 --- a/benches/generated/percentage_width_height.rs +++ b/benches/generated/percentage_width_height.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.3f32), - height: taffy::style::Dimension::Percent(0.3f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.3f32), + height: taffy::style::Dimension::Percent(0.3f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -21,7 +17,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/percentage_width_height_undefined_parent_size.rs b/benches/generated/percentage_width_height_undefined_parent_size.rs index 2b7706699..96452205d 100644 --- a/benches/generated/percentage_width_height_undefined_parent_size.rs +++ b/benches/generated/percentage_width_height_undefined_parent_size.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/benches/generated/relative_position_should_not_nudge_siblings.rs b/benches/generated/relative_position_should_not_nudge_siblings.rs index 2e29c7393..2465f3546 100644 --- a/benches/generated/relative_position_should_not_nudge_siblings.rs +++ b/benches/generated/relative_position_should_not_nudge_siblings.rs @@ -3,30 +3,28 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -35,7 +33,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs index 0bd5a8178..c158105de 100644 --- a/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs +++ b/benches/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -2,18 +2,17 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node2 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node3 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node4 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(113f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs index f8b0aa330..e7e757be3 100644 --- a/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs +++ b/benches/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -2,16 +2,15 @@ pub fn compute() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node2 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_flex_basis_flex_shrink_row.rs b/benches/generated/rounding_flex_basis_flex_shrink_row.rs index 9260874f0..62e08c37d 100644 --- a/benches/generated/rounding_flex_basis_flex_shrink_row.rs +++ b/benches/generated/rounding_flex_basis_flex_shrink_row.rs @@ -3,26 +3,17 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +21,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(101f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_flex_basis_overrides_main_size.rs b/benches/generated/rounding_flex_basis_overrides_main_size.rs index bd6aa8608..cabdc4336 100644 --- a/benches/generated/rounding_flex_basis_overrides_main_size.rs +++ b/benches/generated/rounding_flex_basis_overrides_main_size.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_fractial_input_1.rs b/benches/generated/rounding_fractial_input_1.rs index 9f6669bb3..753f9ceb4 100644 --- a/benches/generated/rounding_fractial_input_1.rs +++ b/benches/generated/rounding_fractial_input_1.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_fractial_input_2.rs b/benches/generated/rounding_fractial_input_2.rs index fcc673533..f7461d5dd 100644 --- a/benches/generated/rounding_fractial_input_2.rs +++ b/benches/generated/rounding_fractial_input_2.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.6f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_fractial_input_3.rs b/benches/generated/rounding_fractial_input_3.rs index 9f6669bb3..753f9ceb4 100644 --- a/benches/generated/rounding_fractial_input_3.rs +++ b/benches/generated/rounding_fractial_input_3.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_fractial_input_4.rs b/benches/generated/rounding_fractial_input_4.rs index 9f6669bb3..753f9ceb4 100644 --- a/benches/generated/rounding_fractial_input_4.rs +++ b/benches/generated/rounding_fractial_input_4.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_total_fractial.rs b/benches/generated/rounding_total_fractial.rs index a5633f617..20a6eb801 100644 --- a/benches/generated/rounding_total_fractial.rs +++ b/benches/generated/rounding_total_fractial.rs @@ -3,35 +3,26 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0.7f32, - flex_basis: taffy::style::Dimension::Points(50.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20.3f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10.7f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(87.4f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/rounding_total_fractial_nested.rs b/benches/generated/rounding_total_fractial_nested.rs index c51f6ecef..5a341b464 100644 --- a/benches/generated/rounding_total_fractial_nested.rs +++ b/benches/generated/rounding_total_fractial_nested.rs @@ -3,34 +3,32 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(9.9f32), ..Size::auto() }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(13.3f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(9.9f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(13.3f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Points(0.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(1.1f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(13.3f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(1.1f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(13.3f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -38,31 +36,25 @@ pub fn compute() { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::Points(50.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20.3f32) }, ..Default::default() }, &[node00, node01], ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10.7f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -71,7 +63,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(87.4f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/size_defined_by_child.rs b/benches/generated/size_defined_by_child.rs index 1031a9172..b214c3269 100644 --- a/benches/generated/size_defined_by_child.rs +++ b/benches/generated/size_defined_by_child.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/benches/generated/size_defined_by_child_with_border.rs b/benches/generated/size_defined_by_child_with_border.rs index fbd3bfd6b..57891aa09 100644 --- a/benches/generated/size_defined_by_child_with_border.rs +++ b/benches/generated/size_defined_by_child_with_border.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ pub fn compute() { right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/size_defined_by_child_with_padding.rs b/benches/generated/size_defined_by_child_with_padding.rs index 46bd791e2..fcb4bb0cd 100644 --- a/benches/generated/size_defined_by_child_with_padding.rs +++ b/benches/generated/size_defined_by_child_with_padding.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ pub fn compute() { right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/benches/generated/size_defined_by_grand_child.rs b/benches/generated/size_defined_by_grand_child.rs index 963953e26..f0717a1e7 100644 --- a/benches/generated/size_defined_by_grand_child.rs +++ b/benches/generated/size_defined_by_grand_child.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs index a28aa623a..024e93685 100644 --- a/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs +++ b/benches/generated/width_smaller_then_content_with_flex_grow_large_size.rs @@ -3,48 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs index e7b400f17..fb9dc71a8 100644 --- a/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs +++ b/benches/generated/width_smaller_then_content_with_flex_grow_small_size.rs @@ -3,48 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs index 16179d9d4..1257d05ca 100644 --- a/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/benches/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -3,48 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], diff --git a/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs b/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs index 014591464..4d460c8a0 100644 --- a/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/benches/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -3,48 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -53,7 +45,7 @@ pub fn compute() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/benches/generated/wrap_column.rs b/benches/generated/wrap_column.rs index 6e6ad58b8..bcda14a66 100644 --- a/benches/generated/wrap_column.rs +++ b/benches/generated/wrap_column.rs @@ -3,56 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(31f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(32f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(33f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(34f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -62,7 +46,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs b/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs index 70e028c62..e7e2c50ec 100644 --- a/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs +++ b/benches/generated/wrap_nodes_with_content_sizing_margin_cross.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( @@ -22,25 +18,23 @@ pub fn compute() { ) .unwrap(); let node010 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, margin: taffy::geometry::Rect { + left: zero(), + right: zero(), top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() + bottom: zero(), }, ..Default::default() }, @@ -51,7 +45,7 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -64,7 +58,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs b/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs index c1ea47059..6a50078b7 100644 --- a/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs +++ b/benches/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -3,17 +3,13 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( @@ -22,25 +18,23 @@ pub fn compute() { ) .unwrap(); let node010 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, margin: taffy::geometry::Rect { + left: zero(), right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, @@ -51,7 +45,7 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -64,7 +58,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrap_reverse_column.rs b/benches/generated/wrap_reverse_column.rs index f8f2bffe6..9964bfeb6 100644 --- a/benches/generated/wrap_reverse_column.rs +++ b/benches/generated/wrap_reverse_column.rs @@ -3,56 +3,40 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(31f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(32f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(33f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(34f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -62,7 +46,6 @@ pub fn compute() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrap_reverse_column_fixed_size.rs b/benches/generated/wrap_reverse_column_fixed_size.rs index 9b4cf9e05..a2b3a32fc 100644 --- a/benches/generated/wrap_reverse_column_fixed_size.rs +++ b/benches/generated/wrap_reverse_column_fixed_size.rs @@ -3,80 +3,59 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrap_reverse_row.rs b/benches/generated/wrap_reverse_row.rs index 76481326f..413cdec3f 100644 --- a/benches/generated/wrap_reverse_row.rs +++ b/benches/generated/wrap_reverse_row.rs @@ -3,62 +3,46 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(31f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(32f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(33f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(34f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/benches/generated/wrap_reverse_row_align_content_center.rs b/benches/generated/wrap_reverse_row_align_content_center.rs index 0c705506e..1cf705014 100644 --- a/benches/generated/wrap_reverse_row_align_content_center.rs +++ b/benches/generated/wrap_reverse_row_align_content_center.rs @@ -3,76 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/benches/generated/wrap_reverse_row_align_content_flex_start.rs b/benches/generated/wrap_reverse_row_align_content_flex_start.rs index ff6a3d818..de6b0855d 100644 --- a/benches/generated/wrap_reverse_row_align_content_flex_start.rs +++ b/benches/generated/wrap_reverse_row_align_content_flex_start.rs @@ -3,76 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::FlexStart, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/benches/generated/wrap_reverse_row_align_content_space_around.rs b/benches/generated/wrap_reverse_row_align_content_space_around.rs index dec703cff..4d0ab8aa5 100644 --- a/benches/generated/wrap_reverse_row_align_content_space_around.rs +++ b/benches/generated/wrap_reverse_row_align_content_space_around.rs @@ -3,76 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::SpaceAround, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::SpaceAround), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/benches/generated/wrap_reverse_row_align_content_stretch.rs b/benches/generated/wrap_reverse_row_align_content_stretch.rs index 0480eb5ef..c2efee912 100644 --- a/benches/generated/wrap_reverse_row_align_content_stretch.rs +++ b/benches/generated/wrap_reverse_row_align_content_stretch.rs @@ -3,75 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/benches/generated/wrap_reverse_row_single_line_different_size.rs b/benches/generated/wrap_reverse_row_single_line_different_size.rs index 7f0d73f51..eb98acbb9 100644 --- a/benches/generated/wrap_reverse_row_single_line_different_size.rs +++ b/benches/generated/wrap_reverse_row_single_line_different_size.rs @@ -3,76 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::FlexStart, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/benches/generated/wrap_row.rs b/benches/generated/wrap_row.rs index 8723125c3..b2bfe7287 100644 --- a/benches/generated/wrap_row.rs +++ b/benches/generated/wrap_row.rs @@ -3,62 +3,46 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(31f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(32f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(33f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(34f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/benches/generated/wrap_row_align_items_center.rs b/benches/generated/wrap_row_align_items_center.rs index 1b36db731..db984a696 100644 --- a/benches/generated/wrap_row_align_items_center.rs +++ b/benches/generated/wrap_row_align_items_center.rs @@ -3,63 +3,47 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/benches/generated/wrap_row_align_items_flex_end.rs b/benches/generated/wrap_row_align_items_flex_end.rs index 016078517..fe4ab8bad 100644 --- a/benches/generated/wrap_row_align_items_flex_end.rs +++ b/benches/generated/wrap_row_align_items_flex_end.rs @@ -3,63 +3,47 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexEnd, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::End), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/benches/generated/wrapped_column_max_height.rs b/benches/generated/wrapped_column_max_height.rs index 4cdea6477..3e27e5849 100644 --- a/benches/generated/wrapped_column_max_height.rs +++ b/benches/generated/wrapped_column_max_height.rs @@ -3,64 +3,50 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(500f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - right: taffy::style::LengthPercentageAuto::Points(20f32), - top: taffy::style::LengthPercentageAuto::Points(20f32), - bottom: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(20f32), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: taffy::style::LengthPercentageAuto::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - align_content: taffy::style::AlignContent::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(700f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrapped_column_max_height_flex.rs b/benches/generated/wrapped_column_max_height_flex.rs index 3d5a621ed..04cf0dc86 100644 --- a/benches/generated/wrapped_column_max_height_flex.rs +++ b/benches/generated/wrapped_column_max_height_flex.rs @@ -3,70 +3,56 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(500f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - right: taffy::style::LengthPercentageAuto::Points(20f32), - top: taffy::style::LengthPercentageAuto::Points(20f32), - bottom: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(20f32), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: taffy::style::LengthPercentageAuto::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - align_content: taffy::style::AlignContent::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(700f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrapped_row_within_align_items_center.rs b/benches/generated/wrapped_row_within_align_items_center.rs index 53046ed7a..f396e317b 100644 --- a/benches/generated/wrapped_row_within_align_items_center.rs +++ b/benches/generated/wrapped_row_within_align_items_center.rs @@ -3,30 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -38,11 +30,10 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrapped_row_within_align_items_flex_end.rs b/benches/generated/wrapped_row_within_align_items_flex_end.rs index d0fa4da7c..7e59b3a31 100644 --- a/benches/generated/wrapped_row_within_align_items_flex_end.rs +++ b/benches/generated/wrapped_row_within_align_items_flex_end.rs @@ -3,30 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -38,11 +30,10 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/benches/generated/wrapped_row_within_align_items_flex_start.rs b/benches/generated/wrapped_row_within_align_items_flex_start.rs index 0e92f720e..2659b69d2 100644 --- a/benches/generated/wrapped_row_within_align_items_flex_start.rs +++ b/benches/generated/wrapped_row_within_align_items_flex_start.rs @@ -3,30 +3,22 @@ pub fn compute() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -38,11 +30,10 @@ pub fn compute() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/deny.toml b/deny.toml index 6502e3bf5..40cf233fd 100644 --- a/deny.toml +++ b/deny.toml @@ -28,7 +28,12 @@ highlight = "all" skip = [ # Bypass problems with wildcard dependencies for dev-dependncies. # Proper fix requires https://github.com/EmbarkStudios/cargo-deny/issues/448 - { name = "taffy" } + { name = "taffy" }, + + # This dependency won't actually end up in the final binary anyway as it a sub-dependency + # of num-cpus and atty only when targetted the hermit unikernel OS + # (https://github.com/hermitcore/rusty-hermit) + { name = "hermit-abi" } ] [sources] diff --git a/docs/style-properties.md b/docs/style-properties.md new file mode 100644 index 000000000..a69018b6d --- /dev/null +++ b/docs/style-properties.md @@ -0,0 +1,53 @@ +# Style Properties + +Y = Supported in spec and implemented in Taffy +~Y = Implemented in Taffy, but not thoroughly tested +N = Supported in spec but not implemented in Taffy +\- = Not applicable to layout mode +1-5 = Priorities for a phased implementation of CSS Grid + +| Property | Flex | Grid | Description | +| --- | --- | --- | --- | +| **Layout Mode** | | | | +| `display` | Y | Y | What layout strategy should be used? | +| **Position** | | | | +| `position_type` | Y | 2 | Absolute vs. in-flow position | +| `position` | Y | 2 | How should the position of this element be tweaked relative to the layout defined? | +| **Item size** | | | | +| `size` | Y | Y | The nominal height and width of item | +| `min_size` | Y | Y | The minimum height and width of the item | +| `max_size` | Y | Y | The maximum height and width of the item | +| `aspect_ratio` | Y | 3 | The preferred aspect ratio (calculated as width divided by height) | +| **Item spacing** | | | | +| `padding` | Y | ~Y | How large should the padding be on each side? | +| `border` | Y | ~Y | How large should the border be on each side? | +| `margin` | Y | ~Y | How large should the margin be on each side? | +| `gap` | Y | Y | The size of the vertical and horizontal gaps between flex items / grid rows | +| **Alignment** | | | | +| `align_items` | Y | Y | How should items be aligned relative to the cross axis? | +| `align_self` | Y | Y | Should this item violate the cross axis alignment specified by its parent's [`AlignItems`]? | +| `align_content` | Y | Y | How should content contained within this item be aligned relative to the cross axis? | +| `justify_items` | - | Y | How should items be aligned relative to the main axis? | +| `justify_self` | - | Y | Should this item violate the main axis alignment specified by its parent's [`AlignItems`]? | +| `justify_content` | Y | Y | How should content contained within this item be aligned relative to the main axis? | +| **Flexbox** | | | | +| `flex_direction` | Y | - | Which direction does the main axis flow in? | +| `flex_wrap` | Y | - | Should elements wrap, or stay in a single line? | +| `flex_basis` | Y | - | Sets the initial main axis size of the item | +| `flex_grow` | Y | - | The relative rate at which this item grows when it is expanding to fill space | +| `flex_shrink` | Y | - | The relative rate at which this item shrinks when it is contracting to fit into space | +| **CSS Grid (Container)** | | | | +| `grid-template-columns` | - | Y | The track sizing functions of the grid's explicit columns | +| `grid-template-rows` | - | Y | The track sizing functions of the grid's explicit rows | +| `grid-template-areas` | - | 5 | Defines named grid areas | +| `grid-auto-rows` | - | Y | Track sizing functions for the grid's implicitly generated rows | +| `grid-auto-columns` | - | Y | Track sizing functions for the grid's implicitly generated columns | +| `grid-auto-flow` | - | Y | Whether auto-placed items are placed row-wise or column-wise. And sparsely or densely. | +| **CSS Grid (Child)** | | | | +| `grid-row-start` | - | Y | The (row) grid line the item starts at (or a span) | +| `grid-row-end` | - | Y | The (row) grid line the item ends at (or a span) | +| `grid-column-start` | - | Y | The (column) grid line the item starts at (or a span) | +| `grid-column-end` | - | Y | The (column) grid line the item end at (or a span) | +| `grid-column` | - | 4 | Shorthand for grid-column-start/grid-column-end | +| `grid-row` | - | 4 | Shorthand for grid-row-start/grid-row-end | +| `grid-area` | - | 5 | Accepts either shorthand row/column-start/end or a named grid area | diff --git a/examples/basic.rs b/examples/basic.rs index 80197fda3..bc196ad1a 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), taffy::error::TaffyError> { let node = taffy.new_with_children( Style { size: Size { width: Dimension::Points(100.0), height: Dimension::Points(100.0) }, - justify_content: JustifyContent::Center, + justify_content: Some(JustifyContent::Center), ..Default::default() }, &[child], diff --git a/examples/flexbox-gap.rs b/examples/flexbox_gap.rs similarity index 100% rename from examples/flexbox-gap.rs rename to examples/flexbox_gap.rs diff --git a/examples/grid_holy_grail.rs b/examples/grid_holy_grail.rs new file mode 100644 index 000000000..951d39be0 --- /dev/null +++ b/examples/grid_holy_grail.rs @@ -0,0 +1,48 @@ +// This creates a so-called "holy grail" layout using the CSS Grid layout algorithm +// See: https://en.wikipedia.org/wiki/Holy_grail_(web_design) + +// NOTE: This example requires the `experimental_grid` feature flag to be enabled. + +#[cfg(not(feature = "experimental_grid"))] +fn main() { + println!("Error: this example requires the 'experimental_grid' feature to be enabled"); + println!("Try:"); + println!(" cargo run --example grid_holy_grail --features experimental_grid") +} + +#[cfg(feature = "experimental_grid")] +fn default() -> T { + Default::default() +} + +#[cfg(feature = "experimental_grid")] +fn main() -> Result<(), taffy::error::TaffyError> { + use taffy::prelude::*; + + let mut taffy = Taffy::new(); + + // Setup the grid + let root_style = Style { + display: Display::Grid, + size: Size { width: points(800.0), height: points(600.0) }, + grid_template_columns: vec![points(250.0), flex(1.0), points(250.0)], + grid_template_rows: vec![points(150.0), flex(1.0), points(150.0)], + ..default() + }; + + // Define the child nodes + let header = taffy.new_leaf(Style { grid_row: line(1), grid_column: span(3), ..default() })?; + let left_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(1), ..default() })?; + let content_area = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(2), ..default() })?; + let right_sidebar = taffy.new_leaf(Style { grid_row: line(2), grid_column: line(3), ..default() })?; + let footer = taffy.new_leaf(Style { grid_row: line(3), grid_column: span(3), ..default() })?; + + // Create the container with the children + let root = taffy.new_with_children(root_style, &[header, left_sidebar, content_area, right_sidebar, footer])?; + + // Compute layout and print result + taffy.compute_layout(root, Size { width: points(800.0), height: points(600.0) })?; + taffy::debug::print_tree(&taffy, root); + + Ok(()) +} diff --git a/scripts/gentest/Cargo.toml b/scripts/gentest/Cargo.toml index 6dfad54c9..6669b24c4 100644 --- a/scripts/gentest/Cargo.toml +++ b/scripts/gentest/Cargo.toml @@ -8,7 +8,6 @@ edition = "2018" convert_case = "0.6.0" env_logger = "0.10.0" fantoccini = "0.19.0" -json = "0.12.0" log = "0.4" proc-macro2 = "1.0.6" quote = "1.0.2" diff --git a/scripts/gentest/src/main.rs b/scripts/gentest/src/main.rs index 75a7a1716..4ad16ac72 100644 --- a/scripts/gentest/src/main.rs +++ b/scripts/gentest/src/main.rs @@ -4,10 +4,10 @@ use std::process::Command; use convert_case::{Case, Casing}; use fantoccini::{Client, ClientBuilder}; - use log::*; use proc_macro2::{Span, TokenStream}; use quote::{format_ident, quote}; +use serde_json::Value; use syn::Ident; #[tokio::main] @@ -24,6 +24,7 @@ async fn main() { let mut fixtures: Vec<_> = fixtures .into_iter() .filter_map(|a| a.ok()) + .filter(|f| !f.file_name().to_string_lossy().starts_with('x')) // ignore tests beginning with x .filter(|f| f.path().is_file() && f.path().extension().map(|p| p == "html").unwrap_or(false)) .map(|f| { let fixture_path = f.path(); @@ -80,22 +81,38 @@ async fn main() { .iter() .map(|(name, _)| { let bench_mod = Ident::new(name, Span::call_site()); - quote!(#bench_mod::compute()) + if name.starts_with("grid") { + quote!(#[cfg(feature = "experimental_grid")] #bench_mod::compute()) + } else { + quote!(#bench_mod::compute()) + } }) .collect(); - let test_mods = test_descs + let mod_statemnts = test_descs .iter() .map(|(name, _)| { - let name = Ident::new(name, Span::call_site()); - quote!(mod #name;) + let name_ident = Ident::new(name, Span::call_site()); + if name.starts_with("grid") { + quote!(#[cfg(feature = "experimental_grid")] mod #name_ident;) + } else { + quote!(mod #name_ident;) + } }) .fold(quote!(), |a, b| quote!(#a #b)); + let generic_measure_function = generate_generic_measure_function(); + + let test_mod_file = quote!( + #generic_measure_function + #mod_statemnts + ); - let bench_mods = quote!( + let bench_mod_file = quote!( use criterion::{criterion_group, criterion_main, Criterion}; - #test_mods + #generic_measure_function + + #mod_statemnts fn benchmark(c: &mut Criterion) { c.bench_function("generated benchmarks", |b| { @@ -117,7 +134,7 @@ async fn main() { debug!("writing {} to disk...", &name); fs::write(bench_filename, bench_body.to_string()).unwrap(); } - fs::write(benches_base_path.join("mod.rs"), bench_mods.to_string()).unwrap(); + fs::write(benches_base_path.join("mod.rs"), bench_mod_file.to_string()).unwrap(); info!("writing generated test file to disk..."); let tests_base_path = repo_root.join("tests").join("generated"); @@ -129,13 +146,13 @@ async fn main() { debug!("writing {} to disk...", &name); fs::write(test_filename, test_body.to_string()).unwrap(); } - fs::write(tests_base_path.join("mod.rs"), test_mods.to_string()).unwrap(); + fs::write(tests_base_path.join("mod.rs"), test_mod_file.to_string()).unwrap(); info!("formatting the source directory"); Command::new("cargo").arg("fmt").current_dir(repo_root).status().unwrap(); } -async fn test_root_element(client: Client, name: String, fixture_path: impl AsRef) -> (String, json::JsonValue) { +async fn test_root_element(client: Client, name: String, fixture_path: impl AsRef) -> (String, Value) { let fixture_path = fixture_path.as_ref(); let url = format!("file://{}", fixture_path.display()); @@ -146,11 +163,11 @@ async fn test_root_element(client: Client, name: String, fixture_path: impl AsRe .await .unwrap(); let description_string = description.as_str().unwrap(); - let description = json::parse(description_string).unwrap(); + let description = serde_json::from_str(description_string).unwrap(); (name, description) } -fn generate_bench(description: &json::JsonValue) -> TokenStream { +fn generate_bench(description: &Value) -> TokenStream { let node_description = generate_node("node", description); quote!( @@ -164,7 +181,7 @@ fn generate_bench(description: &json::JsonValue) -> TokenStream { ) } -fn generate_test(name: impl AsRef, description: &json::JsonValue) -> TokenStream { +fn generate_test(name: impl AsRef, description: &Value) -> TokenStream { let name = name.as_ref(); let name = Ident::new(name, Span::call_site()); let node_description = generate_node("node", description); @@ -188,10 +205,10 @@ fn generate_test(name: impl AsRef, description: &json::JsonValue) -> TokenS ) } -fn generate_assertions(ident: &str, node: &json::JsonValue) -> TokenStream { +fn generate_assertions(ident: &str, node: &Value) -> TokenStream { let layout = &node["layout"]; - let read_f32 = |s: &str| layout[s].as_f32().unwrap(); + let read_f32 = |s: &str| layout[s].as_f64().unwrap() as f32; let width = read_f32("width"); let height = read_f32("height"); let x = read_f32("x"); @@ -199,7 +216,7 @@ fn generate_assertions(ident: &str, node: &json::JsonValue) -> TokenStream { let children = { let mut c = Vec::new(); - if let json::JsonValue::Array(ref value) = node["children"] { + if let Value::Array(ref value) = node["children"] { for (idx, child) in value.iter().enumerate() { c.push(generate_assertions(&format!("{ident}{idx}"), child)); } @@ -220,37 +237,37 @@ fn generate_assertions(ident: &str, node: &json::JsonValue) -> TokenStream { } macro_rules! dim_quoted_renamed { - ($obj:ident, $in_name:ident, $out_name:ident, $value_mapper:ident) => { + ($obj:ident, $in_name:ident, $out_name:ident, $value_mapper:ident, $default:expr) => { let $out_name = match $obj.get(stringify!($in_name)) { - Some(json::JsonValue::Object(ref value)) => { + Some(Value::Object(ref value)) => { let dim = $value_mapper(value); quote!($out_name: #dim,) } - _ => quote!(), + _ => { + let dim = $default; + quote!($out_name: #dim,) + } }; }; } macro_rules! dim_quoted { - ($obj:ident, $dim_name:ident, $value_mapper: ident) => { - dim_quoted_renamed!($obj, $dim_name, $dim_name, $value_mapper) + ($obj:ident, $dim_name:ident, $value_mapper: ident, $default:expr) => { + dim_quoted_renamed!($obj, $dim_name, $dim_name, $value_mapper, $default) }; } macro_rules! edges_quoted { ($style:ident, $val:ident, $value_mapper:ident, $default_value: expr) => { let $val = match $style[stringify!($val)] { - json::JsonValue::Object(ref value) => { - dim_quoted!(value, left, $value_mapper); - dim_quoted!(value, right, $value_mapper); - dim_quoted!(value, top, $value_mapper); - dim_quoted!(value, bottom, $value_mapper); - - let def = $default_value; + Value::Object(ref value) => { + dim_quoted!(value, left, $value_mapper, $default_value); + dim_quoted!(value, right, $value_mapper, $default_value); + dim_quoted!(value, top, $value_mapper, $default_value); + dim_quoted!(value, bottom, $value_mapper, $default_value); let edges = quote!(taffy::geometry::Rect { #left #right #top #bottom - ..#def }); quote!($val: #edges,) @@ -260,36 +277,47 @@ macro_rules! edges_quoted { }; } -fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { +fn generate_node(ident: &str, node: &Value) -> TokenStream { let style = &node["style"]; - fn quote_object_prop( + fn snake_case_ident(ident_name: &str) -> Ident { + let name_snake_case = ident_name.to_case(Case::Snake); + format_ident!("{}", name_snake_case) + } + + fn quote_object_value( prop_name: &str, - style: &json::JsonValue, - quoter: impl Fn(&json::object::Object) -> TokenStream, - ) -> TokenStream { - let prop_name_snake_case = prop_name.to_case(Case::Snake); - let prop_name_camel_case = prop_name.to_case(Case::Camel); - let prop_name_ident = format_ident!("{}", prop_name_snake_case); - match style[prop_name_camel_case] { - json::JsonValue::Object(ref value) => { - let prop_value = quoter(value); - quote!(#prop_name_ident: #prop_value,) - } - _ => quote!(), + style: &Value, + quoter: impl Fn(&serde_json::Map) -> TokenStream, + ) -> Option { + match style[prop_name.to_case(Case::Camel)] { + Value::Object(ref value) => Some(quoter(value)), + _ => None, } } - fn quote_array_prop( + fn quote_prop(prop_name: &str, value: TokenStream) -> TokenStream { + let ident = snake_case_ident(prop_name); + quote!(#ident: #value,) + } + + fn quote_object_prop( prop_name: &str, - style: &json::JsonValue, - quoter: impl Fn(&[json::JsonValue]) -> TokenStream, + style: &Value, + quoter: impl Fn(&serde_json::Map) -> TokenStream, ) -> TokenStream { + match quote_object_value(prop_name, style, quoter) { + Some(prop_value) => quote_prop(prop_name, prop_value), + None => quote!(), + } + } + + fn quote_array_prop(prop_name: &str, style: &Value, quoter: impl Fn(&[Value]) -> TokenStream) -> TokenStream { let prop_name_snake_case = prop_name.to_case(Case::Snake); let prop_name_camel_case = prop_name.to_case(Case::Camel); let prop_name_ident = format_ident!("{}", prop_name_snake_case); match style[prop_name_camel_case] { - json::JsonValue::Array(ref value) => { + Value::Array(ref value) => { let prop_value = quoter(value); quote!(#prop_name_ident: #prop_value,) } @@ -297,40 +325,20 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { } } - // This is currently unused, but leaving for future use. - #[allow(dead_code)] - fn quote_string_prop( - prop_name: &str, - style: &json::JsonValue, - quoter: impl Fn(&str) -> TokenStream, - ) -> TokenStream { - let prop_name_snake_case = prop_name.to_case(Case::Snake); - let prop_name_camel_case = prop_name.to_case(Case::Camel); - let prop_name_ident = format_ident!("{}", prop_name_snake_case); - match style[prop_name_camel_case] { - json::JsonValue::Short(ref value) => { - let prop_value = quoter(value.as_ref()); - quote!(#prop_name_ident: #prop_value,) - } - json::JsonValue::String(ref value) => { - let prop_value = quoter(value.as_ref()); - quote!(#prop_name_ident: #prop_value,) - } - _ => quote!(), + fn get_string_value<'a, 'b, 'c: 'b>(prop_name: &'a str, style: &'c Value) -> Option<&'b str> { + match style[prop_name.to_case(Case::Camel)] { + Value::String(ref value) => Some(value), + _ => None, } } - fn quote_number_prop>( - prop_name: &str, - style: &json::JsonValue, - quoter: impl Fn(T) -> TokenStream, - ) -> TokenStream { + fn quote_number_prop(prop_name: &str, style: &Value, quoter: impl Fn(f32) -> TokenStream) -> TokenStream { let prop_name_snake_case = prop_name.to_case(Case::Snake); let prop_name_camel_case = prop_name.to_case(Case::Camel); let prop_name_ident = format_ident!("{}", prop_name_snake_case); match style[prop_name_camel_case] { - json::JsonValue::Number(ref value) => { - let prop_value = quoter((*value).into()); + Value::Number(ref value) => { + let prop_value = quoter(value.as_f64().unwrap() as f32); quote!(#prop_name_ident: #prop_value,) } _ => quote!(), @@ -338,7 +346,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { } let display = match style["display"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "none" => quote!(display: taffy::style::Display::None,), "grid" => quote!(display: taffy::style::Display::Grid,), _ => quote!(display: taffy::style::Display::Flex,), @@ -347,7 +355,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let position_type = match style["positionType"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "absolute" => quote!(position_type: taffy::style::PositionType::Absolute,), _ => quote!(), }, @@ -355,7 +363,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let direction = match style["direction"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "rtl" => quote!(direction: taffy::style::Direction::RTL,), "ltr" => quote!(direction: taffy::style::Direction::LTR,), _ => quote!(), @@ -364,7 +372,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let flex_direction = match style["flexDirection"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "row-reverse" => quote!(flex_direction: taffy::style::FlexDirection::RowReverse,), "column" => quote!(flex_direction: taffy::style::FlexDirection::Column,), "column-reverse" => quote!(flex_direction: taffy::style::FlexDirection::ColumnReverse,), @@ -374,7 +382,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let flex_wrap = match style["flexWrap"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "wrap" => quote!(flex_wrap: taffy::style::FlexWrap::Wrap,), "wrap-reverse" => quote!(flex_wrap: taffy::style::FlexWrap::WrapReverse,), _ => quote!(), @@ -383,7 +391,7 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let overflow = match style["overflow"] { - json::JsonValue::Short(ref value) => match value.as_ref() { + Value::String(ref value) => match value.as_ref() { "hidden" => quote!(overflow: taffy::style::Overflow::Hidden,), "scroll" => quote!(overflow: taffy::style::Overflow::Scroll,), _ => quote!(), @@ -392,48 +400,76 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { }; let align_items = match style["alignItems"] { - json::JsonValue::Short(ref value) => match value.as_ref() { - "flex-start" => quote!(align_items: taffy::style::AlignItems::FlexStart,), - "flex-end" => quote!(align_items: taffy::style::AlignItems::FlexEnd,), - "center" => quote!(align_items: taffy::style::AlignItems::Center,), - "baseline" => quote!(align_items: taffy::style::AlignItems::Baseline,), + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(align_items: Some(taffy::style::AlignItems::Start),), + "flex-end" | "end" => quote!(align_items: Some(taffy::style::AlignItems::End),), + "center" => quote!(align_items: Some(taffy::style::AlignItems::Center),), + "baseline" => quote!(align_items: Some(taffy::style::AlignItems::Baseline),), + "stretch" => quote!(align_items: Some(taffy::style::AlignItems::Stretch),), _ => quote!(), }, _ => quote!(), }; let align_self = match style["alignSelf"] { - json::JsonValue::Short(ref value) => match value.as_ref() { - "flex-start" => quote!(align_self: taffy::style::AlignSelf::FlexStart,), - "flex-end" => quote!(align_self: taffy::style::AlignSelf::FlexEnd,), - "center" => quote!(align_self: taffy::style::AlignSelf::Center,), - "baseline" => quote!(align_self: taffy::style::AlignSelf::Baseline,), - "stretch" => quote!(align_self: taffy::style::AlignSelf::Stretch,), + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(align_self: Some(taffy::style::AlignSelf::Start),), + "flex-end" | "end" => quote!(align_self: Some(taffy::style::AlignSelf::End),), + "center" => quote!(align_self: Some(taffy::style::AlignSelf::Center),), + "baseline" => quote!(align_self: Some(taffy::style::AlignSelf::Baseline),), + "stretch" => quote!(align_self: Some(taffy::style::AlignSelf::Stretch),), + _ => quote!(), + }, + _ => quote!(), + }; + + let justify_items = match style["justifyItems"] { + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(justify_items: Some(taffy::style::JustifyItems::Start),), + "flex-end" | "end" => quote!(justify_items: Some(taffy::style::JustifyItems::End),), + "center" => quote!(justify_items: Some(taffy::style::JustifyItems::Center),), + "baseline" => quote!(justify_items: Some(taffy::style::JustifyItems::Baseline),), + "stretch" => quote!(justify_items: Some(taffy::style::JustifyItems::Stretch),), + _ => quote!(), + }, + _ => quote!(), + }; + + let justify_self = match style["justifySelf"] { + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(justify_self: Some(taffy::style::JustifySelf::Start),), + "flex-end" | "end" => quote!(justify_self: Some(taffy::style::JustifySelf::End),), + "center" => quote!(justify_self: Some(taffy::style::JustifySelf::Center),), + "baseline" => quote!(justify_self: Some(taffy::style::JustifySelf::Baseline),), + "stretch" => quote!(justify_self: Some(taffy::style::JustifySelf::Stretch),), _ => quote!(), }, _ => quote!(), }; let align_content = match style["alignContent"] { - json::JsonValue::Short(ref value) => match value.as_ref() { - "flex-start" => quote!(align_content: taffy::style::AlignContent::FlexStart,), - "flex-end" => quote!(align_content: taffy::style::AlignContent::FlexEnd,), - "center" => quote!(align_content: taffy::style::AlignContent::Center,), - "space-between" => quote!(align_content: taffy::style::AlignContent::SpaceBetween,), - "space-around" => quote!(align_content: taffy::style::AlignContent::SpaceAround,), - "space-evenly" => quote!(align_content: taffy::style::AlignContent::SpaceEvenly,), + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(align_content: Some(taffy::style::AlignContent::Start),), + "flex-end" | "end" => quote!(align_content: Some(taffy::style::AlignContent::End),), + "center" => quote!(align_content: Some(taffy::style::AlignContent::Center),), + "stretch" => quote!(align_content: Some(taffy::style::AlignContent::Stretch),), + "space-between" => quote!(align_content: Some(taffy::style::AlignContent::SpaceBetween),), + "space-around" => quote!(align_content: Some(taffy::style::AlignContent::SpaceAround),), + "space-evenly" => quote!(align_content: Some(taffy::style::AlignContent::SpaceEvenly),), _ => quote!(), }, _ => quote!(), }; let justify_content = match style["justifyContent"] { - json::JsonValue::Short(ref value) => match value.as_ref() { - "flex-end" => quote!(justify_content: taffy::style::JustifyContent::FlexEnd,), - "center" => quote!(justify_content: taffy::style::JustifyContent::Center,), - "space-between" => quote!(justify_content: taffy::style::JustifyContent::SpaceBetween,), - "space-around" => quote!(justify_content: taffy::style::JustifyContent::SpaceAround,), - "space-evenly" => quote!(justify_content: taffy::style::JustifyContent::SpaceEvenly,), + Value::String(ref value) => match value.as_ref() { + "flex-start" | "start" => quote!(justify_content: Some(taffy::style::JustifyContent::Start),), + "flex-end" | "end" => quote!(justify_content: Some(taffy::style::JustifyContent::End),), + "center" => quote!(justify_content: Some(taffy::style::JustifyContent::Center),), + "stretch" => quote!(align_content: Some(taffy::style::AlignContent::Stretch),), + "space-between" => quote!(justify_content: Some(taffy::style::JustifyContent::SpaceBetween),), + "space-around" => quote!(justify_content: Some(taffy::style::JustifyContent::SpaceAround),), + "space-evenly" => quote!(justify_content: Some(taffy::style::JustifyContent::SpaceEvenly),), _ => quote!(), }, _ => quote!(), @@ -455,105 +491,139 @@ fn generate_node(ident: &str, node: &json::JsonValue) -> TokenStream { let grid_auto_columns = quote_array_prop("grid_auto_columns", style, generate_track_definition_list); let grid_auto_flow = quote_object_prop("grid_auto_flow", style, generate_grid_auto_flow); - let grid_row_start = quote_object_prop("grid_row_start", style, generate_grid_position); - let grid_row_end = quote_object_prop("grid_row_end", style, generate_grid_position); - let grid_column_start = quote_object_prop("grid_column_start", style, generate_grid_position); - let grid_column_end = quote_object_prop("grid_column_end", style, generate_grid_position); - - edges_quoted!(style, margin, generate_length_percentage_auto, quote!(Rect::zero())); - edges_quoted!(style, padding, generate_length_percentage, quote!(Rect::zero())); - edges_quoted!(style, border, generate_length_percentage, quote!(Rect::zero())); - edges_quoted!(style, position, generate_length_percentage_auto, quote!(Rect::auto())); - - let (children_body, children) = match node["children"] { - json::JsonValue::Array(ref value) => { - if !value.is_empty() { - let body = - value.iter().enumerate().map(|(i, child)| generate_node(&format!("{ident}{i}"), child)).collect(); - let idents = value - .iter() - .enumerate() - .map(|(i, _)| Ident::new(&format!("{ident}{i}"), Span::call_site())) - .collect::>(); - (body, quote!(&[#(#idents),*])) - } else { - (quote!(), quote!(&[])) - } - } - _ => (quote!(), quote!()), + let default_grid_placement = quote!(taffy::style::GridPlacement::Auto); + + let grid_row_start = quote_object_value("grid_row_start", style, generate_grid_position); + let grid_row_end = quote_object_value("grid_row_end", style, generate_grid_position); + let grid_row = if grid_row_start.is_some() || grid_row_end.is_some() { + quote_prop( + "grid_row", + generate_line( + grid_row_start.unwrap_or(default_grid_placement.clone()), + grid_row_end.unwrap_or(default_grid_placement.clone()), + ), + ) + } else { + quote!() + }; + + let grid_column_start = quote_object_value("grid_column_start", style, generate_grid_position); + let grid_column_end = quote_object_value("grid_column_end", style, generate_grid_position); + let grid_column = if grid_column_start.is_some() || grid_column_end.is_some() { + quote_prop( + "grid_column", + generate_line( + grid_column_start.unwrap_or(default_grid_placement.clone()), + grid_column_end.unwrap_or(default_grid_placement), + ), + ) + } else { + quote!() + }; + + let measure_func: Option<_> = get_string_value("text_content", node).map(generate_measure_function); + + edges_quoted!(style, margin, generate_length_percentage_auto, quote!(zero())); + edges_quoted!(style, padding, generate_length_percentage, quote!(zero())); + edges_quoted!(style, border, generate_length_percentage, quote!(zero())); + edges_quoted!(style, position, generate_length_percentage_auto, quote!(auto())); + + // Quote children + let child_descriptions: Vec = match node["children"] { + Value::Array(ref value) => value.clone(), + _ => vec![], + }; + let has_children = !child_descriptions.is_empty(); + let (children_body, children) = if has_children { + let body = child_descriptions + .iter() + .enumerate() + .map(|(i, child)| generate_node(&format!("{ident}{i}"), child)) + .collect(); + let idents = child_descriptions + .iter() + .enumerate() + .map(|(i, _)| Ident::new(&format!("{ident}{i}"), Span::call_site())) + .collect::>(); + (body, quote!(&[#(#idents),*])) + } else { + (quote!(), quote!()) }; let ident = Ident::new(ident, Span::call_site()); - quote!( - #children_body - let #ident = taffy.new_with_children( - taffy::style::Style { - #display - #direction - #position_type - #flex_direction - #flex_wrap - #overflow - #align_items - #align_self - #align_content - #justify_content - #flex_grow - #flex_shrink - #flex_basis - #gap - #grid_template_rows - #grid_template_columns - #grid_auto_rows - #grid_auto_columns - #grid_auto_flow - #grid_row_start - #grid_row_end - #grid_column_start - #grid_column_end - #size - #min_size - #max_size - #margin - #padding - #position - #border - ..Default::default() - }, - #children - // TODO: Only add children if they exist - ).unwrap();) + let style = quote!(taffy::style::Style { + #display + #direction + #position_type + #flex_direction + #flex_wrap + #overflow + #align_items + #align_self + #justify_items + #justify_self + #align_content + #justify_content + #flex_grow + #flex_shrink + #flex_basis + #gap + #grid_template_rows + #grid_template_columns + #grid_auto_rows + #grid_auto_columns + #grid_auto_flow + #grid_row + #grid_column + #size + #min_size + #max_size + #margin + #padding + #position + #border + ..Default::default() + }); + + if has_children { + quote!( + #children_body + let #ident = taffy.new_with_children(#style,#children).unwrap(); + ) + } else if measure_func.is_some() { + quote!(let #ident = taffy.new_leaf_with_measure(#style,#measure_func,).unwrap();) + } else { + quote!(let #ident = taffy.new_leaf(#style).unwrap();) + } } -fn generate_size(size: &json::object::Object) -> TokenStream { - dim_quoted!(size, width, generate_dimension); - dim_quoted!(size, height, generate_dimension); +fn generate_size(size: &serde_json::Map) -> TokenStream { + dim_quoted!(size, width, generate_dimension, quote!(auto())); + dim_quoted!(size, height, generate_dimension, quote!(auto())); quote!( taffy::geometry::Size { #width #height - ..Size::auto() } ) } -fn generate_gap(size: &json::object::Object) -> TokenStream { - dim_quoted_renamed!(size, column, width, generate_length_percentage); - dim_quoted_renamed!(size, row, height, generate_length_percentage); +fn generate_gap(size: &serde_json::Map) -> TokenStream { + dim_quoted_renamed!(size, column, width, generate_length_percentage, quote!(zero())); + dim_quoted_renamed!(size, row, height, generate_length_percentage, quote!(zero())); quote!( taffy::geometry::Size { #width #height - ..Size::zero() } ) } -fn generate_length_percentage(dimen: &json::object::Object) -> TokenStream { +fn generate_length_percentage(dimen: &serde_json::Map) -> TokenStream { let unit = dimen.get("unit").unwrap(); - let value = || dimen.get("value").unwrap().as_f32().unwrap(); + let value = || dimen.get("value").unwrap().as_f64().unwrap() as f32; match unit { - json::JsonValue::Short(ref unit) => match unit.as_ref() { + Value::String(ref unit) => match unit.as_ref() { "points" => { let value = value(); quote!(taffy::style::LengthPercentage::Points(#value)) @@ -568,12 +638,12 @@ fn generate_length_percentage(dimen: &json::object::Object) -> TokenStream { } } -fn generate_length_percentage_auto(dimen: &json::object::Object) -> TokenStream { +fn generate_length_percentage_auto(dimen: &serde_json::Map) -> TokenStream { let unit = dimen.get("unit").unwrap(); - let value = || dimen.get("value").unwrap().as_f32().unwrap(); + let value = || dimen.get("value").unwrap().as_f64().unwrap() as f32; match unit { - json::JsonValue::Short(ref unit) => match unit.as_ref() { + Value::String(ref unit) => match unit.as_ref() { "auto" => quote!(taffy::style::LengthPercentageAuto::Auto), "points" => { let value = value(); @@ -589,12 +659,12 @@ fn generate_length_percentage_auto(dimen: &json::object::Object) -> TokenStream } } -fn generate_dimension(dimen: &json::object::Object) -> TokenStream { +fn generate_dimension(dimen: &serde_json::Map) -> TokenStream { let unit = dimen.get("unit").unwrap(); - let value = || dimen.get("value").unwrap().as_f32().unwrap(); + let value = || dimen.get("value").unwrap().as_f64().unwrap() as f32; match unit { - json::JsonValue::Short(ref unit) => match unit.as_ref() { + Value::String(ref unit) => match unit.as_ref() { "auto" => quote!(taffy::style::Dimension::Auto), "points" => { let value = value(); @@ -610,7 +680,7 @@ fn generate_dimension(dimen: &json::object::Object) -> TokenStream { } } -fn generate_grid_auto_flow(auto_flow: &json::object::Object) -> TokenStream { +fn generate_grid_auto_flow(auto_flow: &serde_json::Map) -> TokenStream { let direction = auto_flow.get("direction").unwrap().as_str().unwrap(); let algorithm = auto_flow.get("algorithm").unwrap().as_str().unwrap(); @@ -623,20 +693,24 @@ fn generate_grid_auto_flow(auto_flow: &json::object::Object) -> TokenStream { } } -fn generate_grid_position(grid_position: &json::object::Object) -> TokenStream { +fn generate_line(start: TokenStream, end: TokenStream) -> TokenStream { + quote!(taffy::geometry::Line { start:#start, end:#end }) +} + +fn generate_grid_position(grid_position: &serde_json::Map) -> TokenStream { let kind = grid_position.get("kind").unwrap(); - let value = || grid_position.get("value").unwrap().as_f32().unwrap(); + let value = || grid_position.get("value").unwrap().as_f64().unwrap() as f32; match kind { - json::JsonValue::Short(ref kind) => match kind.as_ref() { - "auto" => quote!(taffy::style::GridLine::Auto), + Value::String(ref kind) => match kind.as_ref() { + "auto" => quote!(taffy::style::GridPlacement::Auto), "span" => { let value = value() as u16; - quote!(taffy::style::GridLine::Span(#value)) + quote!(taffy::style::GridPlacement::Span(#value)) } - "track" => { + "line" => { let value = value() as i16; - quote!(taffy::style::GridLine::Track(#value)) + quote!(taffy::style::GridPlacement::Line(#value)) } _ => unreachable!(), }, @@ -644,16 +718,16 @@ fn generate_grid_position(grid_position: &json::object::Object) -> TokenStream { } } -fn generate_track_definition_list(raw_list: &[json::JsonValue]) -> TokenStream { +fn generate_track_definition_list(raw_list: &[Value]) -> TokenStream { let list = raw_list.iter().map(|obj| match obj { - json::JsonValue::Object(inner) => generate_track_definition(inner), + Value::Object(inner) => generate_track_definition(inner), _ => unreachable!(), }); quote!(vec![#(#list),*]) } -fn generate_track_definition(track_definition: &json::object::Object) -> TokenStream { +fn generate_track_definition(track_definition: &serde_json::Map) -> TokenStream { let kind = track_definition.get("kind").unwrap().as_str().unwrap(); let name = || track_definition.get("name").unwrap().as_str().unwrap(); let arguments = || track_definition.get("arguments").unwrap(); @@ -661,19 +735,55 @@ fn generate_track_definition(track_definition: &json::object::Object) -> TokenSt match kind { "scalar" => generate_scalar_definition(track_definition), "function" => match (name(), arguments()) { - ("minmax", json::JsonValue::Array(arguments)) => { + ("fit-content", Value::Array(arguments)) => { + if arguments.len() != 1 { + panic!("fit-content function with the wrong number of arguments"); + } + let argument = match arguments[0] { + Value::Object(ref arg) => generate_scalar_definition(arg), + _ => unreachable!(), + }; + quote!(fit_content(#argument)) + } + ("minmax", Value::Array(arguments)) => { if arguments.len() != 2 { panic!("minmax function with the wrong number of arguments"); } let min = match arguments[0] { - json::JsonValue::Object(ref arg) => generate_scalar_definition(arg), + Value::Object(ref arg) => generate_scalar_definition(arg), _ => unreachable!(), }; let max = match arguments[1] { - json::JsonValue::Object(ref arg) => generate_scalar_definition(arg), + Value::Object(ref arg) => generate_scalar_definition(arg), _ => unreachable!(), }; - quote!(taffy::style::GridTrackSizingFunction::MinMax{ min: #min, max: #max }) + quote!(minmax(#min, #max)) + } + ("repeat", Value::Array(arguments)) => { + if arguments.len() < 2 { + panic!("repeat function with the wrong number of arguments"); + } + let repetition = match arguments[0] { + Value::Object(ref arg) => { + let unit = arg.get("unit").unwrap().as_str().unwrap(); + let value = || arg.get("value").unwrap().as_u64().unwrap() as u16; + + match unit { + "auto-fill" => quote!(GridTrackRepetition::AutoFill), + // Not yet implemented in taffy + "auto-fit" => quote!(GridTrackRepetition::AutoFit), + // Not yet implemented in taffy + "integer" => { + let repetition_count = value(); + quote!(GridTrackRepetition::Count(#repetition_count)) + } + _ => unreachable!(), + } + } + _ => unreachable!(), + }; + let track_list = generate_track_definition_list(&arguments[1..]); + quote!(repeat(#repetition, #track_list)) } // TODO: Add support for fit-content _ => unreachable!(), @@ -682,22 +792,84 @@ fn generate_track_definition(track_definition: &json::object::Object) -> TokenSt } } -fn generate_scalar_definition(track_definition: &json::object::Object) -> TokenStream { +fn generate_scalar_definition(track_definition: &serde_json::Map) -> TokenStream { let unit = || track_definition.get("unit").unwrap().as_str().unwrap(); - let value = || track_definition.get("value").unwrap().as_f32().unwrap(); + let value = || track_definition.get("value").unwrap().as_f64().unwrap() as f32; match unit() { - "auto" => quote!(taffy::style::GridTrackSizingFunction::Auto), - "min-content" => quote!(taffy::style::GridTrackSizingFunction::MinContent), - "max-content" => quote!(taffy::style::GridTrackSizingFunction::MaxContent), - "points" | "percent" => { - let value = generate_dimension(track_definition); - quote!(taffy::style::GridTrackSizingFunction::Fixed(#value)) - } - "fraction" => { - let value: f32 = value(); - quote!(taffy::style::GridTrackSizingFunction::Flex(#value)) + "auto" => quote!(auto()), + "min-content" => quote!(min_content()), + "max-content" => quote!(max_content()), + "points" | "percent" | "fraction" => { + let value = value(); + match unit() { + "points" => quote!(points(#value)), + "percent" => quote!(percent(#value)), + "fraction" => quote!(flex(#value)), + _ => unreachable!(), + } } _ => unreachable!(), } } + +fn generate_generic_measure_function() -> TokenStream { + quote!( + // WARNING: This function is generated by the gentest script. Do not edit directly + #[allow(dead_code)] + fn measure_standard_text( + known_dimensions: taffy::geometry::Size>, + available_space: taffy::geometry::Size, + text_content: &str, + ) -> taffy::geometry::Size { + use taffy::prelude::*; + const ZWS: char = '\u{200B}'; + const H_WIDTH: f32 = 10.0; + const H_HEIGHT: f32 = 10.0; + + if let Size { width: Some(width), height: Some(height) } = known_dimensions { + return Size { width, height }; + } + + let lines: Vec<&str> = text_content.split(ZWS).collect(); + if lines.is_empty() { + return Size::ZERO; + } + + let min_line_length: usize = lines.iter().map(|line| line.len()).max().unwrap_or(0); + let max_line_length: usize = lines.iter().map(|line| line.len()).sum(); + let width = known_dimensions.width.unwrap_or_else(|| match available_space.width { + AvailableSpace::MinContent => min_line_length as f32 * H_WIDTH, + AvailableSpace::MaxContent => max_line_length as f32 * H_WIDTH, + AvailableSpace::Definite(width) => { + width.min(max_line_length as f32 * H_WIDTH).max(min_line_length as f32 * H_WIDTH) + } + }); + let height = known_dimensions.height.unwrap_or_else(|| { + let width_line_length = (width / H_WIDTH).floor() as usize; + let mut line_count = 1; + let mut current_line_length = 0; + for line in &lines { + if current_line_length + line.len() > width_line_length { + line_count += 1; + current_line_length = line.len(); + } else { + current_line_length += line.len(); + }; + } + (line_count as f32) * H_HEIGHT + }); + + Size { width, height } + } + ) +} + +fn generate_measure_function(text_content: &str) -> TokenStream { + quote!( + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT : &str = #text_content; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }) + ) +} diff --git a/scripts/gentest/test_base_style.css b/scripts/gentest/test_base_style.css index d9c038e3a..e06d7c6e9 100644 --- a/scripts/gentest/test_base_style.css +++ b/scripts/gentest/test_base_style.css @@ -1,3 +1,18 @@ + +/* The font "silkscreen" subsetted to only contain the"H" (capital h) glyph + The "H" glyph in this font happens to be exactly 10 pixels wide by 14 high + Furthermore, we can use a line-height of 0.71428571428 to scale the height to 10 pixels + + By combining H's with zero-width space characters (​) we can reliably set an elements + min-content and max-content sizes. +*/ +@font-face { + font-family: 'silkscreen-h'; + src: url(data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAAOAABAAAAAAB7wAAAMkAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP0ZGVE0cGh4GVgCCWggoCWQRCAqBZIFjCw4AATYCJAMYBCAFhAgHRQxTG5IGAC4GnDLLNaI4Ih4+4mqyRg9HHA8fX6MqHp72+9+vvWfOXEdEkkaIJglvYpJJhEbI4o0QLSQ8tJ/ez/fn9/eeN4h3Sl/w0L7uB5CWVVeaGMPcBJ633fsTGVBiIcZj6bwqRjr/xwv9r0t5/9KdBfjyxtcttVqp2BpQ5igTsIwHKEClWemU7qWRJxTUvMlUEGFYTu6MiB4KAT+fp/dg+5v9Fv69218CBMZYBKQQOqEiEXk09nVq/s6XeKGtjZ/YGaTvuOsU8iDXv/GnFcEbKGugCQSgoGAFApzQKrBCmx3AUF9KE2vo188/xL88/d//tz8HAgCiEYBIJJqaQGH+cAUj836+xIwmiKdguu3lmr40xRRttVIHO9vba0mbR4MOy0bNii8ytRLxqinknInaInQ5/fyRo50El0++w51kOyRDQbdLiMP9JaQ7ndb6ImiT0iv8w9zYdBmYv0UBQkyZDRoYo2IJsAKAiqdaACFqHddRN6mnHNuQ1xoZxagOY6ibXWetv11yO7O8lNrMNr/YtP2GLBIM+xS27eNenffMPGrd71AqqStRoU7XEGjzf4SiWL7W1joeDmyy35U6kk1Hw1JyFFqXJYz6vaKF/UPjTYGsxZIgaOLfZSQfyPCjxejHY90mIBDM3vrQeXa2+LVrsW3mZzN9onlv0ZcgKGv+G/lfRwME063FM+sBMbP03UqzskBpxvIcqW+nHpxmAGDshSLqAEdAjLCAHWnsEopVMqjW2UVnh0M0C9zhiwk/+IqeEXzTFbu13w3E4Yl+FMuyKQ9LCUL8csB9bl9eLPMpwHKJgjRmMTEvLUUufpyCgjiMKi0nzCUqIS4vIAfDUqz1cJKPTefqCrvV87VoxnEZqOgQF58CRKEoDGFiQBg4hNjYhJj4l0Ng1adXbsD8Qm8ULUC3oeIOPrmyBGGh1yt5hDi40xlH52nomGIchmVkdMjyhaI87eSvdMkqisrJwRJagGndGDN+IzKKYlPa2tVb1UyE0Vm8E6WDQ+0fisnRquQDfePRqLVMer19ufM5pj3RRNRTJ2E/0i2NeZW75H150GioP1GlAAA=) format('woff2'); + font-weight: normal; + font-style: normal; +} + body { padding: 0; margin: 0; @@ -6,7 +21,7 @@ body { div, span, img { box-sizing: border-box; position: relative; - border: 0 solid black; + border: 0 solid red; margin: 0; padding: 0; display: flex; @@ -14,6 +29,14 @@ div, span, img { body > * { position: absolute; + border-color: red; +} + +#test-root { + font-family: silkscreen-h; + line-height: 0.71428571428; + font-size: 14px; + color: white; } div { diff --git a/scripts/gentest/test_helper.js b/scripts/gentest/test_helper.js index 376fd2a52..27462f75a 100644 --- a/scripts/gentest/test_helper.js +++ b/scripts/gentest/test_helper.js @@ -74,20 +74,27 @@ class TrackSizingParser { } _parseScalarItem(item) { - const res = parseDimension(item, { allowFrUnits: this.options.allowFrUnits }); + const res = parseRepetition(item) || parseDimension(item, { allowFrUnits: this.options.allowFrUnits }); if (!res) throw new Error(`Invalid scalar grid track sizing function ${item}`); return res; } } +function parseRepetition(input) { + if (input === "auto-fill") return { unit: 'auto-fill' }; + if (input === "auto-fit") return { unit: 'auto-fit' }; + if (/^[0-9]*$/.test(input)) return { 'unit': 'integer', value: parseInt(input, 10) }; + return undefined; +} + function parseDimension(input, options = { allowFrUnits: false }) { if (options.allowFrUnits && input.endsWith('fr')) return { unit: 'fraction', value: parseFloat(input.replace('fr','')) }; if (input.endsWith('px')) return { unit: 'points', value: parseFloat(input.replace('px','')) }; - if (input.endsWith('%')) return { unit: 'percent', value: parseFloat(input.replace('%','')) / 100 }; - if (input === 'auto') return { unit: 'auto' }; - if (input === 'min-content') return { unit: 'min-content' }; - if (input === 'max-content') return { unit: 'max-content' }; + if (input.endsWith('%')) return { unit: 'percent', value: parseFloat(input.replace('%','')) / 100 }; + if (input === 'auto') return { unit: 'auto' }; + if (input === 'min-content') return { unit: 'min-content' }; + if (input === 'max-content') return { unit: 'max-content' }; return undefined; } @@ -146,11 +153,12 @@ function parseGridAutoFlow(input) { function parseGridPosition(input) { if (input === 'auto') return { kind: 'auto' } if (/^span +\d+$/.test(input)) return { kind: 'span', value: parseInt(input.replace(/[^\d]/g, ''), 10)} - if (/^-?\d+$/.test(input)) return { kind: 'track', value: parseInt(input, 10)} + if (/^-?\d+$/.test(input)) return { kind: 'line', value: parseInt(input, 10)} return undefined; } function describeElement(e) { + return { style: { display: parseEnum(e.style.display), @@ -164,8 +172,10 @@ function describeElement(e) { alignItems: parseEnum(e.style.alignItems), alignSelf: parseEnum(e.style.alignSelf), + justifyItems: parseEnum(e.style.justifyItems), + justifySelf: parseEnum(e.style.justifySelf), + alignContent: parseEnum(e.style.alignContent), - justifyContent: parseEnum(e.style.justifyContent), flexGrow: parseNumber(e.style.flexGrow), @@ -218,6 +228,10 @@ function describeElement(e) { }), }, + // The textContent is used for generating intrinsic sizing measure funcs + // So we're only interested in the text content of leaf nodes + textContent: e.childElementCount === 0 && e.textContent.length && e.textContent !== "\n" ? e.textContent : undefined, + layout: { width: e.offsetWidth, height: e.offsetHeight, diff --git a/src/axis.rs b/src/axis.rs new file mode 100644 index 000000000..df52c902d --- /dev/null +++ b/src/axis.rs @@ -0,0 +1,85 @@ +//! Axis enums representing CSS Grid axis +use crate::geometry::{Rect, Size}; +use core::ops::Add; + +/// The simple absolute horizontal and vertical axis +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum AbsoluteAxis { + /// The horizontal axis + Horizontal, + /// The vertical axis + Vertical, +} + +impl AbsoluteAxis { + /// Returns the other variant of the enum + #[inline] + pub const fn other_axis(&self) -> Self { + match *self { + AbsoluteAxis::Horizontal => AbsoluteAxis::Vertical, + AbsoluteAxis::Vertical => AbsoluteAxis::Horizontal, + } + } +} + +impl Size { + #[inline(always)] + /// Get either the width or height depending on the AbsoluteAxis passed in + pub fn get_abs(self, axis: AbsoluteAxis) -> T { + match axis { + AbsoluteAxis::Horizontal => self.width, + AbsoluteAxis::Vertical => self.height, + } + } +} + +impl Rect { + #[inline(always)] + /// Get either the width or height depending on the AbsoluteAxis passed in + pub fn grid_axis_sum(self, axis: AbsoluteAxis) -> ::Output { + match axis { + AbsoluteAxis::Horizontal => self.left + self.right, + AbsoluteAxis::Vertical => self.top + self.bottom, + } + } +} + +/// The CSS abstract axis +/// https://www.w3.org/TR/css-writing-modes-3/#abstract-axes +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +pub enum AbstractAxis { + /// The axis in the inline dimension, i.e. the horizontal axis in horizontal writing modes and the vertical axis in vertical writing modes. + Inline, + /// The axis in the block dimension, i.e. the vertical axis in horizontal writing modes and the horizontal axis in vertical writing modes. + Block, +} + +impl AbstractAxis { + /// Returns the other variant of the enum + pub fn other(&self) -> AbstractAxis { + match *self { + AbstractAxis::Inline => AbstractAxis::Block, + AbstractAxis::Block => AbstractAxis::Inline, + } + } +} + +/// Container that holds an item in each absolute axis without specifying +/// what kind of item it is. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(crate) struct InBothAbsAxis { + /// The item in the horizontal axis + pub horizontal: T, + /// The item in the vertical axis + pub vertical: T, +} + +impl InBothAbsAxis { + /// Get the contained item based on the AbsoluteAxis passed + pub fn get(&self, axis: AbsoluteAxis) -> T { + match axis { + AbsoluteAxis::Horizontal => self.horizontal, + AbsoluteAxis::Vertical => self.vertical, + } + } +} diff --git a/src/compute/common/alignment.rs b/src/compute/common/alignment.rs new file mode 100644 index 000000000..9920e8a9a --- /dev/null +++ b/src/compute/common/alignment.rs @@ -0,0 +1,76 @@ +//! Generic CSS alignment code that is shared between both the Flexbox and CSS Grid algorithms. +use crate::style::AlignContent; + +/// Generic alignment function that is used: +/// - For both align-content and justify-content alignment +/// - For both the Flexbox and CSS Grid algorithms +/// CSS Grid does not apply gaps as part of alignment, so the gap parameter should +/// always be set to zero for CSS Grid. +pub(crate) fn compute_alignment_offset( + free_space: f32, + num_items: usize, + gap: f32, + alignment_mode: AlignContent, + layout_is_reversed: bool, + is_first: bool, +) -> f32 { + match alignment_mode { + AlignContent::Start => { + if is_first { + if layout_is_reversed { + free_space + } else { + 0.0 + } + } else { + gap + } + } + AlignContent::End => { + if is_first { + if !layout_is_reversed { + free_space + } else { + 0.0 + } + } else { + gap + } + } + AlignContent::Center => { + if is_first { + free_space / 2.0 + } else { + gap + } + } + AlignContent::Stretch => { + if is_first { + 0.0 + } else { + gap + } + } + AlignContent::SpaceBetween => { + if is_first { + 0.0 + } else { + gap + (free_space / (num_items - 1) as f32) + } + } + AlignContent::SpaceAround => { + if is_first { + (free_space / num_items as f32) / 2.0 + } else { + gap + (free_space / num_items as f32) + } + } + AlignContent::SpaceEvenly => { + if is_first { + free_space / (num_items + 1) as f32 + } else { + gap + (free_space / (num_items + 1) as f32) + } + } + } +} diff --git a/src/compute/common/mod.rs b/src/compute/common/mod.rs new file mode 100644 index 000000000..ca1e1a85e --- /dev/null +++ b/src/compute/common/mod.rs @@ -0,0 +1,2 @@ +//! Generic code that is shared between multiple layout algorithms +pub(crate) mod alignment; diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs index fc4aaa558..6eb546859 100644 --- a/src/compute/flexbox.rs +++ b/src/compute/flexbox.rs @@ -3,14 +3,17 @@ //! Note that some minor steps appear to be missing: see https://github.com/DioxusLabs/taffy/issues for more information. use core::f32; +use crate::compute::common::alignment::compute_alignment_offset; use crate::compute::compute_node_layout; use crate::geometry::{Point, Rect, Size}; -use crate::layout::{AvailableSpace, Layout, RunMode, SizingMode}; +use crate::layout::{Layout, RunMode, SizingMode}; use crate::math::MaybeMath; use crate::node::Node; +use crate::prelude::TaffyMaxContent; use crate::resolve::{MaybeResolve, ResolveOrZero}; use crate::style::{ - AlignContent, AlignSelf, Dimension, Display, FlexWrap, JustifyContent, LengthPercentageAuto, PositionType, + AlignContent, AlignItems, AlignSelf, AvailableSpace, Dimension, Display, FlexWrap, JustifyContent, + LengthPercentageAuto, PositionType, }; use crate::style::{FlexDirection, Style}; use crate::sys::Vec; @@ -30,6 +33,8 @@ struct FlexItem { min_size: Size>, /// The maximum allowable size of this item max_size: Size>, + /// The cross-alignment of this item + align_self: AlignSelf, /// The final offset of this item position: Rect>, @@ -105,6 +110,8 @@ struct AlgoConstants { padding_border: Rect, /// The gap of this section gap: Size, + /// The align_items property of this node + align_items: AlignItems, /// The size of the internal node node_inner_size: Size>, @@ -188,13 +195,12 @@ fn compute_preliminary( NODE_LOGGER.log("determine_available_space"); let available_space = determine_available_space(known_dimensions, parent_size, &constants); - let has_baseline_child = - flex_items.iter().any(|child| tree.style(child.node).align_self(tree.style(node)) == AlignSelf::Baseline); + let has_baseline_child = flex_items.iter().any(|child| child.align_self == AlignSelf::Baseline); // 3. Determine the flex base size and hypothetical main size of each item. #[cfg(feature = "debug")] NODE_LOGGER.log("determine_flex_base_size"); - determine_flex_base_size(tree, node, known_dimensions, &constants, available_space, &mut flex_items); + determine_flex_base_size(tree, known_dimensions, &constants, available_space, &mut flex_items); // TODO: Add step 4 according to spec: https://www.w3.org/TR/css-flexbox-1/#algo-main-container // 9.3. Main Size Determination @@ -264,7 +270,7 @@ fn compute_preliminary( // 8. Calculate the cross size of each flex line. #[cfg(feature = "debug")] NODE_LOGGER.log("calculate_cross_size"); - calculate_cross_size(tree, &mut flex_lines, node, known_dimensions, &constants); + calculate_cross_size(tree, &mut flex_lines, known_dimensions, &constants); // 9. Handle 'align-content: stretch'. #[cfg(feature = "debug")] @@ -289,7 +295,7 @@ fn compute_preliminary( // 11. Determine the used cross size of each flex item. #[cfg(feature = "debug")] NODE_LOGGER.log("determine_used_cross_size"); - determine_used_cross_size(tree, &mut flex_lines, node, &constants); + determine_used_cross_size(tree, &mut flex_lines, &constants); // 9.5. Main-Axis Alignment @@ -303,7 +309,7 @@ fn compute_preliminary( // 13. Resolve cross-axis auto margins (also includes 14). #[cfg(feature = "debug")] NODE_LOGGER.log("resolve_cross_axis_auto_margins"); - resolve_cross_axis_auto_margins(tree, &mut flex_lines, node, &constants); + resolve_cross_axis_auto_margins(tree, &mut flex_lines, &constants); // 15. Determine the flex container’s used cross size. #[cfg(feature = "debug")] @@ -338,8 +344,15 @@ fn compute_preliminary( for order in 0..len { let child = tree.child(node, order); if tree.style(child).display == Display::None { - // if self.nodes[*child].style.display == Display::None { - hidden_layout(tree, child, order as _); + *tree.layout_mut(node) = Layout::with_order(order as u32); + compute_node_layout( + tree, + child, + Size::NONE, + Size::MAX_CONTENT, + RunMode::PeformLayout, + SizingMode::InherentSize, + ); } } @@ -357,6 +370,7 @@ fn compute_constants(style: &Style, node_size: Size>, parent_size: S let margin = style.margin.resolve_or_zero(parent_size.width.into_option()); let padding = style.padding.resolve_or_zero(parent_size.width.into_option()); let border = style.border.resolve_or_zero(parent_size.width.into_option()); + let align_items = style.align_items.unwrap_or(crate::style::AlignItems::Stretch); let padding_border = Rect { left: padding.left + border.left, @@ -383,6 +397,7 @@ fn compute_constants(style: &Style, node_size: Size>, parent_size: S border, gap, padding_border, + align_items, node_inner_size, container_size, inner_container_size, @@ -410,6 +425,7 @@ fn generate_anonymous_flex_items(tree: &impl LayoutTree, node: Node, constants: margin: child_style.margin.resolve_or_zero(constants.node_inner_size.width), padding: child_style.padding.resolve_or_zero(constants.node_inner_size.width), border: child_style.border.resolve_or_zero(constants.node_inner_size.width), + align_self: child_style.align_self.unwrap_or(constants.align_items), flex_basis: 0.0, inner_flex_basis: 0.0, violation: 0.0, @@ -493,7 +509,6 @@ fn determine_available_space( #[inline] fn determine_flex_base_size( tree: &mut impl LayoutTree, - node: Node, node_size: Size>, constants: &AlgoConstants, available_space: Size, @@ -550,7 +565,7 @@ fn determine_flex_base_size( let child_known_dimensions = { let mut ckd = child.size; - if child_style.align_self(tree.style(node)) == AlignSelf::Stretch { + if child.align_self == AlignSelf::Stretch { if constants.is_column && ckd.width.is_none() { ckd.width = available_space.width.into_option(); } @@ -1053,7 +1068,6 @@ fn calculate_children_base_lines( fn calculate_cross_size( tree: &mut impl LayoutTree, flex_lines: &mut [FlexLine], - node: Node, node_size: Size>, constants: &AlgoConstants, ) { @@ -1081,7 +1095,7 @@ fn calculate_cross_size( .iter() .map(|child| { let child_style = tree.style(child.node); - if child_style.align_self(tree.style(node)) == AlignSelf::Baseline + if child.align_self == AlignSelf::Baseline && child_style.cross_margin_start(constants.dir) != LengthPercentageAuto::Auto && child_style.cross_margin_end(constants.dir) != LengthPercentageAuto::Auto && child_style.cross_size(constants.dir) == Dimension::Auto @@ -1111,7 +1125,8 @@ fn handle_align_content_stretch( node_size: Size>, constants: &AlgoConstants, ) { - if tree.style(node).align_content == AlignContent::Stretch && node_size.cross(constants.dir).is_some() { + let align_content = tree.style(node).align_content.unwrap_or(AlignContent::Stretch); + if align_content == AlignContent::Stretch && node_size.cross(constants.dir).is_some() { let total_cross_axis_gap = sum_axis_gaps(constants.gap.cross(constants.dir), flex_lines.len()); let total_cross: f32 = flex_lines.iter().map(|line| line.cross_size).sum::() + total_cross_axis_gap; let inner_cross = @@ -1138,12 +1153,7 @@ fn handle_align_content_stretch( /// /// **Note that this step does not affect the main size of the flex item, even if it has an intrinsic aspect ratio**. #[inline] -fn determine_used_cross_size( - tree: &mut impl LayoutTree, - flex_lines: &mut [FlexLine], - node: Node, - constants: &AlgoConstants, -) { +fn determine_used_cross_size(tree: &mut impl LayoutTree, flex_lines: &mut [FlexLine], constants: &AlgoConstants) { for line in flex_lines { let line_cross_size = line.cross_size; @@ -1151,7 +1161,7 @@ fn determine_used_cross_size( let child_style = tree.style(child.node); child.target_size.set_cross( constants.dir, - if child_style.align_self(tree.style(node)) == AlignSelf::Stretch + if child.align_self == AlignSelf::Stretch && child_style.cross_margin_start(constants.dir) != LengthPercentageAuto::Auto && child_style.cross_margin_end(constants.dir) != LengthPercentageAuto::Auto && child_style.cross_size(constants.dir) == Dimension::Auto @@ -1229,62 +1239,12 @@ fn distribute_remaining_free_space( let num_items = line.items.len(); let layout_reverse = constants.dir.is_reverse(); let gap = constants.gap.main(constants.dir); + let justify_content_mode: JustifyContent = + tree.style(node).justify_content.unwrap_or(JustifyContent::Start); let justify_item = |(i, child): (usize, &mut FlexItem)| { - let is_first = i == 0; - - child.offset_main = match tree.style(node).justify_content { - JustifyContent::FlexStart => { - if is_first { - if layout_reverse { - free_space - } else { - 0.0 - } - } else { - gap - } - } - JustifyContent::Center => { - if is_first { - free_space / 2.0 - } else { - gap - } - } - JustifyContent::FlexEnd => { - if is_first { - if !layout_reverse { - free_space - } else { - 0.0 - } - } else { - gap - } - } - JustifyContent::SpaceBetween => { - if is_first { - 0.0 - } else { - gap + (free_space / (num_items - 1) as f32) - } - } - JustifyContent::SpaceAround => { - if is_first { - (free_space / num_items as f32) / 2.0 - } else { - gap + (free_space / num_items as f32) - } - } - JustifyContent::SpaceEvenly => { - if is_first { - free_space / (num_items + 1) as f32 - } else { - gap + (free_space / (num_items + 1) as f32) - } - } - }; + child.offset_main = + compute_alignment_offset(free_space, num_items, gap, justify_content_mode, layout_reverse, i == 0); }; if layout_reverse { @@ -1309,12 +1269,7 @@ fn distribute_remaining_free_space( /// - Otherwise, if the block-start or inline-start margin (whichever is in the cross axis) is auto, set it to zero. /// Set the opposite margin so that the outer cross size of the item equals the cross size of its flex line. #[inline] -fn resolve_cross_axis_auto_margins( - tree: &mut impl LayoutTree, - flex_lines: &mut [FlexLine], - node: Node, - constants: &AlgoConstants, -) { +fn resolve_cross_axis_auto_margins(tree: &mut impl LayoutTree, flex_lines: &mut [FlexLine], constants: &AlgoConstants) { for line in flex_lines { let line_cross_size = line.cross_size; let max_baseline: f32 = line.items.iter_mut().map(|child| child.baseline).fold(0.0, |acc, x| acc.max(x)); @@ -1347,15 +1302,7 @@ fn resolve_cross_axis_auto_margins( } } else { // 14. Align all flex items along the cross-axis. - child.offset_cross = align_flex_items_along_cross_axis( - tree, - node, - child, - child_style, - free_space, - max_baseline, - constants, - ); + child.offset_cross = align_flex_items_along_cross_axis(child, free_space, max_baseline, constants); } } } @@ -1369,24 +1316,20 @@ fn resolve_cross_axis_auto_margins( /// if neither of the item's cross-axis margins are `auto`. #[inline] fn align_flex_items_along_cross_axis( - tree: &impl LayoutTree, - node: Node, child: &mut FlexItem, - child_style: &Style, free_space: f32, max_baseline: f32, constants: &AlgoConstants, ) -> f32 { - match child_style.align_self(tree.style(node)) { - AlignSelf::Auto => unreachable!(), - AlignSelf::FlexStart => { + match child.align_self { + AlignSelf::Start => { if constants.is_wrap_reverse { free_space } else { 0.0 } } - AlignSelf::FlexEnd => { + AlignSelf::End => { if constants.is_wrap_reverse { 0.0 } else { @@ -1466,71 +1409,13 @@ fn align_flex_lines_per_align_content( ) { let num_lines = flex_lines.len(); let gap = constants.gap.cross(constants.dir); + let align_content_mode = tree.style(node).align_content.unwrap_or(AlignContent::Stretch); let total_cross_axis_gap = sum_axis_gaps(gap, num_lines); let free_space = constants.inner_container_size.cross(constants.dir) - total_cross_size - total_cross_axis_gap; let align_line = |(i, line): (usize, &mut FlexLine)| { - let is_first = i == 0; - - line.offset_cross = match tree.style(node).align_content { - AlignContent::FlexStart => { - if is_first { - if constants.is_wrap_reverse { - free_space - } else { - 0.0 - } - } else { - gap - } - } - AlignContent::FlexEnd => { - if is_first { - if !constants.is_wrap_reverse { - free_space - } else { - 0.0 - } - } else { - gap - } - } - AlignContent::Center => { - if is_first { - free_space / 2.0 - } else { - gap - } - } - AlignContent::Stretch => { - if is_first { - 0.0 - } else { - gap - } - } - AlignContent::SpaceEvenly => { - if is_first { - free_space / (num_lines + 1) as f32 - } else { - gap + (free_space / (num_lines + 1) as f32) - } - } - AlignContent::SpaceBetween => { - if is_first { - 0.0 - } else { - gap + (free_space / (num_lines - 1) as f32) - } - } - AlignContent::SpaceAround => { - if is_first { - (free_space / num_lines as f32) / 2.0 - } else { - gap + (free_space / num_lines as f32) - } - } - }; + line.offset_cross = + compute_alignment_offset(free_space, num_lines, gap, align_content_mode, constants.is_wrap_reverse, i == 0); }; if constants.is_wrap_reverse { @@ -1763,11 +1648,13 @@ fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node } else if end_main.is_some() { free_main_space - end_main.unwrap_or(0.0) - constants.border.main_end(constants.dir) } else { - match tree.style(node).justify_content { - JustifyContent::SpaceBetween | JustifyContent::FlexStart => { + match tree.style(node).justify_content.unwrap_or(JustifyContent::Start) { + // Stretch is an invalid value for justify_content in the flexbox algorithm, so we + // treat it as if it wasn't set (and thus we default to FlexStart behaviour) + JustifyContent::SpaceBetween | JustifyContent::Start | JustifyContent::Stretch => { constants.padding_border.main_start(constants.dir) } - JustifyContent::FlexEnd => free_main_space - constants.padding_border.main_end(constants.dir), + JustifyContent::End => free_main_space - constants.padding_border.main_end(constants.dir), JustifyContent::SpaceEvenly | JustifyContent::SpaceAround | JustifyContent::Center => { free_main_space / 2.0 } @@ -1779,16 +1666,15 @@ fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node } else if end_cross.is_some() { free_cross_space - end_cross.unwrap_or(0.0) - constants.border.cross_end(constants.dir) } else { - match child_style.align_self(tree.style(node)) { - AlignSelf::Auto => unreachable!(), - AlignSelf::FlexStart => { + match child_style.align_self.unwrap_or(constants.align_items) { + AlignSelf::Start => { if constants.is_wrap_reverse { free_cross_space - constants.padding_border.cross_end(constants.dir) } else { constants.padding_border.cross_start(constants.dir) } } - AlignSelf::FlexEnd => { + AlignSelf::End => { if constants.is_wrap_reverse { constants.padding_border.cross_start(constants.dir) } else { @@ -1818,17 +1704,6 @@ fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node } } -/// Creates a layout for this node and its children, recursively. -/// Each hidden node has zero size and is placed at the origin -fn hidden_layout(tree: &mut impl LayoutTree, node: Node, order: u32) { - *tree.layout_mut(node) = Layout::with_order(order); - - let len = tree.child_count(node); - for order in 0..len { - hidden_layout(tree, tree.child(node, order), order as _); - } -} - /// Computes the total space taken up by gaps in an axis given: /// - The size of each gap /// - The number of items (children or flex-lines) between which there are gaps @@ -1846,10 +1721,9 @@ fn sum_axis_gaps(gap: f32, num_items: usize) -> f32 { #[cfg(test)] mod tests { - use super::hidden_layout; - use crate::geometry::Point; - use crate::style::Display; - use crate::style::Display::Flex; + #![allow(clippy::redundant_clone)] + + use crate::style_helpers::*; use crate::{ math::MaybeMath, prelude::{Rect, Size}, @@ -1864,7 +1738,7 @@ mod tests { let mut tree = Taffy::with_capacity(16); let style = Style::default(); - let node_id = tree.new_leaf(style).unwrap(); + let node_id = tree.new_leaf(style.clone()).unwrap(); let node_size = Size::NONE; let parent_size = Size::MAX_CONTENT; @@ -1877,13 +1751,13 @@ mod tests { assert!(constants.is_column == style.flex_direction.is_column()); assert!(constants.is_wrap_reverse == (style.flex_wrap == FlexWrap::WrapReverse)); - let margin = style.margin.resolve_or_zero(parent_size.as_options()); + let margin = style.margin.resolve_or_zero(parent_size.into_options()); assert_eq!(constants.margin, margin); - let border = style.border.resolve_or_zero(parent_size.as_options()); + let border = style.border.resolve_or_zero(parent_size.into_options()); assert_eq!(constants.border, border); - let padding = style.padding.resolve_or_zero(parent_size.as_options()); + let padding = style.padding.resolve_or_zero(parent_size.into_options()); // TODO: Replace with something less hardcoded? let padding_border = Rect { @@ -1905,39 +1779,4 @@ mod tests { assert_eq!(constants.container_size, Size::zero()); assert_eq!(constants.inner_container_size, Size::zero()); } - - #[test] - fn hidden_layout_should_hide_recursively() { - let mut taffy = Taffy::new(); - - let style: Style = Style { display: Flex, size: Size::from_points(50.0, 50.0), ..Default::default() }; - - let grandchild_00 = taffy.new_leaf(style).unwrap(); - - let grandchild_01 = taffy.new_leaf(style).unwrap(); - - let grandchild_02 = taffy.new_leaf(style).unwrap(); - - let child_00 = taffy.new_with_children(style, &[grandchild_00, grandchild_01]).unwrap(); - - let child_01 = taffy.new_with_children(style, &[grandchild_02]).unwrap(); - - let root = taffy - .new_with_children( - Style { display: Display::None, size: Size::from_points(50.0, 50.0), ..Default::default() }, - &[child_00, child_01], - ) - .unwrap(); - - hidden_layout(&mut taffy, root, 0); - - // Whatever size and display-mode the nodes had previously, - // all layouts should resolve to ZERO due to the root's DISPLAY::NONE - for (node, _) in &taffy.nodes { - if let Ok(layout) = taffy.layout(node) { - assert_eq!(layout.size, Size::zero()); - assert_eq!(layout.location, Point::zero()); - } - } - } } diff --git a/src/compute/grid/alignment.rs b/src/compute/grid/alignment.rs new file mode 100644 index 000000000..54c12d3e4 --- /dev/null +++ b/src/compute/grid/alignment.rs @@ -0,0 +1,262 @@ +//! Alignment of tracks and final positioning of items +use super::types::GridTrack; +use crate::axis::InBothAbsAxis; +use crate::compute::common::alignment::compute_alignment_offset; +use crate::compute::compute_node_layout; +use crate::geometry::{Line, Point, Rect, Size}; +use crate::layout::{Layout, RunMode, SizingMode}; +use crate::math::MaybeMath; +use crate::node::Node; +use crate::resolve::MaybeResolve; +use crate::style::{AlignContent, AlignItems, AlignSelf, AvailableSpace, PositionType}; +use crate::sys::{f32_max, f32_min}; +use crate::tree::LayoutTree; + +/// Align the grid tracks within the grid according to the align-content (rows) or +/// justify-content (columns) property. This only does anything if the size of the +/// grid is not equal to the size of the grid container in the axis being aligned. +pub(super) fn align_tracks( + grid_container_content_box_size: f32, + padding: Line, + border: Line, + tracks: &mut [GridTrack], + track_alignment_style: AlignContent, +) { + let used_size: f32 = tracks.iter().map(|track| track.base_size).sum(); + let size_diff = grid_container_content_box_size - used_size; + let free_space = f32_max(size_diff, 0.0); + let overflow = f32_min(size_diff, 0.0); + + // If the used_size > grid_container_size then the tracks must overflow their container + // The direction in which they do so is determined by the alignment style + let origin = padding.start + + border.start + + match track_alignment_style { + AlignContent::Start => 0.0, + AlignContent::End => overflow, + AlignContent::Center => overflow / 2.0, + AlignContent::Stretch => 0.0, + AlignContent::SpaceBetween => 0.0, + AlignContent::SpaceEvenly => 0.0, + AlignContent::SpaceAround => 0.0, + }; + + // Count the number of non-collapsed tracks (not counting gutters) + let num_tracks = tracks.iter().skip(1).step_by(2).filter(|track| !track.is_collapsed).count(); + + // Grid layout treats gaps as full tracks rather than applying them at alignment so we + // simply pass zero here. Grid layout is never reversed. + let gap = 0.0; + let layout_is_reversed = false; + + // Compute offsets + let mut total_offset = origin; + tracks.iter_mut().enumerate().for_each(|(i, track)| { + // Odd tracks are gutters (but slices are zero-indexed, so odd tracks have even indicies) + let is_gutter = i % 2 == 0; + + // The first non-gutter track is index 1 + let is_first = i == 1; + + let offset = if is_gutter { + 0.0 + } else { + compute_alignment_offset(free_space, num_tracks, gap, track_alignment_style, layout_is_reversed, is_first) + }; + + track.offset = total_offset + offset; + total_offset = total_offset + offset + track.base_size; + }); +} + +/// Align and size a grid item into it's final position +pub(super) fn align_and_position_item( + tree: &mut impl LayoutTree, + node: Node, + order: u32, + grid_area: Rect, + container_content_box: Size, + container_alignment_styles: InBothAbsAxis>, +) { + let grid_area_size = Size { width: grid_area.right - grid_area.left, height: grid_area.bottom - grid_area.top }; + + let style = tree.style(node); + let aspect_ratio = style.aspect_ratio; + let justify_self = style.justify_self; + let align_self = style.align_self; + + let position_type = style.position_type; + let inset_horizontal = + style.position.horizontal_components().map(|size| size.resolve_to_option(container_content_box.width)); + let inset_vertical = + style.position.vertical_components().map(|size| size.resolve_to_option(container_content_box.height)); + let inherent_size = style.size.maybe_resolve(container_content_box); + let min_size = style.min_size.maybe_resolve(container_content_box); + let max_size = style.max_size.maybe_resolve(container_content_box); + + // Resolve default alignment styles if they are set on neither the parent or the node itself + let alignment_styles = InBothAbsAxis { + horizontal: container_alignment_styles.horizontal.or(justify_self).unwrap_or_else(|| { + if inherent_size.width.is_some() || aspect_ratio.is_some() { + AlignSelf::Start + } else { + AlignSelf::Stretch + } + }), + vertical: container_alignment_styles.vertical.or(align_self).unwrap_or_else(|| { + if inherent_size.height.is_some() || aspect_ratio.is_some() { + AlignSelf::Start + } else { + AlignSelf::Stretch + } + }), + }; + + // Note: This is not a bug. It is part of the CSS spec that both horizontal and vertical margins + // resolve against the WIDTH of the grid area. + let margin = style.margin.map(|margin| margin.resolve_to_option(grid_area_size.width)); + let grid_area_minus_item_margins_size = Size { + width: grid_area_size.width.maybe_sub(margin.left).maybe_sub(margin.right), + height: grid_area_size.height.maybe_sub(margin.top).maybe_sub(margin.bottom), + }; + + // If node is absolutely positioned and width is not set explicitly, then deduce it + // from left, right and container_content_box if both are set. + let width = inherent_size.width.or_else(|| { + // Apply width derived from both the left and right properties of an absolutely + // positioned element being set + if position_type == PositionType::Absolute { + if let (Some(left), Some(right)) = (inset_horizontal.start, inset_horizontal.end) { + return Some(f32_max(grid_area_size.width - left - right, 0.0)); + } + } + + // Apply width based on stretch alignment (clamped by max size) if: + // - Alignment style is "stretch" + // - The node is not absolutely positioned + // - The node does not have auto margins in this axis. + if margin.left.is_some() + && margin.right.is_some() + && alignment_styles.horizontal == AlignSelf::Stretch + && position_type != PositionType::Absolute + { + return Some(grid_area_minus_item_margins_size.width.maybe_min(max_size.width).maybe_max(min_size.width)); + } + + None + }); + let height = inherent_size.height.or_else(|| { + if position_type == PositionType::Absolute { + if let (Some(top), Some(bottom)) = (inset_vertical.start, inset_vertical.end) { + return Some(f32_max(grid_area_size.height - top - bottom, 0.0)); + } + } + + // Apply height based on stretch alignment (clamped by max size) if: + // - Alignment style is "stretch" + // - The node is not absolutely positioned + // - The node does not have auto margins in this axis. + if margin.top.is_some() + && margin.bottom.is_some() + && alignment_styles.vertical == AlignSelf::Stretch + && position_type != PositionType::Absolute + { + return Some( + grid_area_minus_item_margins_size.height.maybe_min(max_size.height).maybe_max(min_size.height), + ); + } + + None + }); + + // Layout node + let measured_size = compute_node_layout( + tree, + node, + Size { width, height }, + grid_area_minus_item_margins_size.map(AvailableSpace::Definite), + RunMode::PeformLayout, + SizingMode::InherentSize, + ); + + let (x, width) = align_and_size_item_within_area( + Line { start: grid_area.left, end: grid_area.right }, + justify_self.unwrap_or(alignment_styles.horizontal), + width, + measured_size.width, + position_type, + inset_horizontal, + margin.horizontal_components(), + ); + let (y, height) = align_and_size_item_within_area( + Line { start: grid_area.top, end: grid_area.bottom }, + align_self.unwrap_or(alignment_styles.vertical), + height, + measured_size.height, + position_type, + inset_vertical, + margin.vertical_components(), + ); + + *tree.layout_mut(node) = Layout { order, size: Size { width, height }, location: Point { x, y } }; +} + +/// Align and size a grid item along a single axis +pub(super) fn align_and_size_item_within_area( + grid_area: Line, + alignment_style: AlignSelf, + style_size: Option, + measured_size: f32, + position_type: PositionType, + inset: Line>, + margin: Line>, +) -> (f32, f32) { + // Calculate grid area dimension in the axis + let non_auto_margin = Line { start: margin.start.unwrap_or(0.0), end: margin.end.unwrap_or(0.0) }; + let grid_area_size = f32_max(grid_area.end - grid_area.start, 0.0); + let free_space = f32_max(grid_area_size - style_size.unwrap_or(measured_size) - non_auto_margin.sum(), 0.0); + + // Expand auto margins to fill available space + let auto_margin_count = margin.start.is_none() as u8 + margin.end.is_none() as u8; + let auto_margin_size = if auto_margin_count > 0 { free_space / auto_margin_count as f32 } else { 0.0 }; + let resolved_margin = + Line { start: margin.start.unwrap_or(auto_margin_size), end: margin.end.unwrap_or(auto_margin_size) }; + + // Compute size in the axis + let size = style_size.unwrap_or_else(|| { + if alignment_style == AlignItems::Stretch && position_type != PositionType::Absolute { + f32_max(grid_area_size - resolved_margin.sum(), measured_size) + } else { + measured_size + } + }); + + // Compute offset in the axis + let alignment_based_offset = match alignment_style { + AlignSelf::Start => resolved_margin.start, + AlignSelf::End => grid_area_size - size - resolved_margin.end, + AlignSelf::Center => (grid_area_size - size + resolved_margin.start - resolved_margin.end) / 2.0, + // TODO: Add support for baseline alignment. For now we treat it as "start". + AlignSelf::Baseline => resolved_margin.start, + AlignSelf::Stretch => resolved_margin.start, + }; + + let offset_within_area = if position_type == PositionType::Absolute { + if let Some(start) = inset.start { + start + non_auto_margin.start + } else if let Some(end) = inset.end { + grid_area_size - end - size - non_auto_margin.end + } else { + alignment_based_offset + } + } else { + alignment_based_offset + }; + + let mut start = grid_area.start + offset_within_area; + if position_type == PositionType::Relative { + start += inset.start.or(inset.end.map(|pos| -pos)).unwrap_or(0.0); + } + + (start, size) +} diff --git a/src/compute/grid/explicit_grid.rs b/src/compute/grid/explicit_grid.rs new file mode 100644 index 000000000..6cdadbf54 --- /dev/null +++ b/src/compute/grid/explicit_grid.rs @@ -0,0 +1,460 @@ +//! Helper functions for intialising GridTrack's from styles +//! This mainly consists of evaluating GridAutoTracks +use super::types::{GridTrack, TrackCounts}; +use crate::axis::AbsoluteAxis; +use crate::math::MaybeMath; +use crate::resolve::ResolveOrZero; +use crate::style::{ + AvailableSpace, GridTrackRepetition, LengthPercentage, NonRepeatedTrackSizingFunction, Style, TrackSizingFunction, +}; +use crate::style_helpers::TaffyAuto; +use crate::sys::{GridTrackVec, Vec}; +use core::cmp::{max, min}; + +/// Compute the number of rows and columns in the explicit grid +pub(crate) fn compute_explicit_grid_size_in_axis(style: &Style, axis: AbsoluteAxis) -> u16 { + // Load the grid-template-rows or grid-template-columns definition (depending on the axis) + let template = style.grid_template_tracks(axis); + + // If template contains no tracks, then there are trivially zero explcit tracks + if template.is_empty() { + return 0; + } + + let auto_repetition_count = template.iter().filter(|track_def| track_def.is_auto_repetition()).count() as u16; + let non_repeating_track_count = (template.len() as u16) - auto_repetition_count; + let all_track_defs_have_fixed_component = template.iter().all(|track_def| match track_def { + TrackSizingFunction::Single(sizing_function) => sizing_function.has_fixed_component(), + TrackSizingFunction::AutoRepeat(_, tracks) => { + tracks.iter().all(|sizing_function| sizing_function.has_fixed_component()) + } + }); + + let template_is_valid = + auto_repetition_count == 0 || (auto_repetition_count == 1 && all_track_defs_have_fixed_component); + + // If the template is invalid because it contains multiple auto-repetition definitions or it combines an auto-repetition + // definition with non-fixed-size track sizing functions, then disregard it entirely and default to zero explicit tracks + if !template_is_valid { + return 0; + } + + // If there are no repetitions, then the number of explicit tracks is simply equal to the lengths of the track definition + // vector (as each item in the Vec represents one track). + if auto_repetition_count == 0 { + return template.len() as u16; + } + + let repetition_definition = template + .iter() + .find_map(|def| match def { + TrackSizingFunction::Single(_) => None, + TrackSizingFunction::AutoRepeat(_, tracks) => Some(tracks), + }) + .unwrap(); + let repetition_track_count = repetition_definition.len() as u16; + + // If the repetition contains no tracks, then the whole definition should be considered invalid and we default to no explcit tracks + if repetition_track_count == 0 { + return 0u16; + } + + // Otherwise, run logic to resolve the auto-repeated track count: + // + // If the grid container has a definite size or max size in the relevant axis: + // - then the number of repetitions is the largest possible positive integer that does not cause the grid to overflow the content + // box of its grid container. + // Otherwise, if the grid container has a definite min size in the relevant axis: + // - then the number of repetitions is the smallest possible positive integer that fulfills that minimum requirement + // Otherwise, the specified track list repeats only once. + let style_size = style.size.get_abs(axis).into_option(); + let style_min_size = style.min_size.get_abs(axis).into_option(); + let style_max_size = style.max_size.get_abs(axis).into_option(); + + let outer_container_size = style_size.maybe_min(style_max_size).or(style_max_size).or(style_min_size); + let inner_container_size = outer_container_size.map(|size| { + let padding_sum = style.padding.resolve_or_zero(outer_container_size).grid_axis_sum(axis); + let border_sum = style.border.resolve_or_zero(outer_container_size).grid_axis_sum(axis); + size - padding_sum - border_sum + }); + let size_is_maximum = style_size.is_some() || style_max_size.is_some(); + + // Determine the number of repetitions + let num_repetitions: u16 = match inner_container_size { + None => 1, + Some(inner_container_size) => { + let available_space = AvailableSpace::Definite(inner_container_size); + + /// ...treating each track as its max track sizing function if that is definite or as its minimum track sizing function + /// otherwise, flooring the max track sizing function by the min track sizing function if both are definite + fn track_definite_value( + sizing_function: &NonRepeatedTrackSizingFunction, + available_space: AvailableSpace, + ) -> f32 { + let max_size = sizing_function.max.definite_value(available_space); + let min_size = sizing_function.max.definite_value(available_space); + max_size.map(|max| max.maybe_min(min_size)).or(min_size).unwrap() + } + + let non_repeating_track_used_space: f32 = template + .iter() + .map(|track_def| match track_def { + TrackSizingFunction::Single(sizing_function) => { + track_definite_value(sizing_function, available_space) + } + TrackSizingFunction::AutoRepeat(_, _) => 0.0, + }) + .sum(); + let gap_size = style.gap.get_abs(axis).resolve_or_zero(Some(inner_container_size)); + + // Compute the amount of space that a single repetition of the repeated track list takes + let per_repetition_track_used_space: f32 = repetition_definition + .iter() + .map(|sizing_function| track_definite_value(sizing_function, available_space)) + .sum::(); + + // We special case the first repetition here because the number of gaps in the first repetition + // depends on the number of non-repeating tracks in the template + let first_repetition_and_non_repeating_tracks_used_space = non_repeating_track_used_space + + per_repetition_track_used_space + + ((non_repeating_track_count + repetition_track_count).saturating_sub(1) as f32 * gap_size); + + // If a single repetition already overflows the container then we return 1 as the repetition count + // (the number of repetitions is floored at 1) + if first_repetition_and_non_repeating_tracks_used_space > inner_container_size { + 1u16 + } else { + let per_repetition_gap_used_space = (repetition_definition.len() as f32) * gap_size; + let per_repetition_used_space = per_repetition_track_used_space + per_repetition_gap_used_space; + let num_repetition_that_fit = (inner_container_size + - first_repetition_and_non_repeating_tracks_used_space) + / per_repetition_used_space; + + // If the container size is a preferred or maximum size: + // Then we return the maximum number of repetitions that fit into the container without overflowing. + // If the container size is a minimum size: + // - Then we return the minimum number of repititions required to overflow the size. + // + // In all cases we add the additional repetition that was already accounted for in the special-case computation above + if size_is_maximum { + (num_repetition_that_fit.floor() as u16) + 1 + } else { + (num_repetition_that_fit.ceil() as u16) + 1 + } + } + } + }; + + non_repeating_track_count + (repetition_track_count * num_repetitions) +} + +/// Resolve the track sizing functions of explicit tracks, automatically created tracks, and gutters +/// given a set of track counts and all of the relevant styles +pub(super) fn initialize_grid_tracks( + tracks: &mut Vec, + counts: TrackCounts, + track_template: &GridTrackVec, + auto_tracks: &Vec, + gap: LengthPercentage, + track_has_items: impl Fn(usize) -> bool, +) { + // Clear vector (in case this is a re-layout), reserve space for all tracks ahead of time to reduce allocations, + // and push the initial gutter + tracks.clear(); + tracks.reserve((counts.len() * 2) + 1); + tracks.push(GridTrack::gutter(gap)); + + // Create negative implicit tracks + if auto_tracks.is_empty() { + let iter = core::iter::repeat(NonRepeatedTrackSizingFunction::AUTO); + create_implicit_tracks(tracks, counts.negative_implicit, iter, gap) + } else { + let max_count = max(auto_tracks.len(), counts.negative_implicit as usize); + let min_count = min(auto_tracks.len(), counts.negative_implicit as usize); + let offset = max_count % min_count; + let iter = auto_tracks.iter().copied().cycle().skip(offset); + create_implicit_tracks(tracks, counts.negative_implicit, iter, gap) + } + + let mut current_track_index = (counts.negative_implicit) as usize; + + // Create explicit tracks + // An explicit check against the count (rather than just relying on track_template being empty) is required here + // because a count of zero can result from the track_template being invalid, in which case it should be ignored. + if counts.explicit > 0 { + track_template.iter().for_each(|track_sizing_function| match track_sizing_function { + TrackSizingFunction::Single(sizing_function) => { + tracks + .push(GridTrack::new(sizing_function.min_sizing_function(), sizing_function.max_sizing_function())); + tracks.push(GridTrack::gutter(gap)); + current_track_index += 1; + } + TrackSizingFunction::AutoRepeat(repetition_kind, repeated_tracks) => { + let auto_repeated_track_count = (counts.explicit - (track_template.len() as u16 - 1)) as usize; + let iter = repeated_tracks.iter().copied().cycle(); + for track_def in iter.take(auto_repeated_track_count) { + let mut track = GridTrack::new(track_def.min_sizing_function(), track_def.max_sizing_function()); + let mut gutter = GridTrack::gutter(gap); + + // Auto-fit tracks that don't contain should be collapsed. + if *repetition_kind == GridTrackRepetition::AutoFit && !track_has_items(current_track_index) { + track.collapse(); + gutter.collapse(); + } + + tracks.push(track); + tracks.push(gutter); + + current_track_index += 1; + } + } + }); + } + + // Create positive implicit tracks + if auto_tracks.is_empty() { + let iter = core::iter::repeat(NonRepeatedTrackSizingFunction::AUTO); + create_implicit_tracks(tracks, counts.positive_implicit, iter, gap) + } else { + let iter = auto_tracks.iter().copied().cycle(); + create_implicit_tracks(tracks, counts.positive_implicit, iter, gap) + } + + // Mark first and last grid lines as collapsed + tracks.first_mut().unwrap().collapse(); + tracks.last_mut().unwrap().collapse(); +} + +/// Utility function for repeating logic of creating implicit tracks +fn create_implicit_tracks( + tracks: &mut Vec, + count: u16, + mut auto_tracks_iter: impl Iterator, + gap: LengthPercentage, +) { + for _ in 0..count { + let track_def = auto_tracks_iter.next().unwrap(); + tracks.push(GridTrack::new(track_def.min_sizing_function(), track_def.max_sizing_function())); + tracks.push(GridTrack::gutter(gap)); + } +} + +#[cfg(test)] +mod test { + use super::compute_explicit_grid_size_in_axis; + use super::initialize_grid_tracks; + use crate::axis::AbsoluteAxis; + use crate::compute::grid::types::GridTrackKind; + use crate::compute::grid::types::TrackCounts; + use crate::compute::grid::util::*; + use crate::prelude::*; + + #[test] + fn explicit_grid_sizing_no_repeats() { + let grid_style = (600.0, 600.0, 2, 4).into_grid(); + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 2); + assert_eq!(height, 4); + } + + #[test] + fn explicit_grid_sizing_auto_fill_exact_fit() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(120.0), height: points(80.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 3); + assert_eq!(height, 4); + } + + #[test] + fn explicit_grid_sizing_auto_fill_non_exact_fit() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(140.0), height: points(90.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 3); + assert_eq!(height, 4); + } + + #[test] + fn explicit_grid_sizing_auto_fill_min_size_exact_fit() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + min_size: Size { width: points(120.0), height: points(80.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 3); + assert_eq!(height, 4); + } + + #[test] + fn explicit_grid_sizing_auto_fill_min_size_non_exact_fit() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + min_size: Size { width: points(140.0), height: points(90.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 4); + assert_eq!(height, 5); + } + + #[test] + fn explicit_grid_sizing_auto_fill_multiple_repeated_tracks() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(140.0), height: points(100.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0), points(20.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0), points(10.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 4); // 2 repetitions * 2 repeated tracks = 4 tracks in total + assert_eq!(height, 6); // 3 repetitions * 2 repeated tracks = 4 tracks in total + } + + #[test] + fn explicit_grid_sizing_auto_fill_gap() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(140.0), height: points(100.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + gap: points(20.0), + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 2); // 2 tracks + 1 gap + assert_eq!(height, 3); // 3 tracks + 2 gaps + } + + #[test] + fn explicit_grid_sizing_no_defined_size() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + grid_template_columns: vec![repeat(AutoFill, vec![points(40.0), percent(0.5), points(20.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + gap: points(20.0), + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 3); + assert_eq!(height, 1); + } + + #[test] + fn explicit_grid_sizing_mix_repeated_and_non_repeated() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(140.0), height: points(100.0) }, + grid_template_columns: vec![points(20.0), repeat(AutoFill, vec![points(40.0)])], + grid_template_rows: vec![points(40.0), repeat(AutoFill, vec![points(20.0)])], + gap: points(20.0), + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 3); // 3 tracks + 2 gaps + assert_eq!(height, 2); // 2 tracks + 1 gap + } + + #[test] + fn explicit_grid_sizing_mix_with_padding() { + use GridTrackRepetition::AutoFill; + let grid_style = Style { + display: Display::Grid, + size: Size { width: points(120.0), height: points(120.0) }, + padding: Rect { left: points(10.0), right: points(10.0), top: points(20.0), bottom: points(20.0) }, + grid_template_columns: vec![repeat(AutoFill, vec![points(20.0)])], + grid_template_rows: vec![repeat(AutoFill, vec![points(20.0)])], + ..Default::default() + }; + let width = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Horizontal); + let height = compute_explicit_grid_size_in_axis(&grid_style, AbsoluteAxis::Vertical); + assert_eq!(width, 5); // 40px horizontal padding + assert_eq!(height, 4); // 20px vertical padding + } + + #[test] + fn test_initialize_grid_tracks() { + let px0 = LengthPercentage::Points(0.0); + let px20 = LengthPercentage::Points(20.0); + let px100 = LengthPercentage::Points(100.0); + + // Setup test + let track_template = vec![points(100.0), minmax(points(100.0), flex(2.0)), flex(1.0)]; + let track_counts = + TrackCounts { negative_implicit: 3, explicit: track_template.len() as u16, positive_implicit: 3 }; + let auto_tracks = vec![auto(), points(100.0)]; + let gap = px20; + + // Call function + let mut tracks = Vec::new(); + initialize_grid_tracks(&mut tracks, track_counts, &track_template, &auto_tracks, gap, |_| false); + + // Assertions + let expected = vec![ + // Gutter + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px0), MaxTrackSizingFunction::Fixed(px0)), + // Negative implict tracks + (GridTrackKind::Track, MinTrackSizingFunction::Fixed(px100), MaxTrackSizingFunction::Fixed(px100)), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Auto, MaxTrackSizingFunction::Auto), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Fixed(px100), MaxTrackSizingFunction::Fixed(px100)), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + // Explicit tracks + (GridTrackKind::Track, MinTrackSizingFunction::Fixed(px100), MaxTrackSizingFunction::Fixed(px100)), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Fixed(px100), MaxTrackSizingFunction::Flex(2.0)), // Note: separate min-max functions + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Auto, MaxTrackSizingFunction::Flex(1.0)), // Note: min sizing function of flex sizing functions is auto + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + // Positive implict tracks + (GridTrackKind::Track, MinTrackSizingFunction::Auto, MaxTrackSizingFunction::Auto), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Fixed(px100), MaxTrackSizingFunction::Fixed(px100)), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px20), MaxTrackSizingFunction::Fixed(px20)), + (GridTrackKind::Track, MinTrackSizingFunction::Auto, MaxTrackSizingFunction::Auto), + (GridTrackKind::Gutter, MinTrackSizingFunction::Fixed(px0), MaxTrackSizingFunction::Fixed(px0)), + ]; + + assert_eq!(tracks.len(), expected.len(), "Number of tracks doesn't match"); + + for (idx, (actual, (kind, min, max))) in tracks.into_iter().zip(expected).enumerate() { + assert_eq!(actual.kind, kind, "Track {idx} (0-based index)"); + assert_eq!(actual.min_track_sizing_function, min, "Track {idx} (0-based index)"); + assert_eq!(actual.max_track_sizing_function, max, "Track {idx} (0-based index)"); + } + } +} diff --git a/src/compute/grid/implicit_grid.rs b/src/compute/grid/implicit_grid.rs new file mode 100644 index 000000000..2319b0caf --- /dev/null +++ b/src/compute/grid/implicit_grid.rs @@ -0,0 +1,231 @@ +//! This module is not required for spec compliance, but is used as a performance optimisation +//! to reduce the number of allocations required when creating a grid. +use crate::geometry::Line; +use crate::style::{GridPlacement, Style}; +use core::cmp::{max, min}; + +use super::types::TrackCounts; +use super::util::css_grid_line_into_origin_zero_coords; + +/// Estimate the number of rows and columns in the grid +/// This is used as a performance optimisation to pre-size vectors and reduce allocations. It also forms a necessary step +/// in the auto-placement +/// - The estimates for the explicit and negative implicit track counts are exact. +/// - However, the estimates for the positive explicit track count is a lower bound as auto-placement can affect this +/// in ways which are impossible to predict until the auto-placement algorithm is run. +/// +/// Note that this function internally mixes use of grid track numbers and grid line numbers +pub(crate) fn compute_grid_size_estimate<'a>( + explicit_col_count: u16, + explicit_row_count: u16, + child_styles_iter: impl Iterator, +) -> (TrackCounts, TrackCounts) { + // Iterate over children, producing an estimate of the min and max grid lines (in origin-zero coordinates where) + // along with the span of each itme + let (col_min, col_max, col_max_span, row_min, row_max, row_max_span) = + get_known_child_positions(child_styles_iter, explicit_col_count, explicit_row_count); + + // Compute *track* count estimates for each axis from: + // - The explicit track counts + // - The origin-zero coordinate min and max grid line variables + let negative_implicit_inline_tracks = col_min.unsigned_abs(); + let explicit_inline_tracks = explicit_col_count; + let mut positive_implicit_inline_tracks = max(explicit_col_count, col_max.unsigned_abs()) - explicit_col_count; + let negative_implicit_block_tracks = row_min.unsigned_abs(); + let explicit_block_tracks = explicit_row_count; + let mut positive_implicit_block_tracks = max(explicit_row_count, row_max.unsigned_abs()) - explicit_row_count; + + // In each axis, adjust positive track estimate if any items have a span that does not fit within + // the total number of tracks in the estimate + let tot_inline_tracks = negative_implicit_inline_tracks + explicit_inline_tracks + positive_implicit_inline_tracks; + if tot_inline_tracks < col_max_span { + positive_implicit_inline_tracks = col_max_span - explicit_inline_tracks - negative_implicit_inline_tracks; + } + + let tot_block_tracks = negative_implicit_block_tracks + explicit_block_tracks + positive_implicit_block_tracks; + if tot_block_tracks < row_max_span { + positive_implicit_block_tracks = row_max_span - explicit_block_tracks - negative_implicit_block_tracks; + } + + let column_counts = + TrackCounts::from_raw(negative_implicit_inline_tracks, explicit_inline_tracks, positive_implicit_inline_tracks); + + let row_counts = + TrackCounts::from_raw(negative_implicit_block_tracks, explicit_block_tracks, positive_implicit_block_tracks); + + (column_counts, row_counts) +} + +/// Iterate over children, producing an estimate of the min and max grid *lines* along with the span of each item +/// +/// Min and max grid lines are returned in origin-zero coordinates) +/// The span is measured in tracks spanned +fn get_known_child_positions<'a>( + children_iter: impl Iterator, + explicit_col_count: u16, + explicit_row_count: u16, +) -> (i16, i16, u16, i16, i16, u16) { + let (mut col_min, mut col_max, mut col_max_span, mut row_min, mut row_max, mut row_max_span) = (0, 0, 0, 0, 0, 0); + children_iter.for_each(|child_style: &Style| { + // Note: that the children reference the lines in between (and around) the tracks not tracks themselves, + // and thus we must subtract 1 to get an accurate estimate of the number of tracks + let (child_col_min, child_col_max, child_col_span) = + child_min_line_max_line_span(child_style.grid_column, explicit_col_count); + let (child_row_min, child_row_max, child_row_span) = + child_min_line_max_line_span(child_style.grid_row, explicit_row_count); + col_min = min(col_min, child_col_min); + col_max = max(col_max, child_col_max); + col_max_span = max(col_max_span, child_col_span); + row_min = min(row_min, child_row_min); + row_max = max(row_max, child_row_max); + row_max_span = max(row_max_span, child_row_span); + }); + + (col_min, col_max, col_max_span, row_min, row_max, row_max_span) +} + +/// Helper function for `compute_grid_size_estimate` +/// Produces a conservative estimate of the greatest and smallest grid lines used by a single grid item +/// +/// Values are returned in origin-zero coordinates +#[inline] +fn child_min_line_max_line_span(line: Line, explicit_track_count: u16) -> (i16, i16, u16) { + use GridPlacement::*; + + // 8.3.1. Grid Placement Conflict Handling + // A. If the placement for a grid item contains two lines, and the start line is further end-ward than the end line, swap the two lines. + // B. If the start line is equal to the end line, remove the end line. + // C. If the placement contains two spans, remove the one contributed by the end grid-placement property. + // D. If the placement contains only a span for a named line, replace it with a span of 1. + + let into_oz = |grid_line: i16| css_grid_line_into_origin_zero_coords(grid_line, explicit_track_count); + + let min = match (line.start, line.end) { + // Both tracks specified + (Line(track1), Line(track2)) => { + let track1_oz = into_oz(track1); + let track2_oz = into_oz(track2); + // See rules A and B above + if track1_oz == track2_oz { + track1_oz + } else { + min(track1_oz, track2_oz) + } + } + + // Start track specified + (Line(track), Auto) => into_oz(track), + (Line(track), Span(_)) => into_oz(track), + + // End track specified + (Auto, Line(track)) => into_oz(track), + (Span(span), Line(track)) => into_oz(track) - (span as i16), + + // Only spans or autos + // We ignore spans here by returning 1 which never effect the estimate as these are accounted for separately + (Auto | Span(_), Auto | Span(_)) => 1, + }; + + let max = match (line.start, line.end) { + // Both tracks specified + (Line(track1), Line(track2)) => { + let track1_oz = into_oz(track1); + let track2_oz = into_oz(track2); + // See rules A and B above + if track1_oz == track2_oz { + track1_oz + 1 + } else { + max(track1_oz, track2_oz) + } + } + + // Start track specified + (Line(track), Auto) => into_oz(track) + 1, + (Line(track), Span(span)) => into_oz(track) + (span as i16), + + // End track specified + (Auto, Line(track)) => into_oz(track), + (Span(_), Line(track)) => into_oz(track), + + // Only spans or autos + // We ignore spans here by returning 1 which never effect the estimate as these are accounted for separately + (Auto | Span(_), Auto | Span(_)) => 1, + }; + + // Calculate span only for indefinitely placed items as we don't need for other items (whose required space will + // be taken into account by min and max) + let span = match (line.start, line.end) { + (Auto | Span(_), Auto | Span(_)) => line.indefinite_span(), + _ => 1, + }; + + (min, max, span) +} + +#[allow(clippy::bool_assert_comparison)] +#[cfg(test)] +mod tests { + mod test_child_min_max_line { + use super::super::child_min_line_max_line_span; + use crate::geometry::Line; + use crate::style::GridPlacement::*; + + #[test] + fn child_min_max_line_auto() { + let (min_col, max_col, span) = child_min_line_max_line_span(Line { start: Line(5), end: Span(6) }, 6); + assert_eq!(min_col, 4); + assert_eq!(max_col, 10); + assert_eq!(span, 1); + } + + #[test] + fn child_min_max_line_negative_track() { + let (min_col, max_col, span) = child_min_line_max_line_span(Line { start: Line(-5), end: Span(3) }, 6); + assert_eq!(min_col, 2); + assert_eq!(max_col, 5); + assert_eq!(span, 1); + } + } + + mod test_intial_grid_sizing { + use super::super::compute_grid_size_estimate; + use crate::compute::grid::util::test_helpers::*; + use crate::style::GridPlacement::*; + + #[test] + fn explicit_grid_sizing_with_children() { + let explicit_col_count = 6; + let explicit_row_count = 8; + let child_styles = vec![ + (Line(1), Span(2), Line(2), Auto).into_grid_child(), + (Line(-4), Auto, Line(-2), Auto).into_grid_child(), + ]; + let (inline, block) = + compute_grid_size_estimate(explicit_col_count, explicit_row_count, child_styles.iter()); + assert_eq!(inline.negative_implicit, 0); + assert_eq!(inline.explicit, explicit_col_count); + assert_eq!(inline.positive_implicit, 0); + assert_eq!(block.negative_implicit, 0); + assert_eq!(block.explicit, explicit_row_count); + assert_eq!(block.positive_implicit, 0); + } + + #[test] + fn negative_implicit_grid_sizing() { + let explicit_col_count = 4; + let explicit_row_count = 4; + let child_styles = vec![ + (Line(-6), Span(2), Line(-8), Auto).into_grid_child(), + (Line(4), Auto, Line(3), Auto).into_grid_child(), + ]; + let (inline, block) = + compute_grid_size_estimate(explicit_col_count, explicit_row_count, child_styles.iter()); + assert_eq!(inline.negative_implicit, 1); + assert_eq!(inline.explicit, explicit_col_count); + assert_eq!(inline.positive_implicit, 0); + assert_eq!(block.negative_implicit, 3); + assert_eq!(block.explicit, explicit_row_count); + assert_eq!(block.positive_implicit, 0); + } + } +} diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs new file mode 100644 index 000000000..bf30b4a63 --- /dev/null +++ b/src/compute/grid/mod.rs @@ -0,0 +1,297 @@ +//! This module is a partial implementation of the CSS Grid Level 1 specification +//! https://www.w3.org/TR/css-grid-1/ +use crate::axis::{AbsoluteAxis, AbstractAxis, InBothAbsAxis}; +use crate::geometry::{Line, Rect, Size}; +use crate::layout::{Layout, RunMode, SizingMode}; +use crate::math::MaybeMath; +use crate::node::Node; +use crate::resolve::{MaybeResolve, ResolveOrZero}; +use crate::style::{AlignContent, AvailableSpace, Display, PositionType}; +use crate::style_helpers::*; +use crate::sys::{GridTrackVec, Vec}; +use crate::tree::LayoutTree; +use alignment::{align_and_position_item, align_tracks}; +use explicit_grid::{compute_explicit_grid_size_in_axis, initialize_grid_tracks}; +use implicit_grid::compute_grid_size_estimate; +use placement::place_grid_items; +use track_sizing::{determine_if_item_crosses_flexible_tracks, resolve_item_track_indexes, track_sizing_algorithm}; +use types::{CellOccupancyMatrix, GridTrack}; +use util::coordinates::css_grid_line_into_origin_zero_coords; + +use super::compute_node_layout; + +mod alignment; +mod explicit_grid; +mod implicit_grid; +mod placement; +mod track_sizing; +mod types; +mod util; + +/// Grid layout algorithm +/// This consists of a few phases: +/// - Resolving the explicit grid +/// - Placing items (which also resolves the implicit grid) +/// - Track (row/column) sizing +/// - Alignment & Final item placement +pub fn compute(tree: &mut impl LayoutTree, node: Node, available_space: Size) -> Size { + let get_child_styles_iter = |node| tree.children(node).into_iter().map(|child_node: &Node| tree.style(*child_node)); + let style = tree.style(node).clone(); + let child_styles_iter = get_child_styles_iter(node); + + // 1. Resolve the explicit grid + // Exactly compute the number of rows and columns in the explicit grid. + let explicit_col_count = compute_explicit_grid_size_in_axis(&style, AbsoluteAxis::Horizontal); + let explicit_row_count = compute_explicit_grid_size_in_axis(&style, AbsoluteAxis::Vertical); + + // 2. Implicit Grid: Estimate Track Counts + // Estimate the number of rows and columns in the implicit grid (= the entire grid) + // This is necessary as part of placement. Doing it early here is a perf optimisation to reduce allocations. + let (est_col_counts, est_row_counts) = + compute_grid_size_estimate(explicit_col_count, explicit_row_count, child_styles_iter); + + // 2. Grid Item Placement + // Match items (children) to a definite grid position (row start/end and column start/end position) + let mut items = Vec::with_capacity(tree.child_count(node)); + let mut cell_occupancy_matrix = CellOccupancyMatrix::with_track_counts(est_col_counts, est_row_counts); + let grid_auto_flow = style.grid_auto_flow; + let in_flow_children_iter = || { + tree.children(node) + .into_iter() + .copied() + .enumerate() + .map(|(index, child_node)| (index, child_node, tree.style(child_node))) + .filter(|(_, _, style)| style.display != Display::None && style.position_type != PositionType::Absolute) + }; + place_grid_items(&mut cell_occupancy_matrix, &mut items, in_flow_children_iter, grid_auto_flow); + + // Extract track counts from previous step (auto-placement can expand the number of tracks) + let final_col_counts = *cell_occupancy_matrix.track_counts(AbsoluteAxis::Horizontal); + let final_row_counts = *cell_occupancy_matrix.track_counts(AbsoluteAxis::Vertical); + + // 3. Initialize Tracks + // Initialize (explicit and implicit) grid tracks (and gutters) + // This resolves the min and max track sizing functions for all tracks and gutters + let mut columns = GridTrackVec::new(); + let mut rows = GridTrackVec::new(); + initialize_grid_tracks( + &mut columns, + final_col_counts, + &style.grid_template_columns, + &style.grid_auto_columns, + style.gap.width, + |column_index| cell_occupancy_matrix.column_is_occupied(column_index), + ); + initialize_grid_tracks( + &mut rows, + final_row_counts, + &style.grid_template_rows, + &style.grid_auto_rows, + style.gap.height, + |row_index| cell_occupancy_matrix.row_is_occupied(row_index), + ); + + // 4. Compute "available grid space" + // https://www.w3.org/TR/css-grid-1/#available-grid-space + let padding = style.padding.resolve_or_zero(available_space.width.into_option()); + let border = style.border.resolve_or_zero(available_space.width.into_option()); + let min_size = style.min_size.maybe_resolve(available_space.into_options()); + let max_size = style.max_size.maybe_resolve(available_space.into_options()); + let size = style.size.maybe_resolve(available_space.into_options()); + + let constrained_available_space = size + .maybe_clamp(min_size, max_size) + .map(|size| size.map(AvailableSpace::Definite)) + .unwrap_or(available_space.maybe_clamp(min_size, max_size)); + + let available_grid_space = Size { + width: constrained_available_space + .width + .map_definite_value(|space| space - padding.horizontal_axis_sum() - border.horizontal_axis_sum()), + height: constrained_available_space + .height + .map_definite_value(|space| space - padding.vertical_axis_sum() - border.vertical_axis_sum()), + }; + + // 5. Track Sizing + + // Convert grid placements in origin-zero coordinates to indexes into the GridTrack (rows and columns) vectors + // This computation is relatively trivial, but it requires the final number of negative (implicit) tracks in + // each axis, and doing it up-front here means we don't have to keep repeating that calculation + resolve_item_track_indexes(&mut items, final_col_counts, final_row_counts); + + // For each item, and in each axis, determine whether the item crosses any flexible (fr) tracks + // Record this as a boolean (per-axis) on each item for later use in the track-sizing algorithm + determine_if_item_crosses_flexible_tracks(&mut items, &columns, &rows); + + // Run track sizing algorithm for Inline axis + track_sizing_algorithm( + tree, + AbstractAxis::Inline, + available_space, + available_grid_space, + &style, + &mut columns, + &mut rows, + &mut items, + |track: &GridTrack, available_space: AvailableSpace| { + track.max_track_sizing_function.definite_value(available_space) + }, + ); + // Run track sizing algorithm for Block axis + track_sizing_algorithm( + tree, + AbstractAxis::Block, + available_space, + available_grid_space, + &style, + &mut rows, + &mut columns, + &mut items, + |track: &GridTrack, available_space: AvailableSpace| { + track.max_track_sizing_function.definite_value(available_space) + }, + ); + // Re-run track sizing algorithm for Inline axis + track_sizing_algorithm( + tree, + AbstractAxis::Inline, + available_space, + available_grid_space, + &style, + &mut columns, + &mut rows, + &mut items, + |track: &GridTrack, _| Some(track.base_size), + ); + // Re-run track sizing algorithm for Block axis + track_sizing_algorithm( + tree, + AbstractAxis::Block, + available_space, + available_grid_space, + &style, + &mut rows, + &mut columns, + &mut items, + |track: &GridTrack, _| Some(track.base_size), + ); + + // 6. Compute container size + let resolved_style_size = style.size.maybe_resolve(available_space.into_options()); + let container_border_box = Size { + width: resolved_style_size.get(AbstractAxis::Inline).unwrap_or_else(|| { + columns.iter().map(|track| track.base_size).sum::() + + padding.horizontal_axis_sum() + + border.horizontal_axis_sum() + }), + height: resolved_style_size.get(AbstractAxis::Block).unwrap_or_else(|| { + rows.iter().map(|track| track.base_size).sum::() + + padding.vertical_axis_sum() + + border.vertical_axis_sum() + }), + }; + let container_content_box = Size { + width: container_border_box.width - padding.horizontal_axis_sum() - border.horizontal_axis_sum(), + height: container_border_box.height - padding.vertical_axis_sum() - border.vertical_axis_sum(), + }; + + // 7. Track Alignment + + // Align columns + align_tracks( + container_content_box.get(AbstractAxis::Inline), + Line { start: padding.left, end: padding.right }, + Line { start: border.left, end: border.right }, + &mut columns, + style.justify_content.unwrap_or(AlignContent::Stretch), + ); + // Align rows + align_tracks( + container_content_box.get(AbstractAxis::Block), + Line { start: padding.top, end: padding.bottom }, + Line { start: border.top, end: border.bottom }, + &mut rows, + style.align_content.unwrap_or(AlignContent::Stretch), + ); + + // 8. Size, Align, and Position Grid Items + + // Sort items back into original order to allow them to be matched up with styles + items.sort_by_key(|item| item.source_order); + + let container_alignment_styles = InBothAbsAxis { horizontal: style.justify_items, vertical: style.align_items }; + + // Position in-flow children (stored in items vector) + for (index, item) in items.iter().enumerate() { + let grid_area = Rect { + top: rows[item.row_indexes.start as usize + 1].offset, + bottom: rows[item.row_indexes.end as usize].offset, + left: columns[item.column_indexes.start as usize + 1].offset, + right: columns[item.column_indexes.end as usize].offset, + }; + align_and_position_item( + tree, + item.node, + index as u32, + grid_area, + container_content_box, + container_alignment_styles, + ); + } + + // Position hidden and absolutely positioned children + let mut order = items.len() as u32; + (0..tree.child_count(node)).for_each(|index| { + let child = tree.child(node, index); + let child_style = tree.style(child); + + // Position hidden child + if child_style.display == Display::None { + *tree.layout_mut(node) = Layout::with_order(order); + compute_node_layout( + tree, + child, + Size::NONE, + Size::MAX_CONTENT, + RunMode::PeformLayout, + SizingMode::InherentSize, + ); + order += 1; + return; + } + + // Position absolutely positioned child + if child_style.position_type == PositionType::Absolute { + // Convert grid-col-{start/end} into Option's of indexes into the columns vector + // The Option is None if the style property is Auto and an unresolvable Span + let maybe_grid_cols = child_style.grid_column.resolve_absolutely_positioned_grid_tracks(); + let maybe_col_indexes = maybe_grid_cols.map(|maybe_grid_line| { + maybe_grid_line.map(|grid_line| { + let oz_line = css_grid_line_into_origin_zero_coords(grid_line, final_col_counts.explicit); + final_col_counts.oz_line_to_grid_track_vec_index(oz_line) as usize + }) + }); + // Convert grid-row-{start/end} into Option's of indexes into the row vector + // The Option is None if the style property is Auto and an unresolvable Span + let maybe_grid_rows = child_style.grid_row.resolve_absolutely_positioned_grid_tracks(); + let maybe_row_indexes = maybe_grid_rows.map(|maybe_grid_line| { + maybe_grid_line.map(|grid_line| { + let oz_line = css_grid_line_into_origin_zero_coords(grid_line, final_row_counts.explicit); + final_row_counts.oz_line_to_grid_track_vec_index(oz_line) as usize + }) + }); + + let grid_area = Rect { + top: maybe_row_indexes.start.map(|index| rows[index].offset).unwrap_or(0.0), + bottom: maybe_row_indexes.end.map(|index| rows[index].offset).unwrap_or(container_border_box.height), + left: maybe_col_indexes.start.map(|index| columns[index].offset).unwrap_or(0.0), + right: maybe_col_indexes.end.map(|index| columns[index].offset).unwrap_or(container_border_box.width), + }; + align_and_position_item(tree, child, order, grid_area, container_content_box, container_alignment_styles); + order += 1; + } + }); + + container_border_box +} diff --git a/src/compute/grid/placement.rs b/src/compute/grid/placement.rs new file mode 100644 index 000000000..0c8218848 --- /dev/null +++ b/src/compute/grid/placement.rs @@ -0,0 +1,532 @@ +//! Implements placing items in the grid and resolving the implicit grid. +//! https://www.w3.org/TR/css-grid-1/#placement +use super::types::{CellOccupancyMatrix, CellOccupancyState, GridItem}; +use super::util::css_grid_line_into_origin_zero_coords; +use crate::axis::{AbsoluteAxis, InBothAbsAxis}; +use crate::geometry::Line; +use crate::node::Node; +use crate::style::{GridAutoFlow, GridPlacement, Style}; +use crate::sys::Vec; + +/// 8.5. Grid Item Placement Algorithm +/// Place items into the grid, generating new rows/column into the implicit grid as required +/// +/// [Specification](https://www.w3.org/TR/css-grid-2/#auto-placement-algo) +pub(super) fn place_grid_items<'a, ChildIter>( + cell_occupancy_matrix: &mut CellOccupancyMatrix, + items: &mut Vec, + children_iter: impl Fn() -> ChildIter, + grid_auto_flow: GridAutoFlow, +) where + ChildIter: Iterator, +{ + let primary_axis = grid_auto_flow.primary_axis(); + let secondary_axis = primary_axis.other_axis(); + + let map_child_style_to_origin_zero_placement = { + let explicit_col_count = cell_occupancy_matrix.track_counts(AbsoluteAxis::Horizontal).explicit; + let explicit_row_count = cell_occupancy_matrix.track_counts(AbsoluteAxis::Vertical).explicit; + move |(index, node, style): (usize, Node, &'a Style)| -> (_, _, _, &'a Style) { + let origin_zero_placement = InBothAbsAxis { + horizontal: style.grid_column.map(|placement| { + placement.map_track(|track| css_grid_line_into_origin_zero_coords(track, explicit_col_count)) + }), + vertical: style.grid_row.map(|placement| { + placement.map_track(|track| css_grid_line_into_origin_zero_coords(track, explicit_row_count)) + }), + }; + (index, node, origin_zero_placement, style) + } + }; + + // 1. Place children with definite positions + children_iter() + .filter(|(_, _, child_style)| child_style.grid_row.is_definite() && child_style.grid_column.is_definite()) + .map(map_child_style_to_origin_zero_placement) + .for_each(|(index, child_node, child_placement, style)| { + let (row_span, col_span) = place_definite_grid_item(child_placement, primary_axis); + record_grid_placement( + cell_occupancy_matrix, + items, + child_node, + index, + style, + primary_axis, + row_span, + col_span, + CellOccupancyState::DefinitelyPlaced, + ); + }); + + // 2. Place remaining children with definite secondary axis positions + children_iter() + .filter(|(_, _, child_style)| { + child_style.grid_placement(secondary_axis).is_definite() + && !child_style.grid_placement(primary_axis).is_definite() + }) + .map(map_child_style_to_origin_zero_placement) + .for_each(|(index, child_node, child_placement, style)| { + let (primary_span, secondary_span) = + place_definite_secondary_axis_item(&*cell_occupancy_matrix, child_placement, grid_auto_flow); + + record_grid_placement( + cell_occupancy_matrix, + items, + child_node, + index, + style, + primary_axis, + primary_span, + secondary_span, + CellOccupancyState::AutoPlaced, + ); + }); + + // 3. Determine the number of columns in the implicit grid + // By the time we get to this point in the execution, this is actually already accounted for: + // + // 3.1 Start with the columns from the explicit grid + // => Handled by grid size estimate which is used to pre-size the GridOccupancyMatrix + // + // 3.2 Among all the items with a definite column position (explicitly positioned items, items positioned in the previous step, + // and items not yet positioned but with a definite column) add columns to the beginning and end of the implicit grid as necessary + // to accommodate those items. + // => Handled by expand_to_fit_range which expands the GridOccupancyMatrix as necessary + // -> Called by mark_area_as + // -> Called by record_grid_placement + // + // 3.3 If the largest column span among all the items without a definite column position is larger than the width of + // the implicit grid, add columns to the end of the implicit grid to accommodate that column span. + // => Handled by grid size estimate which is used to pre-size the GridOccupancyMatrix + + // 4. Position the remaining grid items + // (which either have definite position only in the secondary axis or indefinite positions in both axis) + let mut grid_position: (u16, u16) = (0, 0); + let mut idx = 0; + children_iter() + .filter(|(_, _, child_style)| !child_style.grid_placement(secondary_axis).is_definite()) + .map(map_child_style_to_origin_zero_placement) + .for_each(|(index, child_node, child_placement, style)| { + idx += 1; + #[cfg(test)] + println!("\nItem {idx}\n=============="); + + // Compute placement + let (primary_span, secondary_span) = place_indefinitely_positioned_item( + &*cell_occupancy_matrix, + child_placement, + grid_auto_flow, + grid_position, + ); + + // Record item + record_grid_placement( + cell_occupancy_matrix, + items, + child_node, + index, + style, + primary_axis, + primary_span, + secondary_span, + CellOccupancyState::AutoPlaced, + ); + + // If using the "dense" placement algorithm then reset the grid position back to (0, 0) ready for the next item + // Otherwise set it to the position of the current item so that the next item it placed after it. + grid_position = match grid_auto_flow.is_dense() { + true => (0, 0), + false => (primary_span.end as u16, secondary_span.start as u16), + } + }); +} + +/// 8.5. Grid Item Placement Algorithm +/// Place a single definitely placed item into the grid +fn place_definite_grid_item( + placement: InBothAbsAxis>, + primary_axis: AbsoluteAxis, +) -> (Line, Line) { + // Resolve spans to tracks + let primary_span = placement.get(primary_axis).resolve_definite_grid_tracks(); + let secondary_span = placement.get(primary_axis.other_axis()).resolve_definite_grid_tracks(); + + (primary_span, secondary_span) +} + +/// 8.5. Grid Item Placement Algorithm +/// Step 2. Place remaining children with definite secondary axis positions +fn place_definite_secondary_axis_item( + cell_occupancy_matrix: &CellOccupancyMatrix, + placement: InBothAbsAxis>, + auto_flow: GridAutoFlow, +) -> (Line, Line) { + let primary_axis = auto_flow.primary_axis(); + let secondary_axis = primary_axis.other_axis(); + + let secondary_axis_placement = placement.get(secondary_axis).resolve_definite_grid_tracks(); + let starting_position = match auto_flow.is_dense() { + true => 0, + false => cell_occupancy_matrix + .last_of_type(primary_axis, secondary_axis_placement.start, CellOccupancyState::AutoPlaced) + .unwrap_or(0), + }; + + let mut position: i16 = starting_position; + loop { + let primary_axis_placement = placement.get(primary_axis).resolve_indefinite_grid_tracks(position); + + let does_fit = cell_occupancy_matrix.line_area_is_unoccupied( + primary_axis, + primary_axis_placement, + secondary_axis_placement, + ); + + if does_fit { + return (primary_axis_placement, secondary_axis_placement); + } else { + position += 1; + } + } +} + +/// 8.5. Grid Item Placement Algorithm +/// Step 4. Position the remaining grid items. +fn place_indefinitely_positioned_item( + cell_occupancy_matrix: &CellOccupancyMatrix, + placement: InBothAbsAxis>, + auto_flow: GridAutoFlow, + grid_position: (u16, u16), +) -> (Line, Line) { + let primary_axis = auto_flow.primary_axis(); + + let primary_placement_style = placement.get(primary_axis); + let secondary_placement_style = placement.get(primary_axis.other_axis()); + + let primary_span = primary_placement_style.indefinite_span(); + let secondary_span = secondary_placement_style.indefinite_span(); + let has_definite_primary_axis_position = primary_placement_style.is_definite(); + let primary_axis_length = cell_occupancy_matrix.track_counts(primary_axis).len() as i16; + + let track_area_is_unoccupied = |primary_range, secondary_range| { + cell_occupancy_matrix.track_area_is_unoccupied(primary_axis, primary_range, secondary_range) + }; + let tracks_to_lines = |range| cell_occupancy_matrix.tracks_to_lines(primary_axis, range); + + let (mut primary_idx, mut secondary_idx) = grid_position; + + if has_definite_primary_axis_position { + let definite_primary_placement = primary_placement_style.resolve_definite_grid_tracks(); + let defined_primary_idx = + cell_occupancy_matrix.lines_to_tracks(primary_axis.other_axis(), definite_primary_placement).start as u16; + + // Compute starting position for search + if defined_primary_idx < primary_idx && secondary_idx != 0 { + secondary_idx = 0; + primary_idx = defined_primary_idx + 1; + } else { + primary_idx = defined_primary_idx; + } + + // Item has fixed primary axis position: so we simply increment the secondary axis position + // until we find a space that the item fits in + loop { + let primary_range = (primary_idx as i16)..((primary_idx + primary_span) as i16); + let secondary_range = (secondary_idx as i16)..((secondary_idx + secondary_span) as i16); + + let place_here = track_area_is_unoccupied(primary_range.clone(), secondary_range.clone()); + if place_here { + let primary_span = tracks_to_lines(primary_range); + let secondary_span = tracks_to_lines(secondary_range); + return (primary_span, secondary_span); + } + + secondary_idx += 1; + } + } else { + // Item does not have any fixed axis, so we search along the primary axis until we hit the end of the already + // existent tracks, and then we reset the primary axis back to zero and increment the secondary axis index. + // We continue in this vein until we find a space that the item fits in. + loop { + let primary_range = (primary_idx as i16)..((primary_idx + primary_span) as i16); + let secondary_range = (secondary_idx as i16)..((secondary_idx + secondary_span) as i16); + + // Check if item fits in it's current position, and if so place it there + let primary_out_of_bounds = primary_range.end > primary_axis_length; + let place_here = + !primary_out_of_bounds && track_area_is_unoccupied(primary_range.clone(), secondary_range.clone()); + if place_here { + let primary_span = tracks_to_lines(primary_range); + let secondary_span = tracks_to_lines(secondary_range); + return (primary_span, secondary_span); + } + + // Else check the next position + if primary_out_of_bounds { + secondary_idx += 1; + primary_idx = 0; + } else { + primary_idx += 1; + } + } + } +} + +/// Record the grid item in both CellOccupancyMatric and the GridItems list +/// once a definite placement has been determined +#[allow(clippy::too_many_arguments)] +fn record_grid_placement( + cell_occupancy_matrix: &mut CellOccupancyMatrix, + items: &mut Vec, + node: Node, + index: usize, + style: &Style, + primary_axis: AbsoluteAxis, + primary_span: Line, + secondary_span: Line, + placement_type: CellOccupancyState, +) { + #[cfg(test)] + println!("BEFORE placement:"); + #[cfg(test)] + println!("{cell_occupancy_matrix:?}"); + + // Mark area of grid as occupied + cell_occupancy_matrix.mark_area_as(primary_axis, primary_span, secondary_span, placement_type); + + // Create grid item + let (col_span, row_span) = match primary_axis { + AbsoluteAxis::Horizontal => (primary_span, secondary_span), + AbsoluteAxis::Vertical => (secondary_span, primary_span), + }; + items.push(GridItem::new_with_placement_style_and_order(node, col_span, row_span, style, index as u16)); + + #[cfg(test)] + println!("AFTER placement:"); + #[cfg(test)] + println!("{cell_occupancy_matrix:?}"); + #[cfg(test)] + println!("\n"); +} + +#[allow(clippy::bool_assert_comparison)] +#[cfg(test)] +mod tests { + // It's more readable if the test code is uniform, so we tolerate unnecessary clones in tests + #![allow(clippy::redundant_clone)] + + mod test_placement_algorithm { + use crate::compute::grid::implicit_grid::compute_grid_size_estimate; + use crate::compute::grid::types::TrackCounts; + use crate::compute::grid::util::*; + use crate::compute::grid::CellOccupancyMatrix; + use crate::prelude::*; + use crate::style::{GridAutoFlow, GridPlacement::*}; + use slotmap::SlotMap; + + use super::super::place_grid_items; + + type ExpectedPlacement = (i16, i16, i16, i16); + + fn placement_test_runner( + explicit_col_count: u16, + explicit_row_count: u16, + children: Vec<(usize, Node, Style, ExpectedPlacement)>, + expected_col_counts: TrackCounts, + expected_row_counts: TrackCounts, + flow: GridAutoFlow, + ) { + // Setup test + let children_iter = || children.iter().map(|(index, node, style, _)| (*index, *node, style)); + let child_styles_iter = children.iter().map(|(_, _, style, _)| style); + let estimated_sizes = compute_grid_size_estimate(explicit_col_count, explicit_row_count, child_styles_iter); + let mut items = Vec::new(); + let mut cell_occupancy_matrix = + CellOccupancyMatrix::with_track_counts(estimated_sizes.0, estimated_sizes.1); + + // Run placement algorithm + place_grid_items(&mut cell_occupancy_matrix, &mut items, children_iter, flow); + + // Assert that each item has been placed in the right location + let mut sorted_children = children.clone(); + sorted_children.sort_by_key(|child| child.0); + for (idx, ((_sort_order, node, _style, expected_placement), item)) in + sorted_children.iter().zip(items.iter()).enumerate() + { + assert_eq!(item.node, *node); + let actual_placement = (item.column.start, item.column.end, item.row.start, item.row.end); + assert_eq!(actual_placement, *expected_placement, "Item {idx} (0-indexed)"); + } + + // Assert that the correct number of implicit rows have been generated + let actual_row_counts = *cell_occupancy_matrix.track_counts(crate::compute::grid::AbsoluteAxis::Vertical); + assert_eq!(actual_row_counts, expected_row_counts, "row track counts"); + let actual_col_counts = *cell_occupancy_matrix.track_counts(crate::compute::grid::AbsoluteAxis::Horizontal); + assert_eq!(actual_col_counts, expected_col_counts, "column track counts"); + } + + #[test] + fn test_only_fixed_placement() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + vec![ + // node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), (Line(1), Auto, Line(1), Auto).into_grid_child(), (0, 1, 0, 1)), + (2, sm.insert(()), (Line(-4), Auto, Line(-3), Auto).into_grid_child(), (-1, 0, 0, 1)), + (3, sm.insert(()), (Line(-3), Auto, Line(-4), Auto).into_grid_child(), (0, 1, -1, 0)), + (4, sm.insert(()), (Line(3), Span(2), Line(5), Auto).into_grid_child(), (2, 4, 4, 5)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 1, explicit: 2, positive_implicit: 2 }; + let expected_rows = TrackCounts { negative_implicit: 1, explicit: 2, positive_implicit: 3 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_only_auto_placement_row_flow() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + let auto_child = (Auto, Auto, Auto, Auto).into_grid_child(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), auto_child.clone(), (0, 1, 0, 1)), + (2, sm.insert(()), auto_child.clone(), (1, 2, 0, 1)), + (3, sm.insert(()), auto_child.clone(), (0, 1, 1, 2)), + (4, sm.insert(()), auto_child.clone(), (1, 2, 1, 2)), + (5, sm.insert(()), auto_child.clone(), (0, 1, 2, 3)), + (6, sm.insert(()), auto_child.clone(), (1, 2, 2, 3)), + (7, sm.insert(()), auto_child.clone(), (0, 1, 3, 4)), + (8, sm.insert(()), auto_child.clone(), (1, 2, 3, 4)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 0 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 2 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_only_auto_placement_column_flow() { + let flow = GridAutoFlow::Column; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + let auto_child = (Auto, Auto, Auto, Auto).into_grid_child(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), auto_child.clone(), (0, 1, 0, 1)), + (2, sm.insert(()), auto_child.clone(), (0, 1, 1, 2)), + (3, sm.insert(()), auto_child.clone(), (1, 2, 0, 1)), + (4, sm.insert(()), auto_child.clone(), (1, 2, 1, 2)), + (5, sm.insert(()), auto_child.clone(), (2, 3, 0, 1)), + (6, sm.insert(()), auto_child.clone(), (2, 3, 1, 2)), + (7, sm.insert(()), auto_child.clone(), (3, 4, 0, 1)), + (8, sm.insert(()), auto_child.clone(), (3, 4, 1, 2)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 2 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 0 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_oversized_item() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), (Span(5), Auto, Auto, Auto).into_grid_child(), (0, 5, 0, 1)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 3 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 0 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_fixed_in_secondary_axis() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), (Span(2), Auto, Line(1), Auto).into_grid_child(), (0, 2, 0, 1)), + (2, sm.insert(()), (Auto, Auto, Line(2), Auto).into_grid_child(), (0, 1, 1, 2)), + (3, sm.insert(()), (Auto, Auto, Line(1), Auto).into_grid_child(), (2, 3, 0, 1)), + (4, sm.insert(()), (Auto, Auto, Line(4), Auto).into_grid_child(), (0, 1, 3, 4)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 1 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 2 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_definite_in_secondary_axis_with_fully_definite_negative() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 2; + let explicit_row_count = 2; + let children = { + let mut sm = SlotMap::new(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (2, sm.insert(()), (Auto, Auto, Line(2), Auto).into_grid_child(), (0, 1, 1, 2)), + (1, sm.insert(()), (Line(-4), Auto, Line(2), Auto).into_grid_child(), (-1, 0, 1, 2)), + (3, sm.insert(()), (Auto, Auto, Line(1), Auto).into_grid_child(), (0, 1, 0, 1)), + ] + }; + let expected_cols = TrackCounts { negative_implicit: 1, explicit: 2, positive_implicit: 0 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 2, positive_implicit: 0 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_dense_packing_algorithm() { + let flow = GridAutoFlow::RowDense; + let explicit_col_count = 4; + let explicit_row_count = 4; + let children = { + let mut sm = SlotMap::new(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), (Line(2), Auto, Line(1), Auto).into_grid_child(), (1, 2, 0, 1)), // Definitely positioned in column 2 + (2, sm.insert(()), (Span(2), Auto, Auto, Auto).into_grid_child(), (2, 4, 0, 1)), // Spans 2 columns, so positioned after item 1 + (3, sm.insert(()), (Auto, Auto, Auto, Auto).into_grid_child(), (0, 1, 0, 1)), // Spans 1 column, so should be positioned before item 1 + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 4, positive_implicit: 0 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 4, positive_implicit: 0 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + + #[test] + fn test_sparse_packing_algorithm() { + let flow = GridAutoFlow::Row; + let explicit_col_count = 4; + let explicit_row_count = 4; + let children = { + let mut sm = SlotMap::new(); + vec![ + // output order, node, style (grid coords), expected_placement (oz coords) + (1, sm.insert(()), (Auto, Span(3), Auto, Auto).into_grid_child(), (0, 3, 0, 1)), // Width 3 + (2, sm.insert(()), (Auto, Span(3), Auto, Auto).into_grid_child(), (0, 3, 1, 2)), // Width 3 (wraps to next row) + (3, sm.insert(()), (Auto, Span(1), Auto, Auto).into_grid_child(), (3, 4, 1, 2)), // Width 1 (uses second row as we're already on it) + ] + }; + let expected_cols = TrackCounts { negative_implicit: 0, explicit: 4, positive_implicit: 0 }; + let expected_rows = TrackCounts { negative_implicit: 0, explicit: 4, positive_implicit: 0 }; + placement_test_runner(explicit_col_count, explicit_row_count, children, expected_cols, expected_rows, flow); + } + } +} diff --git a/src/compute/grid/track_sizing.rs b/src/compute/grid/track_sizing.rs new file mode 100644 index 000000000..861c03bd1 --- /dev/null +++ b/src/compute/grid/track_sizing.rs @@ -0,0 +1,904 @@ +//! Implements the track sizing algorithm +//! https://www.w3.org/TR/css-grid-1/#layout-algorithm +use super::types::{GridItem, GridTrack, TrackCounts}; +use crate::axis::AbstractAxis; +use crate::geometry::Size; +use crate::math::MaybeMath; +use crate::prelude::LayoutTree; +use crate::resolve::{MaybeResolve, ResolveOrZero}; +use crate::style::{AlignContent, AvailableSpace, MaxTrackSizingFunction, MinTrackSizingFunction, Style}; +use crate::sys::{f32_max, f32_min}; +use core::cmp::Ordering; + +/// Takes an axis, and a list of grid items sorted firstly by whether they cross a flex track +/// in the specified axis (items that don't cross a flex track first) and then by the number +/// of tracks they cross in specified axis (ascending order). +struct ItemBatcher { + /// The axis in which the ItemBatcher is operating. Used when querying properties from items. + axis: AbstractAxis, + /// The starting index of the current batch + index_offset: usize, + /// The span of the items in the current batch + current_span: u16, + /// Whether the current batch of items cross a flexible track + current_is_flex: bool, +} + +impl ItemBatcher { + /// Create a new ItemBatcher for the specified axis + fn new(axis: AbstractAxis) -> Self { + ItemBatcher { index_offset: 0, axis, current_span: 1, current_is_flex: false } + } + + /// This is basically a manual version of Iterator::next which passes `items` + /// in as a parameter on each iteration to work around borrow checker rules + fn next<'items>(&mut self, items: &'items mut [GridItem]) -> Option<(&'items mut [GridItem], bool)> { + if self.current_is_flex || self.index_offset >= items.len() { + return None; + } + + let item = &items[self.index_offset]; + self.current_span = item.span(self.axis); + self.current_is_flex = item.crosses_flexible_track(self.axis); + + let next_index_offset = if self.current_is_flex { + items.len() + } else { + items + .iter() + .position(|item: &GridItem| { + item.crosses_flexible_track(self.axis) || item.span(self.axis) > self.current_span + }) + .unwrap_or(items.len()) + }; + + let batch_range = self.index_offset..next_index_offset; + self.index_offset = next_index_offset; + + let batch = &mut items[batch_range]; + Some((batch, self.current_is_flex)) + } +} + +/// To make track sizing efficient we want to order tracks +/// Here a placement is either a Line representing a row-start/row-end or a column-start/column-end +#[inline(always)] +pub(super) fn cmp_by_cross_flex_then_span_then_start( + axis: AbstractAxis, +) -> impl FnMut(&GridItem, &GridItem) -> Ordering { + move |item_a: &GridItem, item_b: &GridItem| -> Ordering { + match (item_a.crosses_flexible_track(axis), item_b.crosses_flexible_track(axis)) { + (false, true) => Ordering::Less, + (true, false) => Ordering::Greater, + _ => { + let placement_a = item_a.placement(axis); + let placement_b = item_b.placement(axis); + let a_span = placement_a.end - placement_a.start; + let b_span = placement_b.end - placement_b.start; + match a_span.cmp(&b_span) { + Ordering::Less => Ordering::Less, + Ordering::Greater => Ordering::Greater, + Ordering::Equal => placement_a.start.cmp(&placement_b.start), + } + } + } + } +} + +/// When applying the track sizing algorithm and estimating the size in the other axis for content sizing items +/// we should take into account align-content/justify-content if both the grid container and all items in the +/// other axis have definite sizes. This function computes such a per-gutter additional size adjustment. +pub(super) fn compute_alignment_gutter_adjustment( + alignment: AlignContent, + available_space: AvailableSpace, + get_track_size_estimate: impl Fn(&GridTrack, AvailableSpace) -> Option, + tracks: &[GridTrack], +) -> f32 { + // As items never cross the outermost gutters in a grid, we can simplify our calculations by treating + // AlignContent::Start and AlignContent::End the same + let outer_gutter_weight = match alignment { + AlignContent::Start => 1, + AlignContent::End => 1, + AlignContent::Center => 1, + AlignContent::Stretch => 0, + AlignContent::SpaceBetween => 0, + AlignContent::SpaceAround => 1, + AlignContent::SpaceEvenly => 1, + }; + + let inner_gutter_weight = match alignment { + AlignContent::Start => 0, + AlignContent::End => 0, + AlignContent::Center => 0, + AlignContent::Stretch => 0, + AlignContent::SpaceBetween => 1, + AlignContent::SpaceAround => 2, + AlignContent::SpaceEvenly => 1, + }; + + if inner_gutter_weight > 0 && available_space.is_definite() && tracks.len() > 1 { + let inner_available_space = tracks + .iter() + .map(|track| get_track_size_estimate(track, available_space)) + .sum::>() + .map(|track_size_sum| f32_max(0.0, available_space.unwrap() - track_size_sum)) + .unwrap_or(0.0); + + let weighted_track_count = + (((tracks.len() - 3) / 2) * inner_gutter_weight as usize) + (2 * outer_gutter_weight as usize); + + (inner_available_space / weighted_track_count as f32) * inner_gutter_weight as f32 + } else { + 0.0 + } +} + +/// Convert origin-zero coordinates track placement in grid track vector indexes +pub(super) fn resolve_item_track_indexes(items: &mut [GridItem], column_counts: TrackCounts, row_counts: TrackCounts) { + for item in items { + item.column_indexes = item.column.map(|oz_index| column_counts.oz_line_to_grid_track_vec_index(oz_index)); + item.row_indexes = item.row.map(|oz_index| row_counts.oz_line_to_grid_track_vec_index(oz_index)); + } +} + +/// Determine (in each axis) whether the item crosses any flexible tracks +pub(super) fn determine_if_item_crosses_flexible_tracks( + items: &mut Vec, + columns: &[GridTrack], + rows: &[GridTrack], +) { + for item in items { + item.crosses_flexible_column = + item.track_range_excluding_lines(AbstractAxis::Inline).any(|i| columns[i].is_flexible()); + item.crosses_flexible_row = + item.track_range_excluding_lines(AbstractAxis::Block).any(|i| rows[i].is_flexible()); + } +} + +/// Track sizing algorithm +/// Note: Gutters are treated as empty fixed-size tracks for the purpose of the track sizing algorithm. +#[allow(clippy::too_many_arguments)] +pub(super) fn track_sizing_algorithm( + tree: &mut Tree, + axis: AbstractAxis, + available_space: Size, + available_grid_space: Size, + container_style: &Style, + axis_tracks: &mut [GridTrack], + other_axis_tracks: &mut [GridTrack], + items: &mut [GridItem], + get_track_size_estimate: impl Fn(&GridTrack, AvailableSpace) -> Option, +) { + // 11.4 Initialise Track sizes + // Initialize each track’s base size and growth limit. + initialize_track_sizes(axis_tracks, available_space.get(axis)); + + // If all tracks have base_size = growth_limit, then skip the rest of this function. + // Note: this can only happen both track sizing function have the same fixed track sizing function + if axis_tracks.iter().all(|track| track.base_size == track.growth_limit) { + return; + } + + // Clear caches + // These caches are only valid for a single run of the track sizing algorithm, so ensure that they are clear. + items.iter_mut().for_each(|item| item.clear_contribution_caches()); + + // Pre-computations for 11.5 Resolve Intrinsic Track Sizes + + // The track sizing algorithm requires us to iterate through the items in ascendeding order of the number of + // tracks they span (first items that span 1 track, then items that span 2 tracks, etc). + // To avoid having to do multiple iterations of the items, we pre-sort them into this order. + items.sort_by(cmp_by_cross_flex_then_span_then_start(axis)); + + // Compute an additional amount to add to each spanned gutter when computing item's estimated size in the + // in the opposite axis based on the alignment, container size, and estimated track sizes in that axis + let gutter_alignment_adjustment = compute_alignment_gutter_adjustment( + container_style.grid_align_content(axis.other()), + available_space.get(axis.other()), + &get_track_size_estimate, + other_axis_tracks, + ); + if other_axis_tracks.len() > 3 { + let len = other_axis_tracks.len(); + let inner_gutter_tracks = other_axis_tracks[2..len].iter_mut().step_by(2); + for track in inner_gutter_tracks { + track.content_alignment_adjustment = gutter_alignment_adjustment; + } + } + + // 11.5 Resolve Intrinsic Track Sizes + resolve_intrinsic_track_sizes( + tree, + axis, + axis_tracks, + other_axis_tracks, + items, + available_space, + get_track_size_estimate, + ); + + // 11.6. Maximise Tracks + // Distributes free space (if any) to tracks with FINITE growth limits, up to their limits. + maximise_tracks(axis, axis_tracks, available_grid_space); + + // 11.7. Expand Flexible Tracks + // This step sizes flexible tracks using the largest value it can assign to an fr without exceeding the available space. + let axis_min_size = container_style.min_size.get(axis).into_option(); + let axis_max_size = container_style.max_size.get(axis).into_option(); + expand_flexible_tracks(tree, axis, axis_tracks, items, axis_min_size, axis_max_size, available_grid_space); + + // 11.8. Stretch auto Tracks + // This step expands tracks that have an auto max track sizing function by dividing any remaining positive, definite free space equally amongst them. + stretch_auto_tracks(axis, axis_tracks, container_style, available_space, available_grid_space); +} + +/// Whether it is a minimum or maximum size's space being distributed +/// This controls behaviour of the space distribution algorithm when distributing beyond limits +/// See "distributing space beyond limits" at https://www.w3.org/TR/css-grid-1/#extra-space +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +enum IntrinsicContributionType { + /// It's a minimum size's space being distributed + Minimum, + /// It's a maximum size's space being distributed + Maximum, +} + +/// Add any planned base size increases to the base size after a round of distributing space to base sizes +/// Reset the planed base size increase to zero ready for the next round. +fn flush_planned_base_size_increases(tracks: &mut [GridTrack]) { + for track in tracks { + track.base_size += track.base_size_planned_increase; + track.base_size_planned_increase = 0.0; + } +} + +/// Add any planned growth limit increases to the growth limit after a round of distributing space to growth limits +/// Reset the planed growth limit increase to zero ready for the next round. +fn flush_planned_growth_limit_increases(tracks: &mut [GridTrack], set_infinitely_growable: bool) { + for track in tracks { + if track.growth_limit_planned_increase > 0.0 { + track.growth_limit = if track.growth_limit == f32::INFINITY { + track.base_size + track.growth_limit_planned_increase + } else { + track.growth_limit + track.growth_limit_planned_increase + }; + track.infinitely_growable = set_infinitely_growable; + } else { + track.infinitely_growable = false; + } + track.growth_limit_planned_increase = 0.0 + } +} + +/// 11.4 Initialise Track sizes +/// Initialize each track’s base size and growth limit. +fn initialize_track_sizes(axis_tracks: &mut [GridTrack], axis_available_space: AvailableSpace) { + let last_track_idx = axis_tracks.len() - 1; + + // First and last grid lines are always zero-sized. + axis_tracks[0].base_size = 0.0; + axis_tracks[0].growth_limit = 0.0; + axis_tracks[last_track_idx].base_size = 0.0; + axis_tracks[last_track_idx].growth_limit = 0.0; + + let all_but_first_and_last = 1..last_track_idx; + for track in axis_tracks[all_but_first_and_last].iter_mut() { + // For each track, if the track’s min track sizing function is: + // - A fixed sizing function + // Resolve to an absolute length and use that size as the track’s initial base size. + // Note: Indefinite lengths cannot occur, as they’re treated as auto. + // - An intrinsic sizing function + // Use an initial base size of zero. + track.base_size = track.min_track_sizing_function.definite_value(axis_available_space).unwrap_or(0.0); + + // For each track, if the track’s max track sizing function is: + // - A fixed sizing function + // Resolve to an absolute length and use that size as the track’s initial growth limit. + // - An intrinsic sizing function + // Use an initial growth limit of infinity. + // - A flexible sizing function + // Use an initial growth limit of infinity. + track.growth_limit = + track.max_track_sizing_function.definite_value(axis_available_space).unwrap_or(f32::INFINITY); + + // In all cases, if the growth limit is less than the base size, increase the growth limit to match the base size. + if track.growth_limit < track.base_size { + track.growth_limit = track.base_size; + } + } +} + +/// 11.5 Resolve Intrinsic Track Sizes +fn resolve_intrinsic_track_sizes( + tree: &mut impl LayoutTree, + axis: AbstractAxis, + axis_tracks: &mut [GridTrack], + other_axis_tracks: &mut [GridTrack], + items: &mut [GridItem], + available_space: Size, + get_track_size_estimate: impl Fn(&GridTrack, AvailableSpace) -> Option, +) { + // Step 1. Shim baseline-aligned items so their intrinsic size contributions reflect their baseline alignment. + // TODO: we do not yet support baseline alignment for CSS Grid + + // Step 2. We skip Step 2 as it is noted that: + // + // This step is a simplification of the steps below for handling spanning items, and should yield + // the same behavior as running those instructions on items with a span of 1. + // + // We choose this alternative of running Step 3 on items with a span of 1 as we need to write the code for this anyway. + + // Step 3 and Step 4 + // 3. Iterate over items that don't cross a flex track. Items should have already been sorted in ascending order + // of the number of tracks they cross. + // 4. Next, repeat the previous step instead considering (together, rather than grouped by span size) all items + // that do span a track with a flexible sizing function while + + // Compute item's intrinsic (content-based) sizes + // Note: For items with a specified minimum size of auto (the initial value), the minimum contribution is usually equivalent + // to the min-content contribution—but can differ in some cases, see §6.6 Automatic Minimum Size of Grid Items. + // Also, minimum contribution <= min-content contribution <= max-content contribution. + // TODO: be smarter about only computing these when they are required + let mut compute_item_sizes = |item: &mut GridItem, axis_tracks: &[GridTrack]| { + let known_dimensions = item.known_dimensions_cached( + axis, + other_axis_tracks, + available_space.get(axis.other()), + &get_track_size_estimate, + ); + + let margin = item.margin.map(|m| m.resolve_or_zero(available_space.width.into_option())).sum_axes(); + + let min_content_size = item.min_content_contribution_cached(tree, known_dimensions) + margin; + let max_content_size = item.max_content_contribution_cached(tree, known_dimensions) + margin; + let axis_minimum_size = + item.minimum_contribution_cached(tree, axis, axis_tracks, available_space, known_dimensions) + + margin.get(axis); + + (axis_minimum_size, min_content_size.get(axis), max_content_size.get(axis)) + }; + + let axis_available_space = available_space.get(axis); + + let mut batched_item_iterator = ItemBatcher::new(axis); + while let Some((batch, is_flex)) = batched_item_iterator.next(items) { + // 1. For intrinsic minimums: + // First increase the base size of tracks with an intrinsic min track sizing function + let has_intrinsic_min_track_sizing_function = move |track: &GridTrack| { + track.min_track_sizing_function.definite_value(available_space.get(axis)).is_none() + }; + for item in batch.iter_mut() { + let (axis_minimum_size, axis_min_content_size, _) = compute_item_sizes(item, axis_tracks); + + // ...by distributing extra space as needed to accommodate these items’ minimum contributions. + // If the grid container is being sized under a min- or max-content constraint, use the items’ limited min-content contributions + // in place of their minimum contributions here. + let space = match axis_available_space { + AvailableSpace::MinContent | AvailableSpace::MaxContent => { + let limit = item.spanned_fixed_track_limit(axis, axis_tracks, axis_available_space); + axis_min_content_size.maybe_min(limit).max(axis_minimum_size) + } + AvailableSpace::Definite(_) => axis_minimum_size, + }; + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + if space > 0.0 { + distribute_item_space_to_base_size( + is_flex, + space, + tracks, + has_intrinsic_min_track_sizing_function, + IntrinsicContributionType::Minimum, + ); + } + } + flush_planned_base_size_increases(axis_tracks); + + // 2. For content-based minimums: + // Next continue to increase the base size of tracks with a min track sizing function of min-content or max-content + // by distributing extra space as needed to account for these items' min-content contributions. + let has_min_or_max_content_min_track_sizing_function = move |track: &GridTrack| { + use MinTrackSizingFunction::{MaxContent, MinContent}; + matches!(track.min_track_sizing_function, MinContent | MaxContent) + }; + for item in batch.iter_mut() { + let (_, axis_min_content_size, _) = compute_item_sizes(item, axis_tracks); + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + let space = axis_min_content_size; + if space > 0.0 { + distribute_item_space_to_base_size( + is_flex, + space, + tracks, + has_min_or_max_content_min_track_sizing_function, + IntrinsicContributionType::Minimum, + ); + } + } + flush_planned_base_size_increases(axis_tracks); + + // 3. For max-content minimums: + + // If the grid container is being sized under a max-content constraint, continue to increase the base size of tracks with + // a min track sizing function of auto or max-content by distributing extra space as needed to account for these items' + // limited max-content contributions. + if axis_available_space == AvailableSpace::MaxContent { + let has_auto_or_max_content_min_track_sizing_function = move |track: &GridTrack| { + use MinTrackSizingFunction::{Auto, MaxContent}; + matches!(track.min_track_sizing_function, Auto | MaxContent) + }; + for item in batch.iter_mut() { + let (_, _, axis_max_content_size) = compute_item_sizes(item, axis_tracks); + let limit = item.spanned_fixed_track_limit(axis, axis_tracks, axis_available_space); + let space = axis_max_content_size.maybe_min(limit); + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + if space > 0.0 { + distribute_item_space_to_base_size( + is_flex, + space, + tracks, + has_auto_or_max_content_min_track_sizing_function, + IntrinsicContributionType::Minimum, + ); + } + } + flush_planned_base_size_increases(axis_tracks); + } + + // In all cases, continue to increase the base size of tracks with a min track sizing function of max-content by distributing + // extra space as needed to account for these items' max-content contributions. + let has_max_content_min_track_sizing_function = + move |track: &GridTrack| matches!(track.min_track_sizing_function, MinTrackSizingFunction::MaxContent); + for item in batch.iter_mut() { + let (_, _, axis_max_content_size) = compute_item_sizes(item, axis_tracks); + let space = axis_max_content_size; + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + if space > 0.0 { + distribute_item_space_to_base_size( + is_flex, + space, + tracks, + has_max_content_min_track_sizing_function, + IntrinsicContributionType::Maximum, + ); + } + } + flush_planned_base_size_increases(axis_tracks); + + // 4. If at this point any track’s growth limit is now less than its base size, increase its growth limit to match its base size. + for track in axis_tracks.iter_mut() { + if track.growth_limit < track.base_size { + track.growth_limit = track.base_size; + } + } + + // If a track is a flexible track, then it has flexible max track sizing function + // It cannot also have an intrinsic max track sizing function, so these steps do not apply. + if !is_flex { + // 5. For intrinsic maximums: Next increase the growth limit of tracks with an intrinsic max track sizing function by + // distributing extra space as needed to account for these items' min-content contributions. + let has_intrinsic_max_track_sizing_function = move |track: &GridTrack| { + track.max_track_sizing_function.definite_value(available_space.get(axis)).is_none() + }; + for item in batch.iter_mut() { + let (_, axis_min_content_size, _) = compute_item_sizes(item, axis_tracks); + let space = axis_min_content_size; + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + if space > 0.0 { + distribute_item_space_to_growth_limit(space, tracks, has_intrinsic_max_track_sizing_function); + } + } + // Mark any tracks whose growth limit changed from infinite to finite in this step as infinitely growable for the next step. + flush_planned_growth_limit_increases(axis_tracks, true); + + // 6. For max-content maximums: Lastly continue to increase the growth limit of tracks with a max track sizing function of max-content + // by distributing extra space as needed to account for these items' max-content contributions. However, limit the growth of any + // fit-content() tracks by their fit-content() argument. + let has_max_content_max_track_sizing_function = + move |track: &GridTrack| track.max_track_sizing_function == MaxTrackSizingFunction::MaxContent; + for item in batch.iter_mut() { + let (_, _, axis_max_content_size) = compute_item_sizes(item, axis_tracks); + let space = axis_max_content_size; + let tracks = &mut axis_tracks[item.track_range_excluding_lines(axis)]; + if space > 0.0 { + distribute_item_space_to_growth_limit(space, tracks, has_max_content_max_track_sizing_function); + } + } + // Mark any tracks whose growth limit changed from infinite to finite in this step as infinitely growable for the next step. + flush_planned_growth_limit_increases(axis_tracks, false); + } + } + + // Step 5. If any track still has an infinite growth limit (because, for example, it had no items placed + // in it or it is a flexible track), set its growth limit to its base size. + // NOTE: this step is super-important to ensure that the "Maximise Tracks" step doesn't affect flexible tracks + axis_tracks + .iter_mut() + .filter(|track| track.growth_limit == f32::INFINITY) + .for_each(|track| track.growth_limit = track.base_size); +} + +/// 11.5.1. Distributing Extra Space Across Spanned Tracks +/// https://www.w3.org/TR/css-grid-1/#extra-space +fn distribute_item_space_to_base_size( + is_flex: bool, + space: f32, + tracks: &mut [GridTrack], + track_is_affected: impl Fn(&GridTrack) -> bool, + intrinsic_contribution_type: IntrinsicContributionType, +) { + if is_flex { + let filter = |track: &GridTrack| track.is_flexible() && track_is_affected(track); + distribute_item_space_to_base_size_inner(space, tracks, filter, intrinsic_contribution_type) + } else { + distribute_item_space_to_base_size_inner(space, tracks, track_is_affected, intrinsic_contribution_type) + } + + /// Inner function that doesn't account for differences due to distributing to flex items + /// This difference is handled by the closure passed in above + fn distribute_item_space_to_base_size_inner( + space: f32, + tracks: &mut [GridTrack], + track_is_affected: impl Fn(&GridTrack) -> bool, + intrinsic_contribution_type: IntrinsicContributionType, + ) { + // Skip this distribution if there is either + // - no space to distribute + // - no affected tracks to distribute space to + if space == 0.0 || tracks.iter().filter(|track| track_is_affected(track)).count() == 0 { + return; + } + + // 1. Find the space to distribute + let track_sizes: f32 = tracks.iter().map(|track| track.base_size).sum(); + let extra_space: f32 = f32_max(0.0, space - track_sizes); + + // 2. Distribute space up to limits: + // Note: there are two exit conditions to this loop: + // - We run out of space to distribute (extra_space falls below THRESHOLD) + // - We run out of growable tracks to distribute to + + /// Define a small constant to avoid infinite loops due to rounding errors. Rather than stopping distributing + /// extra space when it gets to exactly zero, we will stop when it falls below this amount + const THRESHOLD: f32 = 0.000001; + + let extra_space = distribute_space_up_to_limits( + extra_space, + tracks, + &track_is_affected, + GridTrack::fit_content_limited_growth_limit, + ); + + // 3. Distribute remaining span beyond limits (if any) + if extra_space > THRESHOLD { + // When accommodating minimum contributions or accommodating min-content contributions: + // - any affected track that happens to also have an intrinsic max track sizing function; + // When accommodating max-content contributions: + // - any affected track that happens to also have a max-content max track sizing function + let mut filter = match intrinsic_contribution_type { + IntrinsicContributionType::Minimum => { + (|track: &GridTrack| track.max_track_sizing_function.is_intrinsic()) as fn(&GridTrack) -> bool + } + IntrinsicContributionType::Maximum => { + (|track: &GridTrack| track.max_track_sizing_function.is_max_content_alike()) + as fn(&GridTrack) -> bool + } + }; + + // If there are no such tracks (matching filter above), then use all affected tracks. + let number_of_tracks = + tracks.iter().filter(|track| track_is_affected(track)).filter(|track| filter(track)).count(); + if number_of_tracks == 0 { + filter = (|_| true) as fn(&GridTrack) -> bool; + } + + distribute_space_up_to_limits(extra_space, tracks, filter, GridTrack::fit_content_limit); + } + + // 4. For each affected track, if the track’s item-incurred increase is larger than the track’s planned increase + // set the track’s planned increase to that value. + for track in tracks.iter_mut() { + if track.item_incurred_increase > track.base_size_planned_increase { + track.base_size_planned_increase = track.item_incurred_increase; + } + + // Reset the item_incurresed increase ready for the next space distribution + track.item_incurred_increase = 0.0; + } + } +} + +/// 11.5.1. Distributing Extra Space Across Spanned Tracks +/// This is simplified (and faster) version of the algorithm for growth limits +/// https://www.w3.org/TR/css-grid-1/#extra-space +fn distribute_item_space_to_growth_limit( + space: f32, + tracks: &mut [GridTrack], + track_is_affected: impl Fn(&GridTrack) -> bool, +) { + // 1. Find the space to distribute + let track_sizes: f32 = tracks + .iter() + .map(|track| if track.growth_limit == f32::INFINITY { track.base_size } else { track.growth_limit }) + .sum(); + let extra_space: f32 = f32_max(0.0, space - track_sizes); + + // 2. Distribute space up to limits: + // 3. Distribute space beyond limits + // If space remains after all tracks are frozen, unfreeze and continue to distribute space to the item-incurred increase + // when handling any intrinsic growth limit: all affected tracks. + let number_of_growable_tracks = + tracks.iter().filter(|track| track_is_affected(track)).filter(|track| track.infinitely_growable).count(); + if number_of_growable_tracks > 0 { + let item_incurred_increase = extra_space / number_of_growable_tracks as f32; + for track in + tracks.iter_mut().filter(|track| track_is_affected(track)).filter(|track| track.infinitely_growable) + { + if item_incurred_increase > track.growth_limit_planned_increase { + track.growth_limit_planned_increase = item_incurred_increase; + } + } + } else { + let number_of_affected_tracks = tracks.iter().filter(|track| track_is_affected(track)).count(); + if number_of_affected_tracks > 0 { + let item_incurred_increase = extra_space / number_of_affected_tracks as f32; + for track in tracks.iter_mut().filter(|track| track_is_affected(track)) { + if item_incurred_increase > track.growth_limit_planned_increase { + track.growth_limit_planned_increase = item_incurred_increase; + } + } + } + }; +} + +/// 11.6 Maximise Tracks +/// Distributes free space (if any) to tracks with FINITE growth limits, up to their limits. +fn maximise_tracks(axis: AbstractAxis, axis_tracks: &mut [GridTrack], available_grid_space: Size) { + let used_space: f32 = axis_tracks.iter().map(|track| track.base_size).sum(); + let free_space = available_grid_space.get(axis).compute_free_space(used_space); + if free_space == f32::INFINITY { + axis_tracks.iter_mut().for_each(|track| track.base_size = track.growth_limit); + } else if free_space > 0.0 { + distribute_space_up_to_limits(free_space, axis_tracks, |_| true, GridTrack::fit_content_limited_growth_limit); + for track in axis_tracks.iter_mut() { + track.base_size += track.item_incurred_increase; + track.item_incurred_increase = 0.0; + } + } +} + +/// 11.7. Expand Flexible Tracks +/// This step sizes flexible tracks using the largest value it can assign to an fr without exceeding the available space. +fn expand_flexible_tracks( + tree: &mut impl LayoutTree, + axis: AbstractAxis, + axis_tracks: &mut [GridTrack], + items: &mut [GridItem], + axis_min_size: Option, + axis_max_size: Option, + available_grid_space: Size, +) { + // First, find the grid’s used flex fraction: + let flex_fraction = match available_grid_space.get(axis) { + // If the free space is zero: + // The used flex fraction is zero. + // Otherwise, if the free space is a definite length: + // The used flex fraction is the result of finding the size of an fr using all of the grid tracks and + // a space to fill of the available grid space. + AvailableSpace::Definite(available_space) => { + let used_space: f32 = axis_tracks.iter().map(|track| track.base_size).sum(); + let free_space = available_space - used_space; + if free_space == 0.0 { + 0.0 + } else { + find_size_of_fr(axis_tracks, available_space) + } + } + // If ... sizing the grid container under a min-content constraint the used flex fraction is zero. + AvailableSpace::MinContent => 0.0, + // Otherwise, if the free space is an indefinite length: + AvailableSpace::MaxContent => { + // The used flex fraction is the maximum of: + let flex_fraction = f32_max( + // For each flexible track, if the flexible track’s flex factor is greater than one, + // the result of dividing the track’s base size by its flex factor; otherwise, the track’s base size. + axis_tracks + .iter() + .filter(|track| track.max_track_sizing_function.is_flexible()) + .map(|track| { + let flex_factor = track.flex_factor(); + if flex_factor > 1.0 { + track.base_size * flex_factor + } else { + track.base_size + } + }) + .max_by(|a, b| a.total_cmp(b)) + .unwrap_or(0.0), + // For each grid item that crosses a flexible track, the result of finding the size of an fr using all the grid tracks + // that the item crosses and a space to fill of the item’s max-content contribution. + items + .iter_mut() + .filter(|item| item.crosses_flexible_track(axis)) + .map(|item| { + let tracks = &axis_tracks[item.track_range_excluding_lines(axis)]; + // TODO: plumb estimate of other axis size (known_dimensions) in here rather than just passing Size::NONE? + let max_content_contribution = item.max_content_contribution_cached(tree, Size::NONE); + find_size_of_fr(tracks, max_content_contribution.get(axis)) + }) + .max_by(|a, b| a.total_cmp(b)) + .unwrap_or(0.0), + ); + + // If using this flex fraction would cause the grid to be smaller than the grid container’s min-width/height (or larger than the + // grid container’s max-width/height), then redo this step, treating the free space as definite and the available grid space as equal + // to the grid container’s inner size when it’s sized to its min-width/height (max-width/height). + // (Note: min_size takes precedence over max_size) + let hypothetical_grid_size: f32 = axis_tracks + .iter() + .map(|track| match track.max_track_sizing_function { + MaxTrackSizingFunction::Flex(track_flex_factor) => { + f32_max(track.base_size, track_flex_factor * flex_fraction) + } + _ => track.base_size, + }) + .sum(); + let axis_min_size = axis_min_size.unwrap_or(0.0); + let axis_max_size = axis_max_size.unwrap_or(f32::INFINITY); + if hypothetical_grid_size < axis_min_size { + find_size_of_fr(axis_tracks, axis_min_size) + } else if hypothetical_grid_size > axis_max_size { + find_size_of_fr(axis_tracks, axis_max_size) + } else { + flex_fraction + } + } + }; + + // For each flexible track, if the product of the used flex fraction and the track’s flex factor is greater + // than the track’s base size, set its base size to that product. + for track in axis_tracks.iter_mut() { + if let MaxTrackSizingFunction::Flex(track_flex_factor) = track.max_track_sizing_function { + track.base_size = f32_max(track.base_size, track_flex_factor * flex_fraction); + } + } +} + +/// 11.7.1. Find the Size of an fr +/// This algorithm finds the largest size that an fr unit can be without exceeding the target size. +/// It must be called with a set of grid tracks and some quantity of space to fill. +fn find_size_of_fr(tracks: &[GridTrack], space_to_fill: f32) -> f32 { + // Handle the trivial case where there is no space to fill + // Do not remove as otherwise the loop below will loop infinitely + if space_to_fill == 0.0 { + return 0.0; + } + + // If the product of the hypothetical fr size (computed below) and any flexible track’s flex factor + // is less than the track’s base size, then we must restart this algorithm treating all such tracks as inflexible. + // We therefore wrap the entire algorithm in a loop, with an hypotherical_fr_size of INFINITY such that the above + // condition can never be true for the first iteration. + let mut hypothetical_fr_size = f32::INFINITY; + let mut previous_iter_hypothetical_fr_size; + loop { + // Let leftover space be the space to fill minus the base sizes of the non-flexible grid tracks. + // Let flex factor sum be the sum of the flex factors of the flexible tracks. If this value is less than 1, set it to 1 instead. + // We compute both of these in a single loop to avoid iterating over the data twice + let mut used_space = 0.0; + let mut naive_flex_factor_sum = 0.0; + for track in tracks.iter() { + match track.max_track_sizing_function { + // Tracks for which flex_factor * hypothetical_fr_size < track.base_size are treated as inflexible + MaxTrackSizingFunction::Flex(flex_factor) if flex_factor * hypothetical_fr_size >= track.base_size => { + naive_flex_factor_sum += flex_factor; + } + _ => used_space += track.base_size, + }; + } + let leftover_space = space_to_fill - used_space; + let flex_factor = f32_max(naive_flex_factor_sum, 1.0); + + // Let the hypothetical fr size be the leftover space divided by the flex factor sum. + previous_iter_hypothetical_fr_size = hypothetical_fr_size; + hypothetical_fr_size = leftover_space / flex_factor; + + // If the product of the hypothetical fr size and a flexible track’s flex factor is less than the track’s base size, + // restart this algorithm treating all such tracks as inflexible. + // We keep track of the hypothetical_fr_size + let hypotherical_fr_size_is_valid = tracks.iter().all(|track| match track.max_track_sizing_function { + MaxTrackSizingFunction::Flex(flex_factor) => { + flex_factor * hypothetical_fr_size >= track.base_size + || flex_factor * previous_iter_hypothetical_fr_size < track.base_size + } + _ => true, + }); + if hypotherical_fr_size_is_valid { + break; + } + } + + // Return the hypothetical fr size. + hypothetical_fr_size +} + +/// 11.8. Stretch auto Tracks +/// This step expands tracks that have an auto max track sizing function by dividing any remaining positive, definite free space equally amongst them. +fn stretch_auto_tracks( + axis: AbstractAxis, + axis_tracks: &mut [GridTrack], + container_style: &Style, + available_space: Size, + available_grid_space: Size, +) { + let num_auto_tracks = + axis_tracks.iter().filter(|track| track.max_track_sizing_function == MaxTrackSizingFunction::Auto).count(); + if num_auto_tracks > 0 { + let used_space: f32 = axis_tracks.iter().map(|track| track.base_size).sum(); + + // If the free space is indefinite, but the grid container has a definite min-width/height + // use that size to calculate the free space for this step instead. + let free_space = if available_grid_space.get(axis).is_definite() { + available_grid_space.get(axis).compute_free_space(used_space) + } else { + match container_style.min_size.maybe_resolve(available_space.into_options()).get(axis) { + Some(size) => size - used_space, + None => 0.0, + } + }; + if free_space > 0.0 { + let extra_space_per_auto_track = free_space / num_auto_tracks as f32; + axis_tracks + .iter_mut() + .filter(|track| track.max_track_sizing_function == MaxTrackSizingFunction::Auto) + .for_each(|track| track.base_size += extra_space_per_auto_track); + } + } +} + +/// Helper function for distributing space to tracks evenly +/// Used by both distribute_item_space_to_base_size and maximise_tracks steps +fn distribute_space_up_to_limits( + space_to_distribute: f32, + tracks: &mut [GridTrack], + track_is_affected: impl Fn(&GridTrack) -> bool, + track_limit: impl Fn(&GridTrack) -> f32, +) -> f32 { + /// Define a small constant to avoid infinite loops due to rounding errors. Rather than stopping distributing + /// extra space when it gets to exactly zero, we will stop when it falls below this amount + const THRESHOLD: f32 = 0.000001; + + let mut space_to_distribute = space_to_distribute; + while space_to_distribute > THRESHOLD { + let number_of_growable_tracks = tracks + .iter() + .filter(|track| track.base_size + track.item_incurred_increase < track_limit(track)) + .filter(|track| track_is_affected(track)) + .count(); + + if number_of_growable_tracks == 0 { + break; + } + + // Compute item-incurred increase for this iteration + let min_increase_limit = tracks + .iter() + .filter(|track| track.base_size + track.item_incurred_increase < track_limit(track)) + .filter(|track| track_is_affected(track)) + .map(|track| track_limit(track) - track.base_size) + .min_by(|a, b| a.total_cmp(b)) + .unwrap(); // We will never pass an empty track list to this function + let iteration_item_incurred_increase = + f32_min(min_increase_limit, space_to_distribute / number_of_growable_tracks as f32); + + for track in tracks + .iter_mut() + .filter(|track| track_is_affected(track)) + .filter(|track| track.base_size + track.item_incurred_increase < track_limit(track)) + { + track.item_incurred_increase += iteration_item_incurred_increase; + } + + space_to_distribute -= iteration_item_incurred_increase * number_of_growable_tracks as f32; + } + + space_to_distribute +} diff --git a/src/compute/grid/types/cell_occupancy.rs b/src/compute/grid/types/cell_occupancy.rs new file mode 100644 index 000000000..8fa9450d2 --- /dev/null +++ b/src/compute/grid/types/cell_occupancy.rs @@ -0,0 +1,258 @@ +//! Contains CellOccupancyMatrix used to track occupied cells during grid placement +use super::TrackCounts; +use crate::axis::AbsoluteAxis; +use crate::geometry::Line; +use crate::sys::Vec; +use core::cmp::{max, min}; +use core::fmt::Debug; +use core::ops::Range; +use grid::Grid; + +/// The occupancy state of a single grid cell +#[derive(Debug, PartialEq, Eq, Clone, Copy, Default)] +pub(crate) enum CellOccupancyState { + #[default] + /// Indicates that a grid cell is unoccupied + Unoccupied, + /// Indicates that a grid cell is occupied by a definitely placed item + DefinitelyPlaced, + /// Indicates that a grid cell is occupied by an item that was placed by the auto placement algorithm + AutoPlaced, +} + +/// A dynamically sized matrix (2d grid) which tracks the occupancy of each grid cell during auto-placement +/// It also keeps tabs on how many tracks there are and which tracks are implicit and which are explicit. +pub(crate) struct CellOccupancyMatrix { + /// The grid of occupancy states + inner: Grid, + /// The counts of implicit and explicit columns + columns: TrackCounts, + /// The counts of implicit and explicit rows + rows: TrackCounts, +} + +/// Debug impl that represents the matrix in a compact 2d text format +impl Debug for CellOccupancyMatrix { + fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { + writeln!( + f, + "Rows: neg_implicit={} explicit={} pos_implicit={}", + self.rows.negative_implicit, self.rows.explicit, self.rows.positive_implicit + )?; + writeln!( + f, + "Cols: neg_implicit={} explicit={} pos_implicit={}", + self.columns.negative_implicit, self.columns.explicit, self.columns.positive_implicit + )?; + writeln!(f, "State:")?; + + for row_idx in 0..self.inner.rows() { + for cell in self.inner.iter_row(row_idx) { + let letter = match *cell { + CellOccupancyState::Unoccupied => '_', + CellOccupancyState::DefinitelyPlaced => 'D', + CellOccupancyState::AutoPlaced => 'A', + }; + write!(f, "{letter}")?; + } + writeln!(f)?; + } + + Ok(()) + } +} + +impl CellOccupancyMatrix { + /// Create a CellOccupancyMatrix given a set of provisional track counts. The grid can expand as needed to fit more tracks, + /// the provisional track counts represent a best effort attempt to avoid the extra allocations this requires. + pub fn with_track_counts(columns: TrackCounts, rows: TrackCounts) -> Self { + Self { inner: Grid::new(rows.len(), columns.len()), rows, columns } + } + + /// Determines whether the specified area fits within the tracks currently represented by the matrix + pub fn is_area_in_range( + &mut self, + primary_axis: AbsoluteAxis, + primary_range: Range, + secondary_range: Range, + ) -> bool { + if primary_range.start < 0 || primary_range.end > self.track_counts(primary_axis).len() as i16 { + return false; + } + if secondary_range.start < 0 || secondary_range.end > self.track_counts(primary_axis.other_axis()).len() as i16 + { + return false; + } + true + } + + /// Expands the grid (potentially in all 4 directions) in order to ensure that the specified range fits within the allocated space + fn expand_to_fit_range(&mut self, row_range: Range, col_range: Range) { + // Calculate number of rows and columns missing to accomodate ranges (if any) + let req_negative_rows = min(row_range.start, 0); + let req_positive_rows = max(row_range.end - self.rows.explicit as i16 - self.rows.positive_implicit as i16, 0); + let req_negative_cols = min(col_range.start, 0); + let req_positive_cols = + max(col_range.end - self.columns.explicit as i16 - self.columns.positive_implicit as i16, 0); + + let old_row_count = self.rows.len(); + let old_col_count = self.columns.len(); + let new_row_count = old_row_count + (req_negative_rows + req_positive_rows) as usize; + let new_col_count = old_col_count + (req_negative_cols + req_positive_cols) as usize; + + let mut data = Vec::with_capacity(new_row_count * new_col_count); + + // Push new negative rows + for _ in 0..(req_negative_rows as usize * new_col_count) { + data.push(CellOccupancyState::Unoccupied); + } + + // Push existing rows + for row in 0..old_row_count { + // Push new negative columns + for _ in 0..req_negative_cols { + data.push(CellOccupancyState::Unoccupied); + } + // Push existing columns + for col in 0..old_col_count { + data.push(*self.inner.get(row, col).unwrap()); + } + // Push new positive columns + for _ in 0..req_positive_cols { + data.push(CellOccupancyState::Unoccupied); + } + } + + // Push new negative rows + for _ in 0..(req_positive_rows as usize * new_col_count) { + data.push(CellOccupancyState::Unoccupied); + } + + // Update self with new data + self.inner = Grid::from_vec(data, new_col_count); + self.rows.negative_implicit += req_negative_rows as u16; + self.rows.positive_implicit += req_positive_rows as u16; + self.columns.negative_implicit += req_negative_cols as u16; + self.columns.positive_implicit += req_positive_cols as u16; + } + + /// Mark an area of the matrix as occupied, expanding the allocated space as necessary to accomodate the passed area. + pub fn mark_area_as( + &mut self, + primary_axis: AbsoluteAxis, + primary_span: Line, + secondary_span: Line, + value: CellOccupancyState, + ) { + let (row_span, column_span) = match primary_axis { + AbsoluteAxis::Horizontal => (secondary_span, primary_span), + AbsoluteAxis::Vertical => (primary_span, secondary_span), + }; + + let mut col_range = self.columns.oz_line_range_to_track_range(column_span); + let mut row_range = self.rows.oz_line_range_to_track_range(row_span); + + // Check that if the resolved ranges fit within the allocated grid. And if they don't then expand the grid to fit + // and then re-resolve the ranges once the grid has been expanded as the resolved indexes may have changed + let is_in_range = self.is_area_in_range(AbsoluteAxis::Horizontal, col_range.clone(), row_range.clone()); + if !is_in_range { + self.expand_to_fit_range(row_range.clone(), col_range.clone()); + col_range = self.columns.oz_line_range_to_track_range(column_span); + row_range = self.rows.oz_line_range_to_track_range(row_span); + } + + for x in row_range { + for y in col_range.clone() { + *self.inner.get_mut(x as usize, y as usize).unwrap() = value; + } + } + } + + /// Converts a span of grid lines in OriginZero coordinates into a range a tracks suitable + /// for indexing into this CellOccupancyMatrix + pub fn lines_to_tracks(&self, axis: AbsoluteAxis, span: Line) -> Range { + self.track_counts(axis).oz_line_range_to_track_range(span) + } + + /// Converts a range a tracks indexes from this CellOccupancyMatrix into a span of grid lines + /// in OriginZero coordinates + pub fn tracks_to_lines(&self, axis: AbsoluteAxis, span: Range) -> Line { + self.track_counts(axis).track_range_to_oz_line_range(span) + } + + /// Determines whether a grid area specified by the bounding grid lines in OriginZero coordinates + /// is entirely unnocupied. Returns true if all grid cells within the grid area are unnocupied, else false. + pub fn line_area_is_unoccupied( + &self, + primary_axis: AbsoluteAxis, + primary_span: Line, + secondary_span: Line, + ) -> bool { + let primary_range = self.track_counts(primary_axis).oz_line_range_to_track_range(primary_span); + let secondary_range = self.track_counts(primary_axis.other_axis()).oz_line_range_to_track_range(secondary_span); + self.track_area_is_unoccupied(primary_axis, primary_range, secondary_range) + } + + /// Determines whether a grid area specified by a range of indexes into this CellOccupancyMatrix + /// is entirely unnocupied. Returns true if all grid cells within the grid area are unnocupied, else false. + pub fn track_area_is_unoccupied( + &self, + primary_axis: AbsoluteAxis, + primary_range: Range, + secondary_range: Range, + ) -> bool { + let (row_range, col_range) = match primary_axis { + AbsoluteAxis::Horizontal => (secondary_range, primary_range), + AbsoluteAxis::Vertical => (primary_range, secondary_range), + }; + + // Search for occupied cells in the specified area. Out of bounds cells are considered unoccupied. + for x in row_range { + for y in col_range.clone() { + match self.inner.get(x as usize, y as usize) { + None | Some(CellOccupancyState::Unoccupied) => continue, + _ => return false, + } + } + } + + true + } + + /// Determines whether the specified row contains any items + pub fn row_is_occupied(&self, row_index: usize) -> bool { + self.inner.iter_row(row_index).any(|cell| !matches!(cell, CellOccupancyState::Unoccupied)) + } + + /// Determines whether the specified column contains any items + pub fn column_is_occupied(&self, column_index: usize) -> bool { + self.inner.iter_col(column_index).any(|cell| !matches!(cell, CellOccupancyState::Unoccupied)) + } + + /// Returns the track counts of this CellOccunpancyMatrix in the relevant axis + pub fn track_counts(&self, track_type: AbsoluteAxis) -> &TrackCounts { + match track_type { + AbsoluteAxis::Horizontal => &self.columns, + AbsoluteAxis::Vertical => &self.rows, + } + } + + /// Given an axis and a track index + /// Search backwards from the end of the track and find the last grid cell matching the specified state (if any) + /// Return the index of that cell or None. + pub fn last_of_type(&self, track_type: AbsoluteAxis, track_index: i16, kind: CellOccupancyState) -> Option { + let track_counts = self.track_counts(track_type.other_axis()); + let track_computed_index = track_counts.oz_line_to_next_track(track_index); + + let maybe_index = match track_type { + AbsoluteAxis::Horizontal => { + self.inner.iter_row(track_computed_index as usize).rposition(|item| *item == kind) + } + AbsoluteAxis::Vertical => { + self.inner.iter_col(track_computed_index as usize).rposition(|item| *item == kind) + } + }; + + maybe_index.map(|idx| track_counts.track_to_prev_oz_line(idx as u16)) + } +} diff --git a/src/compute/grid/types/grid_item.rs b/src/compute/grid/types/grid_item.rs new file mode 100644 index 000000000..4c666eee8 --- /dev/null +++ b/src/compute/grid/types/grid_item.rs @@ -0,0 +1,287 @@ +//! Contains GridItem used to represent a single grid item during layout +use super::GridTrack; +use crate::axis::AbstractAxis; +use crate::compute::compute_node_layout; +use crate::geometry::{Line, Rect, Size}; +use crate::layout::{RunMode, SizingMode}; +use crate::node::Node; +use crate::prelude::LayoutTree; +use crate::resolve::MaybeResolve; +use crate::style::{AvailableSpace, LengthPercentageAuto, MaxTrackSizingFunction, MinTrackSizingFunction, Style}; +use crate::style_helpers::*; +use core::cmp::max; +use core::ops::Range; + +/// Represents a single grid item +#[derive(Debug)] +pub(in super::super) struct GridItem { + /// The id of the Node that this item represents + pub node: Node, + + /// The order of the item in the children array + /// + /// We sort the list of grid items during track sizing. This field allows us to sort back the original order + /// for final positioning + pub source_order: u16, + + /// The item's definite row-start and row-end, as resolved by the placement algorithm + /// (in origin-zero coordinates) + pub row: Line, + /// The items definite column-start and column-end, as resolved by the placement algorithm + /// (in origin-zero coordinates) + pub column: Line, + + /// The item's margin style + pub margin: Rect, + + /// The item's definite row-start and row-end (same as `row` field, except in a different coordinate system) + /// (as indexes into the Vec stored in a grid's AbstractAxisTracks) + pub row_indexes: Line, + /// The items definite column-start and column-end (same as `column` field, except in a different coordinate system) + /// (as indexes into the Vec stored in a grid's AbstractAxisTracks) + pub column_indexes: Line, + + /// Whether the item crosses a flexible row + pub crosses_flexible_row: bool, + /// Whether the item crosses a flexible column + pub crosses_flexible_column: bool, + + // Caches for intrinsic size computation. These caches are only valid for a single run of the track-sizing algorithm. + /// Cache for the known_dimensions input to intrinsic sizing computation + pub known_dimensions_cache: Option>>, + /// Cache for the min-content size + pub min_content_contribution_cache: Option>, + /// Cache for the minimum contribution + pub minimum_contribution_cache: Option, + /// Cache for the max-content size + pub max_content_contribution_cache: Option>, +} + +impl GridItem { + /// Create a new item given a concrete placement in both axes + pub fn new_with_placement_style_and_order( + node: Node, + col_span: Line, + row_span: Line, + style: &Style, + source_order: u16, + ) -> Self { + GridItem { + node, + source_order, + row: row_span, + column: col_span, + margin: style.margin, + row_indexes: Line { start: 0, end: 0 }, // Properly initialised later + column_indexes: Line { start: 0, end: 0 }, // Properly initialised later + crosses_flexible_row: false, // Properly initialised later + crosses_flexible_column: false, // Properly initialised later + known_dimensions_cache: None, + min_content_contribution_cache: None, + max_content_contribution_cache: None, + minimum_contribution_cache: None, + } + } + + /// This item's placement in the specified axis in OriginZero coordinates + pub fn placement(&self, axis: AbstractAxis) -> Line { + match axis { + AbstractAxis::Block => self.row, + AbstractAxis::Inline => self.column, + } + } + + /// This item's placement in the specified axis as GridTrackVec indices + pub fn placement_indexes(&self, axis: AbstractAxis) -> Line { + match axis { + AbstractAxis::Block => self.row_indexes, + AbstractAxis::Inline => self.column_indexes, + } + } + + /// Returns a range which can be used as an index into the GridTrackVec in the specified axis + /// which will produce a sub-slice of covering all the tracks and lines that this item spans + /// excluding the lines that bound it. + pub fn track_range_excluding_lines(&self, axis: AbstractAxis) -> Range { + let indexes = self.placement_indexes(axis); + (indexes.start as usize + 1)..(indexes.end as usize) + } + + /// Returns the number of tracks that this item spans in the specified axis + pub fn span(&self, axis: AbstractAxis) -> u16 { + match axis { + AbstractAxis::Block => max(self.row.end - self.row.start, 0) as u16, + AbstractAxis::Inline => max(self.column.end - self.column.start, 0) as u16, + } + } + + /// Returns the pre-computed value indicating whether the grid item crosses a flexible track in + /// the specified axis + pub fn crosses_flexible_track(&self, axis: AbstractAxis) -> bool { + match axis { + AbstractAxis::Inline => self.crosses_flexible_column, + AbstractAxis::Block => self.crosses_flexible_row, + } + } + + /// Compute the known_dimensions to be passed to the child sizing functions + /// These are estimates based on either the max track sizing function on the provisional base size in the opposite + /// axis to the one currently being sized. + /// https://www.w3.org/TR/css-grid-1/#algo-overview + pub fn known_dimensions_cached( + &mut self, + axis: AbstractAxis, + other_axis_tracks: &[GridTrack], + other_axis_available_space: AvailableSpace, + get_track_size_estimate: impl Fn(&GridTrack, AvailableSpace) -> Option, + ) -> Size> { + self.known_dimensions_cache.unwrap_or_else(|| { + let item_other_axis_size: Option = { + other_axis_tracks[self.track_range_excluding_lines(axis.other())] + .iter() + .map(|track| { + get_track_size_estimate(track, other_axis_available_space) + .map(|size| size + track.content_alignment_adjustment) + }) + .sum::>() + }; + let known_dimensions = { + let mut size = Size::NONE; + size.set(axis.other(), item_other_axis_size); + size + }; + + self.known_dimensions_cache = Some(known_dimensions); + + known_dimensions + }) + } + + /// For an item spanning multiple tracks, the upper limit used to calculate its limited min-/max-content contribution is the + /// sum of the fixed max track sizing functions of any tracks it spans, and is applied if it only spans such tracks. + pub fn spanned_fixed_track_limit( + &mut self, + axis: AbstractAxis, + axis_tracks: &[GridTrack], + axis_available_space: AvailableSpace, + ) -> Option { + let spanned_tracks = &axis_tracks[self.track_range_excluding_lines(axis)]; + let tracks_all_fixed = spanned_tracks + .iter() + .all(|track| track.max_track_sizing_function.definite_value(axis_available_space).is_some()); + if tracks_all_fixed { + let limit: f32 = spanned_tracks + .iter() + .map(|track| track.max_track_sizing_function.definite_value(axis_available_space).unwrap()) + .sum(); + Some(limit) + } else { + None + } + } + + /// Retrieve the item's min content contribution from the cache or compute it using the provided parameters + pub fn min_content_contribution_cached( + &mut self, + tree: &mut impl LayoutTree, + known_dimensions: Size>, + ) -> Size { + self.min_content_contribution_cache.unwrap_or_else(|| { + let size = compute_node_layout( + tree, + self.node, + known_dimensions, + Size::MIN_CONTENT, + RunMode::ComputeSize, + SizingMode::InherentSize, + ); + self.min_content_contribution_cache = Some(size); + size + }) + } + + /// Retrieve the item's max content contribution from the cache or compute it using the provided parameters + pub fn max_content_contribution_cached( + &mut self, + tree: &mut impl LayoutTree, + known_dimensions: Size>, + ) -> Size { + self.max_content_contribution_cache.unwrap_or_else(|| { + let size = compute_node_layout( + tree, + self.node, + known_dimensions, + Size::MAX_CONTENT, + RunMode::ComputeSize, + SizingMode::InherentSize, + ); + self.max_content_contribution_cache = Some(size); + size + }) + } + + /// The minimum contribution of an item is the smallest outer size it can have. + /// Specifically: + /// - If the item’s computed preferred size behaves as auto or depends on the size of its containing block in the relevant axis: + /// Its minimum contribution is the outer size that would result from assuming the item’s used minimum size as its preferred size; + /// - Else the item’s minimum contribution is its min-content contribution. + /// Because the minimum contribution often depends on the size of the item’s content, it is considered a type of intrinsic size contribution. + pub fn minimum_contribution_cached( + &mut self, + tree: &mut impl LayoutTree, + axis: AbstractAxis, + axis_tracks: &[GridTrack], + available_space: Size, + known_dimensions: Size>, + ) -> f32 { + self.minimum_contribution_cache.unwrap_or_else(|| { + let style = tree.style(self.node); + let axis_available_space = available_space.get(axis).into_option(); + style + .size + .get(axis) + .maybe_resolve(axis_available_space) + .or_else(|| style.min_size.get(axis).maybe_resolve(axis_available_space)) + .unwrap_or_else(|| { + // Automatic minimum size. See https://www.w3.org/TR/css-grid-1/#min-size-auto + + // To provide a more reasonable default minimum size for grid items, the used value of its automatic minimum size + // in a given axis is the content-based minimum size if all of the following are true: + let item_axis_tracks = &axis_tracks[self.track_range_excluding_lines(axis)]; + + // it is not a scroll container + // TODO: support overflow propety + + // it spans at least one track in that axis whose min track sizing function is auto + let spans_auto_min_track = axis_tracks + .iter() + // TODO: should this be 'behaves as auto' rather than just literal auto? + .any(|track| track.min_track_sizing_function == MinTrackSizingFunction::Auto); + + // if it spans more than one track in that axis, none of those tracks are flexible + let only_span_one_track = item_axis_tracks.len() == 1; + let spans_a_flexible_track = axis_tracks + .iter() + .any(|track| matches!(track.max_track_sizing_function, MaxTrackSizingFunction::Flex(_))); + + let use_content_based_minimum = + spans_auto_min_track && (only_span_one_track || !spans_a_flexible_track); + + // Otherwise, the automatic minimum size is zero, as usual. + if use_content_based_minimum { + self.min_content_contribution_cached(tree, known_dimensions).get(axis) + } else { + 0.0 + } + }) + }) + } + + /// Clears the per-track-sizing-alogrithm-run caches + pub fn clear_contribution_caches(&mut self) { + self.known_dimensions_cache = None; + self.min_content_contribution_cache = None; + self.max_content_contribution_cache = None; + self.minimum_contribution_cache = None; + } +} diff --git a/src/compute/grid/types/grid_track.rs b/src/compute/grid/types/grid_track.rs new file mode 100644 index 000000000..c272f63b1 --- /dev/null +++ b/src/compute/grid/types/grid_track.rs @@ -0,0 +1,139 @@ +//! Contains GridTrack used to represent a single grid track (row/column) during layout +use crate::{ + style::{LengthPercentage, MaxTrackSizingFunction, MinTrackSizingFunction}, + sys::f32_min, +}; + +/// Whether a GridTrack represents an actual track or a gutter. +#[derive(Copy, Clone, Debug, PartialEq)] +pub(in super::super) enum GridTrackKind { + /// Track is an actual track + Track, + /// Track is a gutter (aka grid line) (aka gap) + Gutter, // { name: Option }, +} + +/// Internal sizing information for a single grid track (row/column) +/// Gutters between tracks are sized similarly to actual tracks, so they +/// are also represented by this struct +#[derive(Debug, Clone)] +pub(in super::super) struct GridTrack { + #[allow(dead_code)] // Used in tests + may be useful in future + /// Whether the track is a full track, a gutter, or a placeholder that has not yet been initialised + pub kind: GridTrackKind, + + /// Whether the track is a collapsed track/gutter. Collapsed tracks are effectively treated as if + /// they don't exist for the purposes of grid sizing. Gutters between collapsed tracks are also collapsed. + pub is_collapsed: bool, + + /// The minimum track sizing function of the track + pub min_track_sizing_function: MinTrackSizingFunction, + + /// The maximum track sizing function of the track + pub max_track_sizing_function: MaxTrackSizingFunction, + + /// The distance of the start of the track from the start of the grid container + pub offset: f32, + + /// The size (width/height as applicable) of the track + pub base_size: f32, + + /// A temporary scratch value when sizing tracks + /// Note: can be infinity + pub growth_limit: f32, + + /// A temporary scratch value when sizing tracks. Is used as an additional amount to add to the + /// estimate for the available space in the opposite axis when content sizing items + pub content_alignment_adjustment: f32, + + /// A temporary scratch value when "distributing space" to avoid clobbering planned increase variable + pub item_incurred_increase: f32, + /// A temporary scratch value when "distributing space" to avoid clobbering the main variable + pub base_size_planned_increase: f32, + /// A temporary scratch value when "distributing space" to avoid clobbering the main variable + pub growth_limit_planned_increase: f32, + /// A temporary scratch value when "distributing space" + /// See: https://www.w3.org/TR/css3-grid-layout/#infinitely-growable + pub infinitely_growable: bool, +} + +impl GridTrack { + /// GridTrack constructor with all configuration parameters for the other constructors exposed + fn new_with_kind( + kind: GridTrackKind, + min_track_sizing_function: MinTrackSizingFunction, + max_track_sizing_function: MaxTrackSizingFunction, + ) -> GridTrack { + GridTrack { + kind, + is_collapsed: false, + min_track_sizing_function, + max_track_sizing_function, + offset: 0.0, + base_size: 0.0, + growth_limit: 0.0, + content_alignment_adjustment: 0.0, + item_incurred_increase: 0.0, + base_size_planned_increase: 0.0, + growth_limit_planned_increase: 0.0, + infinitely_growable: false, + } + } + + /// Create new GridTrack representing an actual track (not a gutter) + pub fn new( + min_track_sizing_function: MinTrackSizingFunction, + max_track_sizing_function: MaxTrackSizingFunction, + ) -> GridTrack { + Self::new_with_kind(GridTrackKind::Track, min_track_sizing_function, max_track_sizing_function) + } + + /// Create a new GridTrack representing a gutter + pub fn gutter(size: LengthPercentage) -> GridTrack { + Self::new_with_kind( + GridTrackKind::Gutter, + MinTrackSizingFunction::Fixed(size), + MaxTrackSizingFunction::Fixed(size), + ) + } + + /// Mark a GridTrack as collapsed. Also sets both of the track's sizing functions + /// to fixed zero-sized sizing functions. + pub fn collapse(&mut self) { + self.is_collapsed = true; + self.min_track_sizing_function = MinTrackSizingFunction::Fixed(LengthPercentage::Points(0.0)); + self.max_track_sizing_function = MaxTrackSizingFunction::Fixed(LengthPercentage::Points(0.0)); + } + + #[inline] + /// Returns true if the track is flexible (has a Flex MaxTrackSizingFunction), else false. + pub fn is_flexible(&self) -> bool { + matches!(self.max_track_sizing_function, MaxTrackSizingFunction::Flex(_)) + } + + #[inline] + /// Returns true if the track is flexible (has a Flex MaxTrackSizingFunction), else false. + pub fn fit_content_limit(&self) -> f32 { + match self.max_track_sizing_function { + MaxTrackSizingFunction::FitContent(LengthPercentage::Points(limit)) => limit, + // TODO: properly support percentage fit-content values + MaxTrackSizingFunction::FitContent(LengthPercentage::Percent(_)) => f32::INFINITY, + _ => f32::INFINITY, + } + } + + #[inline] + /// Returns true if the track is flexible (has a Flex MaxTrackSizingFunction), else false. + pub fn fit_content_limited_growth_limit(&self) -> f32 { + f32_min(self.growth_limit, self.fit_content_limit()) + } + + #[inline] + /// Returns the track's flex factor if it is a flex track, else 0. + pub fn flex_factor(&self) -> f32 { + match self.max_track_sizing_function { + MaxTrackSizingFunction::Flex(flex_factor) => flex_factor, + _ => 0.0, + } + } +} diff --git a/src/compute/grid/types/grid_track_counts.rs b/src/compute/grid/types/grid_track_counts.rs new file mode 100644 index 000000000..efd6745ad --- /dev/null +++ b/src/compute/grid/types/grid_track_counts.rs @@ -0,0 +1,107 @@ +//! Contains TrackCounts used to keep track of the number of tracks in the explicit and implicit grids. +//! Also contains coordinate conversion functions which depend on those counts +//! +//! Taffy uses two coordinate systems to refer to grid lines (the gaps/gutters between rows/columns): +//! +//! "CSS Grid Line" coordinates are those used in grid-row/grid-column in the CSS grid spec: +//! - 0 is not a valid index +//! - The line at left hand (or top) edge of the explicit grid is line 1 +//! (and counts up from there) +//! - The line at the right hand (or bottom) edge of the explicit grid in -1 +//! (and counts down from there) +//! +//! "OriginZero" coordinates are a normalized form: +//! - The line at left hand (or top) edge of the explicit grid is line 0 +//! - The next line to the right (or down) is 1, and so on +//! - The next line to the left (or up) is -1, and so on +//! +//! Taffy also uses two coordinate systems to refer to grid tracks (rows/columns): +//! +//! Both of these systems represent the entire implicit grid, not just the explicit grid. +//! +//! "CellOccupancyMatrix track indices": +//! - These are indexes into the CellOccupancyMatrix +//! - The CellOccupancyMatrix stores only tracks +//! - 0 is the leftmost track of the implicit grid, and indexes count up there +//! +//! "GridTrackVec track indices": +//! - The GridTrackVecs store both lines and tracks, so: +//! - even indices (0, 2, 4, etc) represent lines +//! - odd indices (1, 3, 5, etc) represent tracks +//! - These is always an odd number of +//! - Index 1 is the leftmost track of the implict grid. Index 3 is the second leftmost track, etc. +//! - Index 0 is the leftmost grid line. Index 2 is the second leftmost line, etc. +//! +use crate::geometry::Line; +use core::ops::Range; + +/// Stores the number of tracks in a given dimension. +/// Stores seperately the number of tracks in the implicit and explicit grids +#[derive(Clone, Copy, Debug, PartialEq, Default)] +pub(crate) struct TrackCounts { + /// The number of track in the implicit grid before the explicit grid + pub negative_implicit: u16, + /// The number of tracks in the explicit grid + pub explicit: u16, + /// The number of tracks in the implicit grid after the explicit grid + pub positive_implicit: u16, +} + +impl TrackCounts { + /// Create a TrackCounts instance from raw track count numbers + pub fn from_raw(negative_implicit: u16, explicit: u16, positive_implicit: u16) -> Self { + Self { negative_implicit, explicit, positive_implicit } + } + + /// Count the total number of tracks in the axis + pub fn len(&self) -> usize { + (self.negative_implicit + self.explicit + self.positive_implicit) as usize + } +} + +/// Conversion functions between OriginZero coordinates and GridTrackVec indexes +impl TrackCounts { + /// Converts a grid line in OriginZero coordinates into the index of that same grid line in the GridTrackVec. + pub fn oz_line_to_grid_track_vec_index(&self, index: i16) -> u16 { + assert!( + index >= -(self.negative_implicit as i16), + "OriginZero grid line cannot be less than the number of negative grid lines" + ); + assert!( + index <= (self.explicit + self.positive_implicit) as i16, + "OriginZero grid line cannot be more than the number of positive grid lines" + ); + 2 * ((index + self.negative_implicit as i16) as u16) + } +} + +/// Conversion functions between OriginZero coordinates and CellOccupancyMatrix track indexes +impl TrackCounts { + /// Converts a grid line in OriginZero coordinates into the track immediately + /// following that grid line as an index into the CellOccupancyMatrix. + pub fn oz_line_to_next_track(&self, index: i16) -> i16 { + index + (self.negative_implicit as i16) + } + + /// Converts start and end grid lines in OriginZero coordinates into a range of tracks + /// as indexes into the CellOccupancyMatrix + pub fn oz_line_range_to_track_range(&self, input: Line) -> Range { + let start = self.oz_line_to_next_track(input.start); + let end = self.oz_line_to_next_track(input.end); // Don't subtract 1 as output range is exclusive + start..end + } + + /// Converts a track as an index into the CellOccupancyMatrix into the grid line immediately + /// preceeding that track in OriginZero coordinates. + pub fn track_to_prev_oz_line(&self, index: u16) -> i16 { + (index as i16) - (self.negative_implicit as i16) + } + + /// Converts a range of tracks as indexes into the CellOccupancyMatrix into + /// start and end grid lines in OriginZero coordinates + pub fn track_range_to_oz_line_range(&self, input: Range) -> Line { + let start = self.track_to_prev_oz_line(input.start as u16); + let end = self.track_to_prev_oz_line(input.end as u16); // Don't add 1 as input range is exclusive + Line { start, end } + } +} diff --git a/src/compute/grid/types/mod.rs b/src/compute/grid/types/mod.rs new file mode 100644 index 000000000..1260c9bfd --- /dev/null +++ b/src/compute/grid/types/mod.rs @@ -0,0 +1,39 @@ +//! Structs and enums that are used within the grid module +mod cell_occupancy; +mod grid_item; +mod grid_track; +mod grid_track_counts; + +// Publish only locally in the grid module +pub(super) use cell_occupancy::{CellOccupancyMatrix, CellOccupancyState}; +pub(super) use grid_item::GridItem; +pub(super) use grid_track::GridTrack; +pub(super) use grid_track_counts::TrackCounts; + +#[allow(unused_imports)] +pub(super) use grid_track::GridTrackKind; + +// pub(super) enum GridPosition { +// Auto, +// LineIndex(i16), +// LineName(u16), +// // GridAreaStart(u16), +// // GridAreaEnd(u16), +// } + +// pub(super) struct NamedArea { +// name: u16, +// row_start: u16, +// row_end: u16, +// column_start: u16, +// column_end: u16, +// } + +// pub(super) struct CssGrid { +// pub available_space: Size, +// pub cell_occupancy_matrix: CellOccupancyMatrix, +// pub items: Vec, +// pub columns: GridAxisTracks, +// pub rows: GridAxisTracks, +// pub named_areas: Vec, +// } diff --git a/src/compute/grid/util/coordinates.rs b/src/compute/grid/util/coordinates.rs new file mode 100644 index 000000000..6e8de2086 --- /dev/null +++ b/src/compute/grid/util/coordinates.rs @@ -0,0 +1,36 @@ +//! Taffy uses two coordinate systems to refer to grid lines (the gaps/gutters between rows/columns): +//! +//! "CSS Grid Line" coordinates are those used in grid-row/grid-column in the CSS grid spec: +//! - The line at left hand (or top) edge of the explicit grid is line 1 +//! (and counts up from there) +//! - The line at the right hand (or bottom) edge of the explicit grid in -1 +//! (and counts down from there) +//! - 0 is not a valid index +//! +//! "OriginZero" coordinates are a normalized form: +//! - The line at left hand (or top) edge of the explicit grid is line 0 +//! - The next line to the right (or down) is 1, and so on +//! - The next line to the left (or up) is -1, and so on +//! +use core::cmp::Ordering; + +/// Convert from CSS Grid Line coordinates to our custom OriginZero coordinates +pub(crate) fn css_grid_line_into_origin_zero_coords(grid_line: i16, explicit_track_count: u16) -> i16 { + let explicit_line_count = explicit_track_count + 1; + match grid_line.cmp(&0) { + Ordering::Greater => grid_line - 1, + Ordering::Less => grid_line + explicit_line_count as i16, + Ordering::Equal => panic!("Grid line of zero is invalid"), + } +} + +#[allow(dead_code)] +/// Convert from OriginZero coordinates to CSS Grid Line coordinates +pub(crate) fn origin_zero_coords_into_css_grid_line(origin_zero_line: i16, explicit_track_count: u16) -> i16 { + let explicit_line_count = explicit_track_count + 1; + if origin_zero_line >= 0 { + origin_zero_line + 1 + } else { + -(origin_zero_line + explicit_line_count as i16) + } +} diff --git a/src/compute/grid/util/mod.rs b/src/compute/grid/util/mod.rs new file mode 100644 index 000000000..2e5108a81 --- /dev/null +++ b/src/compute/grid/util/mod.rs @@ -0,0 +1,11 @@ +//! Utility functions used within the grid module +pub(super) mod coordinates; + +pub(super) use coordinates::css_grid_line_into_origin_zero_coords; +#[allow(unused_imports)] +pub(super) use coordinates::origin_zero_coords_into_css_grid_line; + +#[cfg(test)] +pub(super) mod test_helpers; +#[cfg(test)] +pub(super) use test_helpers::{CreateChildTestNode, CreateParentTestNode}; diff --git a/src/compute/grid/util/test_helpers.rs b/src/compute/grid/util/test_helpers.rs new file mode 100644 index 000000000..5e43032c4 --- /dev/null +++ b/src/compute/grid/util/test_helpers.rs @@ -0,0 +1,31 @@ +//! Helpers for use in unit tests within the grid module +use crate::prelude::*; +use crate::style::{Dimension, GridPlacement, Style}; + +pub(crate) trait CreateParentTestNode { + fn into_grid(self) -> Style; +} +impl CreateParentTestNode for (f32, f32, i32, i32) { + fn into_grid(self) -> Style { + Style { + display: Display::Grid, + size: Size { width: Dimension::Points(self.0), height: Dimension::Points(self.1) }, + grid_template_columns: vec![flex(1f32); self.2 as usize], + grid_template_rows: vec![flex(1f32); self.3 as usize], + ..Default::default() + } + } +} +pub(crate) trait CreateChildTestNode { + fn into_grid_child(self) -> Style; +} +impl CreateChildTestNode for (GridPlacement, GridPlacement, GridPlacement, GridPlacement) { + fn into_grid_child(self) -> Style { + Style { + display: Display::Grid, + grid_column: Line { start: self.0, end: self.1 }, + grid_row: Line { start: self.2, end: self.3 }, + ..Default::default() + } + } +} diff --git a/src/compute/leaf.rs b/src/compute/leaf.rs index 07a507c25..94a09b5d2 100644 --- a/src/compute/leaf.rs +++ b/src/compute/leaf.rs @@ -1,10 +1,11 @@ //! Computes size using styles and measure functions use crate::geometry::Size; -use crate::layout::{AvailableSpace, RunMode, SizingMode}; +use crate::layout::{RunMode, SizingMode}; use crate::math::MaybeMath; use crate::node::Node; use crate::resolve::{MaybeResolve, ResolveOrZero}; +use crate::style::AvailableSpace; use crate::tree::LayoutTree; #[cfg(feature = "debug")] @@ -31,10 +32,10 @@ pub(crate) fn compute( (node_size, node_min_size, node_max_size) } SizingMode::InherentSize => { - let style_size = style.size.maybe_resolve(available_space.as_options()); + let style_size = style.size.maybe_resolve(available_space.into_options()); let node_size = known_dimensions.or(style_size); - let node_min_size = style.min_size.maybe_resolve(available_space.as_options()); - let node_max_size = style.max_size.maybe_resolve(available_space.as_options()); + let node_min_size = style.min_size.maybe_resolve(available_space.into_options()); + let node_max_size = style.max_size.maybe_resolve(available_space.into_options()); (node_size, node_min_size, node_max_size) } }; @@ -56,8 +57,16 @@ pub(crate) fn compute( if tree.needs_measure(node) { // Compute available space let available_space = Size { - width: available_space.width.maybe_set(node_size.width), - height: available_space.height.maybe_set(node_size.height), + width: available_space + .width + .maybe_set(node_size.width) + .maybe_set(node_max_size.width) + .map_definite_value(|size| size.maybe_clamp(node_min_size.width, node_max_size.width)), + height: available_space + .height + .maybe_set(node_size.height) + .maybe_set(node_max_size.height) + .map_definite_value(|size| size.maybe_clamp(node_min_size.height, node_max_size.height)), }; // Measure node diff --git a/src/compute/mod.rs b/src/compute/mod.rs index bc6bbc39b..8758f4927 100644 --- a/src/compute/mod.rs +++ b/src/compute/mod.rs @@ -1,13 +1,17 @@ //! The layout algorithms themselves +pub(crate) mod common; pub(crate) mod flexbox; pub(crate) mod leaf; +#[cfg(feature = "experimental_grid")] +pub(crate) mod grid; + use crate::error::TaffyError; use crate::geometry::{Point, Size}; -use crate::layout::{AvailableSpace, Cache, Layout, RunMode, SizingMode}; +use crate::layout::{Cache, Layout, RunMode, SizingMode}; use crate::node::Node; -use crate::style::Display; +use crate::style::{AvailableSpace, Display}; use crate::sys::round; use crate::tree::LayoutTree; @@ -115,10 +119,12 @@ fn compute_node_layout( NODE_LOGGER.log("Algo: flexbox"); self::flexbox::compute(tree, node, known_dimensions, available_space, run_mode) } + #[cfg(feature = "experimental_grid")] + Display::Grid => self::grid::compute(tree, node, available_space), Display::None => { #[cfg(feature = "debug")] NODE_LOGGER.log("Algo: none"); - Size { width: 0.0, height: 0.0 } + perform_hidden_layout(tree, node) } } }; @@ -183,6 +189,24 @@ fn compute_from_cache( None } +/// Creates a layout for this node and its children, recursively. +/// Each hidden node has zero size and is placed at the origin +fn perform_hidden_layout(tree: &mut impl LayoutTree, node: Node) -> Size { + /// Recursive function to apply hidden layout to all descendents + fn perform_hidden_layout_inner(tree: &mut impl LayoutTree, node: Node, order: u32) { + *tree.layout_mut(node) = Layout::with_order(order); + for order in 0..tree.child_count(node) { + perform_hidden_layout_inner(tree, tree.child(node, order), order as _); + } + } + + for order in 0..tree.child_count(node) { + perform_hidden_layout_inner(tree, tree.child(node, order), order as _); + } + + Size::ZERO +} + /// Rounds the calculated [`NodeData`] according to the spec fn round_layout(tree: &mut impl LayoutTree, root: Node, abs_x: f32, abs_y: f32) { let layout = tree.layout_mut(root); @@ -201,3 +225,43 @@ fn round_layout(tree: &mut impl LayoutTree, root: Node, abs_x: f32, abs_y: f32) round_layout(tree, child, abs_x, abs_y); } } + +#[cfg(test)] +mod tests { + use super::perform_hidden_layout; + use crate::geometry::{Point, Size}; + use crate::style::{Display, Style}; + use crate::Taffy; + + #[test] + fn hidden_layout_should_hide_recursively() { + let mut taffy = Taffy::new(); + + let style: Style = Style { display: Display::Flex, size: Size::from_points(50.0, 50.0), ..Default::default() }; + + let grandchild_00 = taffy.new_leaf(style.clone()).unwrap(); + let grandchild_01 = taffy.new_leaf(style.clone()).unwrap(); + let child_00 = taffy.new_with_children(style.clone(), &[grandchild_00, grandchild_01]).unwrap(); + + let grandchild_02 = taffy.new_leaf(style.clone()).unwrap(); + let child_01 = taffy.new_with_children(style.clone(), &[grandchild_02]).unwrap(); + + let root = taffy + .new_with_children( + Style { display: Display::None, size: Size::from_points(50.0, 50.0), ..Default::default() }, + &[child_00, child_01], + ) + .unwrap(); + + perform_hidden_layout(&mut taffy, root); + + // Whatever size and display-mode the nodes had previously, + // all layouts should resolve to ZERO due to the root's DISPLAY::NONE + for (node, _) in taffy.nodes.iter().filter(|(node, _)| *node != root) { + if let Ok(layout) = taffy.layout(node) { + assert_eq!(layout.size, Size::zero()); + assert_eq!(layout.location, Point::zero()); + } + } + } +} diff --git a/src/debug.rs b/src/debug.rs index 729921628..5690965e3 100644 --- a/src/debug.rs +++ b/src/debug.rs @@ -18,13 +18,14 @@ fn print_node(tree: &impl LayoutTree, node: Node, has_sibling: bool, lines_strin let fork_string = if has_sibling { "├── " } else { "└── " }; println!( - "{lines}{fork}[x: {x}, y: {y}, width: {width}, height: {height}]", + "{lines}{fork}[x: {x:<4} y: {y:<4} width: {width:<4} height: {height:<4}] ({key:?})", lines = lines_string, fork = fork_string, x = layout.location.x, y = layout.location.y, width = layout.size.width, height = layout.size.height, + key = node.data(), ); let bar = if has_sibling { "│ " } else { " " }; let new_string = lines_string + bar; diff --git a/src/geometry.rs b/src/geometry.rs index ba4762c08..8a549b459 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -3,6 +3,9 @@ use crate::style::{Dimension, FlexDirection}; use core::ops::Add; +#[cfg(feature = "experimental_grid")] +use crate::axis::AbstractAxis; + /// An axis-aligned UI rectangle #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] @@ -57,18 +60,39 @@ impl Rect { bottom: f(self.bottom, size.height), } } + + /// Applies the function `f` to the left, right, top, and bottom properties + /// + /// This is used to transform a `Rect` into a `Rect`. + pub fn map(self, f: F) -> Rect + where + F: Fn(T) -> R, + { + Rect { top: f(self.top), bottom: f(self.bottom), left: f(self.left), right: f(self.right) } + } + + /// Returns a Line representing the left and right properties of the Rect + pub fn horizontal_components(self) -> Line { + Line { start: self.left, end: self.right } + } + + /// Returns a Line containing the top and bottom properties of the Rect + pub fn vertical_components(self) -> Line { + Line { start: self.top, end: self.bottom } + } } -impl Rect +impl Rect where - T: Add + Copy + Clone, + T: Add + Copy + Clone, { /// The sum of [`Rect.start`](Rect) and [`Rect.end`](Rect) /// /// This is typically used when computing total padding. /// /// **NOTE:** this is *not* the width of the rectangle. - pub(crate) fn horizontal_axis_sum(&self) -> T { + #[inline(always)] + pub(crate) fn horizontal_axis_sum(&self) -> U { self.left + self.right } @@ -77,17 +101,27 @@ where /// This is typically used when computing total padding. /// /// **NOTE:** this is *not* the height of the rectangle. - pub(crate) fn vertical_axis_sum(&self) -> T { + #[inline(always)] + pub(crate) fn vertical_axis_sum(&self) -> U { self.top + self.bottom } + /// Both horizontal_axis_sum and vertical_axis_sum as a Size + /// + /// **NOTE:** this is *not* the width/height of the rectangle. + #[inline(always)] + #[allow(dead_code)] // Fixes spurious clippy warning: this function is used! + pub(crate) fn sum_axes(&self) -> Size { + Size { width: self.horizontal_axis_sum(), height: self.vertical_axis_sum() } + } + /// The sum of the two fields of the [`Rect`] representing the main axis. /// /// This is typically used when computing total padding. /// /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::horizontal`]. /// Otherwise, this is [`Rect::vertical`]. - pub(crate) fn main_axis_sum(&self, direction: FlexDirection) -> T { + pub(crate) fn main_axis_sum(&self, direction: FlexDirection) -> U { if direction.is_row() { self.horizontal_axis_sum() } else { @@ -99,7 +133,7 @@ where /// /// If the [`FlexDirection`] is [`FlexDirection::Row`] or [`FlexDirection::RowReverse`], this is [`Rect::vertical`]. /// Otherwise, this is [`Rect::horizontal`]. - pub(crate) fn cross_axis_sum(&self, direction: FlexDirection) -> T { + pub(crate) fn cross_axis_sum(&self, direction: FlexDirection) -> U { if direction.is_row() { self.vertical_axis_sum() } else { @@ -160,6 +194,36 @@ impl Rect { } } +/// An abstract "line". Represents any type that has a start and an end +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct Line { + /// The start position of a line + pub start: T, + /// The end position of a line + pub end: T, +} + +impl Line { + /// Applies the function `f` to both the width and height + /// + /// This is used to transform a `Line` into a `Line`. + pub fn map(self, f: F) -> Line + where + F: Fn(T) -> R, + { + Line { start: f(self.start), end: f(self.end) } + } +} + +impl Line { + /// Adds the start and end values together and returns the result + pub fn sum(&self) -> ::Output { + self.start + self.end + } +} + /// The width and height of a [`Rect`] #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] @@ -177,6 +241,15 @@ impl Default for Size { } } +// Generic Add impl for Size + Size where T + U has an Add impl +impl> Add> for Size { + type Output = Size<>::Output>; + + fn add(self, rhs: Size) -> Self::Output { + Size { width: self.width + rhs.width, height: self.height + rhs.height } + } +} + impl Size { /// Applies the function `f` to both the width and height /// @@ -256,6 +329,26 @@ impl Size { self.width } } + + /// Gets the extent of the specified layout axis + /// Whether this is the width or height depends on the `GridAxis` provided + #[cfg(feature = "experimental_grid")] + pub(crate) fn get(self, axis: AbstractAxis) -> T { + match axis { + AbstractAxis::Inline => self.width, + AbstractAxis::Block => self.height, + } + } + + /// Sets the extent of the specified layout axis + /// Whether this is the width or height depends on the `GridAxis` provided + #[cfg(feature = "experimental_grid")] + pub(crate) fn set(&mut self, axis: AbstractAxis, value: T) { + match axis { + AbstractAxis::Inline => self.width = value, + AbstractAxis::Block => self.height = value, + } + } } impl Size { @@ -272,14 +365,16 @@ impl Size> { pub const fn new(width: f32, height: f32) -> Self { Size { width: Some(width), height: Some(height) } } +} +impl Size> { /// Performs Option::unwrap_or on each component separately - pub fn unwrap_or(self, alt: Size) -> Size { + pub fn unwrap_or(self, alt: Size) -> Size { Size { width: self.width.unwrap_or(alt.width), height: self.height.unwrap_or(alt.height) } } /// Performs Option::or on each component separately - pub fn or(self, alt: Size>) -> Size> { + pub fn or(self, alt: Size>) -> Size> { Size { width: self.width.or(alt.width), height: self.height.or(alt.height) } } } @@ -313,3 +408,12 @@ impl Point { /// A [`Point`] with values (0,0), representing the origin pub const ZERO: Point = Self { x: 0.0, y: 0.0 }; } + +/// Generic struct which holds a "min" value and a "max" value +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +pub struct MinMax { + /// The value representing the minimum + pub min: Min, + /// The value representing the maximum + pub max: Max, +} diff --git a/src/layout.rs b/src/layout.rs index 020b25af9..c9e343f6b 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -1,7 +1,7 @@ //! Final and cached data structures that represent the high-level UI layout use crate::geometry::{Point, Size}; -use crate::sys::abs; +use crate::style::AvailableSpace; /// Whether we are performing a full layout, or we merely need to size the node #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -22,88 +22,6 @@ pub enum SizingMode { InherentSize, } -/// The amount of space available to a node in a given axis -#[derive(Copy, Clone, Debug, PartialEq)] -pub enum AvailableSpace { - /// The amount of space available is the specified number of pixels - Definite(f32), - /// The amount of space available is indefinite and the node should be laid out under a min-content constraint - MinContent, - /// The amount of space available is indefinite and the node should be laid out under a max-content constraint - MaxContent, -} - -impl AvailableSpace { - /// A definite available space of zero - pub const ZERO: AvailableSpace = AvailableSpace::Definite(0.0); - - /// Returns true for definite values, else false - pub fn is_definite(self) -> bool { - matches!(self, AvailableSpace::Definite(_)) - } - - /// Convert to Option - /// Definite values become Some(value). Contraints become None. - pub fn into_option(self) -> Option { - match self { - AvailableSpace::Definite(value) => Some(value), - _ => None, - } - } - - /// Return the definite value or a default value - pub fn unwrap_or(self, default: f32) -> f32 { - self.into_option().unwrap_or(default) - } - - /// Return the definite value. Panic is the value is not definite. - #[track_caller] - pub fn unwrap(self) -> f32 { - self.into_option().unwrap() - } - - /// If passed value is Some then return AvailableSpace::Definite containing that value, else return self - pub fn maybe_set(self, value: Option) -> AvailableSpace { - match value { - Some(value) => AvailableSpace::Definite(value), - None => self, - } - } - - /// Compare equality with another AvailableSpace, treating definite values - /// that are within f32::EPSILON of each other as equal - pub fn is_roughly_equal(self, other: AvailableSpace) -> bool { - use AvailableSpace::*; - match (self, other) { - (Definite(a), Definite(b)) => abs(a - b) < f32::EPSILON, - (MinContent, MinContent) => true, - (MaxContent, MaxContent) => true, - _ => false, - } - } -} - -impl From for AvailableSpace { - fn from(value: f32) -> Self { - Self::Definite(value) - } -} - -impl Size { - /// A Size containing a MaxContent constraint in both dimensions - pub const MAX_CONTENT: Size = - Size { width: AvailableSpace::MaxContent, height: AvailableSpace::MaxContent }; - - /// A Size containing a MinContent constraint in both dimensions - pub const MIN_CONTENT: Size = - Size { width: AvailableSpace::MinContent, height: AvailableSpace::MinContent }; - - /// Convert Size into Size> - pub fn as_options(self) -> Size> { - Size { width: self.width.into_option(), height: self.height.into_option() } - } -} - /// The final result of a layout algorithm for a single [`Node`](crate::node::Node). #[derive(Copy, Debug, Clone)] pub struct Layout { diff --git a/src/lib.rs b/src/lib.rs index a04c80a38..217899db9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,8 @@ pub mod style; pub mod style_helpers; pub mod tree; +#[cfg(feature = "experimental_grid")] +mod axis; #[cfg(feature = "random")] pub mod randomizable; diff --git a/src/math.rs b/src/math.rs index 56dddeb61..d02a96194 100644 --- a/src/math.rs +++ b/src/math.rs @@ -2,7 +2,7 @@ #![allow(clippy::manual_clamp)] use crate::geometry::Size; -use crate::layout::AvailableSpace; +use crate::style::AvailableSpace; /// A trait to conveniently calculate minimums and maximums when some data may not be defined /// diff --git a/src/node.rs b/src/node.rs index a280b366f..fd6ce46b5 100644 --- a/src/node.rs +++ b/src/node.rs @@ -8,9 +8,9 @@ pub type Node = slotmap::DefaultKey; use crate::error::{TaffyError, TaffyResult}; use crate::geometry::Size; -use crate::layout::{AvailableSpace, Cache, Layout}; +use crate::layout::{Cache, Layout}; use crate::prelude::LayoutTree; -use crate::style::Style; +use crate::style::{AvailableSpace, Style}; #[cfg(any(feature = "std", feature = "alloc"))] use crate::sys::Box; use crate::sys::{new_vec_with_capacity, ChildrenVec, Vec}; @@ -371,10 +371,9 @@ mod tests { #![allow(clippy::bool_assert_comparison)] use super::*; - use crate::{ - style::{Dimension, Display, FlexDirection}, - sys, - }; + use crate::style::{Dimension, Display, FlexDirection}; + use crate::style_helpers::*; + use crate::sys; #[test] fn new_should_allocate_default_capacity() { @@ -646,7 +645,7 @@ mod tests { let style = Style { display: Display::None, flex_direction: FlexDirection::RowReverse, ..Default::default() }; - let node = taffy.new_leaf(style).unwrap(); + let node = taffy.new_leaf(style.clone()).unwrap(); let res = taffy.style(node); assert!(res.is_ok()); diff --git a/src/prelude.rs b/src/prelude.rs index dd6e8dc0c..c688859b9 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -2,13 +2,24 @@ pub use crate::{ compute::flexbox::compute as layout_flexbox, - geometry::{Rect, Size}, - layout::{AvailableSpace, Layout}, + geometry::{Line, Rect, Size}, + layout::Layout, node::{Node, Taffy}, style::{ - AlignContent, AlignItems, AlignSelf, Dimension, Display, FlexDirection, FlexWrap, JustifyContent, - LengthPercentage, LengthPercentageAuto, PositionType, Style, + AlignContent, AlignItems, AlignSelf, AvailableSpace, Dimension, Display, FlexDirection, FlexWrap, + JustifyContent, JustifyItems, JustifySelf, LengthPercentage, LengthPercentageAuto, PositionType, Style, + }, + style_helpers::{ + auto, fit_content, flex, max_content, min_content, minmax, percent, points, zero, FromFlex, FromPercent, + FromPoints, TaffyAuto, TaffyFitContent, TaffyMaxContent, TaffyMinContent, TaffyZero, }, - style_helpers::{auto, points, zero}, tree::LayoutTree, }; + +#[cfg(feature = "experimental_grid")] +pub use crate::style::{ + GridAutoFlow, GridPlacement, GridTrackRepetition, MaxTrackSizingFunction, MinTrackSizingFunction, + NonRepeatedTrackSizingFunction, TrackSizingFunction, +}; +#[cfg(feature = "experimental_grid")] +pub use crate::style_helpers::{line, repeat, span, TaffyGridLine, TaffyGridSpan}; diff --git a/src/style.rs b/src/style.rs deleted file mode 100644 index 871f4c5c7..000000000 --- a/src/style.rs +++ /dev/null @@ -1,751 +0,0 @@ -//! A representation of [CSS layout properties](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) in Rust, used for flexbox layout - -use crate::geometry::{Rect, Size}; - -/// How [`Nodes`](crate::node::Node) are aligned relative to the cross axis -/// -/// The default behavior is [`AlignItems::Stretch`]. -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-items-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum AlignItems { - /// Items are packed toward the start of the cross axis - FlexStart, - /// Items are packed toward the end of the cross axis - FlexEnd, - /// Items are packed along the center of the cross axis - Center, - /// Items are aligned such as their baselines align - Baseline, - /// Stretch to fill the container - Stretch, -} - -impl Default for AlignItems { - fn default() -> Self { - Self::Stretch - } -} - -/// Overrides the inherited [`AlignItems`] behavior for this node. -/// -/// The behavior of any child nodes will be controlled by this node's [`AlignItems`] value. -/// -/// The default behavior is [`AlignSelf::Auto`]. -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-items-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum AlignSelf { - /// Inherits the [`AlignItems`] behavior of the parent - Auto, - /// Items are packed toward the start of the cross axis - FlexStart, - /// Items are packed toward the end of the cross axis - FlexEnd, - /// Items are packed along the center of the cross axis - Center, - /// Items are aligned such as their baselines align - Baseline, - /// Distribute items evenly, but stretch them to fill the container - Stretch, -} - -impl Default for AlignSelf { - fn default() -> Self { - Self::Auto - } -} - -/// Sets the distribution of space between and around content items along the cross-axis -/// -/// The default value is [`AlignContent::Stretch`]. -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#align-content-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum AlignContent { - /// Items are packed toward the start of the axis - FlexStart, - /// Items are packed toward the end of the axis - FlexEnd, - /// Items are centered around the middle of the axis - Center, - /// Items are stretched to fill the container - Stretch, - /// The first and last items are aligned flush with the edges of the container (no gap) - /// The gap between items is distributed evenly. - SpaceBetween, - /// The gap between the first and last items is exactly THE SAME as the gap between items. - /// The gaps are distributed evenly - SpaceEvenly, - /// The gap between the first and last items is exactly HALF the gap between items. - /// The gaps are distributed evenly in proportion to these ratios. - SpaceAround, -} - -impl Default for AlignContent { - fn default() -> Self { - Self::Stretch - } -} - -/// Sets the layout used for the children of this node -/// -/// [`Display::Flex`] is the default value. -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum Display { - /// The children will follow the flexbox layout algorithm - Flex, - /// The children will not be laid out, and will follow absolute positioning - None, -} - -impl Default for Display { - fn default() -> Self { - Self::Flex - } -} - -/// The direction of the flexbox layout main axis. -/// -/// There are always two perpendicular layout axes: main (or primary) and cross (or secondary). -/// Adding items will cause them to be positioned adjacent to each other along the main axis. -/// By varying this value throughout your tree, you can create complex axis-aligned layouts. -/// -/// Items are always aligned relative to the cross axis, and justified relative to the main axis. -/// -/// The default behavior is [`FlexDirection::Row`]. -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-direction-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum FlexDirection { - /// Defines +x as the main axis - /// - /// Items will be added from left to right in a row. - Row, - /// Defines +y as the main axis - /// - /// Items will be added from top to bottom in a column. - Column, - /// Defines -x as the main axis - /// - /// Items will be added from right to left in a row. - RowReverse, - /// Defines -y as the main axis - /// - /// Items will be added from bottom to top in a column. - ColumnReverse, -} - -impl Default for FlexDirection { - fn default() -> Self { - Self::Row - } -} - -impl FlexDirection { - #[inline] - /// Is the direction [`FlexDirection::Row`] or [`FlexDirection::RowReverse`]? - pub(crate) fn is_row(self) -> bool { - matches!(self, Self::Row | Self::RowReverse) - } - - #[inline] - /// Is the direction [`FlexDirection::Column`] or [`FlexDirection::ColumnReverse`]? - pub(crate) fn is_column(self) -> bool { - matches!(self, Self::Column | Self::ColumnReverse) - } - - #[inline] - /// Is the direction [`FlexDirection::RowReverse`] or [`FlexDirection::ColumnReverse`]? - pub(crate) fn is_reverse(self) -> bool { - matches!(self, Self::RowReverse | Self::ColumnReverse) - } -} - -/// Sets the distribution of space between and around content items along the main-axis -/// -/// The default value is [`JustifyContent::FlexStart`]. -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#justify-content-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum JustifyContent { - /// Items are packed toward the start of the main axis - FlexStart, - /// Items are packed toward the end of the main axis - FlexEnd, - /// Items are packed along the center of the main axis - Center, - /// The first and last items are aligned flush with the edges of the container (no gap) - /// The gaps between items are distributed evenly. - SpaceBetween, - /// The gap between the first and last items is exactly THE SAME as the gap between items. - /// The gaps are distributed evenly - SpaceEvenly, - /// The gap between the first and last items is exactly HALF the gap between items. - /// The gaps are distributed evenly in proportion to these ratios. - SpaceAround, -} - -impl Default for JustifyContent { - fn default() -> Self { - Self::FlexStart - } -} - -/// The positioning strategy for this item. -/// -/// This controls both how the origin is determined for the [`Style::position`] field, -/// and whether or not the item will be controlled by flexbox's layout algorithm. -/// -/// WARNING: this enum follows the behavior of [CSS's `position` property](https://developer.mozilla.org/en-US/docs/Web/CSS/position), -/// which can be unintuitive. -/// -/// [`PositionType::Relative`] is the default value, in contrast to the default behavior in CSS. -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum PositionType { - /// The offset is computed relative to the final position given by the layout algorithm. - /// Offsets do not affect the position of any other items; they are effectively a correction factor applied at the end. - Relative, - /// The offset is computed relative to this item's closest positioned ancestor, if any. - /// Otherwise, it is placed relative to the origin. - /// No space is created for the item in the page layout, and its size will not be altered. - /// - /// WARNING: to opt-out of layouting entirely, you must use [`Display::None`] instead on your [`Style`] object. - Absolute, -} - -impl Default for PositionType { - fn default() -> Self { - Self::Relative - } -} - -/// Controls whether flex items are forced onto one line or can wrap onto multiple lines. -/// -/// Defaults to [`FlexWrap::NoWrap`] -/// -/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-wrap-property) -#[derive(Copy, Clone, PartialEq, Eq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum FlexWrap { - /// Items will not wrap and stay on a single line - NoWrap, - /// Items will wrap according to this item's [`FlexDirection`] - Wrap, - /// Items will wrap in the opposite direction to this item's [`FlexDirection`] - WrapReverse, -} - -impl Default for FlexWrap { - fn default() -> Self { - Self::NoWrap - } -} - -/// A unit of linear measurement -/// -/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. -#[derive(Copy, Clone, PartialEq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum LengthPercentage { - /// Points are abstract absolute units. Users of Taffy may define what they correspond - /// to in their application (pixels, logical pixels, mm, etc) as they see fit. - Points(f32), - /// The dimension is stored in percentage relative to the parent item. - Percent(f32), -} - -/// A unit of linear measurement -/// -/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. -#[derive(Copy, Clone, PartialEq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum LengthPercentageAuto { - /// Points are abstract absolute units. Users of Taffy may define what they correspond - /// to in their application (pixels, logical pixels, mm, etc) as they see fit. - Points(f32), - /// The dimension is stored in percentage relative to the parent item. - Percent(f32), - /// The dimension should be automatically computed - Auto, -} - -/// A unit of linear measurement -/// -/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. -#[derive(Copy, Clone, PartialEq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -pub enum Dimension { - /// Points are abstract absolute units. Users of Taffy may define what they correspond - /// to in their application (pixels, logical pixels, mm, etc) as they see fit. - Points(f32), - /// The dimension is stored in percentage relative to the parent item. - Percent(f32), - /// The dimension should be automatically computed - Auto, -} - -impl Dimension { - /// Is this value defined? - pub(crate) fn is_defined(self) -> bool { - matches!(self, Dimension::Points(_) | Dimension::Percent(_)) - } -} - -impl Rect { - /// Generates a [`Rect`] using [`Dimension::Points`] values for `start` and `top` - #[must_use] - pub const fn top_from_points(start: f32, top: f32) -> Rect { - Rect { left: Dimension::Points(start), top: Dimension::Points(top), ..Rect::AUTO } - } - - /// Generates a [`Rect`] using [`Dimension::Points`] values for `end` and `bottom` - #[must_use] - pub const fn bot_from_points(end: f32, bottom: f32) -> Rect { - Rect { right: Dimension::Points(end), bottom: Dimension::Points(bottom), ..Rect::AUTO } - } - - /// Generates a [`Rect`] using [`Dimension::Percent`] values for `start` and `top` - #[must_use] - pub const fn top_from_percent(start: f32, top: f32) -> Rect { - Rect { left: Dimension::Percent(start), top: Dimension::Percent(top), ..Rect::AUTO } - } - - /// Generates a [`Rect`] using [`Dimension::Percent`] values for `end` and `bottom` - #[must_use] - pub const fn bot_from_percent(end: f32, bottom: f32) -> Rect { - Rect { right: Dimension::Percent(end), bottom: Dimension::Percent(bottom), ..Rect::AUTO } - } - - /// Generates a [`Rect`] using [`Dimension::Auto`] for all values - pub const AUTO: Rect = - Self { left: Dimension::Auto, right: Dimension::Auto, top: Dimension::Auto, bottom: Dimension::Auto }; - - /// Create a new Rect with [`Dimension::Points`] - #[must_use] - pub const fn from_points(start: f32, end: f32, top: f32, bottom: f32) -> Self { - Rect { - left: Dimension::Points(start), - right: Dimension::Points(end), - top: Dimension::Points(top), - bottom: Dimension::Points(bottom), - } - } - - /// Create a new Rect with [`Dimension::Percent`] - #[must_use] - pub const fn from_percent(start: f32, end: f32, top: f32, bottom: f32) -> Self { - Rect { - left: Dimension::Percent(start), - right: Dimension::Percent(end), - top: Dimension::Percent(top), - bottom: Dimension::Percent(bottom), - } - } -} - -/// The flexbox layout information for a single [`Node`](crate::node::Node). -/// -/// The most important idea in flexbox is the notion of a "main" and "cross" axis, which are always perpendicular to each other. -/// The orientation of these axes are controlled via the [`FlexDirection`] field of this struct. -/// -/// This struct follows the [CSS equivalent](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox) directly; -/// information about the behavior on the web should transfer directly. -/// -/// Detailed information about the exact behavior of each of these fields -/// can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS) by searching for the field name. -/// The distinction between margin, padding and border is explained well in -/// this [introduction to the box model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model). -/// -/// If the behavior does not match the flexbox layout algorithm on the web, please file a bug! -#[derive(Copy, Clone, PartialEq, Debug)] -#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] -#[cfg_attr(feature = "serde", serde(default))] -pub struct Style { - /// What layout strategy should be used? - pub display: Display, - /// What should the `position` value of this struct use as a base offset? - pub position_type: PositionType, - /// Which direction does the main axis flow in? - pub flex_direction: FlexDirection, - /// Should elements wrap, or stay in a single line? - pub flex_wrap: FlexWrap, - /// How should items be aligned relative to the cross axis? - pub align_items: AlignItems, - /// Should this item violate the cross axis alignment specified by its parent's [`AlignItems`]? - pub align_self: AlignSelf, - /// How should content contained within this item be aligned relative to the cross axis? - pub align_content: AlignContent, - /// How should items be aligned relative to the main axis? - pub justify_content: JustifyContent, - /// How should the position of this element be tweaked relative to the layout defined? - pub position: Rect, - /// How large should the margin be on each side? - pub margin: Rect, - /// How large should the padding be on each side? - pub padding: Rect, - /// How large should the border be on each side? - pub border: Rect, - // Gap - /// How large should the gaps between items in a grid or flex container be? - pub gap: Size, - /// The relative rate at which this item grows when it is expanding to fill space - /// - /// 0.0 is the default value, and this value must not be negative. - pub flex_grow: f32, - /// The relative rate at which this item shrinks when it is contracting to fit into space - /// - /// 1.0 is the default value, and this value must not be negative. - pub flex_shrink: f32, - /// Sets the initial main axis size of the item - pub flex_basis: Dimension, - /// Sets the initial size of the item - // TODO: why does this exist as distinct from flex_basis? How do they interact? - pub size: Size, - /// Controls the minimum size of the item - pub min_size: Size, - /// Controls the maximum size of the item - pub max_size: Size, - /// Sets the preferred aspect ratio for the item - /// - /// The ratio is calculated as width divided by height. - pub aspect_ratio: Option, -} - -impl Style { - /// The [`Default`] layout, in a form that can be used in const functions - pub const DEFAULT: Style = Style { - display: Display::Flex, - position_type: PositionType::Relative, - flex_direction: FlexDirection::Row, - flex_wrap: FlexWrap::NoWrap, - align_items: AlignItems::Stretch, - align_self: AlignSelf::Auto, - align_content: AlignContent::Stretch, - justify_content: JustifyContent::FlexStart, - position: Rect::auto(), - margin: Rect::zero(), - padding: Rect::zero(), - border: Rect::zero(), - gap: Size::zero(), - flex_grow: 0.0, - flex_shrink: 1.0, - flex_basis: Dimension::Auto, - size: Size::auto(), - min_size: Size::auto(), - max_size: Size::auto(), - aspect_ratio: None, - }; -} - -impl Default for Style { - fn default() -> Self { - Style::DEFAULT - } -} - -impl Style { - /// If the `direction` is row-oriented, the min width. Otherwise the min height - pub(crate) fn min_main_size(&self, direction: FlexDirection) -> Dimension { - if direction.is_row() { - self.min_size.width - } else { - self.min_size.height - } - } - - /// If the `direction` is row-oriented, the max width. Otherwise the max height - pub(crate) fn max_main_size(&self, direction: FlexDirection) -> Dimension { - if direction.is_row() { - self.max_size.width - } else { - self.max_size.height - } - } - - /// If the `direction` is row-oriented, the margin start. Otherwise the margin top - pub(crate) fn main_margin_start(&self, direction: FlexDirection) -> LengthPercentageAuto { - if direction.is_row() { - self.margin.left - } else { - self.margin.top - } - } - - /// If the `direction` is row-oriented, the margin end. Otherwise the margin bottom - pub(crate) fn main_margin_end(&self, direction: FlexDirection) -> LengthPercentageAuto { - if direction.is_row() { - self.margin.right - } else { - self.margin.bottom - } - } - - /// If the `direction` is row-oriented, the height. Otherwise the width - pub(crate) fn cross_size(&self, direction: FlexDirection) -> Dimension { - if direction.is_row() { - self.size.height - } else { - self.size.width - } - } - - /// If the `direction` is row-oriented, the min height. Otherwise the min width - pub(crate) fn min_cross_size(&self, direction: FlexDirection) -> Dimension { - if direction.is_row() { - self.min_size.height - } else { - self.min_size.width - } - } - - /// If the `direction` is row-oriented, the max height. Otherwise the max width - pub(crate) fn max_cross_size(&self, direction: FlexDirection) -> Dimension { - if direction.is_row() { - self.max_size.height - } else { - self.max_size.width - } - } - - /// If the `direction` is row-oriented, the margin top. Otherwise the margin start - pub(crate) fn cross_margin_start(&self, direction: FlexDirection) -> LengthPercentageAuto { - if direction.is_row() { - self.margin.top - } else { - self.margin.left - } - } - - /// If the `direction` is row-oriented, the margin bottom. Otherwise the margin end - pub(crate) fn cross_margin_end(&self, direction: FlexDirection) -> LengthPercentageAuto { - if direction.is_row() { - self.margin.bottom - } else { - self.margin.right - } - } - - /// Computes the final alignment of this item based on the parent's [`AlignItems`] and this item's [`AlignSelf`] - pub(crate) fn align_self(&self, parent: &Style) -> AlignSelf { - // FUTURE WARNING: This function should never return AlignSelf::Auto - // See #169 https://github.com/DioxusLabs/taffy/pull/169#issuecomment-1157698840 - - if self.align_self == AlignSelf::Auto { - match parent.align_items { - AlignItems::FlexStart => AlignSelf::FlexStart, - AlignItems::FlexEnd => AlignSelf::FlexEnd, - AlignItems::Center => AlignSelf::Center, - AlignItems::Baseline => AlignSelf::Baseline, - AlignItems::Stretch => AlignSelf::Stretch, - } - } else { - self.align_self - } - } -} - -#[allow(clippy::bool_assert_comparison)] -#[cfg(test)] -mod tests { - use super::Style; - use crate::geometry::{Rect, Size}; - - #[test] - fn defaults_match() { - let old_defaults = Style { - display: Default::default(), - position_type: Default::default(), - flex_direction: Default::default(), - flex_wrap: Default::default(), - align_items: Default::default(), - align_self: Default::default(), - align_content: Default::default(), - justify_content: Default::default(), - position: Rect::auto(), - margin: Rect::zero(), - padding: Rect::zero(), - border: Rect::zero(), - gap: Size::zero(), - flex_grow: 0.0, - flex_shrink: 1.0, - flex_basis: super::Dimension::Auto, - size: Size::auto(), - min_size: Size::auto(), - max_size: Size::auto(), - aspect_ratio: Default::default(), - }; - - assert_eq!(Style::DEFAULT, Style::default()); - assert_eq!(Style::DEFAULT, old_defaults); - } - - mod test_flex_direction { - use crate::style::*; - - #[test] - fn flex_direction_is_row() { - assert_eq!(FlexDirection::Row.is_row(), true); - assert_eq!(FlexDirection::RowReverse.is_row(), true); - assert_eq!(FlexDirection::Column.is_row(), false); - assert_eq!(FlexDirection::ColumnReverse.is_row(), false); - } - - #[test] - fn flex_direction_is_column() { - assert_eq!(FlexDirection::Row.is_column(), false); - assert_eq!(FlexDirection::RowReverse.is_column(), false); - assert_eq!(FlexDirection::Column.is_column(), true); - assert_eq!(FlexDirection::ColumnReverse.is_column(), true); - } - - #[test] - fn flex_direction_is_reverse() { - assert_eq!(FlexDirection::Row.is_reverse(), false); - assert_eq!(FlexDirection::RowReverse.is_reverse(), true); - assert_eq!(FlexDirection::Column.is_reverse(), false); - assert_eq!(FlexDirection::ColumnReverse.is_reverse(), true); - } - } - - mod test_flexbox_layout { - use crate::style::*; - use crate::style_helpers::*; - - fn layout_from_align_items(align: AlignItems) -> Style { - Style { align_items: align, ..Default::default() } - } - - fn layout_from_align_self(align: AlignSelf) -> Style { - Style { align_self: align, ..Default::default() } - } - - #[test] - fn flexbox_layout_min_main_size() { - let layout = Style { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; - assert_eq!(layout.min_main_size(FlexDirection::Row), Dimension::Points(1.0)); - assert_eq!(layout.min_main_size(FlexDirection::Column), Dimension::Points(2.0)); - } - - #[test] - fn flexbox_layout_max_main_size() { - let layout = Style { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; - assert_eq!(layout.max_main_size(FlexDirection::Row), Dimension::Points(1.0)); - assert_eq!(layout.max_main_size(FlexDirection::Column), Dimension::Points(2.0)); - } - - #[test] - fn flexbox_layout_main_margin_start() { - let layout = Style { - margin: Rect { top: points(1.0), bottom: auto(), left: points(2.0), right: auto() }, - ..Default::default() - }; - assert_eq!(layout.main_margin_start(FlexDirection::Row), points(2.0)); - assert_eq!(layout.main_margin_start(FlexDirection::Column), points(1.0)); - } - - #[test] - fn flexbox_layout_main_margin_end() { - let layout = Style { - margin: Rect { top: auto(), bottom: points(1.0), left: auto(), right: points(2.0) }, - ..Default::default() - }; - assert_eq!(layout.main_margin_end(FlexDirection::Row), points(2.0)); - assert_eq!(layout.main_margin_end(FlexDirection::Column), points(1.0)); - } - - #[test] - fn flexbox_layout_cross_size() { - let layout = Style { size: Size::from_points(1.0, 2.0), ..Default::default() }; - assert_eq!(layout.cross_size(FlexDirection::Row), Dimension::Points(2.0)); - assert_eq!(layout.cross_size(FlexDirection::Column), Dimension::Points(1.0)); - } - - #[test] - fn flexbox_layout_min_cross_size() { - let layout = Style { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; - assert_eq!(layout.min_cross_size(FlexDirection::Row), Dimension::Points(2.0)); - assert_eq!(layout.min_cross_size(FlexDirection::Column), Dimension::Points(1.0)); - } - - #[test] - fn flexbox_layout_max_cross_size() { - let layout = Style { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; - assert_eq!(layout.max_cross_size(FlexDirection::Row), Dimension::Points(2.0)); - assert_eq!(layout.max_cross_size(FlexDirection::Column), Dimension::Points(1.0)); - } - - #[test] - fn flexbox_layout_cross_margin_start() { - let layout = Style { - margin: Rect { top: points(1.0), bottom: auto(), left: points(2.0), right: auto() }, - ..Default::default() - }; - assert_eq!(layout.cross_margin_start(FlexDirection::Row), points(1.0)); - assert_eq!(layout.cross_margin_start(FlexDirection::Column), points(2.0)); - } - - #[test] - fn flexbox_layout_cross_margin_end() { - let layout = Style { - margin: Rect { top: auto(), bottom: points(1.0), left: auto(), right: points(2.0) }, - ..Default::default() - }; - assert_eq!(layout.cross_margin_end(FlexDirection::Row), points(1.0)); - assert_eq!(layout.cross_margin_end(FlexDirection::Column), points(2.0)); - } - - #[test] - fn flexbox_layout_align_self_auto() { - let parent = layout_from_align_items(AlignItems::FlexStart); - let layout = layout_from_align_self(AlignSelf::Auto); - assert_eq!(layout.align_self(&parent), AlignSelf::FlexStart); - - let parent = layout_from_align_items(AlignItems::FlexEnd); - let layout = layout_from_align_self(AlignSelf::Auto); - assert_eq!(layout.align_self(&parent), AlignSelf::FlexEnd); - - let parent = layout_from_align_items(AlignItems::Center); - let layout = layout_from_align_self(AlignSelf::Auto); - assert_eq!(layout.align_self(&parent), AlignSelf::Center); - - let parent = layout_from_align_items(AlignItems::Baseline); - let layout = layout_from_align_self(AlignSelf::Auto); - assert_eq!(layout.align_self(&parent), AlignSelf::Baseline); - - let parent = layout_from_align_items(AlignItems::Stretch); - let layout = layout_from_align_self(AlignSelf::Auto); - assert_eq!(layout.align_self(&parent), AlignSelf::Stretch); - } - - #[test] - fn align_self() { - let parent = layout_from_align_items(AlignItems::FlexEnd); - let layout = layout_from_align_self(AlignSelf::FlexStart); - assert_eq!(layout.align_self(&parent), AlignSelf::FlexStart); - - let parent = layout_from_align_items(AlignItems::FlexStart); - let layout = layout_from_align_self(AlignSelf::FlexEnd); - assert_eq!(layout.align_self(&parent), AlignSelf::FlexEnd); - - let parent = layout_from_align_items(AlignItems::FlexStart); - let layout = layout_from_align_self(AlignSelf::Center); - assert_eq!(layout.align_self(&parent), AlignSelf::Center); - - let parent = layout_from_align_items(AlignItems::FlexStart); - let layout = layout_from_align_self(AlignSelf::Baseline); - assert_eq!(layout.align_self(&parent), AlignSelf::Baseline); - - let parent = layout_from_align_items(AlignItems::FlexStart); - let layout = layout_from_align_self(AlignSelf::Stretch); - assert_eq!(layout.align_self(&parent), AlignSelf::Stretch); - } - } -} diff --git a/src/style/alignment.rs b/src/style/alignment.rs new file mode 100644 index 000000000..ab15a05d6 --- /dev/null +++ b/src/style/alignment.rs @@ -0,0 +1,75 @@ +//! Style types for controlling alignment + +/// Used to control how child [`Nodes`](crate::node::Node) are aligned. +/// For Flexbox it controls alignment in the cross axis +/// For Grid it controls alignment in the block axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum AlignItems { + /// Items are packed toward the start of the cross axis + Start, + /// Items are packed toward the end of the cross axis + End, + /// Items are packed along the center of the cross axis + Center, + /// Items are aligned such as their baselines align + Baseline, + /// Stretch to fill the container + Stretch, +} +/// Used to control how child [`Nodes`](crate::node::Node) are aligned. +/// Does not apply to Flexbox, and will be ignored if specified on a flex container +/// For Grid it controls alignment in the inline axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) +pub type JustifyItems = AlignItems; +/// Used to control how the specified [`Nodes`](crate::node::Node) is aligned. +/// Overrides the parent Node's `AlignItems` property. +/// For Flexbox it controls alignment in the cross axis +/// For Grid it controls alignment in the block axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) +pub type AlignSelf = AlignItems; +/// Used to control how the specified [`Nodes`](crate::node::Node) is aligned. +/// Overrides the parent Node's `JustifyItems` property. +/// Does not apply to Flexbox, and will be ignored if specified on a flex child +/// For Grid it controls alignment in the inline axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) +pub type JustifySelf = AlignItems; + +/// Sets the distribution of space between and around content items +/// For Flexbox it controls alignment in the cross axis +/// For Grid it controls alignment in the block axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum AlignContent { + /// Items are packed toward the start of the axis + Start, + /// Items are packed toward the end of the axis + End, + /// Items are centered around the middle of the axis + Center, + /// Items are stretched to fill the container + Stretch, + /// The first and last items are aligned flush with the edges of the container (no gap) + /// The gap between items is distributed evenly. + SpaceBetween, + /// The gap between the first and last items is exactly THE SAME as the gap between items. + /// The gaps are distributed evenly + SpaceEvenly, + /// The gap between the first and last items is exactly HALF the gap between items. + /// The gaps are distributed evenly in proportion to these ratios. + SpaceAround, +} + +/// Sets the distribution of space between and around content items +/// For Flexbox it controls alignment in the main axis +/// For Grid it controls alignment in the inline axis +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) +pub type JustifyContent = AlignContent; diff --git a/src/style/dimension.rs b/src/style/dimension.rs new file mode 100644 index 000000000..02e44b40c --- /dev/null +++ b/src/style/dimension.rs @@ -0,0 +1,316 @@ +//! Style types for representing lengths / sizes + +use crate::geometry::{Rect, Size}; +use crate::style_helpers::{FromPercent, FromPoints, TaffyAuto, TaffyMaxContent, TaffyMinContent, TaffyZero}; +use crate::sys::abs; + +/// A unit of linear measurement +/// +/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. +#[derive(Copy, Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum LengthPercentage { + /// Points are abstract absolute units. Users of Taffy may define what they correspond + /// to in their application (pixels, logical pixels, mm, etc) as they see fit. + Points(f32), + /// The dimension is stored in percentage relative to the parent item. + Percent(f32), +} +impl TaffyZero for LengthPercentage { + const ZERO: Self = Self::Points(0.0); +} +impl FromPoints for LengthPercentage { + fn from_points + Copy>(points: Input) -> Self { + Self::Points(points.into()) + } +} +impl FromPercent for LengthPercentage { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Points(percent.into()) + } +} + +/// A unit of linear measurement +/// +/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. +#[derive(Copy, Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum LengthPercentageAuto { + /// Points are abstract absolute units. Users of Taffy may define what they correspond + /// to in their application (pixels, logical pixels, mm, etc) as they see fit. + Points(f32), + /// The dimension is stored in percentage relative to the parent item. + Percent(f32), + /// The dimension should be automatically computed + Auto, +} +impl TaffyZero for LengthPercentageAuto { + const ZERO: Self = Self::Points(0.0); +} +impl TaffyAuto for LengthPercentageAuto { + const AUTO: Self = Self::Auto; +} +impl FromPoints for LengthPercentageAuto { + fn from_points + Copy>(points: Input) -> Self { + Self::Points(points.into()) + } +} +impl FromPercent for LengthPercentageAuto { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Points(percent.into()) + } +} + +impl From for LengthPercentageAuto { + fn from(input: LengthPercentage) -> Self { + match input { + LengthPercentage::Points(value) => Self::Points(value), + LengthPercentage::Percent(value) => Self::Percent(value), + } + } +} + +impl LengthPercentageAuto { + /// Returns: + /// - Some(points) for Points variants + /// - Some(resolved) using the provided context for Percent variants + /// - None for Auto variants + pub fn resolve_to_option(self, context: f32) -> Option { + match self { + Self::Points(points) => Some(points), + Self::Percent(percent) => Some(context * percent), + Self::Auto => None, + } + } +} + +/// A unit of linear measurement +/// +/// This is commonly combined with [`Rect`], [`Point`](crate::geometry::Point) and [`Size`]. +#[derive(Copy, Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum Dimension { + /// Points are abstract absolute units. Users of Taffy may define what they correspond + /// to in their application (pixels, logical pixels, mm, etc) as they see fit. + Points(f32), + /// The dimension is stored in percentage relative to the parent item. + Percent(f32), + /// The dimension should be automatically computed + Auto, +} +impl TaffyZero for Dimension { + const ZERO: Self = Self::Points(0.0); +} +impl TaffyAuto for Dimension { + const AUTO: Self = Self::Auto; +} +impl FromPoints for Dimension { + fn from_points + Copy>(points: Input) -> Self { + Self::Points(points.into()) + } +} +impl FromPercent for Dimension { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Points(percent.into()) + } +} + +impl From for Dimension { + fn from(input: LengthPercentage) -> Self { + match input { + LengthPercentage::Points(value) => Self::Points(value), + LengthPercentage::Percent(value) => Self::Percent(value), + } + } +} + +impl From for Dimension { + fn from(input: LengthPercentageAuto) -> Self { + match input { + LengthPercentageAuto::Points(value) => Self::Points(value), + LengthPercentageAuto::Percent(value) => Self::Percent(value), + LengthPercentageAuto::Auto => Self::Auto, + } + } +} + +impl Dimension { + /// Is this value defined? + pub(crate) fn is_defined(self) -> bool { + matches!(self, Dimension::Points(_) | Dimension::Percent(_)) + } + + /// Get Points value if value is Points variant + #[cfg(feature = "experimental_grid")] + pub(crate) fn into_option(self) -> Option { + match self { + Dimension::Points(value) => Some(value), + _ => None, + } + } +} + +impl Rect { + /// Generates a [`Rect`] using [`Dimension::Points`] values for `start` and `top` + #[must_use] + pub const fn top_from_points(start: f32, top: f32) -> Rect { + Rect { left: Dimension::Points(start), top: Dimension::Points(top), ..Rect::AUTO } + } + + /// Generates a [`Rect`] using [`Dimension::Points`] values for `end` and `bottom` + #[must_use] + pub const fn bot_from_points(end: f32, bottom: f32) -> Rect { + Rect { right: Dimension::Points(end), bottom: Dimension::Points(bottom), ..Rect::AUTO } + } + + /// Generates a [`Rect`] using [`Dimension::Percent`] values for `start` and `top` + #[must_use] + pub const fn top_from_percent(start: f32, top: f32) -> Rect { + Rect { left: Dimension::Percent(start), top: Dimension::Percent(top), ..Rect::AUTO } + } + + /// Generates a [`Rect`] using [`Dimension::Percent`] values for `end` and `bottom` + #[must_use] + pub const fn bot_from_percent(end: f32, bottom: f32) -> Rect { + Rect { right: Dimension::Percent(end), bottom: Dimension::Percent(bottom), ..Rect::AUTO } + } + + /// Create a new Rect with [`Dimension::Points`] + #[must_use] + pub const fn from_points(start: f32, end: f32, top: f32, bottom: f32) -> Self { + Rect { + left: Dimension::Points(start), + right: Dimension::Points(end), + top: Dimension::Points(top), + bottom: Dimension::Points(bottom), + } + } + + /// Create a new Rect with [`Dimension::Percent`] + #[must_use] + pub const fn from_percent(start: f32, end: f32, top: f32, bottom: f32) -> Self { + Rect { + left: Dimension::Percent(start), + right: Dimension::Percent(end), + top: Dimension::Percent(top), + bottom: Dimension::Percent(bottom), + } + } +} + +/// The amount of space available to a node in a given axis +/// https://www.w3.org/TR/css-sizing-3/#available +#[derive(Copy, Clone, Debug, PartialEq)] +pub enum AvailableSpace { + /// The amount of space available is the specified number of pixels + Definite(f32), + /// The amount of space available is indefinite and the node should be laid out under a min-content constraint + MinContent, + /// The amount of space available is indefinite and the node should be laid out under a max-content constraint + MaxContent, +} +impl TaffyZero for AvailableSpace { + const ZERO: Self = Self::Definite(0.0); +} +impl TaffyMaxContent for AvailableSpace { + const MAX_CONTENT: Self = Self::MaxContent; +} +impl TaffyMinContent for AvailableSpace { + const MIN_CONTENT: Self = Self::MinContent; +} +impl FromPoints for AvailableSpace { + fn from_points + Copy>(points: Input) -> Self { + Self::Definite(points.into()) + } +} + +impl AvailableSpace { + /// Returns true for definite values, else false + pub fn is_definite(self) -> bool { + matches!(self, AvailableSpace::Definite(_)) + } + + /// Convert to Option + /// Definite values become Some(value). Contraints become None. + pub fn into_option(self) -> Option { + match self { + AvailableSpace::Definite(value) => Some(value), + _ => None, + } + } + + /// Return the definite value or a default value + pub fn unwrap_or(self, default: f32) -> f32 { + self.into_option().unwrap_or(default) + } + + /// Return the definite value. Panic is the value is not definite. + #[track_caller] + pub fn unwrap(self) -> f32 { + self.into_option().unwrap() + } + + /// If passed value is Some then return AvailableSpace::Definite containing that value, else return self + pub fn maybe_set(self, value: Option) -> AvailableSpace { + match value { + Some(value) => AvailableSpace::Definite(value), + None => self, + } + } + + /// If passed value is Some then return AvailableSpace::Definite containing that value, else return self + pub fn map_definite_value(self, map_function: impl FnOnce(f32) -> f32) -> AvailableSpace { + match self { + AvailableSpace::Definite(value) => AvailableSpace::Definite(map_function(value)), + _ => self, + } + } + + /// Compute free_space given the passed used_space + pub fn compute_free_space(&self, used_space: f32) -> f32 { + match self { + AvailableSpace::MaxContent => f32::INFINITY, + AvailableSpace::MinContent => 0.0, + AvailableSpace::Definite(available_space) => available_space - used_space, + } + } + + /// Compare equality with another AvailableSpace, treating definite values + /// that are within f32::EPSILON of each other as equal + pub fn is_roughly_equal(self, other: AvailableSpace) -> bool { + use AvailableSpace::*; + match (self, other) { + (Definite(a), Definite(b)) => abs(a - b) < f32::EPSILON, + (MinContent, MinContent) => true, + (MaxContent, MaxContent) => true, + _ => false, + } + } +} + +impl From for AvailableSpace { + fn from(value: f32) -> Self { + Self::Definite(value) + } +} + +impl From> for AvailableSpace { + fn from(option: Option) -> Self { + match option { + Some(value) => Self::Definite(value), + None => Self::MaxContent, + } + } +} + +impl Size { + /// Convert Size into Size> + pub fn into_options(self) -> Size> { + Size { width: self.width.into_option(), height: self.height.into_option() } + } + + /// If passed value is Some then return AvailableSpace::Definite containing that value, else return self + pub fn maybe_set(self, value: Size>) -> Size { + Size { width: self.width.maybe_set(value.width), height: self.height.maybe_set(value.height) } + } +} diff --git a/src/style/flex.rs b/src/style/flex.rs new file mode 100644 index 000000000..a81a83284 --- /dev/null +++ b/src/style/flex.rs @@ -0,0 +1,81 @@ +//! Style types for Flexbox layout + +/// Controls whether flex items are forced onto one line or can wrap onto multiple lines. +/// +/// Defaults to [`FlexWrap::NoWrap`] +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-wrap-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum FlexWrap { + /// Items will not wrap and stay on a single line + NoWrap, + /// Items will wrap according to this item's [`FlexDirection`] + Wrap, + /// Items will wrap in the opposite direction to this item's [`FlexDirection`] + WrapReverse, +} + +impl Default for FlexWrap { + fn default() -> Self { + Self::NoWrap + } +} + +/// The direction of the flexbox layout main axis. +/// +/// There are always two perpendicular layout axes: main (or primary) and cross (or secondary). +/// Adding items will cause them to be positioned adjacent to each other along the main axis. +/// By varying this value throughout your tree, you can create complex axis-aligned layouts. +/// +/// Items are always aligned relative to the cross axis, and justified relative to the main axis. +/// +/// The default behavior is [`FlexDirection::Row`]. +/// +/// [Specification](https://www.w3.org/TR/css-flexbox-1/#flex-direction-property) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum FlexDirection { + /// Defines +x as the main axis + /// + /// Items will be added from left to right in a row. + Row, + /// Defines +y as the main axis + /// + /// Items will be added from top to bottom in a column. + Column, + /// Defines -x as the main axis + /// + /// Items will be added from right to left in a row. + RowReverse, + /// Defines -y as the main axis + /// + /// Items will be added from bottom to top in a column. + ColumnReverse, +} + +impl Default for FlexDirection { + fn default() -> Self { + Self::Row + } +} + +impl FlexDirection { + #[inline] + /// Is the direction [`FlexDirection::Row`] or [`FlexDirection::RowReverse`]? + pub(crate) fn is_row(self) -> bool { + matches!(self, Self::Row | Self::RowReverse) + } + + #[inline] + /// Is the direction [`FlexDirection::Column`] or [`FlexDirection::ColumnReverse`]? + pub(crate) fn is_column(self) -> bool { + matches!(self, Self::Column | Self::ColumnReverse) + } + + #[inline] + /// Is the direction [`FlexDirection::RowReverse`] or [`FlexDirection::ColumnReverse`]? + pub(crate) fn is_reverse(self) -> bool { + matches!(self, Self::RowReverse | Self::ColumnReverse) + } +} diff --git a/src/style/grid.rs b/src/style/grid.rs new file mode 100644 index 000000000..37a9f8afc --- /dev/null +++ b/src/style/grid.rs @@ -0,0 +1,506 @@ +//! Style types for CSS Grid layout +use super::{AlignContent, LengthPercentage, Style}; +use crate::axis::{AbsoluteAxis, AbstractAxis}; +use crate::geometry::{Line, MinMax}; +use crate::style::AvailableSpace; +use crate::style_helpers::*; +use crate::sys::GridTrackVec; +use core::cmp::{max, min}; + +/// Controls whether grid items are placed row-wise or column-wise. And whether the sparse or dense packing algorithm is used. +/// +/// The "dense" packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause items to appear out-of-order, when doing so would fill in holes left by larger items. +/// +/// Defaults to [`GridAutoFlow::Row`] +/// +/// [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum GridAutoFlow { + /// Items are placed by filling each row in turn, adding new rows as necessary + Row, + /// Items are placed by filling each column in turn, adding new columns as necessary. + Column, + /// Combines `Row` with the dense packing algorithm. + RowDense, + /// Combines `Column` with the dense packing algorithm. + ColumnDense, +} + +impl Default for GridAutoFlow { + fn default() -> Self { + Self::Row + } +} + +impl GridAutoFlow { + /// Whether grid auto placement uses the sparse placement algorithm or the dense placement algorithm + /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values + pub fn is_dense(&self) -> bool { + match self { + Self::Row | Self::Column => false, + Self::RowDense | Self::ColumnDense => true, + } + } + + /// Whether grid auto placement fills areas row-wise or column-wise + /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values + pub fn primary_axis(&self) -> AbsoluteAxis { + match self { + Self::Row | Self::RowDense => AbsoluteAxis::Horizontal, + Self::Column | Self::ColumnDense => AbsoluteAxis::Vertical, + } + } +} + +/// A grid line placement specification. Used for grid-[row/column]-[start/end]. Named tracks are not implemented. +/// +/// Defaults to [`GridLine::Auto`] +/// +/// [Specification](https://www.w3.org/TR/css3-grid-layout/#typedef-grid-row-start-grid-line) +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum GridPlacement { + /// Place item according to the auto-placement algorithm, and the parent's grid_auto_flow property + Auto, + /// Place item at specified line (column or row) index + Line(i16), + /// Item should span specified number of tracks (columns or rows) + Span(u16), +} +impl TaffyAuto for GridPlacement { + const AUTO: Self = Self::Auto; +} +impl TaffyGridLine for GridPlacement { + fn from_line_index(index: i16) -> Self { + match index { + 0 => GridPlacement::Auto, + _ => GridPlacement::Line(index), + } + } +} +impl TaffyGridLine for Line { + fn from_line_index(index: i16) -> Self { + Line { start: GridPlacement::from_line_index(index), end: GridPlacement::Auto } + } +} +impl TaffyGridSpan for GridPlacement { + fn from_span(span: u16) -> Self { + GridPlacement::Span(span) + } +} +impl TaffyGridSpan for Line { + fn from_span(span: u16) -> Self { + Line { start: GridPlacement::from_span(span), end: GridPlacement::Auto } + } +} + +impl Default for GridPlacement { + fn default() -> Self { + Self::Auto + } +} + +impl GridPlacement { + /// Apply a mapping function if the [`GridPlacement`] is a `Track`. Otherwise return `self` unmodified. + pub fn map_track(&self, map_fn: impl FnOnce(i16) -> i16) -> Self { + use GridPlacement::*; + match *self { + Auto => Auto, + Span(span) => Span(span), + Line(track) => Line(map_fn(track)), + } + } +} + +impl Line { + #[inline] + /// Whether the track position is definite in this axis (or the item will need auto placement) + /// The track position is definite if least one of the start and end positions is a track index + pub fn is_definite(&self) -> bool { + use GridPlacement::*; + matches!((self.start, self.end), (Line(_), _) | (_, Line(_))) + } + + /// If at least one of the of the start and end positions is a track index then the other end can be resolved + /// into a track index purely based on the information contained with the placement specification + pub fn resolve_definite_grid_tracks(&self) -> Line { + use GridPlacement as GP; + match (self.start, self.end) { + (GP::Line(track1), GP::Line(track2)) if track1 != 0 && track2 != 0 => { + if track1 == track2 { + Line { start: track1, end: track1 + 1 } + } else { + Line { start: min(track1, track2), end: max(track1, track2) } + } + } + (GP::Line(track), GP::Span(span)) => Line { start: track, end: track + span as i16 }, + (GP::Line(track), GP::Auto | GP::Line(0)) => Line { start: track, end: track + 1_i16 }, + (GP::Span(span), GP::Line(track)) => Line { start: track - span as i16, end: track }, + (GP::Auto | GP::Line(0), GP::Line(track)) => Line { start: track - 1_i16, end: track }, + _ => panic!("resolve_definite_grid_tracks should only be called on definite grid tracks"), + } + } + + /// For absolutely positioned items: + /// - Tracks resolve to definite tracks + /// - For Spans: + /// - If the other position is a Track, they resolve to a definite track relative to the other track + /// - Else resolve to None + /// - Auto resolves to None + /// + /// When finally positioning the item, a value of None means that the item's grid area is bounded by the grid + /// container's border box on that side. + pub fn resolve_absolutely_positioned_grid_tracks(&self) -> Line> { + use GridPlacement as GP; + match (self.start, self.end) { + (GP::Line(track1), GP::Line(track2)) if track1 != 0 && track2 != 0 => { + if track1 == track2 { + Line { start: Some(track1), end: Some(track1 + 1) } + } else { + Line { start: Some(min(track1, track2)), end: Some(max(track1, track2)) } + } + } + (GP::Line(track), GP::Span(span)) => Line { start: Some(track), end: Some(track + span as i16) }, + (GP::Line(track), GP::Auto | GP::Line(0)) => Line { start: Some(track), end: None }, + (GP::Span(span), GP::Line(track)) => Line { start: Some(track - span as i16), end: Some(track) }, + (GP::Auto | GP::Line(0), GP::Line(track)) => Line { start: None, end: Some(track) }, + _ => Line { start: None, end: None }, + } + } + + /// If neither of the start and end positions is a track index then the other end can be resolved + /// into a track index if a definite start position is supplied externally + pub fn resolve_indefinite_grid_tracks(&self, start: i16) -> Line { + use GridPlacement as GP; + match (self.start, self.end) { + (GP::Auto, GP::Auto) => Line { start, end: start + 1 }, + (GP::Span(span), GP::Auto) => Line { start, end: start + span as i16 }, + (GP::Auto, GP::Span(span)) => Line { start, end: start + span as i16 }, + (GP::Span(span), GP::Span(_)) => Line { start, end: start + span as i16 }, + _ => panic!("resolve_indefinite_grid_tracks should only be called on indefinite grid tracks"), + } + } + + /// Resolves the span for an indefinite placement (a placement that does not consist of two `Track`s). + /// Panics if called on a definite placement + pub fn indefinite_span(&self) -> u16 { + use GridPlacement as GP; + match (self.start, self.end) { + (GP::Line(_), GP::Auto) => 1, + (GP::Auto, GP::Line(_)) => 1, + (GP::Auto, GP::Auto) => 1, + (GP::Line(_), GP::Span(span)) => span, + (GP::Span(span), GP::Line(_)) => span, + (GP::Span(span), GP::Auto) => span, + (GP::Auto, GP::Span(span)) => span, + (GP::Span(span), GP::Span(_)) => span, + (GP::Line(_), GP::Line(_)) => panic!("indefinite_span should only be called on indefinite grid tracks"), + } + } +} + +/// Represents the start and end points of a GridItem within a given axis +impl Default for Line { + fn default() -> Self { + Line { start: GridPlacement::Auto, end: GridPlacement::Auto } + } +} + +/// Maximum track sizing function +/// +/// Specifies the maximum size of a grid track. A grid track will automatically size between it's minimum and maximum size based +/// on the size of it's contents, the amount of available space, and the sizing constraint the grid is being size under. +/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns +#[derive(Copy, Clone, PartialEq, Debug)] +pub enum MaxTrackSizingFunction { + /// Track maximum size should be a fixed points or percentage value + Fixed(LengthPercentage), + /// Track maximum size should be content sized under a min-content constraint + MinContent, + /// Track maximum size should be content sized under a max-content constraint + MaxContent, + /// Track maximum size should be sized according to the fit-content formula + FitContent(LengthPercentage), + /// Track maximum size should be automatically sized + Auto, + /// The dimension as a fraction of the total available grid space. + /// Specified value is the numerator of the fraction. Denominator is the sum of all fraction specified in that grid dimension + /// Spec: https://www.w3.org/TR/css3-grid-layout/#fr-unit + Flex(f32), +} +impl TaffyAuto for MaxTrackSizingFunction { + const AUTO: Self = Self::Auto; +} +impl TaffyMinContent for MaxTrackSizingFunction { + const MIN_CONTENT: Self = Self::MinContent; +} +impl TaffyMaxContent for MaxTrackSizingFunction { + const MAX_CONTENT: Self = Self::MaxContent; +} +impl TaffyFitContent for MaxTrackSizingFunction { + fn fit_content(argument: LengthPercentage) -> Self { + Self::FitContent(argument) + } +} +impl TaffyZero for MaxTrackSizingFunction { + const ZERO: Self = Self::Fixed(LengthPercentage::ZERO); +} +impl FromPoints for MaxTrackSizingFunction { + fn from_points + Copy>(points: Input) -> Self { + Self::Fixed(LengthPercentage::from_points(points)) + } +} +impl FromPercent for MaxTrackSizingFunction { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Fixed(LengthPercentage::from_percent(percent)) + } +} +impl FromFlex for MaxTrackSizingFunction { + fn from_flex + Copy>(flex: Input) -> Self { + Self::Flex(flex.into()) + } +} + +impl MaxTrackSizingFunction { + /// Returns true if the max track sizing function is `MinContent`, `MaxContent` or `Auto`, else false. + #[inline(always)] + pub fn is_intrinsic(&self) -> bool { + matches!(self, Self::MinContent | Self::MaxContent | Self::FitContent(_) | Self::Auto) + } + + /// Returns true if the max track sizing function is `MaxContent`, `FitContent` or `Auto` else false. + /// "In all cases, treat auto and fit-content() as max-content, except where specified otherwise for fit-content()." + /// See: https://www.w3.org/TR/css-grid-1/#algo-terms + #[inline(always)] + pub fn is_max_content_alike(&self) -> bool { + matches!(self, Self::MaxContent | Self::FitContent(_) | Self::Auto) + } + + /// Returns true if the max track sizing function is `Flex`, else false. + #[inline(always)] + pub fn is_flexible(&self) -> bool { + matches!(self, Self::Flex(_)) + } + + /// Returns fixed point values directly. Attempts to resolve percentage values against + /// the passed available_space and returns if this results in a concrete value (which it + /// will if the available_space is `Some`). Otherwise returns None. + #[inline(always)] + pub fn definite_value(self, available_space: AvailableSpace) -> Option { + use MaxTrackSizingFunction::{Auto, *}; + match self { + Fixed(LengthPercentage::Points(size)) => Some(size), + Fixed(LengthPercentage::Percent(fraction)) => match available_space { + AvailableSpace::Definite(available_size) => Some(fraction * available_size), + _ => None, + }, + MinContent | MaxContent | FitContent(_) | Auto | Flex(_) => None, + } + } +} + +/// Minimum track sizing function +/// +/// Specifies the minimum size of a grid track. A grid track will automatically size between it's minimum and maximum size based +/// on the size of it's contents, the amount of available space, and the sizing constraint the grid is being size under. +/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns +#[derive(Copy, Clone, PartialEq, Debug)] +pub enum MinTrackSizingFunction { + /// Track minimum size should be a fixed points or percentage value + Fixed(LengthPercentage), + /// Track minimum size should be content sized under a min-content constraint + MinContent, + /// Track minimum size should be content sized under a max-content constraint + MaxContent, + /// Track minimum size should be automatically sized + Auto, +} +impl TaffyAuto for MinTrackSizingFunction { + const AUTO: Self = Self::Auto; +} +impl TaffyMinContent for MinTrackSizingFunction { + const MIN_CONTENT: Self = Self::MinContent; +} +impl TaffyMaxContent for MinTrackSizingFunction { + const MAX_CONTENT: Self = Self::MaxContent; +} +impl TaffyZero for MinTrackSizingFunction { + const ZERO: Self = Self::Fixed(LengthPercentage::ZERO); +} +impl FromPoints for MinTrackSizingFunction { + fn from_points + Copy>(points: Input) -> Self { + Self::Fixed(LengthPercentage::from_points(points)) + } +} +impl FromPercent for MinTrackSizingFunction { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Fixed(LengthPercentage::from_percent(percent)) + } +} + +impl MinTrackSizingFunction { + /// Returns fixed point values directly. Attempts to resolve percentage values against + /// the passed available_space and returns if this results in a concrete value (which it + /// will if the available_space is `Some`). Otherwise returns `None`. + #[inline(always)] + pub fn definite_value(self, available_space: AvailableSpace) -> Option { + use MinTrackSizingFunction::{Auto, *}; + match self { + Fixed(LengthPercentage::Points(size)) => Some(size), + Fixed(LengthPercentage::Percent(fraction)) => match available_space { + AvailableSpace::Definite(available_size) => Some(fraction * available_size), + _ => None, + }, + MinContent | MaxContent | Auto => None, + } + } +} + +/// The sizing function for a grid track (row/column) (either auto-track or template track) +/// May either be a MinMax variant which specifies separate values for the min-/max- track sizing functions +/// or a scalar value which applies to both track sizing functions. +pub type NonRepeatedTrackSizingFunction = MinMax; +impl NonRepeatedTrackSizingFunction { + /// Extract the min track sizing function + pub fn min_sizing_function(&self) -> MinTrackSizingFunction { + self.min + } + /// Extract the max track sizing function + pub fn max_sizing_function(&self) -> MaxTrackSizingFunction { + self.max + } + /// Determine whether at least one of the components ("min" and "max") are fixed sizing function + pub fn has_fixed_component(&self) -> bool { + matches!(self.min, MinTrackSizingFunction::Fixed(_)) || matches!(self.max, MaxTrackSizingFunction::Fixed(_)) + } +} +impl TaffyAuto for NonRepeatedTrackSizingFunction { + const AUTO: Self = Self { min: MinTrackSizingFunction::AUTO, max: MaxTrackSizingFunction::AUTO }; +} +impl TaffyMinContent for NonRepeatedTrackSizingFunction { + const MIN_CONTENT: Self = + Self { min: MinTrackSizingFunction::MIN_CONTENT, max: MaxTrackSizingFunction::MIN_CONTENT }; +} +impl TaffyMaxContent for NonRepeatedTrackSizingFunction { + const MAX_CONTENT: Self = + Self { min: MinTrackSizingFunction::MAX_CONTENT, max: MaxTrackSizingFunction::MAX_CONTENT }; +} +impl TaffyFitContent for NonRepeatedTrackSizingFunction { + fn fit_content(argument: LengthPercentage) -> Self { + Self { min: MinTrackSizingFunction::AUTO, max: MaxTrackSizingFunction::FitContent(argument) } + } +} +impl TaffyZero for NonRepeatedTrackSizingFunction { + const ZERO: Self = Self { min: MinTrackSizingFunction::ZERO, max: MaxTrackSizingFunction::ZERO }; +} +impl FromPoints for NonRepeatedTrackSizingFunction { + fn from_points + Copy>(points: Input) -> Self { + Self { min: MinTrackSizingFunction::from_points(points), max: MaxTrackSizingFunction::from_points(points) } + } +} +impl FromPercent for NonRepeatedTrackSizingFunction { + fn from_percent + Copy>(percent: Input) -> Self { + Self { min: MinTrackSizingFunction::from_percent(percent), max: MaxTrackSizingFunction::from_percent(percent) } + } +} +impl FromFlex for NonRepeatedTrackSizingFunction { + fn from_flex + Copy>(flex: Input) -> Self { + Self { min: MinTrackSizingFunction::AUTO, max: MaxTrackSizingFunction::from_flex(flex) } + } +} + +/// The first argument to a repeated track definition. This type represents the type of automatic repetition to perform. +/// +/// See https://www.w3.org/TR/css-grid-1/#auto-repeat for an explanation of how auto-repeated track definitions work +/// and the difference between AutoFit and AutoFill. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum GridTrackRepetition { + /// Auto-repeating track should be generated to fit the container + /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fill + AutoFill, + /// Auto-repeating track should be generated to fit the container + /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fit + AutoFit, +} + +/// The sizing function for a grid track (row/column) +/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns +#[derive(Clone, PartialEq, Debug)] +pub enum TrackSizingFunction { + /// A single non-repeated track + Single(NonRepeatedTrackSizingFunction), + /// Automatically generate grid tracks to fit the available space using the specified definite track lengths + /// Only valid if every track in template (not just the repitition) has a fixed size. + AutoRepeat(GridTrackRepetition, GridTrackVec), +} +impl TrackSizingFunction { + /// Whether the track definition is a auto-repeated fragment + pub fn is_auto_repetition(&self) -> bool { + matches!(self, Self::AutoRepeat(_, _)) + } +} +impl TaffyAuto for TrackSizingFunction { + const AUTO: Self = Self::Single(NonRepeatedTrackSizingFunction::AUTO); +} +impl TaffyMinContent for TrackSizingFunction { + const MIN_CONTENT: Self = Self::Single(NonRepeatedTrackSizingFunction::MIN_CONTENT); +} +impl TaffyMaxContent for TrackSizingFunction { + const MAX_CONTENT: Self = Self::Single(NonRepeatedTrackSizingFunction::MAX_CONTENT); +} +impl TaffyFitContent for TrackSizingFunction { + fn fit_content(argument: LengthPercentage) -> Self { + Self::Single(NonRepeatedTrackSizingFunction::fit_content(argument)) + } +} +impl TaffyZero for TrackSizingFunction { + const ZERO: Self = Self::Single(NonRepeatedTrackSizingFunction::ZERO); +} +impl FromPoints for TrackSizingFunction { + fn from_points + Copy>(points: Input) -> Self { + Self::Single(NonRepeatedTrackSizingFunction::from_points(points)) + } +} +impl FromPercent for TrackSizingFunction { + fn from_percent + Copy>(percent: Input) -> Self { + Self::Single(NonRepeatedTrackSizingFunction::from_percent(percent)) + } +} +impl FromFlex for TrackSizingFunction { + fn from_flex + Copy>(flex: Input) -> Self { + Self::Single(NonRepeatedTrackSizingFunction::from_flex(flex)) + } +} +impl From> for TrackSizingFunction { + fn from(input: MinMax) -> Self { + Self::Single(input) + } +} + +// Grid extensions to the Style struct +impl Style { + /// Get a grid item's row or column placement depending on the axis passed + pub(crate) fn grid_template_tracks(&self, axis: AbsoluteAxis) -> &GridTrackVec { + match axis { + AbsoluteAxis::Horizontal => &self.grid_template_columns, + AbsoluteAxis::Vertical => &self.grid_template_rows, + } + } + + /// Get a grid item's row or column placement depending on the axis passed + pub(crate) fn grid_placement(&self, axis: AbsoluteAxis) -> Line { + match axis { + AbsoluteAxis::Horizontal => self.grid_column, + AbsoluteAxis::Vertical => self.grid_row, + } + } + + /// Get a grid container's align-content or justify-content alignment depending on the axis passed + pub(crate) fn grid_align_content(&self, axis: AbstractAxis) -> AlignContent { + match axis { + AbstractAxis::Inline => self.justify_content.unwrap_or(AlignContent::Stretch), + AbstractAxis::Block => self.align_content.unwrap_or(AlignContent::Stretch), + } + } +} diff --git a/src/style/mod.rs b/src/style/mod.rs new file mode 100644 index 000000000..4bebcba9d --- /dev/null +++ b/src/style/mod.rs @@ -0,0 +1,476 @@ +//! A representation of [CSS layout properties](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) in Rust, used for flexbox layout +mod alignment; +mod dimension; +mod flex; + +pub use self::alignment::{AlignContent, AlignItems, AlignSelf, JustifyContent, JustifyItems, JustifySelf}; +pub use self::dimension::{AvailableSpace, Dimension, LengthPercentage, LengthPercentageAuto}; +pub use self::flex::{FlexDirection, FlexWrap}; + +#[cfg(feature = "experimental_grid")] +mod grid; +#[cfg(feature = "experimental_grid")] +pub use self::grid::{ + GridAutoFlow, GridPlacement, GridTrackRepetition, MaxTrackSizingFunction, MinTrackSizingFunction, + NonRepeatedTrackSizingFunction, TrackSizingFunction, +}; +use crate::geometry::{Rect, Size}; + +#[cfg(feature = "experimental_grid")] +use crate::geometry::Line; +#[cfg(feature = "experimental_grid")] +use crate::sys::GridTrackVec; + +/// Sets the layout used for the children of this node +/// +/// [`Display::Flex`] is the default value. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum Display { + /// The children will follow the flexbox layout algorithm + Flex, + /// The children will follow the CSS Grid layout algorithm + #[cfg(feature = "experimental_grid")] + Grid, + /// The children will not be laid out, and will follow absolute positioning + None, +} + +impl Default for Display { + fn default() -> Self { + Self::Flex + } +} + +/// The positioning strategy for this item. +/// +/// This controls both how the origin is determined for the [`Style::position`] field, +/// and whether or not the item will be controlled by flexbox's layout algorithm. +/// +/// WARNING: this enum follows the behavior of [CSS's `position` property](https://developer.mozilla.org/en-US/docs/Web/CSS/position), +/// which can be unintuitive. +/// +/// [`PositionType::Relative`] is the default value, in contrast to the default behavior in CSS. +#[derive(Copy, Clone, PartialEq, Eq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +pub enum PositionType { + /// The offset is computed relative to the final position given by the layout algorithm. + /// Offsets do not affect the position of any other items; they are effectively a correction factor applied at the end. + Relative, + /// The offset is computed relative to this item's closest positioned ancestor, if any. + /// Otherwise, it is placed relative to the origin. + /// No space is created for the item in the page layout, and its size will not be altered. + /// + /// WARNING: to opt-out of layouting entirely, you must use [`Display::None`] instead on your [`Style`] object. + Absolute, +} + +impl Default for PositionType { + fn default() -> Self { + Self::Relative + } +} + +/// The flexbox layout information for a single [`Node`](crate::node::Node). +/// +/// The most important idea in flexbox is the notion of a "main" and "cross" axis, which are always perpendicular to each other. +/// The orientation of these axes are controlled via the [`FlexDirection`] field of this struct. +/// +/// This struct follows the [CSS equivalent](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Flexible_Box_Layout/Basic_Concepts_of_Flexbox) directly; +/// information about the behavior on the web should transfer directly. +/// +/// Detailed information about the exact behavior of each of these fields +/// can be found on [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS) by searching for the field name. +/// The distinction between margin, padding and border is explained well in +/// this [introduction to the box model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model). +/// +/// If the behavior does not match the flexbox layout algorithm on the web, please file a bug! +#[derive(Clone, PartialEq, Debug)] +#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] +#[cfg_attr(feature = "serde", serde(default))] +pub struct Style { + /// What layout strategy should be used? + pub display: Display, + + // Position properties + /// What should the `position` value of this struct use as a base offset? + pub position_type: PositionType, + /// How should the position of this element be tweaked relative to the layout defined? + pub position: Rect, + + // Size properies + /// Sets the initial size of the item + pub size: Size, + /// Controls the minimum size of the item + pub min_size: Size, + /// Controls the maximum size of the item + pub max_size: Size, + /// Sets the preferred aspect ratio for the item + /// + /// The ratio is calculated as width divided by height. + pub aspect_ratio: Option, + + // Spacing Properties + /// How large should the margin be on each side? + pub margin: Rect, + /// How large should the padding be on each side? + pub padding: Rect, + /// How large should the border be on each side? + pub border: Rect, + + // Alignment properties + /// How this node's children aligned in the cross/block axis? + pub align_items: Option, + /// How this node should be aligned in the cross/block axis + /// Falls back to the parents [`AlignItems`] if not set + pub align_self: Option, + /// How this node's children should be aligned in the inline axis + #[cfg(feature = "experimental_grid")] + pub justify_items: Option, + /// How this node should be aligned in the inline axis + /// Falls back to the parents [`JustifyItems`] if not set + pub justify_self: Option, + /// How should content contained within this item be aligned in the cross/block axis + pub align_content: Option, + /// How should contained within this item be aligned in the main/inline axis + pub justify_content: Option, + /// How large should the gaps between items in a grid or flex container be? + pub gap: Size, + + // Flexbox properies + /// Which direction does the main axis flow in? + pub flex_direction: FlexDirection, + /// Should elements wrap, or stay in a single line? + pub flex_wrap: FlexWrap, + /// Sets the initial main axis size of the item + pub flex_basis: Dimension, + /// The relative rate at which this item grows when it is expanding to fill space + /// + /// 0.0 is the default value, and this value must be positive. + pub flex_grow: f32, + /// The relative rate at which this item shrinks when it is contracting to fit into space + /// + /// 1.0 is the default value, and this value must be positive. + pub flex_shrink: f32, + + // Grid container properies + /// Defines the track sizing functions (widths) of the grid rows + #[cfg(feature = "experimental_grid")] + pub grid_template_rows: GridTrackVec, + /// Defines the track sizing functions (heights) of the grid columns + #[cfg(feature = "experimental_grid")] + pub grid_template_columns: GridTrackVec, + /// Defines the size of implicitly created rows + #[cfg(feature = "experimental_grid")] + pub grid_auto_rows: GridTrackVec, + /// Defined the size of implicitly created columns + #[cfg(feature = "experimental_grid")] + pub grid_auto_columns: GridTrackVec, + /// Controls how items get placed into the grid for auto-placed items + #[cfg(feature = "experimental_grid")] + pub grid_auto_flow: GridAutoFlow, + + // Grid child properties + /// Defines which row in the grid the item should start and end at + #[cfg(feature = "experimental_grid")] + pub grid_row: Line, + /// Defines which column in the grid the item should start and end at + #[cfg(feature = "experimental_grid")] + pub grid_column: Line, +} + +impl Style { + /// The [`Default`] layout, in a form that can be used in const functions + pub const DEFAULT: Style = Style { + display: Display::Flex, + position_type: PositionType::Relative, + flex_direction: FlexDirection::Row, + flex_wrap: FlexWrap::NoWrap, + align_items: None, + align_self: None, + #[cfg(feature = "experimental_grid")] + justify_items: None, + justify_self: None, + align_content: None, + justify_content: None, + position: Rect::auto(), + margin: Rect::zero(), + padding: Rect::zero(), + border: Rect::zero(), + gap: Size::zero(), + flex_grow: 0.0, + flex_shrink: 1.0, + flex_basis: Dimension::Auto, + size: Size::auto(), + min_size: Size::auto(), + max_size: Size::auto(), + aspect_ratio: None, + #[cfg(feature = "experimental_grid")] + grid_template_rows: GridTrackVec::new(), + #[cfg(feature = "experimental_grid")] + grid_template_columns: GridTrackVec::new(), + #[cfg(feature = "experimental_grid")] + grid_auto_rows: GridTrackVec::new(), + #[cfg(feature = "experimental_grid")] + grid_auto_columns: GridTrackVec::new(), + #[cfg(feature = "experimental_grid")] + grid_auto_flow: GridAutoFlow::Row, + #[cfg(feature = "experimental_grid")] + grid_row: Line { start: GridPlacement::Auto, end: GridPlacement::Auto }, + #[cfg(feature = "experimental_grid")] + grid_column: Line { start: GridPlacement::Auto, end: GridPlacement::Auto }, + }; +} + +impl Default for Style { + fn default() -> Self { + Style::DEFAULT + } +} + +impl Style { + /// If the `direction` is row-oriented, the min width. Otherwise the min height + pub(crate) fn min_main_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.min_size.width + } else { + self.min_size.height + } + } + + /// If the `direction` is row-oriented, the max width. Otherwise the max height + pub(crate) fn max_main_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.max_size.width + } else { + self.max_size.height + } + } + + /// If the `direction` is row-oriented, the margin start. Otherwise the margin top + pub(crate) fn main_margin_start(&self, direction: FlexDirection) -> LengthPercentageAuto { + if direction.is_row() { + self.margin.left + } else { + self.margin.top + } + } + + /// If the `direction` is row-oriented, the margin end. Otherwise the margin bottom + pub(crate) fn main_margin_end(&self, direction: FlexDirection) -> LengthPercentageAuto { + if direction.is_row() { + self.margin.right + } else { + self.margin.bottom + } + } + + /// If the `direction` is row-oriented, the height. Otherwise the width + pub(crate) fn cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.size.height + } else { + self.size.width + } + } + + /// If the `direction` is row-oriented, the min height. Otherwise the min width + pub(crate) fn min_cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.min_size.height + } else { + self.min_size.width + } + } + + /// If the `direction` is row-oriented, the max height. Otherwise the max width + pub(crate) fn max_cross_size(&self, direction: FlexDirection) -> Dimension { + if direction.is_row() { + self.max_size.height + } else { + self.max_size.width + } + } + + /// If the `direction` is row-oriented, the margin top. Otherwise the margin start + pub(crate) fn cross_margin_start(&self, direction: FlexDirection) -> LengthPercentageAuto { + if direction.is_row() { + self.margin.top + } else { + self.margin.left + } + } + + /// If the `direction` is row-oriented, the margin bottom. Otherwise the margin end + pub(crate) fn cross_margin_end(&self, direction: FlexDirection) -> LengthPercentageAuto { + if direction.is_row() { + self.margin.bottom + } else { + self.margin.right + } + } +} + +#[allow(clippy::bool_assert_comparison)] +#[cfg(test)] +mod tests { + use super::Style; + use crate::geometry::*; + + #[test] + fn defaults_match() { + #[cfg(feature = "experimental_grid")] + use super::GridPlacement; + + let old_defaults = Style { + display: Default::default(), + position_type: Default::default(), + flex_direction: Default::default(), + flex_wrap: Default::default(), + align_items: Default::default(), + align_self: Default::default(), + #[cfg(feature = "experimental_grid")] + justify_items: Default::default(), + justify_self: Default::default(), + align_content: Default::default(), + justify_content: Default::default(), + position: Rect::auto(), + margin: Rect::zero(), + padding: Rect::zero(), + border: Rect::zero(), + gap: Size::zero(), + flex_grow: 0.0, + flex_shrink: 1.0, + flex_basis: super::Dimension::Auto, + size: Size::auto(), + min_size: Size::auto(), + max_size: Size::auto(), + aspect_ratio: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_template_rows: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_template_columns: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_auto_rows: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_auto_columns: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_auto_flow: Default::default(), + #[cfg(feature = "experimental_grid")] + grid_row: Line { start: GridPlacement::Auto, end: GridPlacement::Auto }, + #[cfg(feature = "experimental_grid")] + grid_column: Line { start: GridPlacement::Auto, end: GridPlacement::Auto }, + }; + + assert_eq!(Style::DEFAULT, Style::default()); + assert_eq!(Style::DEFAULT, old_defaults); + } + + mod test_flex_direction { + use crate::style::*; + + #[test] + fn flex_direction_is_row() { + assert_eq!(FlexDirection::Row.is_row(), true); + assert_eq!(FlexDirection::RowReverse.is_row(), true); + assert_eq!(FlexDirection::Column.is_row(), false); + assert_eq!(FlexDirection::ColumnReverse.is_row(), false); + } + + #[test] + fn flex_direction_is_column() { + assert_eq!(FlexDirection::Row.is_column(), false); + assert_eq!(FlexDirection::RowReverse.is_column(), false); + assert_eq!(FlexDirection::Column.is_column(), true); + assert_eq!(FlexDirection::ColumnReverse.is_column(), true); + } + + #[test] + fn flex_direction_is_reverse() { + assert_eq!(FlexDirection::Row.is_reverse(), false); + assert_eq!(FlexDirection::RowReverse.is_reverse(), true); + assert_eq!(FlexDirection::Column.is_reverse(), false); + assert_eq!(FlexDirection::ColumnReverse.is_reverse(), true); + } + } + + mod test_flexbox_layout { + use crate::style::*; + use crate::style_helpers::*; + + #[test] + fn flexbox_layout_min_main_size() { + let layout = Style { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.min_main_size(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.min_main_size(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_max_main_size() { + let layout = Style { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.max_main_size(FlexDirection::Row), Dimension::Points(1.0)); + assert_eq!(layout.max_main_size(FlexDirection::Column), Dimension::Points(2.0)); + } + + #[test] + fn flexbox_layout_main_margin_start() { + let layout = Style { + margin: Rect { top: points(1.0), bottom: auto(), left: points(2.0), right: auto() }, + ..Default::default() + }; + assert_eq!(layout.main_margin_start(FlexDirection::Row), points(2.0)); + assert_eq!(layout.main_margin_start(FlexDirection::Column), points(1.0)); + } + + #[test] + fn flexbox_layout_main_margin_end() { + let layout = Style { + margin: Rect { top: auto(), bottom: points(1.0), left: auto(), right: points(2.0) }, + ..Default::default() + }; + assert_eq!(layout.main_margin_end(FlexDirection::Row), points(2.0)); + assert_eq!(layout.main_margin_end(FlexDirection::Column), points(1.0)); + } + + #[test] + fn flexbox_layout_cross_size() { + let layout = Style { size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_min_cross_size() { + let layout = Style { min_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.min_cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.min_cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_max_cross_size() { + let layout = Style { max_size: Size::from_points(1.0, 2.0), ..Default::default() }; + assert_eq!(layout.max_cross_size(FlexDirection::Row), Dimension::Points(2.0)); + assert_eq!(layout.max_cross_size(FlexDirection::Column), Dimension::Points(1.0)); + } + + #[test] + fn flexbox_layout_cross_margin_start() { + let layout = Style { + margin: Rect { top: points(1.0), bottom: auto(), left: points(2.0), right: auto() }, + ..Default::default() + }; + assert_eq!(layout.cross_margin_start(FlexDirection::Row), points(1.0)); + assert_eq!(layout.cross_margin_start(FlexDirection::Column), points(2.0)); + } + + #[test] + fn flexbox_layout_cross_margin_end() { + let layout = Style { + margin: Rect { top: auto(), bottom: points(1.0), left: auto(), right: points(2.0) }, + ..Default::default() + }; + assert_eq!(layout.cross_margin_end(FlexDirection::Row), points(1.0)); + assert_eq!(layout.cross_margin_end(FlexDirection::Column), points(2.0)); + } + } +} diff --git a/src/style_helpers.rs b/src/style_helpers.rs index 51ca4347d..7f3c04932 100644 --- a/src/style_helpers.rs +++ b/src/style_helpers.rs @@ -1,7 +1,45 @@ //! Helper functions which it make it easier to create instances of types in the `style` and `geometry` modules. +use crate::{ + geometry::{MinMax, Point, Rect, Size}, + style::LengthPercentage, +}; -use crate::geometry::{Point, Rect, Size}; -use crate::style::{Dimension, LengthPercentage, LengthPercentageAuto}; +#[cfg(feature = "experimental_grid")] +use crate::style::{GridTrackRepetition, NonRepeatedTrackSizingFunction, TrackSizingFunction}; + +/// Returns an auto-repeated track definition +#[cfg(feature = "experimental_grid")] +pub fn repeat( + repetition_kind: GridTrackRepetition, + track_list: Vec, +) -> TrackSizingFunction { + TrackSizingFunction::AutoRepeat(repetition_kind, track_list) +} + +/// Returns a GridPlacement::Line +pub fn line(index: i16) -> T { + T::from_line_index(index) +} +/// Trait to abstract over grid line values +pub trait TaffyGridLine { + /// Converts an i16 into Self + fn from_line_index(index: i16) -> Self; +} + +/// Returns a GridPlacement::Span +pub fn span(span: u16) -> T { + T::from_span(span) +} +/// Trait to abstract over grid span values +pub trait TaffyGridSpan { + /// Converts an iu6 into Self + fn from_span(span: u16) -> Self; +} + +/// Returns a MinMax with min value of min and max value of max +pub fn minmax>>(min: Min, max: Max) -> Output { + MinMax { min, max }.into() +} /// Returns the zero value for that type pub const fn zero() -> T { @@ -16,15 +54,6 @@ pub trait TaffyZero { impl TaffyZero for f32 { const ZERO: f32 = 0.0; } -impl TaffyZero for LengthPercentage { - const ZERO: LengthPercentage = LengthPercentage::Points(0.0); -} -impl TaffyZero for LengthPercentageAuto { - const ZERO: LengthPercentageAuto = LengthPercentageAuto::Points(0.0); -} -impl TaffyZero for Dimension { - const ZERO: Dimension = Dimension::Points(0.0); -} impl TaffyZero for Option { const ZERO: Option = Some(T::ZERO); } @@ -69,12 +98,6 @@ pub trait TaffyAuto { /// The auto value for type implementing TaffyZero const AUTO: Self; } -impl TaffyAuto for LengthPercentageAuto { - const AUTO: LengthPercentageAuto = LengthPercentageAuto::Auto; -} -impl TaffyAuto for Dimension { - const AUTO: Dimension = Dimension::Auto; -} impl TaffyAuto for Option { const AUTO: Option = Some(T::AUTO); } @@ -109,6 +132,148 @@ impl Rect { } } +/// Returns the auto value for that type +pub const fn min_content() -> T { + T::MIN_CONTENT +} + +/// Trait to abstract over min_content values +pub trait TaffyMinContent { + /// The min_content value for type implementing TaffyZero + const MIN_CONTENT: Self; +} +impl TaffyMinContent for Option { + const MIN_CONTENT: Option = Some(T::MIN_CONTENT); +} +impl TaffyMinContent for Point { + const MIN_CONTENT: Point = Point { x: T::MIN_CONTENT, y: T::MIN_CONTENT }; +} +impl Point { + /// Returns a Point where both the x and y values are the min_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn min_content() -> Self { + min_content::() + } +} +impl TaffyMinContent for Size { + const MIN_CONTENT: Size = Size { width: T::MIN_CONTENT, height: T::MIN_CONTENT }; +} +impl Size { + /// Returns a Size where both the width and height values are the min_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn min_content() -> Self { + min_content::() + } +} +impl TaffyMinContent for Rect { + const MIN_CONTENT: Rect = + Rect { left: T::MIN_CONTENT, right: T::MIN_CONTENT, top: T::MIN_CONTENT, bottom: T::MIN_CONTENT }; +} +impl Rect { + /// Returns a Size where the left, right, top, and bottom values are all the min_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn min_content() -> Self { + min_content::() + } +} + +/// Returns the auto value for that type +pub const fn max_content() -> T { + T::MAX_CONTENT +} + +/// Trait to abstract over max_content values +pub trait TaffyMaxContent { + /// The max_content value for type implementing TaffyZero + const MAX_CONTENT: Self; +} +impl TaffyMaxContent for Option { + const MAX_CONTENT: Option = Some(T::MAX_CONTENT); +} +impl TaffyMaxContent for Point { + const MAX_CONTENT: Point = Point { x: T::MAX_CONTENT, y: T::MAX_CONTENT }; +} +impl Point { + /// Returns a Point where both the x and y values are the max_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn max_content() -> Self { + max_content::() + } +} +impl TaffyMaxContent for Size { + const MAX_CONTENT: Size = Size { width: T::MAX_CONTENT, height: T::MAX_CONTENT }; +} +impl Size { + /// Returns a Size where both the width and height values are the max_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn max_content() -> Self { + max_content::() + } +} +impl TaffyMaxContent for Rect { + const MAX_CONTENT: Rect = + Rect { left: T::MAX_CONTENT, right: T::MAX_CONTENT, top: T::MAX_CONTENT, bottom: T::MAX_CONTENT }; +} +impl Rect { + /// Returns a Size where the left, right, top, and bottom values are all the max_content value of the contained type + /// (e.g. Dimension::Auto or LengthPercentageAuto::Auto) + pub const fn max_content() -> Self { + max_content::() + } +} + +/// Returns a value of the inferred type which represent a constant of points +pub fn fit_content(argument: LengthPercentage) -> T { + T::fit_content(argument) +} + +/// Trait to create constant points values from plain numbers +pub trait TaffyFitContent { + /// Converts into a LengthPercentage into Self + fn fit_content(argument: LengthPercentage) -> Self; +} +impl TaffyFitContent for Point { + fn fit_content(argument: LengthPercentage) -> Self { + Point { x: T::fit_content(argument), y: T::fit_content(argument) } + } +} +impl Point { + /// Returns a Point where both the x and y values are the constant points value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn fit_content(argument: LengthPercentage) -> Self { + fit_content(argument) + } +} +impl TaffyFitContent for Size { + fn fit_content(argument: LengthPercentage) -> Self { + Size { width: T::fit_content(argument), height: T::fit_content(argument) } + } +} +impl Size { + /// Returns a Size where both the width and height values are the constant fit_content value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn fit_content(argument: LengthPercentage) -> Self { + fit_content(argument) + } +} +impl TaffyFitContent for Rect { + fn fit_content(argument: LengthPercentage) -> Self { + Rect { + left: T::fit_content(argument), + right: T::fit_content(argument), + top: T::fit_content(argument), + bottom: T::fit_content(argument), + } + } +} +impl Rect { + /// Returns a Rect where the left, right, top and bottom values are all constant fit_content value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn fit_content(argument: LengthPercentage) -> Self { + fit_content(argument) + } +} + /// Returns a value of the inferred type which represent a constant of points pub fn points + Copy, T: FromPoints>(points: Input) -> T { T::from_points(points) @@ -129,21 +294,6 @@ impl FromPoints for Option { Some(points.into()) } } -impl FromPoints for LengthPercentage { - fn from_points + Copy>(points: Input) -> Self { - LengthPercentage::Points(points.into()) - } -} -impl FromPoints for LengthPercentageAuto { - fn from_points + Copy>(points: Input) -> Self { - LengthPercentageAuto::Points(points.into()) - } -} -impl FromPoints for Dimension { - fn from_points + Copy>(points: Input) -> Self { - Dimension::Points(points.into()) - } -} impl FromPoints for Point { fn from_points + Copy>(points: Input) -> Self { Point { x: T::from_points(points.into()), y: T::from_points(points.into()) } @@ -185,3 +335,76 @@ impl Rect { points::(points_value) } } + +/// Returns a value of the inferred type which represent a constant of points +pub fn percent + Copy, T: FromPercent>(percent: Input) -> T { + T::from_percent(percent) +} + +/// Trait to create constant percent values from plain numbers +pub trait FromPercent { + /// Converts into an Into into Self + fn from_percent + Copy>(percent: Input) -> Self; +} +impl FromPercent for f32 { + fn from_percent + Copy>(percent: Input) -> Self { + percent.into() + } +} +impl FromPercent for Option { + fn from_percent + Copy>(percent: Input) -> Self { + Some(percent.into()) + } +} +impl FromPercent for Point { + fn from_percent + Copy>(percent: Input) -> Self { + Point { x: T::from_percent(percent.into()), y: T::from_percent(percent.into()) } + } +} +impl Point { + /// Returns a Point where both the x and y values are the constant percent value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn percent + Copy>(percent_value: Input) -> Self { + percent::(percent_value) + } +} +impl FromPercent for Size { + fn from_percent + Copy>(percent: Input) -> Self { + Size { width: T::from_percent(percent.into()), height: T::from_percent(percent.into()) } + } +} +impl Size { + /// Returns a Size where both the width and height values are the constant percent value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn percent + Copy>(percent_value: Input) -> Self { + percent::(percent_value) + } +} +impl FromPercent for Rect { + fn from_percent + Copy>(percent: Input) -> Self { + Rect { + left: T::from_percent(percent.into()), + right: T::from_percent(percent.into()), + top: T::from_percent(percent.into()), + bottom: T::from_percent(percent.into()), + } + } +} +impl Rect { + /// Returns a Rect where the left, right, top and bottom values are all constant percent value of the contained type + /// (e.g. 2.1, Some(2.1), or Dimension::Points(2.1)) + pub fn percent + Copy>(percent_value: Input) -> Self { + percent::(percent_value) + } +} + +/// Returns a value of the inferred type which represents a flex fraction +pub fn flex + Copy, T: FromFlex>(flex: Input) -> T { + T::from_flex(flex) +} + +/// Trait to create constant percent values from plain numbers +pub trait FromFlex { + /// Converts into an Into into Self + fn from_flex + Copy>(flex: Input) -> Self; +} diff --git a/src/sys.rs b/src/sys.rs index 5018e0aba..a940f3ee2 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -12,6 +12,18 @@ pub(crate) use self::alloc::*; #[cfg(all(not(feature = "alloc"), not(feature = "std")))] pub(crate) use self::core::*; +/// Returns the largest of two f32 values +#[cfg(feature = "experimental_grid")] +pub(crate) fn f32_max(a: f32, b: f32) -> f32 { + core::cmp::max_by(a, b, |a, b| a.total_cmp(b)) +} + +/// Returns the smallest of two f32 values +#[cfg(feature = "experimental_grid")] +pub(crate) fn f32_min(a: f32, b: f32) -> f32 { + core::cmp::min_by(a, b, |a, b| a.total_cmp(b)) +} + /// For when `std` is enabled #[cfg(feature = "std")] mod std { @@ -21,6 +33,9 @@ mod std { pub(crate) type Vec = std::vec::Vec; /// A vector of child nodes pub(crate) type ChildrenVec = std::vec::Vec; + /// A vector of grid tracks + #[cfg(feature = "experimental_grid")] + pub(crate) type GridTrackVec = std::vec::Vec; /// Creates a new vector with the capacity for the specified number of items before it must be resized #[must_use] @@ -52,6 +67,8 @@ mod alloc { pub(crate) type Vec = alloc::vec::Vec; /// A vector of child nodes pub(crate) type ChildrenVec = alloc::vec::Vec; + /// A vector of grid tracks + pub(crate) type GridTrackVec = alloc::vec::Vec; /// Creates a new vector with the capacity for the specified number of items before it must be resized #[must_use] @@ -79,11 +96,15 @@ mod core { pub const MAX_NODE_COUNT: usize = 256; /// The maximum number of children of any given node pub const MAX_CHILD_COUNT: usize = 16; + /// The maximum number of children of any given node + pub const MAX_GRID_TRACKS: usize = 16; /// An allocation-backend agnostic vector type pub(crate) type Vec = arrayvec::ArrayVec; /// A vector of child nodes, whose length cannot exceed [`MAX_CHILD_COUNT`] pub(crate) type ChildrenVec = arrayvec::ArrayVec; + /// A vector of grid tracks + pub(crate) type GridTrackVec = arrayvec::ArrayVec; /// Creates a new map with the capacity for the specified number of items before it must be resized /// diff --git a/src/tree.rs b/src/tree.rs index ca6248048..0a6448a47 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -4,7 +4,7 @@ use slotmap::DefaultKey; use crate::{ error::TaffyResult, - layout::{AvailableSpace, Cache, Layout}, + layout::{Cache, Layout}, prelude::*, }; diff --git a/test_fixtures/border_no_child.html b/test_fixtures/border_no_child.html index 23e481766..6e023d0eb 100644 --- a/test_fixtures/border_no_child.html +++ b/test_fixtures/border_no_child.html @@ -9,8 +9,7 @@ -
-
+
\ No newline at end of file diff --git a/test_fixtures/grid_absolute_align_self_sized_all.html b/test_fixtures/grid_absolute_align_self_sized_all.html new file mode 100644 index 000000000..bd1a388fa --- /dev/null +++ b/test_fixtures/grid_absolute_align_self_sized_all.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_column_end.html b/test_fixtures/grid_absolute_column_end.html new file mode 100644 index 000000000..ad1320d72 --- /dev/null +++ b/test_fixtures/grid_absolute_column_end.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_column_start.html b/test_fixtures/grid_absolute_column_start.html new file mode 100644 index 000000000..340b46b51 --- /dev/null +++ b/test_fixtures/grid_absolute_column_start.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_bottom_left.html b/test_fixtures/grid_absolute_container_bottom_left.html new file mode 100644 index 000000000..654e2f730 --- /dev/null +++ b/test_fixtures/grid_absolute_container_bottom_left.html @@ -0,0 +1,31 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_bottom_left_margin.html b/test_fixtures/grid_absolute_container_bottom_left_margin.html new file mode 100644 index 000000000..0763190bd --- /dev/null +++ b/test_fixtures/grid_absolute_container_bottom_left_margin.html @@ -0,0 +1,34 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_left_overrides_right.html b/test_fixtures/grid_absolute_container_left_overrides_right.html new file mode 100644 index 000000000..53b0fe66f --- /dev/null +++ b/test_fixtures/grid_absolute_container_left_overrides_right.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_left_right.html b/test_fixtures/grid_absolute_container_left_right.html new file mode 100644 index 000000000..01b194d48 --- /dev/null +++ b/test_fixtures/grid_absolute_container_left_right.html @@ -0,0 +1,31 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_left_right_margin.html b/test_fixtures/grid_absolute_container_left_right_margin.html new file mode 100644 index 000000000..9e9a6e2e5 --- /dev/null +++ b/test_fixtures/grid_absolute_container_left_right_margin.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_negative_position.html b/test_fixtures/grid_absolute_container_negative_position.html new file mode 100644 index 000000000..15fadae73 --- /dev/null +++ b/test_fixtures/grid_absolute_container_negative_position.html @@ -0,0 +1,37 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_negative_position_margin.html b/test_fixtures/grid_absolute_container_negative_position_margin.html new file mode 100644 index 000000000..87b8537ee --- /dev/null +++ b/test_fixtures/grid_absolute_container_negative_position_margin.html @@ -0,0 +1,39 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_top_bottom.html b/test_fixtures/grid_absolute_container_top_bottom.html new file mode 100644 index 000000000..4ed6e8c68 --- /dev/null +++ b/test_fixtures/grid_absolute_container_top_bottom.html @@ -0,0 +1,31 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_top_bottom_margin.html b/test_fixtures/grid_absolute_container_top_bottom_margin.html new file mode 100644 index 000000000..729787536 --- /dev/null +++ b/test_fixtures/grid_absolute_container_top_bottom_margin.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_top_right.html b/test_fixtures/grid_absolute_container_top_right.html new file mode 100644 index 000000000..275cf27ca --- /dev/null +++ b/test_fixtures/grid_absolute_container_top_right.html @@ -0,0 +1,31 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_container_top_right_margin.html b/test_fixtures/grid_absolute_container_top_right_margin.html new file mode 100644 index 000000000..ec7c2a15c --- /dev/null +++ b/test_fixtures/grid_absolute_container_top_right_margin.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_justify_self_sized_all.html b/test_fixtures/grid_absolute_justify_self_sized_all.html new file mode 100644 index 000000000..7a2e4d79b --- /dev/null +++ b/test_fixtures/grid_absolute_justify_self_sized_all.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_row_end.html b/test_fixtures/grid_absolute_row_end.html new file mode 100644 index 000000000..586521cbb --- /dev/null +++ b/test_fixtures/grid_absolute_row_end.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_row_start.html b/test_fixtures/grid_absolute_row_start.html new file mode 100644 index 000000000..73ebdcd4a --- /dev/null +++ b/test_fixtures/grid_absolute_row_start.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_top_overrides_bottom.html b/test_fixtures/grid_absolute_top_overrides_bottom.html new file mode 100644 index 000000000..0863e4279 --- /dev/null +++ b/test_fixtures/grid_absolute_top_overrides_bottom.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_with_padding.html b/test_fixtures/grid_absolute_with_padding.html new file mode 100644 index 000000000..7f52b7f2f --- /dev/null +++ b/test_fixtures/grid_absolute_with_padding.html @@ -0,0 +1,37 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_absolute_with_padding_and_margin.html b/test_fixtures/grid_absolute_with_padding_and_margin.html new file mode 100644 index 000000000..33889f41c --- /dev/null +++ b/test_fixtures/grid_absolute_with_padding_and_margin.html @@ -0,0 +1,39 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_center.html b/test_fixtures/grid_align_content_center.html new file mode 100644 index 000000000..4a11bd535 --- /dev/null +++ b/test_fixtures/grid_align_content_center.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_end.html b/test_fixtures/grid_align_content_end.html new file mode 100644 index 000000000..3bdf4de6b --- /dev/null +++ b/test_fixtures/grid_align_content_end.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_end_with_padding_border.html b/test_fixtures/grid_align_content_end_with_padding_border.html new file mode 100644 index 000000000..9e4bb981b --- /dev/null +++ b/test_fixtures/grid_align_content_end_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_around.html b/test_fixtures/grid_align_content_space_around.html new file mode 100644 index 000000000..a3b88025e --- /dev/null +++ b/test_fixtures/grid_align_content_space_around.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_around_with_padding_border.html b/test_fixtures/grid_align_content_space_around_with_padding_border.html new file mode 100644 index 000000000..2f38a719c --- /dev/null +++ b/test_fixtures/grid_align_content_space_around_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_between.html b/test_fixtures/grid_align_content_space_between.html new file mode 100644 index 000000000..3b6e5b41a --- /dev/null +++ b/test_fixtures/grid_align_content_space_between.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_between_with_padding_border.html b/test_fixtures/grid_align_content_space_between_with_padding_border.html new file mode 100644 index 000000000..9776bcb91 --- /dev/null +++ b/test_fixtures/grid_align_content_space_between_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_evenly.html b/test_fixtures/grid_align_content_space_evenly.html new file mode 100644 index 000000000..01d6373bb --- /dev/null +++ b/test_fixtures/grid_align_content_space_evenly.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_space_evenly_with_padding_border.html b/test_fixtures/grid_align_content_space_evenly_with_padding_border.html new file mode 100644 index 000000000..90c677d83 --- /dev/null +++ b/test_fixtures/grid_align_content_space_evenly_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_start.html b/test_fixtures/grid_align_content_start.html new file mode 100644 index 000000000..42313ec3b --- /dev/null +++ b/test_fixtures/grid_align_content_start.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_content_start_with_padding_border.html b/test_fixtures/grid_align_content_start_with_padding_border.html new file mode 100644 index 000000000..0f52a17b9 --- /dev/null +++ b/test_fixtures/grid_align_content_start_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_items_sized_center.html b/test_fixtures/grid_align_items_sized_center.html new file mode 100644 index 000000000..619939278 --- /dev/null +++ b/test_fixtures/grid_align_items_sized_center.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_items_sized_end.html b/test_fixtures/grid_align_items_sized_end.html new file mode 100644 index 000000000..9819c09cb --- /dev/null +++ b/test_fixtures/grid_align_items_sized_end.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_items_sized_start.html b/test_fixtures/grid_align_items_sized_start.html new file mode 100644 index 000000000..3f13b46f0 --- /dev/null +++ b/test_fixtures/grid_align_items_sized_start.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_items_sized_stretch.html b/test_fixtures/grid_align_items_sized_stretch.html new file mode 100644 index 000000000..0da558358 --- /dev/null +++ b/test_fixtures/grid_align_items_sized_stretch.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_align_self_sized_all.html b/test_fixtures/grid_align_self_sized_all.html new file mode 100644 index 000000000..adbde76f4 --- /dev/null +++ b/test_fixtures/grid_align_self_sized_all.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_columns_fixed_width.html b/test_fixtures/grid_auto_columns_fixed_width.html new file mode 100644 index 000000000..35d07ecc5 --- /dev/null +++ b/test_fixtures/grid_auto_columns_fixed_width.html @@ -0,0 +1,32 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_fill_fixed_size.html b/test_fixtures/grid_auto_fill_fixed_size.html new file mode 100644 index 000000000..f4c5e10c9 --- /dev/null +++ b/test_fixtures/grid_auto_fill_fixed_size.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_fill_with_empty_auto_track.html b/test_fixtures/grid_auto_fill_with_empty_auto_track.html new file mode 100644 index 000000000..cae738ec3 --- /dev/null +++ b/test_fixtures/grid_auto_fill_with_empty_auto_track.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_fit_with_empty_auto_track.html b/test_fixtures/grid_auto_fit_with_empty_auto_track.html new file mode 100644 index 000000000..8cfd7aea4 --- /dev/null +++ b/test_fixtures/grid_auto_fit_with_empty_auto_track.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_single_item.html b/test_fixtures/grid_auto_single_item.html new file mode 100644 index 000000000..59c5095b4 --- /dev/null +++ b/test_fixtures/grid_auto_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_single_item_fixed_width.html b/test_fixtures/grid_auto_single_item_fixed_width.html new file mode 100644 index 000000000..066fa9c79 --- /dev/null +++ b/test_fixtures/grid_auto_single_item_fixed_width.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_auto_single_item_fixed_width_with_definite_width.html b/test_fixtures/grid_auto_single_item_fixed_width_with_definite_width.html new file mode 100644 index 000000000..cb876ea5c --- /dev/null +++ b/test_fixtures/grid_auto_single_item_fixed_width_with_definite_width.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_basic.html b/test_fixtures/grid_basic.html new file mode 100644 index 000000000..01ee6c893 --- /dev/null +++ b/test_fixtures/grid_basic.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_basic_implicit_tracks.html b/test_fixtures/grid_basic_implicit_tracks.html new file mode 100644 index 000000000..db97abcc2 --- /dev/null +++ b/test_fixtures/grid_basic_implicit_tracks.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_basic_with_overflow.html b/test_fixtures/grid_basic_with_overflow.html new file mode 100644 index 000000000..434b91a1b --- /dev/null +++ b/test_fixtures/grid_basic_with_overflow.html @@ -0,0 +1,26 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_basic_with_padding.html b/test_fixtures/grid_basic_with_padding.html new file mode 100644 index 000000000..bc5c97b0c --- /dev/null +++ b/test_fixtures/grid_basic_with_padding.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fit_content_points_argument.html b/test_fixtures/grid_fit_content_points_argument.html new file mode 100644 index 000000000..a739e33be --- /dev/null +++ b/test_fixtures/grid_fit_content_points_argument.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fit_content_points_max_content.html b/test_fixtures/grid_fit_content_points_max_content.html new file mode 100644 index 000000000..6698442ad --- /dev/null +++ b/test_fixtures/grid_fit_content_points_max_content.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fit_content_points_min_content.html b/test_fixtures/grid_fit_content_points_min_content.html new file mode 100644 index 000000000..455a0d639 --- /dev/null +++ b/test_fixtures/grid_fit_content_points_min_content.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HHHH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fr_auto_no_sized_items.html b/test_fixtures/grid_fr_auto_no_sized_items.html new file mode 100644 index 000000000..71fd0fd7e --- /dev/null +++ b/test_fixtures/grid_fr_auto_no_sized_items.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fr_auto_single_item.html b/test_fixtures/grid_fr_auto_single_item.html new file mode 100644 index 000000000..19199a7dc --- /dev/null +++ b/test_fixtures/grid_fr_auto_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fr_fixed_size_no_content.html b/test_fixtures/grid_fr_fixed_size_no_content.html new file mode 100644 index 000000000..62ef195d4 --- /dev/null +++ b/test_fixtures/grid_fr_fixed_size_no_content.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_fr_fixed_size_single_item.html b/test_fixtures/grid_fr_fixed_size_single_item.html new file mode 100644 index 000000000..48963fd3a --- /dev/null +++ b/test_fixtures/grid_fr_fixed_size_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_gap.html b/test_fixtures/grid_gap.html new file mode 100644 index 000000000..e4f938747 --- /dev/null +++ b/test_fixtures/grid_gap.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_hidden.html b/test_fixtures/grid_hidden.html new file mode 100644 index 000000000..7ae37eead --- /dev/null +++ b/test_fixtures/grid_hidden.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_center.html b/test_fixtures/grid_justify_content_center.html new file mode 100644 index 000000000..b3737a65c --- /dev/null +++ b/test_fixtures/grid_justify_content_center.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_center_with_padding_border.html b/test_fixtures/grid_justify_content_center_with_padding_border.html new file mode 100644 index 000000000..c7a17a0e0 --- /dev/null +++ b/test_fixtures/grid_justify_content_center_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_end.html b/test_fixtures/grid_justify_content_end.html new file mode 100644 index 000000000..6782169e0 --- /dev/null +++ b/test_fixtures/grid_justify_content_end.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_end_with_padding_border.html b/test_fixtures/grid_justify_content_end_with_padding_border.html new file mode 100644 index 000000000..1e6fd837d --- /dev/null +++ b/test_fixtures/grid_justify_content_end_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_around.html b/test_fixtures/grid_justify_content_space_around.html new file mode 100644 index 000000000..083c7b720 --- /dev/null +++ b/test_fixtures/grid_justify_content_space_around.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_around_with_padding_border.html b/test_fixtures/grid_justify_content_space_around_with_padding_border.html new file mode 100644 index 000000000..0d97dceb3 --- /dev/null +++ b/test_fixtures/grid_justify_content_space_around_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_between.html b/test_fixtures/grid_justify_content_space_between.html new file mode 100644 index 000000000..2cd3af1ff --- /dev/null +++ b/test_fixtures/grid_justify_content_space_between.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_between_with_padding_border.html b/test_fixtures/grid_justify_content_space_between_with_padding_border.html new file mode 100644 index 000000000..e0c4fae18 --- /dev/null +++ b/test_fixtures/grid_justify_content_space_between_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_evenly.html b/test_fixtures/grid_justify_content_space_evenly.html new file mode 100644 index 000000000..f3d7ec3d3 --- /dev/null +++ b/test_fixtures/grid_justify_content_space_evenly.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_space_evenly_with_padding_border.html b/test_fixtures/grid_justify_content_space_evenly_with_padding_border.html new file mode 100644 index 000000000..eb0c02bca --- /dev/null +++ b/test_fixtures/grid_justify_content_space_evenly_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_start.html b/test_fixtures/grid_justify_content_start.html new file mode 100644 index 000000000..b9d4c3ef0 --- /dev/null +++ b/test_fixtures/grid_justify_content_start.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_content_start_with_padding_border.html b/test_fixtures/grid_justify_content_start_with_padding_border.html new file mode 100644 index 000000000..e99fac3aa --- /dev/null +++ b/test_fixtures/grid_justify_content_start_with_padding_border.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_items_sized_center.html b/test_fixtures/grid_justify_items_sized_center.html new file mode 100644 index 000000000..403a09161 --- /dev/null +++ b/test_fixtures/grid_justify_items_sized_center.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_items_sized_end.html b/test_fixtures/grid_justify_items_sized_end.html new file mode 100644 index 000000000..97b01a681 --- /dev/null +++ b/test_fixtures/grid_justify_items_sized_end.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_items_sized_start.html b/test_fixtures/grid_justify_items_sized_start.html new file mode 100644 index 000000000..267be6644 --- /dev/null +++ b/test_fixtures/grid_justify_items_sized_start.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_items_sized_stretch.html b/test_fixtures/grid_justify_items_sized_stretch.html new file mode 100644 index 000000000..3a7092578 --- /dev/null +++ b/test_fixtures/grid_justify_items_sized_stretch.html @@ -0,0 +1,18 @@ + + + + + + + Test description + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_justify_self_sized_all.html b/test_fixtures/grid_justify_self_sized_all.html new file mode 100644 index 000000000..9176e2099 --- /dev/null +++ b/test_fixtures/grid_justify_self_sized_all.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_auto_margins.html b/test_fixtures/grid_margins_auto_margins.html new file mode 100644 index 000000000..2a8dd50f3 --- /dev/null +++ b/test_fixtures/grid_margins_auto_margins.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_auto_margins_override_stretch.html b/test_fixtures/grid_margins_auto_margins_override_stretch.html new file mode 100644 index 000000000..eaec4b8b3 --- /dev/null +++ b/test_fixtures/grid_margins_auto_margins_override_stretch.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
HH​HH
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_fixed_center.html b/test_fixtures/grid_margins_fixed_center.html new file mode 100644 index 000000000..8db37425d --- /dev/null +++ b/test_fixtures/grid_margins_fixed_center.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_fixed_end.html b/test_fixtures/grid_margins_fixed_end.html new file mode 100644 index 000000000..8aa68b43d --- /dev/null +++ b/test_fixtures/grid_margins_fixed_end.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_fixed_start.html b/test_fixtures/grid_margins_fixed_start.html new file mode 100644 index 000000000..beb4116f4 --- /dev/null +++ b/test_fixtures/grid_margins_fixed_start.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_fixed_stretch.html b/test_fixtures/grid_margins_fixed_stretch.html new file mode 100644 index 000000000..2ee1141b4 --- /dev/null +++ b/test_fixtures/grid_margins_fixed_stretch.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_percent_center.html b/test_fixtures/grid_margins_percent_center.html new file mode 100644 index 000000000..9c5728ad9 --- /dev/null +++ b/test_fixtures/grid_margins_percent_center.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_percent_end.html b/test_fixtures/grid_margins_percent_end.html new file mode 100644 index 000000000..a29b4220d --- /dev/null +++ b/test_fixtures/grid_margins_percent_end.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_percent_start.html b/test_fixtures/grid_margins_percent_start.html new file mode 100644 index 000000000..85b48f812 --- /dev/null +++ b/test_fixtures/grid_margins_percent_start.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_margins_percent_stretch.html b/test_fixtures/grid_margins_percent_stretch.html new file mode 100644 index 000000000..10bd7aaba --- /dev/null +++ b/test_fixtures/grid_margins_percent_stretch.html @@ -0,0 +1,22 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_max_content_maximum_single_item.html b/test_fixtures/grid_max_content_maximum_single_item.html new file mode 100644 index 000000000..97a13ac7a --- /dev/null +++ b/test_fixtures/grid_max_content_maximum_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_max_content_single_item.html b/test_fixtures/grid_max_content_single_item.html new file mode 100644 index 000000000..fafd55374 --- /dev/null +++ b/test_fixtures/grid_max_content_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_max_content_single_item_margin_auto.html b/test_fixtures/grid_max_content_single_item_margin_auto.html new file mode 100644 index 000000000..88bbe1a55 --- /dev/null +++ b/test_fixtures/grid_max_content_single_item_margin_auto.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_max_content_single_item_margin_fixed.html b/test_fixtures/grid_max_content_single_item_margin_fixed.html new file mode 100644 index 000000000..f193bf3c1 --- /dev/null +++ b/test_fixtures/grid_max_content_single_item_margin_fixed.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_max_content_single_item_margin_percent.html b/test_fixtures/grid_max_content_single_item_margin_percent.html new file mode 100644 index 000000000..e8819c1ef --- /dev/null +++ b/test_fixtures/grid_max_content_single_item_margin_percent.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_flex_single_item.html b/test_fixtures/grid_min_content_flex_single_item.html new file mode 100644 index 000000000..b7c39e869 --- /dev/null +++ b/test_fixtures/grid_min_content_flex_single_item.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
HH​HH
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_flex_single_item_margin_auto.html b/test_fixtures/grid_min_content_flex_single_item_margin_auto.html new file mode 100644 index 000000000..c3e3e1ffc --- /dev/null +++ b/test_fixtures/grid_min_content_flex_single_item_margin_auto.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
HH​HH
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_flex_single_item_margin_fixed.html b/test_fixtures/grid_min_content_flex_single_item_margin_fixed.html new file mode 100644 index 000000000..c2c9ca4b6 --- /dev/null +++ b/test_fixtures/grid_min_content_flex_single_item_margin_fixed.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
HH​HH
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_flex_single_item_margin_percent.html b/test_fixtures/grid_min_content_flex_single_item_margin_percent.html new file mode 100644 index 000000000..9df832ad1 --- /dev/null +++ b/test_fixtures/grid_min_content_flex_single_item_margin_percent.html @@ -0,0 +1,24 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
HH​HH
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_maximum_single_item.html b/test_fixtures/grid_min_content_maximum_single_item.html new file mode 100644 index 000000000..febf020f5 --- /dev/null +++ b/test_fixtures/grid_min_content_maximum_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_content_single_item.html b/test_fixtures/grid_min_content_single_item.html new file mode 100644 index 000000000..a09f5212a --- /dev/null +++ b/test_fixtures/grid_min_content_single_item.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
HH​HH
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_max_column_auto.html b/test_fixtures/grid_min_max_column_auto.html new file mode 100644 index 000000000..b57247dbc --- /dev/null +++ b/test_fixtures/grid_min_max_column_auto.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_max_column_fixed_width_above_range.html b/test_fixtures/grid_min_max_column_fixed_width_above_range.html new file mode 100644 index 000000000..264febe8f --- /dev/null +++ b/test_fixtures/grid_min_max_column_fixed_width_above_range.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_max_column_fixed_width_below_range.html b/test_fixtures/grid_min_max_column_fixed_width_below_range.html new file mode 100644 index 000000000..065ac4343 --- /dev/null +++ b/test_fixtures/grid_min_max_column_fixed_width_below_range.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_min_max_column_fixed_width_within_range.html b/test_fixtures/grid_min_max_column_fixed_width_within_range.html new file mode 100644 index 000000000..3b1e9a1eb --- /dev/null +++ b/test_fixtures/grid_min_max_column_fixed_width_within_range.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_out_of_order_items.html b/test_fixtures/grid_out_of_order_items.html new file mode 100644 index 000000000..5b18c13da --- /dev/null +++ b/test_fixtures/grid_out_of_order_items.html @@ -0,0 +1,25 @@ + + + + + + + Test description + + + + +
+
+
+
+
+
+
+
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/grid_size_child_fixed_tracks.html b/test_fixtures/grid_size_child_fixed_tracks.html new file mode 100644 index 000000000..6c7db52ba --- /dev/null +++ b/test_fixtures/grid_size_child_fixed_tracks.html @@ -0,0 +1,21 @@ + + + + + + + Test description + + + + +
+
HH​HH​HH​HH
+
HHH​HHH
+
HH​HHHH
+
HH​HH​HH​HH
+
HH​HH​HH​HH
+
+ + + \ No newline at end of file diff --git a/test_fixtures/max_height_overrides_height_on_root.html b/test_fixtures/max_height_overrides_height_on_root.html index dd41f7a54..bc70acf17 100644 --- a/test_fixtures/max_height_overrides_height_on_root.html +++ b/test_fixtures/max_height_overrides_height_on_root.html @@ -9,8 +9,7 @@ -
-
+
\ No newline at end of file diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs index 7920ea4cc..33fc675e9 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center.rs @@ -4,28 +4,23 @@ fn absolute_layout_align_items_and_justify_content_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs index 516b885a4..0e1737696 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs @@ -4,32 +4,29 @@ fn absolute_layout_align_items_and_justify_content_center_and_bottom_position() use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs index 36ecd614f..e7fa515e6 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs @@ -4,32 +4,29 @@ fn absolute_layout_align_items_and_justify_content_center_and_left_position() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: auto(), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs index 2112e4408..a6807cc5b 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs @@ -4,32 +4,29 @@ fn absolute_layout_align_items_and_justify_content_center_and_right_position() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(5f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs index 020fbc355..98ec448bb 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs @@ -4,32 +4,29 @@ fn absolute_layout_align_items_and_justify_content_center_and_top_position() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs index 30fb9232f..2309eae6e 100644 --- a/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs +++ b/tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs @@ -4,28 +4,23 @@ fn absolute_layout_align_items_and_justify_content_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, - justify_content: taffy::style::JustifyContent::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_center.rs b/tests/generated/absolute_layout_align_items_center.rs index ab47b3e27..b354fa95f 100644 --- a/tests/generated/absolute_layout_align_items_center.rs +++ b/tests/generated/absolute_layout_align_items_center.rs @@ -4,27 +4,22 @@ fn absolute_layout_align_items_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_align_items_center_on_child_only.rs b/tests/generated/absolute_layout_align_items_center_on_child_only.rs index 6d6f2bdc3..d5c70d63d 100644 --- a/tests/generated/absolute_layout_align_items_center_on_child_only.rs +++ b/tests/generated/absolute_layout_align_items_center_on_child_only.rs @@ -4,19 +4,15 @@ fn absolute_layout_align_items_center_on_child_only() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::Center, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ fn absolute_layout_align_items_center_on_child_only() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_child_order.rs b/tests/generated/absolute_layout_child_order.rs index 05f9f1d16..661339925 100644 --- a/tests/generated/absolute_layout_child_order.rs +++ b/tests/generated/absolute_layout_child_order.rs @@ -4,54 +4,41 @@ fn absolute_layout_child_order() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs index c5b44537f..1110cd783 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container.rs @@ -4,18 +4,14 @@ fn absolute_layout_in_wrap_reverse_column_container() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -25,7 +21,6 @@ fn absolute_layout_in_wrap_reverse_column_container() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs index 7b4a4bfca..ca8d9aedd 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs @@ -4,19 +4,15 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -26,7 +22,6 @@ fn absolute_layout_in_wrap_reverse_column_container_flex_end() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs index ce7fcc3f9..38c79b134 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container.rs @@ -4,18 +4,14 @@ fn absolute_layout_in_wrap_reverse_row_container() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ fn absolute_layout_in_wrap_reverse_row_container() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs index 758bc5ed3..f2284ce8b 100644 --- a/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs +++ b/tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs @@ -4,19 +4,15 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -25,7 +21,6 @@ fn absolute_layout_in_wrap_reverse_row_container_flex_end() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_justify_content_center.rs b/tests/generated/absolute_layout_justify_content_center.rs index 51f2198f1..6000f4396 100644 --- a/tests/generated/absolute_layout_justify_content_center.rs +++ b/tests/generated/absolute_layout_justify_content_center.rs @@ -4,27 +4,22 @@ fn absolute_layout_justify_content_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_no_size.rs b/tests/generated/absolute_layout_no_size.rs index 14a963bca..b206fbc0b 100644 --- a/tests/generated/absolute_layout_no_size.rs +++ b/tests/generated/absolute_layout_no_size.rs @@ -4,10 +4,7 @@ fn absolute_layout_no_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { position_type: taffy::style::PositionType::Absolute, ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { position_type: taffy::style::PositionType::Absolute, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -15,7 +12,6 @@ fn absolute_layout_no_size() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs index 06dae4cc2..848fdcda0 100644 --- a/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs +++ b/tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs @@ -4,55 +4,49 @@ fn absolute_layout_percentage_bottom_based_on_parent_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.5f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.5f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -60,7 +54,6 @@ fn absolute_layout_percentage_bottom_based_on_parent_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_start_top_end_bottom.rs b/tests/generated/absolute_layout_start_top_end_bottom.rs index 58ed62336..b1c2c9de9 100644 --- a/tests/generated/absolute_layout_start_top_end_bottom.rs +++ b/tests/generated/absolute_layout_start_top_end_bottom.rs @@ -4,20 +4,16 @@ fn absolute_layout_start_top_end_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -25,7 +21,6 @@ fn absolute_layout_start_top_end_bottom() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_width_height_end_bottom.rs b/tests/generated/absolute_layout_width_height_end_bottom.rs index 394218f9d..b0baf240e 100644 --- a/tests/generated/absolute_layout_width_height_end_bottom.rs +++ b/tests/generated/absolute_layout_width_height_end_bottom.rs @@ -4,23 +4,20 @@ fn absolute_layout_width_height_end_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -28,7 +25,6 @@ fn absolute_layout_width_height_end_bottom() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_width_height_start_top.rs b/tests/generated/absolute_layout_width_height_start_top.rs index 8eee4f907..798432752 100644 --- a/tests/generated/absolute_layout_width_height_start_top.rs +++ b/tests/generated/absolute_layout_width_height_start_top.rs @@ -4,23 +4,20 @@ fn absolute_layout_width_height_start_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -28,7 +25,6 @@ fn absolute_layout_width_height_start_top() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs index 3f428014c..395758e65 100644 --- a/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs +++ b/tests/generated/absolute_layout_width_height_start_top_end_bottom.rs @@ -4,25 +4,20 @@ fn absolute_layout_width_height_start_top_end_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +25,6 @@ fn absolute_layout_width_height_start_top_end_bottom() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/absolute_layout_within_border.rs b/tests/generated/absolute_layout_within_border.rs index f68df8f22..dca166f84 100644 --- a/tests/generated/absolute_layout_within_border.rs +++ b/tests/generated/absolute_layout_within_border.rs @@ -4,94 +4,80 @@ fn absolute_layout_within_border() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(0f32), - top: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(0f32), - bottom: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(0f32), - top: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(0f32), - bottom: taffy::style::LengthPercentageAuto::Points(0f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -99,21 +85,18 @@ fn absolute_layout_within_border() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/align_baseline.rs b/tests/generated/align_baseline.rs index e7dad6eb4..a4be0b312 100644 --- a/tests/generated/align_baseline.rs +++ b/tests/generated/align_baseline.rs @@ -4,39 +4,30 @@ fn align_baseline() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_baseline_child_multiline.rs b/tests/generated/align_baseline_child_multiline.rs index 20c87c5f9..2d681ca6e 100644 --- a/tests/generated/align_baseline_child_multiline.rs +++ b/tests/generated/align_baseline_child_multiline.rs @@ -4,75 +4,55 @@ fn align_baseline_child_multiline() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node11 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node12 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node13 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(25f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(25f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, ..Default::default() }, &[node10, node11, node12, node13], @@ -81,8 +61,8 @@ fn align_baseline_child_multiline() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Baseline), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/align_baseline_nested_child.rs b/tests/generated/align_baseline_nested_child.rs index 3770afc30..f07762fcd 100644 --- a/tests/generated/align_baseline_nested_child.rs +++ b/tests/generated/align_baseline_nested_child.rs @@ -4,30 +4,22 @@ fn align_baseline_nested_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -36,7 +28,6 @@ fn align_baseline_nested_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(20f32), - ..Size::auto() }, ..Default::default() }, @@ -46,11 +37,10 @@ fn align_baseline_nested_child() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Baseline, + align_items: Some(taffy::style::AlignItems::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_center_should_size_based_on_content.rs b/tests/generated/align_center_should_size_based_on_content.rs index c0cd0a483..72c81eb7b 100644 --- a/tests/generated/align_center_should_size_based_on_content.rs +++ b/tests/generated/align_center_should_size_based_on_content.rs @@ -4,17 +4,13 @@ fn align_center_should_size_based_on_content() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) @@ -22,7 +18,7 @@ fn align_center_should_size_based_on_content() { let node0 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, ..Default::default() @@ -33,11 +29,10 @@ fn align_center_should_size_based_on_content() { let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_around_single_line.rs b/tests/generated/align_content_space_around_single_line.rs index e42b556d4..6d7887c0f 100644 --- a/tests/generated/align_content_space_around_single_line.rs +++ b/tests/generated/align_content_space_around_single_line.rs @@ -4,91 +4,66 @@ fn align_content_space_around_single_line() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_around_wrapped.rs b/tests/generated/align_content_space_around_wrapped.rs index 529ab9cff..c6b33c4fc 100644 --- a/tests/generated/align_content_space_around_wrapped.rs +++ b/tests/generated/align_content_space_around_wrapped.rs @@ -4,92 +4,67 @@ fn align_content_space_around_wrapped() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_between_single_line.rs b/tests/generated/align_content_space_between_single_line.rs index 0b142df88..8fdb538b1 100644 --- a/tests/generated/align_content_space_between_single_line.rs +++ b/tests/generated/align_content_space_between_single_line.rs @@ -4,91 +4,66 @@ fn align_content_space_between_single_line() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_between_wrapped.rs b/tests/generated/align_content_space_between_wrapped.rs index dea6cf26b..bffeaa8b8 100644 --- a/tests/generated/align_content_space_between_wrapped.rs +++ b/tests/generated/align_content_space_between_wrapped.rs @@ -4,92 +4,67 @@ fn align_content_space_between_wrapped() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_evenly_single_line.rs b/tests/generated/align_content_space_evenly_single_line.rs index 0cf2e3fe1..9557a12b9 100644 --- a/tests/generated/align_content_space_evenly_single_line.rs +++ b/tests/generated/align_content_space_evenly_single_line.rs @@ -4,91 +4,66 @@ fn align_content_space_evenly_single_line() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_content: taffy::style::AlignContent::SpaceEvenly, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_content_space_evenly_wrapped.rs b/tests/generated/align_content_space_evenly_wrapped.rs index e90a1a931..d90295d9a 100644 --- a/tests/generated/align_content_space_evenly_wrapped.rs +++ b/tests/generated/align_content_space_evenly_wrapped.rs @@ -4,92 +4,67 @@ fn align_content_space_evenly_wrapped() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceEvenly, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_flex_start_with_shrinking_children.rs b/tests/generated/align_flex_start_with_shrinking_children.rs index 673239c86..a73b8f644 100644 --- a/tests/generated/align_flex_start_with_shrinking_children.rs +++ b/tests/generated/align_flex_start_with_shrinking_children.rs @@ -3,15 +3,14 @@ fn align_flex_start_with_shrinking_children() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); @@ -21,7 +20,6 @@ fn align_flex_start_with_shrinking_children() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs index 8af478bcd..d3de06211 100644 --- a/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs +++ b/tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs @@ -3,15 +3,22 @@ fn align_flex_start_with_shrinking_children_with_stretch() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) + .new_with_children( + taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), + flex_grow: 1f32, + flex_shrink: 1f32, + ..Default::default() + }, + &[node000], + ) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexStart, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); @@ -21,7 +28,6 @@ fn align_flex_start_with_shrinking_children_with_stretch() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_flex_start_with_stretching_children.rs b/tests/generated/align_flex_start_with_stretching_children.rs index 3a2c4081c..b0e455bc8 100644 --- a/tests/generated/align_flex_start_with_stretching_children.rs +++ b/tests/generated/align_flex_start_with_stretching_children.rs @@ -3,9 +3,8 @@ fn align_flex_start_with_stretching_children() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node000 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node000 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) .unwrap(); @@ -16,7 +15,6 @@ fn align_flex_start_with_stretching_children() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_center.rs b/tests/generated/align_items_center.rs index 989e29d59..1d5841c0c 100644 --- a/tests/generated/align_items_center.rs +++ b/tests/generated/align_items_center.rs @@ -4,26 +4,21 @@ fn align_items_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs index 138d6a81c..2fab59dfe 100644 --- a/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs @@ -4,38 +4,34 @@ fn align_items_center_child_with_margin_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs index 4498374ce..046bc53e3 100644 --- a/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs @@ -4,33 +4,28 @@ fn align_items_center_child_without_margin_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(70f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::Center, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::Center), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_center_with_child_margin.rs b/tests/generated/align_items_center_with_child_margin.rs index 0e72112a3..8935b9319 100644 --- a/tests/generated/align_items_center_with_child_margin.rs +++ b/tests/generated/align_items_center_with_child_margin.rs @@ -4,30 +4,27 @@ fn align_items_center_with_child_margin() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_center_with_child_top.rs b/tests/generated/align_items_center_with_child_top.rs index 67ad83ca7..bf5e4df6c 100644 --- a/tests/generated/align_items_center_with_child_top.rs +++ b/tests/generated/align_items_center_with_child_top.rs @@ -4,30 +4,27 @@ fn align_items_center_with_child_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_flex_end.rs b/tests/generated/align_items_flex_end.rs index ca6056404..876af7567 100644 --- a/tests/generated/align_items_flex_end.rs +++ b/tests/generated/align_items_flex_end.rs @@ -4,26 +4,21 @@ fn align_items_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs index f1739f1b4..72870acc2 100644 --- a/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs @@ -4,38 +4,34 @@ fn align_items_flex_end_child_with_margin_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::End), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs index 2982fe8a1..429c0bc21 100644 --- a/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs +++ b/tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs @@ -4,33 +4,28 @@ fn align_items_flex_end_child_without_margin_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(70f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(70f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( - taffy::style::Style { align_items: taffy::style::AlignItems::FlexEnd, ..Default::default() }, + taffy::style::Style { align_items: Some(taffy::style::AlignItems::End), ..Default::default() }, &[node00], ) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_flex_start.rs b/tests/generated/align_items_flex_start.rs index 3bc616a82..8849ba058 100644 --- a/tests/generated/align_items_flex_start.rs +++ b/tests/generated/align_items_flex_start.rs @@ -4,26 +4,21 @@ fn align_items_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_items_min_max.rs b/tests/generated/align_items_min_max.rs index 47153b753..d5fcb14c7 100644 --- a/tests/generated/align_items_min_max.rs +++ b/tests/generated/align_items_min_max.rs @@ -4,26 +4,22 @@ fn align_items_min_max() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/align_items_stretch.rs b/tests/generated/align_items_stretch.rs index 935138e2b..48af4b19c 100644 --- a/tests/generated/align_items_stretch.rs +++ b/tests/generated/align_items_stretch.rs @@ -4,13 +4,10 @@ fn align_items_stretch() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,7 +15,6 @@ fn align_items_stretch() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_self_baseline.rs b/tests/generated/align_self_baseline.rs index 096623bd9..d6918c1a0 100644 --- a/tests/generated/align_self_baseline.rs +++ b/tests/generated/align_self_baseline.rs @@ -4,40 +4,31 @@ fn align_self_baseline() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::Baseline, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Baseline), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { - align_self: taffy::style::AlignSelf::Baseline, + align_self: Some(taffy::style::AlignSelf::Baseline), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: taffy::style::Dimension::Points(20f32), - ..Size::auto() }, ..Default::default() }, @@ -50,7 +41,6 @@ fn align_self_baseline() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_self_center.rs b/tests/generated/align_self_center.rs index a8475802c..d941a8433 100644 --- a/tests/generated/align_self_center.rs +++ b/tests/generated/align_self_center.rs @@ -4,18 +4,14 @@ fn align_self_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::Center, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ fn align_self_center() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_self_flex_end.rs b/tests/generated/align_self_flex_end.rs index 2ab37850a..1a7b11b1b 100644 --- a/tests/generated/align_self_flex_end.rs +++ b/tests/generated/align_self_flex_end.rs @@ -4,18 +4,14 @@ fn align_self_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ fn align_self_flex_end() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_self_flex_end_override_flex_start.rs b/tests/generated/align_self_flex_end_override_flex_start.rs index 6fc597753..049313e67 100644 --- a/tests/generated/align_self_flex_end_override_flex_start.rs +++ b/tests/generated/align_self_flex_end_override_flex_start.rs @@ -4,27 +4,22 @@ fn align_self_flex_end_override_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexEnd, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_self_flex_start.rs b/tests/generated/align_self_flex_start.rs index 23c382088..3510acaa1 100644 --- a/tests/generated/align_self_flex_start.rs +++ b/tests/generated/align_self_flex_start.rs @@ -4,18 +4,14 @@ fn align_self_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - align_self: taffy::style::AlignSelf::FlexStart, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +19,6 @@ fn align_self_flex_start() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/align_strech_should_size_based_on_parent.rs b/tests/generated/align_strech_should_size_based_on_parent.rs index c6a85a454..e441a885e 100644 --- a/tests/generated/align_strech_should_size_based_on_parent.rs +++ b/tests/generated/align_strech_should_size_based_on_parent.rs @@ -4,17 +4,13 @@ fn align_strech_should_size_based_on_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[node000]) @@ -22,7 +18,7 @@ fn align_strech_should_size_based_on_parent() { let node0 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), flex_grow: 0f32, flex_shrink: 1f32, ..Default::default() @@ -36,7 +32,6 @@ fn align_strech_should_size_based_on_parent() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/border_center_child.rs b/tests/generated/border_center_child.rs index 7534f9722..e23d71fc4 100644 --- a/tests/generated/border_center_child.rs +++ b/tests/generated/border_center_child.rs @@ -4,32 +4,28 @@ fn border_center_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { + left: zero(), + right: zero(), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/border_flex_child.rs b/tests/generated/border_flex_child.rs index 8b032d3f9..09f79a40e 100644 --- a/tests/generated/border_flex_child.rs +++ b/tests/generated/border_flex_child.rs @@ -4,14 +4,11 @@ fn border_flex_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -19,14 +16,12 @@ fn border_flex_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/border_no_child.rs b/tests/generated/border_no_child.rs index 1afbf7bd5..b8f4a81e4 100644 --- a/tests/generated/border_no_child.rs +++ b/tests/generated/border_no_child.rs @@ -4,19 +4,15 @@ fn border_no_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - border: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(10f32), - right: taffy::style::LengthPercentage::Points(10f32), - top: taffy::style::LengthPercentage::Points(10f32), - bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/border_stretch_child.rs b/tests/generated/border_stretch_child.rs index d8d2a1c66..e8813f578 100644 --- a/tests/generated/border_stretch_child.rs +++ b/tests/generated/border_stretch_child.rs @@ -4,13 +4,10 @@ fn border_stretch_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,14 +15,12 @@ fn border_stretch_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, border: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/child_min_max_width_flexing.rs b/tests/generated/child_min_max_width_flexing.rs index d6c48c27e..ee8d1e4a6 100644 --- a/tests/generated/child_min_max_width_flexing.rs +++ b/tests/generated/child_min_max_width_flexing.rs @@ -4,36 +4,30 @@ fn child_min_max_width_flexing() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(0f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/container_with_unsized_child.rs b/tests/generated/container_with_unsized_child.rs index 77edc2c48..d21538c52 100644 --- a/tests/generated/container_with_unsized_child.rs +++ b/tests/generated/container_with_unsized_child.rs @@ -3,14 +3,13 @@ fn container_with_unsized_child() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/display_none.rs b/tests/generated/display_none.rs index 5b6ca2406..f4467b17b 100644 --- a/tests/generated/display_none.rs +++ b/tests/generated/display_none.rs @@ -3,12 +3,9 @@ fn display_none() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { display: taffy::style::Display::None, flex_grow: 1f32, ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -16,7 +13,6 @@ fn display_none() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/display_none_fixed_size.rs b/tests/generated/display_none_fixed_size.rs index 41fc1dec5..98159aeb2 100644 --- a/tests/generated/display_none_fixed_size.rs +++ b/tests/generated/display_none_fixed_size.rs @@ -3,20 +3,16 @@ fn display_none_fixed_size() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ fn display_none_fixed_size() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/display_none_with_child.rs b/tests/generated/display_none_with_child.rs index 9bbc3d827..53110a0db 100644 --- a/tests/generated/display_none_with_child.rs +++ b/tests/generated/display_none_with_child.rs @@ -4,27 +4,21 @@ fn display_none_with_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -40,15 +34,12 @@ fn display_none_with_child() { ) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -56,7 +47,6 @@ fn display_none_with_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/display_none_with_margin.rs b/tests/generated/display_none_with_margin.rs index 57eafe47a..c34110591 100644 --- a/tests/generated/display_none_with_margin.rs +++ b/tests/generated/display_none_with_margin.rs @@ -4,34 +4,28 @@ fn display_none_with_margin() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/display_none_with_position.rs b/tests/generated/display_none_with_position.rs index 91a6593f4..bfd887a8f 100644 --- a/tests/generated/display_none_with_position.rs +++ b/tests/generated/display_none_with_position.rs @@ -3,20 +3,19 @@ fn display_none_with_position() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::None, - flex_grow: 1f32, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + display: taffy::style::Display::None, + flex_grow: 1f32, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +23,6 @@ fn display_none_with_position() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs index d6ca88fd7..824a5b5f0 100644 --- a/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs +++ b/tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs @@ -4,39 +4,31 @@ fn flex_basis_and_main_dimen_set_when_flexing() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(0f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(0f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_basis_flex_grow_column.rs b/tests/generated/flex_basis_flex_grow_column.rs index 7ffff5db4..e44925750 100644 --- a/tests/generated/flex_basis_flex_grow_column.rs +++ b/tests/generated/flex_basis_flex_grow_column.rs @@ -4,16 +4,13 @@ fn flex_basis_flex_grow_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -21,7 +18,6 @@ fn flex_basis_flex_grow_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_flex_grow_row.rs b/tests/generated/flex_basis_flex_grow_row.rs index 147120f8b..adfc19f8e 100644 --- a/tests/generated/flex_basis_flex_grow_row.rs +++ b/tests/generated/flex_basis_flex_grow_row.rs @@ -4,23 +4,19 @@ fn flex_basis_flex_grow_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_flex_shrink_column.rs b/tests/generated/flex_basis_flex_shrink_column.rs index 1cc10d84e..cb367dbe0 100644 --- a/tests/generated/flex_basis_flex_shrink_column.rs +++ b/tests/generated/flex_basis_flex_shrink_column.rs @@ -4,16 +4,10 @@ fn flex_basis_flex_shrink_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +16,6 @@ fn flex_basis_flex_shrink_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_flex_shrink_row.rs b/tests/generated/flex_basis_flex_shrink_row.rs index a175aea70..72776cc51 100644 --- a/tests/generated/flex_basis_flex_shrink_row.rs +++ b/tests/generated/flex_basis_flex_shrink_row.rs @@ -4,16 +4,10 @@ fn flex_basis_flex_shrink_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(100f32), ..Default::default() }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(50f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -21,7 +15,6 @@ fn flex_basis_flex_shrink_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_larger_than_content_column.rs b/tests/generated/flex_basis_larger_than_content_column.rs index b6793f23d..c6699d364 100644 --- a/tests/generated/flex_basis_larger_than_content_column.rs +++ b/tests/generated/flex_basis_larger_than_content_column.rs @@ -4,17 +4,13 @@ fn flex_basis_larger_than_content_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -30,7 +26,7 @@ fn flex_basis_larger_than_content_column() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_larger_than_content_row.rs b/tests/generated/flex_basis_larger_than_content_row.rs index 11d496e0e..30f2cb8be 100644 --- a/tests/generated/flex_basis_larger_than_content_row.rs +++ b/tests/generated/flex_basis_larger_than_content_row.rs @@ -4,17 +4,13 @@ fn flex_basis_larger_than_content_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -29,7 +25,7 @@ fn flex_basis_larger_than_content_row() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_overrides_main_size.rs b/tests/generated/flex_basis_overrides_main_size.rs index 7ef26d073..52f496840 100644 --- a/tests/generated/flex_basis_overrides_main_size.rs +++ b/tests/generated/flex_basis_overrides_main_size.rs @@ -4,35 +4,26 @@ fn flex_basis_overrides_main_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +31,6 @@ fn flex_basis_overrides_main_size() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs index 416d7690d..5a5353463 100644 --- a/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs @@ -4,17 +4,13 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,17 +24,13 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -54,7 +46,7 @@ fn flex_basis_slightly_smaller_then_content_with_flex_grow_large_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_basis_smaller_than_content_column.rs b/tests/generated/flex_basis_smaller_than_content_column.rs index 32136d204..12f6e83be 100644 --- a/tests/generated/flex_basis_smaller_than_content_column.rs +++ b/tests/generated/flex_basis_smaller_than_content_column.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_than_content_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -30,7 +26,7 @@ fn flex_basis_smaller_than_content_column() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_smaller_than_content_row.rs b/tests/generated/flex_basis_smaller_than_content_row.rs index 844339b79..c83f5e8ad 100644 --- a/tests/generated/flex_basis_smaller_than_content_row.rs +++ b/tests/generated/flex_basis_smaller_than_content_row.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_than_content_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -29,7 +25,7 @@ fn flex_basis_smaller_than_content_row() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_column.rs b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs index e3d7fa95a..92259d500 100644 --- a/tests/generated/flex_basis_smaller_than_main_dimen_column.rs +++ b/tests/generated/flex_basis_smaller_than_main_dimen_column.rs @@ -4,24 +4,20 @@ fn flex_basis_smaller_than_main_dimen_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_smaller_than_main_dimen_row.rs b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs index 014774b47..d5fd2b75d 100644 --- a/tests/generated/flex_basis_smaller_than_main_dimen_row.rs +++ b/tests/generated/flex_basis_smaller_than_main_dimen_row.rs @@ -4,23 +4,19 @@ fn flex_basis_smaller_than_main_dimen_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(10f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(10f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs index 5a24e3ab3..6e0817086 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,17 +24,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -54,7 +46,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_large_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs index d3b7fa3ae..fceadb532 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,17 +24,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -54,7 +46,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_small_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs index 418863b2f..bd19f2eb4 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,17 +24,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( diff --git a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs index 3c0324588..3c089081d 100644 --- a/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs @@ -4,17 +4,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,17 +24,13 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() { ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -54,7 +46,7 @@ fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_basis_unconstraint_column.rs b/tests/generated/flex_basis_unconstraint_column.rs index 20bc8c775..e58536c31 100644 --- a/tests/generated/flex_basis_unconstraint_column.rs +++ b/tests/generated/flex_basis_unconstraint_column.rs @@ -4,14 +4,11 @@ fn flex_basis_unconstraint_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/tests/generated/flex_basis_unconstraint_row.rs b/tests/generated/flex_basis_unconstraint_row.rs index 5f0fe6e85..a39bee61d 100644 --- a/tests/generated/flex_basis_unconstraint_row.rs +++ b/tests/generated/flex_basis_unconstraint_row.rs @@ -4,14 +4,11 @@ fn flex_basis_unconstraint_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/flex_direction_column.rs b/tests/generated/flex_direction_column.rs index 8831f5d13..683ed49f5 100644 --- a/tests/generated/flex_direction_column.rs +++ b/tests/generated/flex_direction_column.rs @@ -4,31 +4,22 @@ fn flex_direction_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -37,7 +28,6 @@ fn flex_direction_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_direction_column_no_height.rs b/tests/generated/flex_direction_column_no_height.rs index bb6687173..43689e6af 100644 --- a/tests/generated/flex_direction_column_no_height.rs +++ b/tests/generated/flex_direction_column_no_height.rs @@ -4,37 +4,28 @@ fn flex_direction_column_no_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/flex_direction_column_reverse.rs b/tests/generated/flex_direction_column_reverse.rs index a157b2d96..f02d829f6 100644 --- a/tests/generated/flex_direction_column_reverse.rs +++ b/tests/generated/flex_direction_column_reverse.rs @@ -4,31 +4,22 @@ fn flex_direction_column_reverse() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -37,7 +28,6 @@ fn flex_direction_column_reverse() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_direction_row.rs b/tests/generated/flex_direction_row.rs index b7bb3fb18..9a19560a9 100644 --- a/tests/generated/flex_direction_row.rs +++ b/tests/generated/flex_direction_row.rs @@ -4,31 +4,22 @@ fn flex_direction_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -36,7 +27,6 @@ fn flex_direction_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_direction_row_no_width.rs b/tests/generated/flex_direction_row_no_width.rs index f12486a24..b1f4138b8 100644 --- a/tests/generated/flex_direction_row_no_width.rs +++ b/tests/generated/flex_direction_row_no_width.rs @@ -4,36 +4,27 @@ fn flex_direction_row_no_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/flex_direction_row_reverse.rs b/tests/generated/flex_direction_row_reverse.rs index d9540b021..653072f8f 100644 --- a/tests/generated/flex_direction_row_reverse.rs +++ b/tests/generated/flex_direction_row_reverse.rs @@ -4,31 +4,22 @@ fn flex_direction_row_reverse() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -37,7 +28,6 @@ fn flex_direction_row_reverse() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_child.rs b/tests/generated/flex_grow_child.rs index ddbeb79cb..187b24b4b 100644 --- a/tests/generated/flex_grow_child.rs +++ b/tests/generated/flex_grow_child.rs @@ -4,15 +4,12 @@ fn flex_grow_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/flex_grow_flex_basis_percent_min_max.rs b/tests/generated/flex_grow_flex_basis_percent_min_max.rs index d3126ee26..2f7838c31 100644 --- a/tests/generated/flex_grow_flex_basis_percent_min_max.rs +++ b/tests/generated/flex_grow_flex_basis_percent_min_max.rs @@ -4,39 +4,32 @@ fn flex_grow_flex_basis_percent_min_max() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(0f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(0f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(120f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_height_maximized.rs b/tests/generated/flex_grow_height_maximized.rs index eb384b318..d4d27dde0 100644 --- a/tests/generated/flex_grow_height_maximized.rs +++ b/tests/generated/flex_grow_height_maximized.rs @@ -4,31 +4,25 @@ fn flex_grow_height_maximized() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node00, node01], @@ -41,7 +35,6 @@ fn flex_grow_height_maximized() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_in_at_most_container.rs b/tests/generated/flex_grow_in_at_most_container.rs index d75932740..f598ac4aa 100644 --- a/tests/generated/flex_grow_in_at_most_container.rs +++ b/tests/generated/flex_grow_in_at_most_container.rs @@ -4,24 +4,20 @@ fn flex_grow_in_at_most_container() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0f32), + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_less_than_factor_one.rs b/tests/generated/flex_grow_less_than_factor_one.rs index e9a9f1cc4..b64ee5cd3 100644 --- a/tests/generated/flex_grow_less_than_factor_one.rs +++ b/tests/generated/flex_grow_less_than_factor_one.rs @@ -4,29 +4,23 @@ fn flex_grow_less_than_factor_one() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0.2f32, - flex_shrink: 0f32, - flex_basis: taffy::style::Dimension::Points(40f32), - ..Default::default() - }, - &[], - ) - .unwrap(); - let node1 = taffy - .new_with_children(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }, &[]) - .unwrap(); - let node2 = taffy - .new_with_children(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }, &[]) + .new_leaf(taffy::style::Style { + flex_grow: 0.2f32, + flex_shrink: 0f32, + flex_basis: taffy::style::Dimension::Points(40f32), + ..Default::default() + }) .unwrap(); + let node1 = + taffy.new_leaf(taffy::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); + let node2 = + taffy.new_leaf(taffy::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_root_minimized.rs b/tests/generated/flex_grow_root_minimized.rs index 98d71a522..c214dba1e 100644 --- a/tests/generated/flex_grow_root_minimized.rs +++ b/tests/generated/flex_grow_root_minimized.rs @@ -4,31 +4,25 @@ fn flex_grow_root_minimized() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node00, node01], @@ -38,9 +32,9 @@ fn flex_grow_root_minimized() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_grow_shrink_at_most.rs b/tests/generated/flex_grow_shrink_at_most.rs index 0eb213cbb..baca33c4d 100644 --- a/tests/generated/flex_grow_shrink_at_most.rs +++ b/tests/generated/flex_grow_shrink_at_most.rs @@ -3,9 +3,8 @@ fn flex_grow_shrink_at_most() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node00 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node00 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy .new_with_children( @@ -13,7 +12,6 @@ fn flex_grow_shrink_at_most() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_to_min.rs b/tests/generated/flex_grow_to_min.rs index 32cd1658b..7a67d372b 100644 --- a/tests/generated/flex_grow_to_min.rs +++ b/tests/generated/flex_grow_to_min.rs @@ -3,25 +3,21 @@ fn flex_grow_to_min() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy - .new_with_children(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }, &[]) - .unwrap(); + let node0 = + taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, flex_shrink: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_within_constrained_max_column.rs b/tests/generated/flex_grow_within_constrained_max_column.rs index e4c525b94..a2730c1f3 100644 --- a/tests/generated/flex_grow_within_constrained_max_column.rs +++ b/tests/generated/flex_grow_within_constrained_max_column.rs @@ -4,30 +4,24 @@ fn flex_grow_within_constrained_max_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_within_constrained_max_row.rs b/tests/generated/flex_grow_within_constrained_max_row.rs index caa6383af..fcad3dd5e 100644 --- a/tests/generated/flex_grow_within_constrained_max_row.rs +++ b/tests/generated/flex_grow_within_constrained_max_row.rs @@ -4,29 +4,23 @@ fn flex_grow_within_constrained_max_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -36,7 +30,7 @@ fn flex_grow_within_constrained_max_row() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_grow_within_constrained_max_width.rs b/tests/generated/flex_grow_within_constrained_max_width.rs index b10a104e0..a44aa0a43 100644 --- a/tests/generated/flex_grow_within_constrained_max_width.rs +++ b/tests/generated/flex_grow_within_constrained_max_width.rs @@ -4,19 +4,16 @@ fn flex_grow_within_constrained_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Size::auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: auto() }, ..Default::default() }, &[node00], @@ -29,7 +26,6 @@ fn flex_grow_within_constrained_max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_grow_within_constrained_min_column.rs b/tests/generated/flex_grow_within_constrained_min_column.rs index 32c09a9f1..c6feeecd2 100644 --- a/tests/generated/flex_grow_within_constrained_min_column.rs +++ b/tests/generated/flex_grow_within_constrained_min_column.rs @@ -3,21 +3,18 @@ fn flex_grow_within_constrained_min_column() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_within_constrained_min_max_column.rs b/tests/generated/flex_grow_within_constrained_min_max_column.rs index 39fc2930a..d6f63f76f 100644 --- a/tests/generated/flex_grow_within_constrained_min_max_column.rs +++ b/tests/generated/flex_grow_within_constrained_min_max_column.rs @@ -3,20 +3,17 @@ fn flex_grow_within_constrained_min_max_column() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_within_constrained_min_row.rs b/tests/generated/flex_grow_within_constrained_min_row.rs index cbc72fdc4..78a107aee 100644 --- a/tests/generated/flex_grow_within_constrained_min_row.rs +++ b/tests/generated/flex_grow_within_constrained_min_row.rs @@ -3,21 +3,18 @@ fn flex_grow_within_constrained_min_row() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_grow_within_max_width.rs b/tests/generated/flex_grow_within_max_width.rs index 84cb0d07f..8e7fc15c0 100644 --- a/tests/generated/flex_grow_within_max_width.rs +++ b/tests/generated/flex_grow_within_max_width.rs @@ -4,19 +4,16 @@ fn flex_grow_within_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00], @@ -29,7 +26,6 @@ fn flex_grow_within_max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_root_ignored.rs b/tests/generated/flex_root_ignored.rs index 7f5c29a32..92ef9a7eb 100644 --- a/tests/generated/flex_root_ignored.rs +++ b/tests/generated/flex_root_ignored.rs @@ -4,31 +4,25 @@ fn flex_root_ignored() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(200f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(200f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(500f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(500f32) }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs index fb9b67d26..e0e6ab41f 100644 --- a/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs +++ b/tests/generated/flex_shrink_by_outer_margin_with_max_size.rs @@ -4,28 +4,26 @@ fn flex_shrink_by_outer_margin_with_max_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(100f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(100f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(80f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs index 7317a67d1..c61e712ee 100644 --- a/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs +++ b/tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs @@ -4,34 +4,26 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -39,7 +31,6 @@ fn flex_shrink_flex_grow_child_flex_shrink_other_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_shrink_flex_grow_row.rs b/tests/generated/flex_shrink_flex_grow_row.rs index c1dfb37b1..ee53f032e 100644 --- a/tests/generated/flex_shrink_flex_grow_row.rs +++ b/tests/generated/flex_shrink_flex_grow_row.rs @@ -4,34 +4,26 @@ fn flex_shrink_flex_grow_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0f32, - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(500f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 0f32, + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(500f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -39,7 +31,6 @@ fn flex_shrink_flex_grow_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_shrink_to_zero.rs b/tests/generated/flex_shrink_to_zero.rs index 2f469c26e..847c63dd2 100644 --- a/tests/generated/flex_shrink_to_zero.rs +++ b/tests/generated/flex_shrink_to_zero.rs @@ -4,51 +4,39 @@ fn flex_shrink_to_zero() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(75f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/flex_wrap_align_stretch_fits_one_row.rs b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs index 58f0a1011..d0e801d8f 100644 --- a/tests/generated/flex_wrap_align_stretch_fits_one_row.rs +++ b/tests/generated/flex_wrap_align_stretch_fits_one_row.rs @@ -4,22 +4,16 @@ fn flex_wrap_align_stretch_fits_one_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -28,7 +22,6 @@ fn flex_wrap_align_stretch_fits_one_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(150f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs index 6bbe35407..0bab542a7 100644 --- a/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs +++ b/tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs @@ -4,32 +4,26 @@ fn flex_wrap_children_with_min_main_overriding_flex_basis() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(55f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/flex_wrap_wrap_to_child_height.rs b/tests/generated/flex_wrap_wrap_to_child_height.rs index f257cfcea..1c5aadb73 100644 --- a/tests/generated/flex_wrap_wrap_to_child_height.rs +++ b/tests/generated/flex_wrap_wrap_to_child_height.rs @@ -4,23 +4,19 @@ fn flex_wrap_wrap_to_child_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node000], @@ -30,24 +26,20 @@ fn flex_wrap_wrap_to_child_height() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), ..Default::default() }, &[node00], ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/tests/generated/gap_column_gap_child_margins.rs b/tests/generated/gap_column_gap_child_margins.rs index 92a82958f..17bca89b6 100644 --- a/tests/generated/gap_column_gap_child_margins.rs +++ b/tests/generated/gap_column_gap_child_margins.rs @@ -4,61 +4,54 @@ fn gap_column_gap_child_margins() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(2f32), - right: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(2f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(15f32), - right: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(15f32), + right: taffy::style::LengthPercentageAuto::Points(15f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_determines_parent_width.rs b/tests/generated/gap_column_gap_determines_parent_width.rs index a88bd2c5d..0a58f2164 100644 --- a/tests/generated/gap_column_gap_determines_parent_width.rs +++ b/tests/generated/gap_column_gap_determines_parent_width.rs @@ -4,37 +4,29 @@ fn gap_column_gap_determines_parent_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_flexible.rs b/tests/generated/gap_column_gap_flexible.rs index b4ad781fd..cb6c7296e 100644 --- a/tests/generated/gap_column_gap_flexible.rs +++ b/tests/generated/gap_column_gap_flexible.rs @@ -4,37 +4,28 @@ fn gap_column_gap_flexible() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -42,12 +33,10 @@ fn gap_column_gap_flexible() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_flexible_undefined_parent.rs b/tests/generated/gap_column_gap_flexible_undefined_parent.rs index 56f82c8a3..579dff9eb 100644 --- a/tests/generated/gap_column_gap_flexible_undefined_parent.rs +++ b/tests/generated/gap_column_gap_flexible_undefined_parent.rs @@ -4,37 +4,28 @@ fn gap_column_gap_flexible_undefined_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -42,9 +33,8 @@ fn gap_column_gap_flexible_undefined_parent() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_inflexible.rs b/tests/generated/gap_column_gap_inflexible.rs index ddfeb2fb0..71073c006 100644 --- a/tests/generated/gap_column_gap_inflexible.rs +++ b/tests/generated/gap_column_gap_inflexible.rs @@ -4,40 +4,30 @@ fn gap_column_gap_inflexible() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_inflexible_undefined_parent.rs b/tests/generated/gap_column_gap_inflexible_undefined_parent.rs index 0acd63a4a..deac07707 100644 --- a/tests/generated/gap_column_gap_inflexible_undefined_parent.rs +++ b/tests/generated/gap_column_gap_inflexible_undefined_parent.rs @@ -4,37 +4,28 @@ fn gap_column_gap_inflexible_undefined_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_justify_center.rs b/tests/generated/gap_column_gap_justify_center.rs index eb2157acb..a0017fdf9 100644 --- a/tests/generated/gap_column_gap_justify_center.rs +++ b/tests/generated/gap_column_gap_justify_center.rs @@ -4,41 +4,31 @@ fn gap_column_gap_justify_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::Center), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_justify_flex_end.rs b/tests/generated/gap_column_gap_justify_flex_end.rs index 63585f28c..51356cbc4 100644 --- a/tests/generated/gap_column_gap_justify_flex_end.rs +++ b/tests/generated/gap_column_gap_justify_flex_end.rs @@ -4,41 +4,31 @@ fn gap_column_gap_justify_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::End), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_justify_flex_start.rs b/tests/generated/gap_column_gap_justify_flex_start.rs index 57600508c..eb2c120f6 100644 --- a/tests/generated/gap_column_gap_justify_flex_start.rs +++ b/tests/generated/gap_column_gap_justify_flex_start.rs @@ -4,40 +4,31 @@ fn gap_column_gap_justify_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::Start), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_justify_space_around.rs b/tests/generated/gap_column_gap_justify_space_around.rs index ee40132ea..e0bfb3a55 100644 --- a/tests/generated/gap_column_gap_justify_space_around.rs +++ b/tests/generated/gap_column_gap_justify_space_around.rs @@ -4,41 +4,31 @@ fn gap_column_gap_justify_space_around() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceAround, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_justify_space_between.rs b/tests/generated/gap_column_gap_justify_space_between.rs index b73c3e2ba..a6e26e72f 100644 --- a/tests/generated/gap_column_gap_justify_space_between.rs +++ b/tests/generated/gap_column_gap_justify_space_between.rs @@ -4,41 +4,31 @@ fn gap_column_gap_justify_space_between() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceBetween, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_justify_space_evenly.rs b/tests/generated/gap_column_gap_justify_space_evenly.rs index 56a497059..83c539b68 100644 --- a/tests/generated/gap_column_gap_justify_space_evenly.rs +++ b/tests/generated/gap_column_gap_justify_space_evenly.rs @@ -4,41 +4,31 @@ fn gap_column_gap_justify_space_evenly() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceEvenly, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_mixed_flexible.rs b/tests/generated/gap_column_gap_mixed_flexible.rs index 4aa463872..60f37eb25 100644 --- a/tests/generated/gap_column_gap_mixed_flexible.rs +++ b/tests/generated/gap_column_gap_mixed_flexible.rs @@ -4,42 +4,32 @@ fn gap_column_gap_mixed_flexible() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs index 19ea2f646..c5b0de967 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_partially_shrinkable.rs @@ -4,50 +4,38 @@ fn gap_column_gap_percentage_cyclic_partially_shrinkable() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.5f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs index 0234a9c95..0759cadca 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_shrinkable.rs @@ -4,48 +4,36 @@ fn gap_column_gap_percentage_cyclic_shrinkable() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs b/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs index bb13f6fd8..cc8433550 100644 --- a/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs +++ b/tests/generated/gap_column_gap_percentage_cyclic_unshrinkable.rs @@ -4,51 +4,39 @@ fn gap_column_gap_percentage_cyclic_unshrinkable() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_column_gap_percentage_flexible.rs b/tests/generated/gap_column_gap_percentage_flexible.rs index b906fd0a7..147b640de 100644 --- a/tests/generated/gap_column_gap_percentage_flexible.rs +++ b/tests/generated/gap_column_gap_percentage_flexible.rs @@ -4,37 +4,28 @@ fn gap_column_gap_percentage_flexible() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -42,12 +33,10 @@ fn gap_column_gap_percentage_flexible() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.1f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_percentage_inflexible.rs b/tests/generated/gap_column_gap_percentage_inflexible.rs index b22e8c4f3..cf437c0a8 100644 --- a/tests/generated/gap_column_gap_percentage_inflexible.rs +++ b/tests/generated/gap_column_gap_percentage_inflexible.rs @@ -4,40 +4,30 @@ fn gap_column_gap_percentage_inflexible() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Percent(0.2f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_center.rs b/tests/generated/gap_column_gap_wrap_align_center.rs index e8d43d75c..f7e789819 100644 --- a/tests/generated/gap_column_gap_wrap_align_center.rs +++ b/tests/generated/gap_column_gap_wrap_align_center.rs @@ -4,97 +4,71 @@ fn gap_column_gap_wrap_align_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::Center, + align_content: Some(taffy::style::AlignContent::Center), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_flex_end.rs b/tests/generated/gap_column_gap_wrap_align_flex_end.rs index b43ebe8e4..5fa9f761d 100644 --- a/tests/generated/gap_column_gap_wrap_align_flex_end.rs +++ b/tests/generated/gap_column_gap_wrap_align_flex_end.rs @@ -4,97 +4,71 @@ fn gap_column_gap_wrap_align_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::FlexEnd, + align_content: Some(taffy::style::AlignContent::End), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_flex_start.rs b/tests/generated/gap_column_gap_wrap_align_flex_start.rs index 2a314b3b3..a9a1a8cb4 100644 --- a/tests/generated/gap_column_gap_wrap_align_flex_start.rs +++ b/tests/generated/gap_column_gap_wrap_align_flex_start.rs @@ -4,97 +4,71 @@ fn gap_column_gap_wrap_align_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::FlexStart, + align_content: Some(taffy::style::AlignContent::Start), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_space_around.rs b/tests/generated/gap_column_gap_wrap_align_space_around.rs index 028a0bb09..b04c3d427 100644 --- a/tests/generated/gap_column_gap_wrap_align_space_around.rs +++ b/tests/generated/gap_column_gap_wrap_align_space_around.rs @@ -4,97 +4,71 @@ fn gap_column_gap_wrap_align_space_around() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceAround, + align_content: Some(taffy::style::AlignContent::SpaceAround), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_space_between.rs b/tests/generated/gap_column_gap_wrap_align_space_between.rs index 4b9ded62b..0e5dacd8c 100644 --- a/tests/generated/gap_column_gap_wrap_align_space_between.rs +++ b/tests/generated/gap_column_gap_wrap_align_space_between.rs @@ -4,97 +4,71 @@ fn gap_column_gap_wrap_align_space_between() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_content: taffy::style::AlignContent::SpaceBetween, + align_content: Some(taffy::style::AlignContent::SpaceBetween), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_gap_wrap_align_stretch.rs b/tests/generated/gap_column_gap_wrap_align_stretch.rs index 51e2c4edb..628c03850 100644 --- a/tests/generated/gap_column_gap_wrap_align_stretch.rs +++ b/tests/generated/gap_column_gap_wrap_align_stretch.rs @@ -4,64 +4,49 @@ fn gap_column_gap_wrap_align_stretch() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(5f32), ..Size::zero() }, + align_content: Some(taffy::style::AlignContent::Stretch), + gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(5f32), height: zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: taffy::style::Dimension::Points(300f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_column_row_gap_wrapping.rs b/tests/generated/gap_column_row_gap_wrapping.rs index 5ea5c6dad..263820342 100644 --- a/tests/generated/gap_column_row_gap_wrapping.rs +++ b/tests/generated/gap_column_row_gap_wrapping.rs @@ -4,121 +4,85 @@ fn gap_column_row_gap_wrapping() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -127,9 +91,8 @@ fn gap_column_row_gap_wrapping() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4, node5, node6, node7, node8], diff --git a/tests/generated/gap_percentage_row_gap_wrapping.rs b/tests/generated/gap_percentage_row_gap_wrapping.rs index eedaa1a58..0286a86f3 100644 --- a/tests/generated/gap_percentage_row_gap_wrapping.rs +++ b/tests/generated/gap_percentage_row_gap_wrapping.rs @@ -4,121 +4,85 @@ fn gap_percentage_row_gap_wrapping() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node6 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node7 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node8 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -127,9 +91,8 @@ fn gap_percentage_row_gap_wrapping() { gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Percent(0.1f32), - ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4, node5, node6, node7, node8], diff --git a/tests/generated/gap_row_gap_align_items_end.rs b/tests/generated/gap_row_gap_align_items_end.rs index 6da74dcd3..f9fc399d8 100644 --- a/tests/generated/gap_row_gap_align_items_end.rs +++ b/tests/generated/gap_row_gap_align_items_end.rs @@ -4,73 +4,53 @@ fn gap_row_gap_align_items_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_row_gap_align_items_stretch.rs b/tests/generated/gap_row_gap_align_items_stretch.rs index ef7720780..8fc7e50fd 100644 --- a/tests/generated/gap_row_gap_align_items_stretch.rs +++ b/tests/generated/gap_row_gap_align_items_stretch.rs @@ -4,72 +4,54 @@ fn gap_row_gap_align_items_stretch() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node5 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, + align_items: Some(taffy::style::AlignItems::Stretch), + align_content: Some(taffy::style::AlignContent::Stretch), gap: taffy::geometry::Size { width: taffy::style::LengthPercentage::Points(10f32), height: taffy::style::LengthPercentage::Points(20f32), - ..Size::zero() }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_row_gap_column_child_margins.rs b/tests/generated/gap_row_gap_column_child_margins.rs index 88248f325..327da36ec 100644 --- a/tests/generated/gap_row_gap_column_child_margins.rs +++ b/tests/generated/gap_row_gap_column_child_margins.rs @@ -4,62 +4,55 @@ fn gap_row_gap_column_child_margins() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(2f32), - bottom: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - bottom: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/gap_row_gap_determines_parent_height.rs b/tests/generated/gap_row_gap_determines_parent_height.rs index 7feb61ce8..1fb2fb009 100644 --- a/tests/generated/gap_row_gap_determines_parent_height.rs +++ b/tests/generated/gap_row_gap_determines_parent_height.rs @@ -4,38 +4,30 @@ fn gap_row_gap_determines_parent_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(30f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(30f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Stretch), + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/gap_row_gap_row_wrap_child_margins.rs b/tests/generated/gap_row_gap_row_wrap_child_margins.rs index 27e7ef879..b7572a486 100644 --- a/tests/generated/gap_row_gap_row_wrap_child_margins.rs +++ b/tests/generated/gap_row_gap_row_wrap_child_margins.rs @@ -4,56 +4,49 @@ fn gap_row_gap_row_wrap_child_margins() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(2f32), - bottom: taffy::style::LengthPercentageAuto::Points(2f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - bottom: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - gap: taffy::geometry::Size { height: taffy::style::LengthPercentage::Points(10f32), ..Size::zero() }, + gap: taffy::geometry::Size { width: zero(), height: taffy::style::LengthPercentage::Points(10f32) }, size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/grid_absolute_align_self_sized_all.rs b/tests/generated/grid_absolute_align_self_sized_all.rs new file mode 100644 index 000000000..0df00a749 --- /dev/null +++ b/tests/generated/grid_absolute_align_self_sized_all.rs @@ -0,0 +1,149 @@ +#[test] +fn grid_absolute_align_self_sized_all() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 0f32); +} diff --git a/tests/generated/grid_absolute_column_end.rs b/tests/generated/grid_absolute_column_end.rs new file mode 100644 index 000000000..b0708894c --- /dev/null +++ b/tests/generated/grid_absolute_column_end.rs @@ -0,0 +1,51 @@ +#[test] +fn grid_absolute_column_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Auto, + end: taffy::style::GridPlacement::Line(1i16), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 33f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 157f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 1f32); +} diff --git a/tests/generated/grid_absolute_column_start.rs b/tests/generated/grid_absolute_column_start.rs new file mode 100644 index 000000000..188b1a812 --- /dev/null +++ b/tests/generated/grid_absolute_column_start.rs @@ -0,0 +1,51 @@ +#[test] +fn grid_absolute_column_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 133f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 157f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 44f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 1f32); +} diff --git a/tests/generated/grid_absolute_container_bottom_left.rs b/tests/generated/grid_absolute_container_bottom_left.rs new file mode 100644 index 000000000..10c452f78 --- /dev/null +++ b/tests/generated/grid_absolute_container_bottom_left.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_bottom_left() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_bottom_left_margin.rs b/tests/generated/grid_absolute_container_bottom_left_margin.rs new file mode 100644 index 000000000..19041168b --- /dev/null +++ b/tests/generated/grid_absolute_container_bottom_left_margin.rs @@ -0,0 +1,97 @@ +#[test] +fn grid_absolute_container_bottom_left_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 147f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_left_overrides_right.rs b/tests/generated/grid_absolute_container_left_overrides_right.rs new file mode 100644 index 000000000..b5b9d4873 --- /dev/null +++ b/tests/generated/grid_absolute_container_left_overrides_right.rs @@ -0,0 +1,88 @@ +#[test] +fn grid_absolute_container_left_overrides_right() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_left_right.rs b/tests/generated/grid_absolute_container_left_right.rs new file mode 100644 index 000000000..f85ab25cf --- /dev/null +++ b/tests/generated/grid_absolute_container_left_right.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_left_right() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 173f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_left_right_margin.rs b/tests/generated/grid_absolute_container_left_right_margin.rs new file mode 100644 index 000000000..28feeb31b --- /dev/null +++ b/tests/generated/grid_absolute_container_left_right_margin.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_left_right_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(5f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: auto(), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 173f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 5f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_negative_position.rs b/tests/generated/grid_absolute_container_negative_position.rs new file mode 100644 index 000000000..7ca7217a9 --- /dev/null +++ b/tests/generated/grid_absolute_container_negative_position.rs @@ -0,0 +1,98 @@ +#[test] +fn grid_absolute_container_negative_position() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(-15f32), + top: taffy::style::LengthPercentageAuto::Points(-5f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(-25f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 195f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -5f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, -35f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 185f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_negative_position_margin.rs b/tests/generated/grid_absolute_container_negative_position_margin.rs new file mode 100644 index 000000000..b6b3432f1 --- /dev/null +++ b/tests/generated/grid_absolute_container_negative_position_margin.rs @@ -0,0 +1,98 @@ +#[test] +fn grid_absolute_container_negative_position_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(-15f32), + top: taffy::style::LengthPercentageAuto::Points(-5f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(-35f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(-25f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 195f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, -5f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, -35f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 185f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_top_bottom.rs b/tests/generated/grid_absolute_container_top_bottom.rs new file mode 100644 index 000000000..a5fb38928 --- /dev/null +++ b/tests/generated/grid_absolute_container_top_bottom.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_top_bottom() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 153f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 2f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_top_bottom_margin.rs b/tests/generated/grid_absolute_container_top_bottom_margin.rs new file mode 100644 index 000000000..ec5f8f641 --- /dev/null +++ b/tests/generated/grid_absolute_container_top_bottom_margin.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_top_bottom_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 153f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 2f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_top_right.rs b/tests/generated/grid_absolute_container_top_right.rs new file mode 100644 index 000000000..771e4c50e --- /dev/null +++ b/tests/generated/grid_absolute_container_top_right.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_top_right() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_container_top_right_margin.rs b/tests/generated/grid_absolute_container_top_right_margin.rs new file mode 100644 index 000000000..9abf543cc --- /dev/null +++ b/tests/generated/grid_absolute_container_top_right_margin.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_absolute_container_top_right_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_justify_self_sized_all.rs b/tests/generated/grid_absolute_justify_self_sized_all.rs new file mode 100644 index 000000000..19a46468f --- /dev/null +++ b/tests/generated/grid_absolute_justify_self_sized_all.rs @@ -0,0 +1,149 @@ +#[test] +fn grid_absolute_justify_self_sized_all() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 30f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 0f32); +} diff --git a/tests/generated/grid_absolute_row_end.rs b/tests/generated/grid_absolute_row_end.rs new file mode 100644 index 000000000..629bcdf8c --- /dev/null +++ b/tests/generated/grid_absolute_row_end.rs @@ -0,0 +1,51 @@ +#[test] +fn grid_absolute_row_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Auto, + end: taffy::style::GridPlacement::Line(1i16), + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 173f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 7f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 1f32); +} diff --git a/tests/generated/grid_absolute_row_start.rs b/tests/generated/grid_absolute_row_start.rs new file mode 100644 index 000000000..8c7fc5694 --- /dev/null +++ b/tests/generated/grid_absolute_row_start.rs @@ -0,0 +1,51 @@ +#[test] +fn grid_absolute_row_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(3f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(2f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 173f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 147f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 11f32); +} diff --git a/tests/generated/grid_absolute_top_overrides_bottom.rs b/tests/generated/grid_absolute_top_overrides_bottom.rs new file mode 100644 index 000000000..c8c785c41 --- /dev/null +++ b/tests/generated/grid_absolute_top_overrides_bottom.rs @@ -0,0 +1,88 @@ +#[test] +fn grid_absolute_top_overrides_bottom() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(5f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 2f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_with_padding.rs b/tests/generated/grid_absolute_with_padding.rs new file mode 100644 index 000000000..515045be6 --- /dev/null +++ b/tests/generated/grid_absolute_with_padding.rs @@ -0,0 +1,98 @@ +#[test] +fn grid_absolute_with_padding() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 150f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_absolute_with_padding_and_margin.rs b/tests/generated/grid_absolute_with_padding_and_margin.rs new file mode 100644 index 000000000..ca97633ab --- /dev/null +++ b/tests/generated/grid_absolute_with_padding_and_margin.rs @@ -0,0 +1,98 @@ +#[test] +fn grid_absolute_with_padding_and_margin() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: auto(), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 180f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 150f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_align_content_center.rs b/tests/generated/grid_align_content_center.rs new file mode 100644 index 000000000..8c7ca9282 --- /dev/null +++ b/tests/generated/grid_align_content_center.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 120f32); +} diff --git a/tests/generated/grid_align_content_end.rs b/tests/generated/grid_align_content_end.rs new file mode 100644 index 000000000..34bbbca08 --- /dev/null +++ b/tests/generated/grid_align_content_end.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 160f32); +} diff --git a/tests/generated/grid_align_content_end_with_padding_border.rs b/tests/generated/grid_align_content_end_with_padding_border.rs new file mode 100644 index 000000000..079f061ee --- /dev/null +++ b/tests/generated/grid_align_content_end_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_align_content_end_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 44f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 44f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 44f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 84f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 84f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 84f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 124f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 124f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 124f32); +} diff --git a/tests/generated/grid_align_content_space_around.rs b/tests/generated/grid_align_content_space_around.rs new file mode 100644 index 000000000..a5e1cefb4 --- /dev/null +++ b/tests/generated/grid_align_content_space_around.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_space_around() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 13f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 13f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 13f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 147f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 147f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 147f32); +} diff --git a/tests/generated/grid_align_content_space_around_with_padding_border.rs b/tests/generated/grid_align_content_space_around_with_padding_border.rs new file mode 100644 index 000000000..cfae2f862 --- /dev/null +++ b/tests/generated/grid_align_content_space_around_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_align_content_space_around_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 17f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 17f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 17f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 119f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 119f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 119f32); +} diff --git a/tests/generated/grid_align_content_space_between.rs b/tests/generated/grid_align_content_space_between.rs new file mode 100644 index 000000000..cd3e7f4bc --- /dev/null +++ b/tests/generated/grid_align_content_space_between.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_space_between() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 160f32); +} diff --git a/tests/generated/grid_align_content_space_between_with_padding_border.rs b/tests/generated/grid_align_content_space_between_with_padding_border.rs new file mode 100644 index 000000000..216443813 --- /dev/null +++ b/tests/generated/grid_align_content_space_between_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_align_content_space_between_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 124f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 124f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 124f32); +} diff --git a/tests/generated/grid_align_content_space_evenly.rs b/tests/generated/grid_align_content_space_evenly.rs new file mode 100644 index 000000000..d7e452b2d --- /dev/null +++ b/tests/generated/grid_align_content_space_evenly.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_space_evenly() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 140f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 140f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 140f32); +} diff --git a/tests/generated/grid_align_content_space_evenly_with_padding_border.rs b/tests/generated/grid_align_content_space_evenly_with_padding_border.rs new file mode 100644 index 000000000..c1093b5b9 --- /dev/null +++ b/tests/generated/grid_align_content_space_evenly_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_align_content_space_evenly_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 68f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 116f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 116f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 116f32); +} diff --git a/tests/generated/grid_align_content_start.rs b/tests/generated/grid_align_content_start.rs new file mode 100644 index 000000000..7c862af9b --- /dev/null +++ b/tests/generated/grid_align_content_start.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_align_content_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_align_content_start_with_padding_border.rs b/tests/generated/grid_align_content_start_with_padding_border.rs new file mode 100644 index 000000000..a2918eb28 --- /dev/null +++ b/tests/generated/grid_align_content_start_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_align_content_start_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_content: Some(taffy::style::AlignContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_align_items_sized_center.rs b/tests/generated/grid_align_items_sized_center.rs new file mode 100644 index 000000000..e5503e0d3 --- /dev/null +++ b/tests/generated/grid_align_items_sized_center.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_align_items_sized_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 70f32); +} diff --git a/tests/generated/grid_align_items_sized_end.rs b/tests/generated/grid_align_items_sized_end.rs new file mode 100644 index 000000000..baaecf40b --- /dev/null +++ b/tests/generated/grid_align_items_sized_end.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_align_items_sized_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 60f32); +} diff --git a/tests/generated/grid_align_items_sized_start.rs b/tests/generated/grid_align_items_sized_start.rs new file mode 100644 index 000000000..bf5702a93 --- /dev/null +++ b/tests/generated/grid_align_items_sized_start.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_align_items_sized_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_align_items_sized_stretch.rs b/tests/generated/grid_align_items_sized_stretch.rs new file mode 100644 index 000000000..723e3fb46 --- /dev/null +++ b/tests/generated/grid_align_items_sized_stretch.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_align_items_sized_stretch() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + align_items: Some(taffy::style::AlignItems::Stretch), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_align_self_sized_all.rs b/tests/generated/grid_align_self_sized_all.rs new file mode 100644 index 000000000..96061faed --- /dev/null +++ b/tests/generated/grid_align_self_sized_all.rs @@ -0,0 +1,141 @@ +#[test] +fn grid_align_self_sized_all() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 30f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_auto_columns_fixed_width.rs b/tests/generated/grid_auto_columns_fixed_width.rs new file mode 100644 index 000000000..5ce6ac438 --- /dev/null +++ b/tests/generated/grid_auto_columns_fixed_width.rs @@ -0,0 +1,112 @@ +#[test] +fn grid_auto_columns_fixed_width() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node10 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node11 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node12 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node13 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node14 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node15 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), auto(), points(40f32), auto()], + grid_template_columns: vec![points(40f32), auto(), points(40f32), auto()], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13, + node14, node15, + ], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node9).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node9).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node9).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node9).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node10).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node10).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node10).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node10).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node11).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node11).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node11).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node11).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node12).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node12).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node12).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node12).unwrap().location.y, 140f32); + assert_eq!(taffy.layout(node13).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node13).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node13).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node13).unwrap().location.y, 140f32); + assert_eq!(taffy.layout(node14).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node14).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node14).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node14).unwrap().location.y, 140f32); + assert_eq!(taffy.layout(node15).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node15).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node15).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node15).unwrap().location.y, 140f32); +} diff --git a/tests/generated/grid_auto_fill_fixed_size.rs b/tests/generated/grid_auto_fill_fixed_size.rs new file mode 100644 index 000000000..6873298d2 --- /dev/null +++ b/tests/generated/grid_auto_fill_fixed_size.rs @@ -0,0 +1,74 @@ +#[test] +fn grid_auto_fill_fixed_size() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), repeat(GridTrackRepetition::AutoFill, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_auto_fill_with_empty_auto_track.rs b/tests/generated/grid_auto_fill_with_empty_auto_track.rs new file mode 100644 index 000000000..d349fa0af --- /dev/null +++ b/tests/generated/grid_auto_fill_with_empty_auto_track.rs @@ -0,0 +1,40 @@ +#[test] +fn grid_auto_fill_with_empty_auto_track() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFill, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/grid_auto_fit_with_empty_auto_track.rs b/tests/generated/grid_auto_fit_with_empty_auto_track.rs new file mode 100644 index 000000000..a3cf7d836 --- /dev/null +++ b/tests/generated/grid_auto_fit_with_empty_auto_track.rs @@ -0,0 +1,40 @@ +#[test] +fn grid_auto_fit_with_empty_auto_track() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![repeat(GridTrackRepetition::AutoFit, vec![points(40f32)])], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 13f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 67f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); +} diff --git a/tests/generated/grid_auto_single_item.rs b/tests/generated/grid_auto_single_item.rs new file mode 100644 index 000000000..d525451df --- /dev/null +++ b/tests/generated/grid_auto_single_item.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_auto_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_auto_single_item_fixed_width.rs b/tests/generated/grid_auto_single_item_fixed_width.rs new file mode 100644 index 000000000..25a823c84 --- /dev/null +++ b/tests/generated/grid_auto_single_item_fixed_width.rs @@ -0,0 +1,76 @@ +#[test] +fn grid_auto_single_item_fixed_width() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 130f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 130f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 130f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs new file mode 100644 index 000000000..eea5528e4 --- /dev/null +++ b/tests/generated/grid_auto_single_item_fixed_width_with_definite_width.rs @@ -0,0 +1,76 @@ +#[test] +fn grid_auto_single_item_fixed_width_with_definite_width() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), auto(), auto()], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 130f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 130f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 170f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_basic.rs b/tests/generated/grid_basic.rs new file mode 100644 index 000000000..849f38231 --- /dev/null +++ b/tests/generated/grid_basic.rs @@ -0,0 +1,74 @@ +#[test] +fn grid_basic() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_basic_implicit_tracks.rs b/tests/generated/grid_basic_implicit_tracks.rs new file mode 100644 index 000000000..b822f5641 --- /dev/null +++ b/tests/generated/grid_basic_implicit_tracks.rs @@ -0,0 +1,43 @@ +#[test] +fn grid_basic_implicit_tracks() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(35f32), + height: taffy::style::Dimension::Points(35f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32)], + grid_template_columns: vec![points(40f32)], + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 75f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 35f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 35f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_basic_with_overflow.rs b/tests/generated/grid_basic_with_overflow.rs new file mode 100644 index 000000000..03a14c0f6 --- /dev/null +++ b/tests/generated/grid_basic_with_overflow.rs @@ -0,0 +1,79 @@ +#[test] +fn grid_basic_with_overflow() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node9 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8, node9], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node9).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node9).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node9).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node9).unwrap().location.y, 120f32); +} diff --git a/tests/generated/grid_basic_with_padding.rs b/tests/generated/grid_basic_with_padding.rs new file mode 100644 index 000000000..a6e9e4c89 --- /dev/null +++ b/tests/generated/grid_basic_with_padding.rs @@ -0,0 +1,76 @@ +#[test] +fn grid_basic_with_padding() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_fit_content_points_argument.rs b/tests/generated/grid_fit_content_points_argument.rs new file mode 100644 index 000000000..ff5666edb --- /dev/null +++ b/tests/generated/grid_fit_content_points_argument.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_fit_content_points_argument() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_fit_content_points_max_content.rs b/tests/generated/grid_fit_content_points_max_content.rs new file mode 100644 index 000000000..ef437251c --- /dev/null +++ b/tests/generated/grid_fit_content_points_max_content.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_fit_content_points_max_content() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_fit_content_points_min_content.rs b/tests/generated/grid_fit_content_points_min_content.rs new file mode 100644 index 000000000..32fb942eb --- /dev/null +++ b/tests/generated/grid_fit_content_points_min_content.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_fit_content_points_min_content() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHHH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), fit_content(points(30f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_fr_auto_no_sized_items.rs b/tests/generated/grid_fr_auto_no_sized_items.rs new file mode 100644 index 000000000..8799f3b30 --- /dev/null +++ b/tests/generated/grid_fr_auto_no_sized_items.rs @@ -0,0 +1,74 @@ +#[test] +fn grid_fr_auto_no_sized_items() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Auto, + height: taffy::style::Dimension::Auto, + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_fr_auto_single_item.rs b/tests/generated/grid_fr_auto_single_item.rs new file mode 100644 index 000000000..6223d2b17 --- /dev/null +++ b/tests/generated/grid_fr_auto_single_item.rs @@ -0,0 +1,79 @@ +#[test] +fn grid_fr_auto_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Auto, + height: taffy::style::Dimension::Auto, + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 240f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_fr_fixed_size_no_content.rs b/tests/generated/grid_fr_fixed_size_no_content.rs new file mode 100644 index 000000000..3d57ec96e --- /dev/null +++ b/tests/generated/grid_fr_fixed_size_no_content.rs @@ -0,0 +1,74 @@ +#[test] +fn grid_fr_fixed_size_no_content() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 120f32); +} diff --git a/tests/generated/grid_fr_fixed_size_single_item.rs b/tests/generated/grid_fr_fixed_size_single_item.rs new file mode 100644 index 000000000..0e326e66a --- /dev/null +++ b/tests/generated/grid_fr_fixed_size_single_item.rs @@ -0,0 +1,79 @@ +#[test] +fn grid_fr_fixed_size_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), flex(1f32), flex(1f32)], + grid_template_columns: vec![points(40f32), flex(1f32), flex(1f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 120f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 120f32); +} diff --git a/tests/generated/grid_gap.rs b/tests/generated/grid_gap.rs new file mode 100644 index 000000000..7784733dd --- /dev/null +++ b/tests/generated/grid_gap.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_gap() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + gap: taffy::geometry::Size { + width: taffy::style::LengthPercentage::Points(40f32), + height: taffy::style::LengthPercentage::Points(40f32), + }, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 160f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 160f32); +} diff --git a/tests/generated/grid_hidden.rs b/tests/generated/grid_hidden.rs new file mode 100644 index 000000000..e83d2da51 --- /dev/null +++ b/tests/generated/grid_hidden.rs @@ -0,0 +1,77 @@ +#[test] +fn grid_hidden() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = + taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::None, ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 0f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_justify_content_center.rs b/tests/generated/grid_justify_content_center.rs new file mode 100644 index 000000000..e786e87eb --- /dev/null +++ b/tests/generated/grid_justify_content_center.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_center_with_padding_border.rs b/tests/generated/grid_justify_content_center_with_padding_border.rs new file mode 100644 index 000000000..1229bdd0d --- /dev/null +++ b/tests/generated/grid_justify_content_center_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_center_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 52f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 132f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 52f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 132f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 52f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 132f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_content_end.rs b/tests/generated/grid_justify_content_end.rs new file mode 100644 index 000000000..e8700d920 --- /dev/null +++ b/tests/generated/grid_justify_content_end.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_end_with_padding_border.rs b/tests/generated/grid_justify_content_end_with_padding_border.rs new file mode 100644 index 000000000..27c3ed7e8 --- /dev/null +++ b/tests/generated/grid_justify_content_end_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_end_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 56f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 96f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 56f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 96f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 56f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 96f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_content_space_around.rs b/tests/generated/grid_justify_content_space_around.rs new file mode 100644 index 000000000..fcbad9b66 --- /dev/null +++ b/tests/generated/grid_justify_content_space_around.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_space_around() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 13f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 147f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 13f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 147f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 13f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 147f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_space_around_with_padding_border.rs b/tests/generated/grid_justify_content_space_around_with_padding_border.rs new file mode 100644 index 000000000..4570af905 --- /dev/null +++ b/tests/generated/grid_justify_content_space_around_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_space_around_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 49f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 49f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 49f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 135f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_content_space_between.rs b/tests/generated/grid_justify_content_space_between.rs new file mode 100644 index 000000000..687e9591b --- /dev/null +++ b/tests/generated/grid_justify_content_space_between.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_space_between() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 160f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_space_between_with_padding_border.rs b/tests/generated/grid_justify_content_space_between_with_padding_border.rs new file mode 100644 index 000000000..a589bd48d --- /dev/null +++ b/tests/generated/grid_justify_content_space_between_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_space_between_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 136f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_content_space_evenly.rs b/tests/generated/grid_justify_content_space_evenly.rs new file mode 100644 index 000000000..3773c57e2 --- /dev/null +++ b/tests/generated/grid_justify_content_space_evenly.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_space_evenly() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 140f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs b/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs new file mode 100644 index 000000000..58d9bc56d --- /dev/null +++ b/tests/generated/grid_justify_content_space_evenly_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_space_evenly_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 134f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 134f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 92f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 134f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_content_start.rs b/tests/generated/grid_justify_content_start.rs new file mode 100644 index 000000000..2cb944593 --- /dev/null +++ b/tests/generated/grid_justify_content_start.rs @@ -0,0 +1,75 @@ +#[test] +fn grid_justify_content_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_content_start_with_padding_border.rs b/tests/generated/grid_justify_content_start_with_padding_border.rs new file mode 100644 index 000000000..5c6c2f16a --- /dev/null +++ b/tests/generated/grid_justify_content_start_with_padding_border.rs @@ -0,0 +1,87 @@ +#[test] +fn grid_justify_content_start_with_padding_border() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_content: Some(taffy::style::JustifyContent::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), + }, + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + border: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(8f32), + right: taffy::style::LengthPercentage::Points(4f32), + top: taffy::style::LengthPercentage::Points(2f32), + bottom: taffy::style::LengthPercentage::Points(6f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 200f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 200f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 12f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 52f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 88f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 92f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 128f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 92f32); +} diff --git a/tests/generated/grid_justify_items_sized_center.rs b/tests/generated/grid_justify_items_sized_center.rs new file mode 100644 index 000000000..7beed2015 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_center.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_justify_items_sized_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Center), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_items_sized_end.rs b/tests/generated/grid_justify_items_sized_end.rs new file mode 100644 index 000000000..f018987c1 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_end.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_justify_items_sized_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::End), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_items_sized_start.rs b/tests/generated/grid_justify_items_sized_start.rs new file mode 100644 index 000000000..46ac06105 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_start.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_justify_items_sized_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Start), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_items_sized_stretch.rs b/tests/generated/grid_justify_items_sized_stretch.rs new file mode 100644 index 000000000..23ccfa1d5 --- /dev/null +++ b/tests/generated/grid_justify_items_sized_stretch.rs @@ -0,0 +1,72 @@ +#[test] +fn grid_justify_items_sized_stretch() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(3i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + justify_items: Some(taffy::style::JustifyItems::Stretch), + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_justify_self_sized_all.rs b/tests/generated/grid_justify_self_sized_all.rs new file mode 100644 index 000000000..8b6d6dccd --- /dev/null +++ b/tests/generated/grid_justify_self_sized_all.rs @@ -0,0 +1,141 @@ +#[test] +fn grid_justify_self_sized_all() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), + }, + ..Default::default() + }) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 100f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, -20f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 60f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_margins_auto_margins.rs b/tests/generated/grid_margins_auto_margins.rs new file mode 100644 index 000000000..c94ec228c --- /dev/null +++ b/tests/generated/grid_margins_auto_margins.rs @@ -0,0 +1,116 @@ +#[test] +fn grid_margins_auto_margins() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Points(0f32), + bottom: taffy::style::LengthPercentageAuto::Points(0f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(0f32), + right: taffy::style::LengthPercentageAuto::Points(0f32), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 130f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 60f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 100f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_margins_auto_margins_override_stretch.rs b/tests/generated/grid_margins_auto_margins_override_stretch.rs new file mode 100644 index 000000000..28457c5c1 --- /dev/null +++ b/tests/generated/grid_margins_auto_margins_override_stretch.rs @@ -0,0 +1,94 @@ +#[test] +fn grid_margins_auto_margins_override_stretch() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 105f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 90f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 90f32); +} diff --git a/tests/generated/grid_margins_fixed_center.rs b/tests/generated/grid_margins_fixed_center.rs new file mode 100644 index 000000000..700a03e42 --- /dev/null +++ b/tests/generated/grid_margins_fixed_center.rs @@ -0,0 +1,77 @@ +#[test] +fn grid_margins_fixed_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(8f32), + right: taffy::style::LengthPercentageAuto::Points(4f32), + top: taffy::style::LengthPercentageAuto::Points(2f32), + bottom: taffy::style::LengthPercentageAuto::Points(6f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 52f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 18f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); +} diff --git a/tests/generated/grid_margins_fixed_end.rs b/tests/generated/grid_margins_fixed_end.rs new file mode 100644 index 000000000..7654d7632 --- /dev/null +++ b/tests/generated/grid_margins_fixed_end.rs @@ -0,0 +1,77 @@ +#[test] +fn grid_margins_fixed_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 58f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 27f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); +} diff --git a/tests/generated/grid_margins_fixed_start.rs b/tests/generated/grid_margins_fixed_start.rs new file mode 100644 index 000000000..9e72bece3 --- /dev/null +++ b/tests/generated/grid_margins_fixed_start.rs @@ -0,0 +1,77 @@ +#[test] +fn grid_margins_fixed_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 44f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 11f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); +} diff --git a/tests/generated/grid_margins_fixed_stretch.rs b/tests/generated/grid_margins_fixed_stretch.rs new file mode 100644 index 000000000..ea17bd5ef --- /dev/null +++ b/tests/generated/grid_margins_fixed_stretch.rs @@ -0,0 +1,77 @@ +#[test] +fn grid_margins_fixed_stretch() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(4f32), + right: taffy::style::LengthPercentageAuto::Points(2f32), + top: taffy::style::LengthPercentageAuto::Points(1f32), + bottom: taffy::style::LengthPercentageAuto::Points(3f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(40f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(30f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 180f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 160f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 44f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 11f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 10f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 50f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 120f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 50f32); +} diff --git a/tests/generated/grid_margins_percent_center.rs b/tests/generated/grid_margins_percent_center.rs new file mode 100644 index 000000000..77a928a1a --- /dev/null +++ b/tests/generated/grid_margins_percent_center.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_margins_percent_center() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Center), + justify_self: Some(taffy::style::JustifySelf::Center), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 1f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 9f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_margins_percent_end.rs b/tests/generated/grid_margins_percent_end.rs new file mode 100644 index 000000000..93fb542d6 --- /dev/null +++ b/tests/generated/grid_margins_percent_end.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_margins_percent_end() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::End), + justify_self: Some(taffy::style::JustifySelf::End), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, -2f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 17f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_margins_percent_start.rs b/tests/generated/grid_margins_percent_start.rs new file mode 100644 index 000000000..47131163b --- /dev/null +++ b/tests/generated/grid_margins_percent_start.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_margins_percent_start() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 1f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_margins_percent_stretch.rs b/tests/generated/grid_margins_percent_stretch.rs new file mode 100644 index 000000000..23032ed28 --- /dev/null +++ b/tests/generated/grid_margins_percent_stretch.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_margins_percent_stretch() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf(taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Stretch), + justify_self: Some(taffy::style::JustifySelf::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(20f32), points(20f32), points(20f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 60f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 4f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 1f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); +} diff --git a/tests/generated/grid_max_content_maximum_single_item.rs b/tests/generated/grid_max_content_maximum_single_item.rs new file mode 100644 index 000000000..3c2f89ab4 --- /dev/null +++ b/tests/generated/grid_max_content_maximum_single_item.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_max_content_maximum_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(0f32), max_content()), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_max_content_single_item.rs b/tests/generated/grid_max_content_single_item.rs new file mode 100644 index 000000000..3cf713a1e --- /dev/null +++ b/tests/generated/grid_max_content_single_item.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_max_content_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_max_content_single_item_margin_auto.rs b/tests/generated/grid_max_content_single_item_margin_auto.rs new file mode 100644 index 000000000..0673f40ef --- /dev/null +++ b/tests/generated/grid_max_content_single_item_margin_auto.rs @@ -0,0 +1,86 @@ +#[test] +fn grid_max_content_single_item_margin_auto() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 15f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_max_content_single_item_margin_fixed.rs b/tests/generated/grid_max_content_single_item_margin_fixed.rs new file mode 100644 index 000000000..6ed4a722c --- /dev/null +++ b/tests/generated/grid_max_content_single_item_margin_fixed.rs @@ -0,0 +1,86 @@ +#[test] +fn grid_max_content_single_item_margin_fixed() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 150f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 5f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 110f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 110f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 70f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 110f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_max_content_single_item_margin_percent.rs b/tests/generated/grid_max_content_single_item_margin_percent.rs new file mode 100644 index 000000000..bce6af080 --- /dev/null +++ b/tests/generated/grid_max_content_single_item_margin_percent.rs @@ -0,0 +1,86 @@ +#[test] +fn grid_max_content_single_item_margin_percent() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), max_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 28f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 32f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 2f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_flex_single_item.rs b/tests/generated/grid_min_content_flex_single_item.rs new file mode 100644 index 000000000..85271c569 --- /dev/null +++ b/tests/generated/grid_min_content_flex_single_item.rs @@ -0,0 +1,84 @@ +#[test] +fn grid_min_content_flex_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_flex_single_item_margin_auto.rs b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs new file mode 100644 index 000000000..0975567c3 --- /dev/null +++ b/tests/generated/grid_min_content_flex_single_item_margin_auto.rs @@ -0,0 +1,96 @@ +#[test] +fn grid_min_content_flex_single_item_margin_auto() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 20f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 55f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs new file mode 100644 index 000000000..a8c439873 --- /dev/null +++ b/tests/generated/grid_min_content_flex_single_item_margin_fixed.rs @@ -0,0 +1,96 @@ +#[test] +fn grid_min_content_flex_single_item_margin_fixed() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: taffy::style::LengthPercentageAuto::Points(5f32), + bottom: taffy::style::LengthPercentageAuto::Points(15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 5f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 45f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_flex_single_item_margin_percent.rs b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs new file mode 100644 index 000000000..5d40d358c --- /dev/null +++ b/tests/generated/grid_min_content_flex_single_item_margin_percent.rs @@ -0,0 +1,96 @@ +#[test] +fn grid_min_content_flex_single_item_margin_percent() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Span(2u16), + end: taffy::style::GridPlacement::Auto, + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.2f32), + right: taffy::style::LengthPercentageAuto::Percent(0.1f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.15f32), + }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), flex(1f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 80f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 38f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 42f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 1f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 28f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 32f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 48f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 42f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 50f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_maximum_single_item.rs b/tests/generated/grid_min_content_maximum_single_item.rs new file mode 100644 index 000000000..2936a4d2b --- /dev/null +++ b/tests/generated/grid_min_content_maximum_single_item.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_min_content_maximum_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(0f32), min_content()), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_content_single_item.rs b/tests/generated/grid_min_content_single_item.rs new file mode 100644 index 000000000..8371d05f3 --- /dev/null +++ b/tests/generated/grid_min_content_single_item.rs @@ -0,0 +1,78 @@ +#[test] +fn grid_min_content_single_item() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { ..Default::default() }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), min_content(), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 100f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_max_column_auto.rs b/tests/generated/grid_min_max_column_auto.rs new file mode 100644 index 000000000..edef7145d --- /dev/null +++ b/tests/generated/grid_min_max_column_auto.rs @@ -0,0 +1,70 @@ +#[test] +fn grid_min_max_column_auto() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_max_column_fixed_width_above_range.rs b/tests/generated/grid_min_max_column_fixed_width_above_range.rs new file mode 100644 index 000000000..6eea80c04 --- /dev/null +++ b/tests/generated/grid_min_max_column_fixed_width_above_range.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_min_max_column_fixed_width_above_range() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(140f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 140f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_max_column_fixed_width_below_range.rs b/tests/generated/grid_min_max_column_fixed_width_below_range.rs new file mode 100644 index 000000000..6c3a45763 --- /dev/null +++ b/tests/generated/grid_min_max_column_fixed_width_below_range.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_min_max_column_fixed_width_below_range() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(90f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 90f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 60f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_min_max_column_fixed_width_within_range.rs b/tests/generated/grid_min_max_column_fixed_width_within_range.rs new file mode 100644 index 000000000..b708a5e9a --- /dev/null +++ b/tests/generated/grid_min_max_column_fixed_width_within_range.rs @@ -0,0 +1,71 @@ +#[test] +fn grid_min_max_column_fixed_width_within_range() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), minmax(points(20f32), points(40f32)), points(40f32)], + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(110f32), height: auto() }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 110f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 70f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_out_of_order_items.rs b/tests/generated/grid_out_of_order_items.rs new file mode 100644 index 000000000..34c859496 --- /dev/null +++ b/tests/generated/grid_out_of_order_items.rs @@ -0,0 +1,115 @@ +#[test] +fn grid_out_of_order_items() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node2 = taffy + .new_leaf(taffy::style::Style { + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(35f32), + height: taffy::style::Dimension::Points(35f32), + }, + ..Default::default() + }) + .unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node5 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + grid_column: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), + }, + ..Default::default() + }) + .unwrap(); + let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node7 = taffy + .new_leaf(taffy::style::Style { + grid_row: taffy::geometry::Line { + start: taffy::style::GridPlacement::Line(1i16), + end: taffy::style::GridPlacement::Auto, + }, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), + }, + ..Default::default() + }) + .unwrap(); + let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + grid_auto_flow: taffy::style::GridAutoFlow::RowDense, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 35f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 35f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node5).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node5).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node5).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node6).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node6).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node6).unwrap().location.y, 80f32); + assert_eq!(taffy.layout(node7).unwrap().size.width, 10f32); + assert_eq!(taffy.layout(node7).unwrap().size.height, 10f32); + assert_eq!(taffy.layout(node7).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node7).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node8).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node8).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node8).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node8).unwrap().location.y, 80f32); +} diff --git a/tests/generated/grid_size_child_fixed_tracks.rs b/tests/generated/grid_size_child_fixed_tracks.rs new file mode 100644 index 000000000..74f3220ca --- /dev/null +++ b/tests/generated/grid_size_child_fixed_tracks.rs @@ -0,0 +1,116 @@ +#[test] +fn grid_size_child_fixed_tracks() { + #[allow(unused_imports)] + use taffy::prelude::*; + let mut taffy = taffy::Taffy::new(); + let node0 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node1 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HHH\u{200b}HHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node2 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HHHH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node3 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node4 = taffy + .new_leaf_with_measure( + taffy::style::Style { + align_self: Some(taffy::style::AlignSelf::Start), + justify_self: Some(taffy::style::JustifySelf::Start), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(30f32), height: auto() }, + ..Default::default() + }, + taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| { + const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH"; + super::measure_standard_text(known_dimensions, available_space, TEXT) + }), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Grid, + grid_template_rows: vec![points(40f32), points(40f32), points(40f32)], + grid_template_columns: vec![points(40f32), points(40f32), points(40f32)], + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(120f32), + height: taffy::style::Dimension::Points(120f32), + }, + ..Default::default() + }, + &[node0, node1, node2, node3, node4], + ) + .unwrap(); + taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); + println!("\nComputed tree:"); + taffy::debug::print_tree(&taffy, node); + println!(); + assert_eq!(taffy.layout(node).unwrap().size.width, 120f32); + assert_eq!(taffy.layout(node).unwrap().size.height, 120f32); + assert_eq!(taffy.layout(node).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node0).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node1).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node1).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node1).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node2).unwrap().size.width, 40f32); + assert_eq!(taffy.layout(node2).unwrap().size.height, 20f32); + assert_eq!(taffy.layout(node2).unwrap().location.x, 80f32); + assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32); + assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32); + assert_eq!(taffy.layout(node3).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32); + assert_eq!(taffy.layout(node3).unwrap().location.y, 40f32); + assert_eq!(taffy.layout(node4).unwrap().size.width, 30f32); + assert_eq!(taffy.layout(node4).unwrap().size.height, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.x, 40f32); + assert_eq!(taffy.layout(node4).unwrap().location.y, 40f32); +} diff --git a/tests/generated/justify_content_column_center.rs b/tests/generated/justify_content_column_center.rs index 771f0b854..3eaa6238f 100644 --- a/tests/generated/justify_content_column_center.rs +++ b/tests/generated/justify_content_column_center.rs @@ -4,41 +4,31 @@ fn justify_content_column_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_column_flex_end.rs b/tests/generated/justify_content_column_flex_end.rs index ab66c0281..348d47c1c 100644 --- a/tests/generated/justify_content_column_flex_end.rs +++ b/tests/generated/justify_content_column_flex_end.rs @@ -4,41 +4,31 @@ fn justify_content_column_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_column_flex_start.rs b/tests/generated/justify_content_column_flex_start.rs index d8d870bb9..8f30a7107 100644 --- a/tests/generated/justify_content_column_flex_start.rs +++ b/tests/generated/justify_content_column_flex_start.rs @@ -4,40 +4,31 @@ fn justify_content_column_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_column_min_height_and_margin_bottom.rs b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs index d9ed1ab2b..f2a4ddf95 100644 --- a/tests/generated/justify_content_column_min_height_and_margin_bottom.rs +++ b/tests/generated/justify_content_column_min_height_and_margin_bottom.rs @@ -4,28 +4,26 @@ fn justify_content_column_min_height_and_margin_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/justify_content_column_min_height_and_margin_top.rs b/tests/generated/justify_content_column_min_height_and_margin_top.rs index 43a998d3a..8e19ad2f3 100644 --- a/tests/generated/justify_content_column_min_height_and_margin_top.rs +++ b/tests/generated/justify_content_column_min_height_and_margin_top.rs @@ -4,28 +4,26 @@ fn justify_content_column_min_height_and_margin_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/justify_content_column_space_around.rs b/tests/generated/justify_content_column_space_around.rs index 95e90f7ce..d9ba86e6a 100644 --- a/tests/generated/justify_content_column_space_around.rs +++ b/tests/generated/justify_content_column_space_around.rs @@ -4,41 +4,31 @@ fn justify_content_column_space_around() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceAround, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_column_space_between.rs b/tests/generated/justify_content_column_space_between.rs index a68e236a2..eae01ec8e 100644 --- a/tests/generated/justify_content_column_space_between.rs +++ b/tests/generated/justify_content_column_space_between.rs @@ -4,41 +4,31 @@ fn justify_content_column_space_between() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceBetween, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_column_space_evenly.rs b/tests/generated/justify_content_column_space_evenly.rs index 5fc73fdc9..bc7460c52 100644 --- a/tests/generated/justify_content_column_space_evenly.rs +++ b/tests/generated/justify_content_column_space_evenly.rs @@ -4,41 +4,31 @@ fn justify_content_column_space_evenly() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::SpaceEvenly, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_min_max.rs b/tests/generated/justify_content_min_max.rs index e01a5558e..9dfbcd57f 100644 --- a/tests/generated/justify_content_min_max.rs +++ b/tests/generated/justify_content_min_max.rs @@ -4,26 +4,22 @@ fn justify_content_min_max() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(60f32), - height: taffy::style::Dimension::Points(60f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(60f32), + height: taffy::style::Dimension::Points(60f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, ..Default::default() }, &[node0], diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs index 2974b9cc7..fca313634 100644 --- a/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs +++ b/tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs @@ -4,42 +4,46 @@ fn justify_content_min_width_with_padding_child_width_greater_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(300f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(300f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(100f32), right: taffy::style::LengthPercentage::Points(100f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, &[node000], ) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(1000f32), height: taffy::style::Dimension::Points(1584f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs index 6464f05ed..07d616cab 100644 --- a/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs +++ b/tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs @@ -4,42 +4,46 @@ fn justify_content_min_width_with_padding_child_width_lower_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(199f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(199f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(100f32), right: taffy::style::LengthPercentage::Points(100f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, &[node000], ) .unwrap(); - let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); + let node0 = taffy + .new_with_children( + taffy::style::Style { align_content: Some(taffy::style::AlignContent::Stretch), ..Default::default() }, + &[node00], + ) + .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_content: Some(taffy::style::AlignContent::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(1080f32), height: taffy::style::Dimension::Points(1584f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_overflow_min_max.rs b/tests/generated/justify_content_overflow_min_max.rs index 791150708..074147f66 100644 --- a/tests/generated/justify_content_overflow_min_max.rs +++ b/tests/generated/justify_content_overflow_min_max.rs @@ -4,54 +4,42 @@ fn justify_content_overflow_min_max() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(110f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(110f32) }, ..Default::default() }, &[node0, node1, node2], diff --git a/tests/generated/justify_content_row_center.rs b/tests/generated/justify_content_row_center.rs index 29d9c3452..f58e0a8d7 100644 --- a/tests/generated/justify_content_row_center.rs +++ b/tests/generated/justify_content_row_center.rs @@ -4,40 +4,30 @@ fn justify_content_row_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_row_flex_end.rs b/tests/generated/justify_content_row_flex_end.rs index 6487cf310..3170d508c 100644 --- a/tests/generated/justify_content_row_flex_end.rs +++ b/tests/generated/justify_content_row_flex_end.rs @@ -4,40 +4,30 @@ fn justify_content_row_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_row_flex_start.rs b/tests/generated/justify_content_row_flex_start.rs index bea5d0552..66cb42fec 100644 --- a/tests/generated/justify_content_row_flex_start.rs +++ b/tests/generated/justify_content_row_flex_start.rs @@ -4,39 +4,30 @@ fn justify_content_row_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + justify_content: Some(taffy::style::JustifyContent::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_row_max_width_and_margin.rs b/tests/generated/justify_content_row_max_width_and_margin.rs index 12e97b8c0..2973895cd 100644 --- a/tests/generated/justify_content_row_max_width_and_margin.rs +++ b/tests/generated/justify_content_row_max_width_and_margin.rs @@ -4,28 +4,26 @@ fn justify_content_row_max_width_and_margin() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(100f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(100f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/justify_content_row_min_width_and_margin.rs b/tests/generated/justify_content_row_min_width_and_margin.rs index 74dc8811f..840b11a65 100644 --- a/tests/generated/justify_content_row_min_width_and_margin.rs +++ b/tests/generated/justify_content_row_min_width_and_margin.rs @@ -4,27 +4,25 @@ fn justify_content_row_min_width_and_margin() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/justify_content_row_space_around.rs b/tests/generated/justify_content_row_space_around.rs index d016f88c8..4c8f7f617 100644 --- a/tests/generated/justify_content_row_space_around.rs +++ b/tests/generated/justify_content_row_space_around.rs @@ -4,40 +4,30 @@ fn justify_content_row_space_around() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceAround, + justify_content: Some(taffy::style::JustifyContent::SpaceAround), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_row_space_between.rs b/tests/generated/justify_content_row_space_between.rs index 1aab054f9..72bf00006 100644 --- a/tests/generated/justify_content_row_space_between.rs +++ b/tests/generated/justify_content_row_space_between.rs @@ -4,40 +4,30 @@ fn justify_content_row_space_between() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceBetween, + justify_content: Some(taffy::style::JustifyContent::SpaceBetween), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/justify_content_row_space_evenly.rs b/tests/generated/justify_content_row_space_evenly.rs index 754b26c5d..54af2c632 100644 --- a/tests/generated/justify_content_row_space_evenly.rs +++ b/tests/generated/justify_content_row_space_evenly.rs @@ -4,40 +4,30 @@ fn justify_content_row_space_evenly() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::SpaceEvenly, + justify_content: Some(taffy::style::JustifyContent::SpaceEvenly), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_and_flex_column.rs b/tests/generated/margin_and_flex_column.rs index df1108975..f969153cc 100644 --- a/tests/generated/margin_and_flex_column.rs +++ b/tests/generated/margin_and_flex_column.rs @@ -4,18 +4,16 @@ fn margin_and_flex_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +22,6 @@ fn margin_and_flex_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_and_flex_row.rs b/tests/generated/margin_and_flex_row.rs index 25e904c86..554811bb0 100644 --- a/tests/generated/margin_and_flex_row.rs +++ b/tests/generated/margin_and_flex_row.rs @@ -4,18 +4,16 @@ fn margin_and_flex_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +21,6 @@ fn margin_and_flex_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_and_stretch_column.rs b/tests/generated/margin_and_stretch_column.rs index 27e3ec6fd..5dcf0c208 100644 --- a/tests/generated/margin_and_stretch_column.rs +++ b/tests/generated/margin_and_stretch_column.rs @@ -4,18 +4,16 @@ fn margin_and_stretch_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +22,6 @@ fn margin_and_stretch_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_and_stretch_row.rs b/tests/generated/margin_and_stretch_row.rs index 3ce6f79a9..5ce17dff9 100644 --- a/tests/generated/margin_and_stretch_row.rs +++ b/tests/generated/margin_and_stretch_row.rs @@ -4,18 +4,16 @@ fn margin_and_stretch_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +21,6 @@ fn margin_and_stretch_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_bottom.rs b/tests/generated/margin_auto_bottom.rs index 4d5310d78..22af16989 100644 --- a/tests/generated/margin_auto_bottom.rs +++ b/tests/generated/margin_auto_bottom.rs @@ -4,40 +4,36 @@ fn margin_auto_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { bottom: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_bottom_and_top.rs b/tests/generated/margin_auto_bottom_and_top.rs index 1e0973e3d..0d7020c0f 100644 --- a/tests/generated/margin_auto_bottom_and_top.rs +++ b/tests/generated/margin_auto_bottom_and_top.rs @@ -4,44 +4,36 @@ fn margin_auto_bottom_and_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_bottom_and_top_justify_center.rs b/tests/generated/margin_auto_bottom_and_top_justify_center.rs index 2e1331d66..76a18b46d 100644 --- a/tests/generated/margin_auto_bottom_and_top_justify_center.rs +++ b/tests/generated/margin_auto_bottom_and_top_justify_center.rs @@ -4,44 +4,36 @@ fn margin_auto_bottom_and_top_justify_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left.rs b/tests/generated/margin_auto_left.rs index b05f840e9..42a86a41b 100644 --- a/tests/generated/margin_auto_left.rs +++ b/tests/generated/margin_auto_left.rs @@ -4,40 +4,36 @@ fn margin_auto_left() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_and_right.rs b/tests/generated/margin_auto_left_and_right.rs index 340ff5a19..10d8e2014 100644 --- a/tests/generated/margin_auto_left_and_right.rs +++ b/tests/generated/margin_auto_left_and_right.rs @@ -4,35 +4,28 @@ fn margin_auto_left_and_right() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -40,7 +33,6 @@ fn margin_auto_left_and_right() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_and_right_column.rs b/tests/generated/margin_auto_left_and_right_column.rs index a88dacdfc..23a844687 100644 --- a/tests/generated/margin_auto_left_and_right_column.rs +++ b/tests/generated/margin_auto_left_and_right_column.rs @@ -4,44 +4,36 @@ fn margin_auto_left_and_right_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_and_right_column_and_center.rs b/tests/generated/margin_auto_left_and_right_column_and_center.rs index 3cfee4430..d80bffa7f 100644 --- a/tests/generated/margin_auto_left_and_right_column_and_center.rs +++ b/tests/generated/margin_auto_left_and_right_column_and_center.rs @@ -4,44 +4,36 @@ fn margin_auto_left_and_right_column_and_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_and_right_strech.rs b/tests/generated/margin_auto_left_and_right_strech.rs index 97a29c553..f0bb23a3c 100644 --- a/tests/generated/margin_auto_left_and_right_strech.rs +++ b/tests/generated/margin_auto_left_and_right_strech.rs @@ -4,43 +4,36 @@ fn margin_auto_left_and_right_strech() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_child_bigger_than_parent.rs index 50f40f3f5..e502b501a 100644 --- a/tests/generated/margin_auto_left_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_child_bigger_than_parent.rs @@ -4,27 +4,27 @@ fn margin_auto_left_child_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs index 071ae075c..9d3c044ac 100644 --- a/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs @@ -4,31 +4,27 @@ fn margin_auto_left_fix_right_child_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs index 9e2ace60b..dbce62d28 100644 --- a/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_auto_left_right_child_bigger_than_parent.rs @@ -4,31 +4,27 @@ fn margin_auto_left_right_child_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Auto, - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_left_stretching_child.rs b/tests/generated/margin_auto_left_stretching_child.rs index 5abd123ab..8db8fdeb3 100644 --- a/tests/generated/margin_auto_left_stretching_child.rs +++ b/tests/generated/margin_auto_left_stretching_child.rs @@ -4,38 +4,35 @@ fn margin_auto_left_stretching_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Auto, + right: zero(), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_mutiple_children_column.rs b/tests/generated/margin_auto_mutiple_children_column.rs index 1b307cad6..0c62e2519 100644 --- a/tests/generated/margin_auto_mutiple_children_column.rs +++ b/tests/generated/margin_auto_mutiple_children_column.rs @@ -4,55 +4,52 @@ fn margin_auto_mutiple_children_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_mutiple_children_row.rs b/tests/generated/margin_auto_mutiple_children_row.rs index 9ba95d9a9..21ab0f6ae 100644 --- a/tests/generated/margin_auto_mutiple_children_row.rs +++ b/tests/generated/margin_auto_mutiple_children_row.rs @@ -4,54 +4,51 @@ fn margin_auto_mutiple_children_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_right.rs b/tests/generated/margin_auto_right.rs index 18b9f6319..5321619ac 100644 --- a/tests/generated/margin_auto_right.rs +++ b/tests/generated/margin_auto_right.rs @@ -4,40 +4,36 @@ fn margin_auto_right() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { right: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_top.rs b/tests/generated/margin_auto_top.rs index df7ee5813..2a2bd1901 100644 --- a/tests/generated/margin_auto_top.rs +++ b/tests/generated/margin_auto_top.rs @@ -4,40 +4,36 @@ fn margin_auto_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_top_and_bottom_strech.rs b/tests/generated/margin_auto_top_and_bottom_strech.rs index d63120bad..3d40761ff 100644 --- a/tests/generated/margin_auto_top_and_bottom_strech.rs +++ b/tests/generated/margin_auto_top_and_bottom_strech.rs @@ -4,44 +4,37 @@ fn margin_auto_top_and_bottom_strech() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Auto, - bottom: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: taffy::style::LengthPercentageAuto::Auto, + }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, + align_items: Some(taffy::style::AlignItems::Stretch), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_auto_top_stretching_child.rs b/tests/generated/margin_auto_top_stretching_child.rs index 8af38f8c4..71dad862f 100644 --- a/tests/generated/margin_auto_top_stretching_child.rs +++ b/tests/generated/margin_auto_top_stretching_child.rs @@ -4,38 +4,35 @@ fn margin_auto_top_stretching_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - margin: taffy::geometry::Rect { top: taffy::style::LengthPercentageAuto::Auto, ..Rect::zero() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Auto, + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_bottom.rs b/tests/generated/margin_bottom.rs index 9caa80651..7a58b5e25 100644 --- a/tests/generated/margin_bottom.rs +++ b/tests/generated/margin_bottom.rs @@ -4,27 +4,25 @@ fn margin_bottom() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs index d5d805da1..4d39b1d98 100644 --- a/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs +++ b/tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs @@ -4,31 +4,27 @@ fn margin_fix_left_auto_right_child_bigger_than_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(72f32), - height: taffy::style::Dimension::Points(72f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - right: taffy::style::LengthPercentageAuto::Auto, - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(72f32), + height: taffy::style::Dimension::Points(72f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: taffy::style::LengthPercentageAuto::Auto, + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(52f32), height: taffy::style::Dimension::Points(52f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_left.rs b/tests/generated/margin_left.rs index 9429aa2ac..3e293c0ca 100644 --- a/tests/generated/margin_left.rs +++ b/tests/generated/margin_left.rs @@ -4,17 +4,16 @@ fn margin_left() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(10f32), + right: zero(), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +21,6 @@ fn margin_left() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_right.rs b/tests/generated/margin_right.rs index 11463a1a5..1d17e5e5d 100644 --- a/tests/generated/margin_right.rs +++ b/tests/generated/margin_right.rs @@ -4,26 +4,24 @@ fn margin_right() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::FlexEnd, + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_should_not_be_part_of_max_height.rs b/tests/generated/margin_should_not_be_part_of_max_height.rs index 91f13dc15..7f63d06e7 100644 --- a/tests/generated/margin_should_not_be_part_of_max_height.rs +++ b/tests/generated/margin_should_not_be_part_of_max_height.rs @@ -4,22 +4,20 @@ fn margin_should_not_be_part_of_max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +25,6 @@ fn margin_should_not_be_part_of_max_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(250f32), height: taffy::style::Dimension::Points(250f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_should_not_be_part_of_max_width.rs b/tests/generated/margin_should_not_be_part_of_max_width.rs index 508536a66..8e9772c44 100644 --- a/tests/generated/margin_should_not_be_part_of_max_width.rs +++ b/tests/generated/margin_should_not_be_part_of_max_width.rs @@ -4,22 +4,20 @@ fn margin_should_not_be_part_of_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: zero(), + top: zero(), + bottom: zero(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +25,6 @@ fn margin_should_not_be_part_of_max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(250f32), height: taffy::style::Dimension::Points(250f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_top.rs b/tests/generated/margin_top.rs index b9d323dc1..40c7b171b 100644 --- a/tests/generated/margin_top.rs +++ b/tests/generated/margin_top.rs @@ -4,17 +4,16 @@ fn margin_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: taffy::style::LengthPercentageAuto::Points(10f32), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,7 +22,6 @@ fn margin_top() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_with_sibling_column.rs b/tests/generated/margin_with_sibling_column.rs index 5a012e569..a4cdd9985 100644 --- a/tests/generated/margin_with_sibling_column.rs +++ b/tests/generated/margin_with_sibling_column.rs @@ -4,19 +4,18 @@ fn margin_with_sibling_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: zero(), + top: zero(), + bottom: taffy::style::LengthPercentageAuto::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -24,7 +23,6 @@ fn margin_with_sibling_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/margin_with_sibling_row.rs b/tests/generated/margin_with_sibling_row.rs index 3d9e15be2..d2fbc0eec 100644 --- a/tests/generated/margin_with_sibling_row.rs +++ b/tests/generated/margin_with_sibling_row.rs @@ -4,26 +4,24 @@ fn margin_with_sibling_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - margin: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + margin: taffy::geometry::Rect { + left: zero(), + right: taffy::style::LengthPercentageAuto::Points(10f32), + top: zero(), + bottom: zero(), }, - &[], - ) + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/max_height.rs b/tests/generated/max_height.rs index 2530719b9..b57695cab 100644 --- a/tests/generated/max_height.rs +++ b/tests/generated/max_height.rs @@ -4,14 +4,11 @@ fn max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -19,7 +16,6 @@ fn max_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/max_height_overrides_height.rs b/tests/generated/max_height_overrides_height.rs index 8b7aceb5f..36a1254ad 100644 --- a/tests/generated/max_height_overrides_height.rs +++ b/tests/generated/max_height_overrides_height.rs @@ -4,14 +4,11 @@ fn max_height_overrides_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/max_height_overrides_height_on_root.rs b/tests/generated/max_height_overrides_height_on_root.rs index f9056bf13..e850bd313 100644 --- a/tests/generated/max_height_overrides_height_on_root.rs +++ b/tests/generated/max_height_overrides_height_on_root.rs @@ -4,14 +4,11 @@ fn max_height_overrides_height_on_root() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/max_width.rs b/tests/generated/max_width.rs index 030eafa8f..8e8f7ef78 100644 --- a/tests/generated/max_width.rs +++ b/tests/generated/max_width.rs @@ -4,14 +4,11 @@ fn max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -20,7 +17,6 @@ fn max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/max_width_overrides_width.rs b/tests/generated/max_width_overrides_width.rs index 0582128ae..e4f59029b 100644 --- a/tests/generated/max_width_overrides_width.rs +++ b/tests/generated/max_width_overrides_width.rs @@ -4,14 +4,11 @@ fn max_width_overrides_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/max_width_overrides_width_on_root.rs b/tests/generated/max_width_overrides_width_on_root.rs index f6428d362..1c670858b 100644 --- a/tests/generated/max_width_overrides_width_on_root.rs +++ b/tests/generated/max_width_overrides_width_on_root.rs @@ -4,14 +4,11 @@ fn max_width_overrides_width_on_root() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/min_height.rs b/tests/generated/min_height.rs index 9409e3bf2..7b60b25ab 100644 --- a/tests/generated/min_height.rs +++ b/tests/generated/min_height.rs @@ -4,16 +4,13 @@ fn min_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(60f32) }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { @@ -21,7 +18,6 @@ fn min_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/min_height_overrides_height.rs b/tests/generated/min_height_overrides_height.rs index af1da80fa..bb404696e 100644 --- a/tests/generated/min_height_overrides_height.rs +++ b/tests/generated/min_height_overrides_height.rs @@ -4,14 +4,11 @@ fn min_height_overrides_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/min_height_overrides_height_on_root.rs b/tests/generated/min_height_overrides_height_on_root.rs index fe01b8e52..d295aaf18 100644 --- a/tests/generated/min_height_overrides_height_on_root.rs +++ b/tests/generated/min_height_overrides_height_on_root.rs @@ -4,14 +4,11 @@ fn min_height_overrides_height_on_root() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/min_height_overrides_max_height.rs b/tests/generated/min_height_overrides_max_height.rs index e660b4c0a..c7cd5edd0 100644 --- a/tests/generated/min_height_overrides_max_height.rs +++ b/tests/generated/min_height_overrides_max_height.rs @@ -4,14 +4,11 @@ fn min_height_overrides_max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(100f32) }, + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(50f32) }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/min_max_percent_no_width_height.rs b/tests/generated/min_max_percent_no_width_height.rs index e9aaee2d3..312f08559 100644 --- a/tests/generated/min_max_percent_no_width_height.rs +++ b/tests/generated/min_max_percent_no_width_height.rs @@ -4,32 +4,26 @@ fn min_max_percent_no_width_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.1f32), - height: taffy::style::Dimension::Percent(0.1f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), }, - &[], - ) + max_size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.1f32), + height: taffy::style::Dimension::Percent(0.1f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/min_width.rs b/tests/generated/min_width.rs index 34ac93bd7..46d1c6b54 100644 --- a/tests/generated/min_width.rs +++ b/tests/generated/min_width.rs @@ -4,23 +4,19 @@ fn min_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() }, + ..Default::default() + }) .unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/min_width_overrides_max_width.rs b/tests/generated/min_width_overrides_max_width.rs index e06216523..052a4b5d5 100644 --- a/tests/generated/min_width_overrides_max_width.rs +++ b/tests/generated/min_width_overrides_max_width.rs @@ -4,14 +4,11 @@ fn min_width_overrides_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/min_width_overrides_width.rs b/tests/generated/min_width_overrides_width.rs index 3a04fa161..651eaaacf 100644 --- a/tests/generated/min_width_overrides_width.rs +++ b/tests/generated/min_width_overrides_width.rs @@ -4,14 +4,11 @@ fn min_width_overrides_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/min_width_overrides_width_on_root.rs b/tests/generated/min_width_overrides_width_on_root.rs index 9d27f8f5f..bd3999a18 100644 --- a/tests/generated/min_width_overrides_width_on_root.rs +++ b/tests/generated/min_width_overrides_width_on_root.rs @@ -4,14 +4,11 @@ fn min_width_overrides_width_on_root() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Size::auto() }, - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs index 5e0a9186c..1e21b06bb 100644 --- a/tests/generated/mod.rs +++ b/tests/generated/mod.rs @@ -1,3 +1,45 @@ +#[allow(dead_code)] +fn measure_standard_text( + known_dimensions: taffy::geometry::Size>, + available_space: taffy::geometry::Size, + text_content: &str, +) -> taffy::geometry::Size { + use taffy::prelude::*; + const ZWS: char = '\u{200B}'; + const H_WIDTH: f32 = 10.0; + const H_HEIGHT: f32 = 10.0; + if let Size { width: Some(width), height: Some(height) } = known_dimensions { + return Size { width, height }; + } + let lines: Vec<&str> = text_content.split(ZWS).collect(); + if lines.is_empty() { + return Size::ZERO; + } + let min_line_length: usize = lines.iter().map(|line| line.len()).max().unwrap_or(0); + let max_line_length: usize = lines.iter().map(|line| line.len()).sum(); + let width = known_dimensions.width.unwrap_or_else(|| match available_space.width { + AvailableSpace::MinContent => min_line_length as f32 * H_WIDTH, + AvailableSpace::MaxContent => max_line_length as f32 * H_WIDTH, + AvailableSpace::Definite(width) => { + width.min(max_line_length as f32 * H_WIDTH).max(min_line_length as f32 * H_WIDTH) + } + }); + let height = known_dimensions.height.unwrap_or_else(|| { + let width_line_length = (width / H_WIDTH).floor() as usize; + let mut line_count = 1; + let mut current_line_length = 0; + for line in &lines { + if current_line_length + line.len() > width_line_length { + line_count += 1; + current_line_length = line.len(); + } else { + current_line_length += line.len(); + }; + } + (line_count as f32) * H_HEIGHT + }); + Size { width, height } +} mod absolute_layout_align_items_and_justify_content_center; mod absolute_layout_align_items_and_justify_content_center_and_bottom_position; mod absolute_layout_align_items_and_justify_content_center_and_left_position; @@ -139,6 +181,206 @@ mod gap_row_gap_align_items_stretch; mod gap_row_gap_column_child_margins; mod gap_row_gap_determines_parent_height; mod gap_row_gap_row_wrap_child_margins; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_align_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_column_end; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_column_start; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_bottom_left; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_bottom_left_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_overrides_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_left_right_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_negative_position; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_negative_position_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_bottom; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_bottom_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_right; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_container_top_right_margin; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_justify_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_row_end; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_row_start; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_top_overrides_bottom; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_with_padding; +#[cfg(feature = "experimental_grid")] +mod grid_absolute_with_padding_and_margin; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_center; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_end; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_end_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_around; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_around_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_between; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_between_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_evenly; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_space_evenly_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_start; +#[cfg(feature = "experimental_grid")] +mod grid_align_content_start_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_center; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_end; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_start; +#[cfg(feature = "experimental_grid")] +mod grid_align_items_sized_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_align_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_auto_columns_fixed_width; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fill_fixed_size; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fill_with_empty_auto_track; +#[cfg(feature = "experimental_grid")] +mod grid_auto_fit_with_empty_auto_track; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item_fixed_width; +#[cfg(feature = "experimental_grid")] +mod grid_auto_single_item_fixed_width_with_definite_width; +#[cfg(feature = "experimental_grid")] +mod grid_basic; +#[cfg(feature = "experimental_grid")] +mod grid_basic_implicit_tracks; +#[cfg(feature = "experimental_grid")] +mod grid_basic_with_overflow; +#[cfg(feature = "experimental_grid")] +mod grid_basic_with_padding; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_argument; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_max_content; +#[cfg(feature = "experimental_grid")] +mod grid_fit_content_points_min_content; +#[cfg(feature = "experimental_grid")] +mod grid_fr_auto_no_sized_items; +#[cfg(feature = "experimental_grid")] +mod grid_fr_auto_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_fr_fixed_size_no_content; +#[cfg(feature = "experimental_grid")] +mod grid_fr_fixed_size_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_gap; +#[cfg(feature = "experimental_grid")] +mod grid_hidden; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_center; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_center_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_end; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_end_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_around; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_around_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_between; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_between_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_evenly; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_space_evenly_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_start; +#[cfg(feature = "experimental_grid")] +mod grid_justify_content_start_with_padding_border; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_center; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_end; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_start; +#[cfg(feature = "experimental_grid")] +mod grid_justify_items_sized_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_justify_self_sized_all; +#[cfg(feature = "experimental_grid")] +mod grid_margins_auto_margins; +#[cfg(feature = "experimental_grid")] +mod grid_margins_auto_margins_override_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_center; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_end; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_start; +#[cfg(feature = "experimental_grid")] +mod grid_margins_fixed_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_center; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_end; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_start; +#[cfg(feature = "experimental_grid")] +mod grid_margins_percent_stretch; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_maximum_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_auto; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_fixed; +#[cfg(feature = "experimental_grid")] +mod grid_max_content_single_item_margin_percent; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_auto; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_fixed; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_flex_single_item_margin_percent; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_maximum_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_content_single_item; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_auto; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_above_range; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_below_range; +#[cfg(feature = "experimental_grid")] +mod grid_min_max_column_fixed_width_within_range; +#[cfg(feature = "experimental_grid")] +mod grid_out_of_order_items; +#[cfg(feature = "experimental_grid")] +mod grid_size_child_fixed_tracks; mod justify_content_column_center; mod justify_content_column_flex_end; mod justify_content_column_flex_start; diff --git a/tests/generated/nested_overflowing_child.rs b/tests/generated/nested_overflowing_child.rs index 8fd8080a1..5a1a8796e 100644 --- a/tests/generated/nested_overflowing_child.rs +++ b/tests/generated/nested_overflowing_child.rs @@ -4,17 +4,13 @@ fn nested_overflowing_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy @@ -23,7 +19,6 @@ fn nested_overflowing_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/nested_overflowing_child_in_constraint_parent.rs b/tests/generated/nested_overflowing_child_in_constraint_parent.rs index 55d1a8f0d..601187529 100644 --- a/tests/generated/nested_overflowing_child_in_constraint_parent.rs +++ b/tests/generated/nested_overflowing_child_in_constraint_parent.rs @@ -4,17 +4,13 @@ fn nested_overflowing_child_in_constraint_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -22,7 +18,6 @@ fn nested_overflowing_child_in_constraint_parent() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, @@ -35,7 +30,6 @@ fn nested_overflowing_child_in_constraint_parent() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/overflow_cross_axis.rs b/tests/generated/overflow_cross_axis.rs index 60b2a763d..7c05749ff 100644 --- a/tests/generated/overflow_cross_axis.rs +++ b/tests/generated/overflow_cross_axis.rs @@ -4,17 +4,13 @@ fn overflow_cross_axis() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +18,6 @@ fn overflow_cross_axis() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/overflow_main_axis.rs b/tests/generated/overflow_main_axis.rs index f8c47a687..41d48e060 100644 --- a/tests/generated/overflow_main_axis.rs +++ b/tests/generated/overflow_main_axis.rs @@ -4,14 +4,11 @@ fn overflow_main_axis() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 0f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 0f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -19,7 +16,6 @@ fn overflow_main_axis() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/padding_align_end_child.rs b/tests/generated/padding_align_end_child.rs index d0f929e16..62edca598 100644 --- a/tests/generated/padding_align_end_child.rs +++ b/tests/generated/padding_align_end_child.rs @@ -4,34 +4,28 @@ fn padding_align_end_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(20f32), - right: taffy::style::LengthPercentage::Points(20f32), - top: taffy::style::LengthPercentage::Points(20f32), - bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(20f32), + right: taffy::style::LengthPercentage::Points(20f32), + top: taffy::style::LengthPercentage::Points(20f32), + bottom: taffy::style::LengthPercentage::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::FlexEnd, - justify_content: taffy::style::JustifyContent::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), + justify_content: Some(taffy::style::JustifyContent::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/padding_center_child.rs b/tests/generated/padding_center_child.rs index 10cdab879..85df24f89 100644 --- a/tests/generated/padding_center_child.rs +++ b/tests/generated/padding_center_child.rs @@ -4,34 +4,28 @@ fn padding_center_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(20f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/padding_flex_child.rs b/tests/generated/padding_flex_child.rs index e7f49d3cc..46557ec6a 100644 --- a/tests/generated/padding_flex_child.rs +++ b/tests/generated/padding_flex_child.rs @@ -4,14 +4,11 @@ fn padding_flex_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -19,14 +16,12 @@ fn padding_flex_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/padding_no_child.rs b/tests/generated/padding_no_child.rs index 29a49851e..06f170d1a 100644 --- a/tests/generated/padding_no_child.rs +++ b/tests/generated/padding_no_child.rs @@ -4,19 +4,15 @@ fn padding_no_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node = taffy - .new_with_children( - taffy::style::Style { - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(10f32), - right: taffy::style::LengthPercentage::Points(10f32), - top: taffy::style::LengthPercentage::Points(10f32), - bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(10f32), + right: taffy::style::LengthPercentage::Points(10f32), + top: taffy::style::LengthPercentage::Points(10f32), + bottom: taffy::style::LengthPercentage::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); println!("\nComputed tree:"); diff --git a/tests/generated/padding_stretch_child.rs b/tests/generated/padding_stretch_child.rs index 7320c7631..5210e98dc 100644 --- a/tests/generated/padding_stretch_child.rs +++ b/tests/generated/padding_stretch_child.rs @@ -4,13 +4,10 @@ fn padding_stretch_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -18,14 +15,12 @@ fn padding_stretch_child() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(10f32), right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/parent_wrap_child_size_overflowing_parent.rs b/tests/generated/parent_wrap_child_size_overflowing_parent.rs index bdd87ccda..d8ee3c87c 100644 --- a/tests/generated/parent_wrap_child_size_overflowing_parent.rs +++ b/tests/generated/parent_wrap_child_size_overflowing_parent.rs @@ -4,22 +4,18 @@ fn parent_wrap_child_size_overflowing_parent() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node00], @@ -31,7 +27,6 @@ fn parent_wrap_child_size_overflowing_parent() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percent_absolute_position.rs b/tests/generated/percent_absolute_position.rs index 0c55ad91b..03d621a48 100644 --- a/tests/generated/percent_absolute_position.rs +++ b/tests/generated/percent_absolute_position.rs @@ -4,22 +4,16 @@ fn percent_absolute_position() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -28,11 +22,12 @@ fn percent_absolute_position() { size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, position: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Percent(0.5f32), - ..Rect::auto() + right: auto(), + top: auto(), + bottom: auto(), }, ..Default::default() }, @@ -46,7 +41,6 @@ fn percent_absolute_position() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: taffy::style::Dimension::Points(50f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percent_within_flex_grow.rs b/tests/generated/percent_within_flex_grow.rs index ce6c240f9..d81a4ff4c 100644 --- a/tests/generated/percent_within_flex_grow.rs +++ b/tests/generated/percent_within_flex_grow.rs @@ -4,22 +4,16 @@ fn percent_within_flex_grow() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( @@ -32,13 +26,10 @@ fn percent_within_flex_grow() { ) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -46,7 +37,6 @@ fn percent_within_flex_grow() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(350f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_absolute_position.rs b/tests/generated/percentage_absolute_position.rs index 549fd8e2c..818b99a43 100644 --- a/tests/generated/percentage_absolute_position.rs +++ b/tests/generated/percentage_absolute_position.rs @@ -4,23 +4,20 @@ fn percentage_absolute_position() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - position_type: taffy::style::PositionType::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.3f32), - top: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + position_type: taffy::style::PositionType::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.3f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.1f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -29,7 +26,6 @@ fn percentage_absolute_position() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_container_in_wrapping_container.rs b/tests/generated/percentage_container_in_wrapping_container.rs index 8477bb6d8..4633c6e2a 100644 --- a/tests/generated/percentage_container_in_wrapping_container.rs +++ b/tests/generated/percentage_container_in_wrapping_container.rs @@ -4,36 +4,28 @@ fn percentage_container_in_wrapping_container() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node001 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(50f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(50f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { - justify_content: taffy::style::JustifyContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Size::auto() }, + justify_content: Some(taffy::style::JustifyContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() }, ..Default::default() }, &[node000, node001], @@ -49,12 +41,11 @@ fn percentage_container_in_wrapping_container() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis.rs b/tests/generated/percentage_flex_basis.rs index 92f445004..924ac7a1b 100644 --- a/tests/generated/percentage_flex_basis.rs +++ b/tests/generated/percentage_flex_basis.rs @@ -4,24 +4,18 @@ fn percentage_flex_basis() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -29,7 +23,6 @@ fn percentage_flex_basis() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_cross.rs b/tests/generated/percentage_flex_basis_cross.rs index e9dfb35c8..fdefc0b5f 100644 --- a/tests/generated/percentage_flex_basis_cross.rs +++ b/tests/generated/percentage_flex_basis_cross.rs @@ -4,24 +4,18 @@ fn percentage_flex_basis_cross() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.5f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.5f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.25f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.25f32), + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +24,6 @@ fn percentage_flex_basis_cross() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_cross_max_height.rs b/tests/generated/percentage_flex_basis_cross_max_height.rs index 3f02bf289..e9e6124ae 100644 --- a/tests/generated/percentage_flex_basis_cross_max_height.rs +++ b/tests/generated/percentage_flex_basis_cross_max_height.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_cross_max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -32,7 +26,6 @@ fn percentage_flex_basis_cross_max_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_cross_max_width.rs b/tests/generated/percentage_flex_basis_cross_max_width.rs index 20e0d8d0a..d5fda49fc 100644 --- a/tests/generated/percentage_flex_basis_cross_max_width.rs +++ b/tests/generated/percentage_flex_basis_cross_max_width.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_cross_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -32,7 +26,6 @@ fn percentage_flex_basis_cross_max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_cross_min_height.rs b/tests/generated/percentage_flex_basis_cross_min_height.rs index a17261924..6efdd0606 100644 --- a/tests/generated/percentage_flex_basis_cross_min_height.rs +++ b/tests/generated/percentage_flex_basis_cross_min_height.rs @@ -4,24 +4,18 @@ fn percentage_flex_basis_cross_min_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 2f32, - min_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.1f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 2f32, + min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.1f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -30,7 +24,6 @@ fn percentage_flex_basis_cross_min_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_cross_min_width.rs b/tests/generated/percentage_flex_basis_cross_min_width.rs index e46102b0c..601de7c9d 100644 --- a/tests/generated/percentage_flex_basis_cross_min_width.rs +++ b/tests/generated/percentage_flex_basis_cross_min_width.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_cross_min_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -32,7 +26,6 @@ fn percentage_flex_basis_cross_min_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_main_max_height.rs b/tests/generated/percentage_flex_basis_main_max_height.rs index 49562df76..561b9a772 100644 --- a/tests/generated/percentage_flex_basis_main_max_height.rs +++ b/tests/generated/percentage_flex_basis_main_max_height.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_main_max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.6f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(0.2f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ fn percentage_flex_basis_main_max_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_main_max_width.rs b/tests/generated/percentage_flex_basis_main_max_width.rs index d4fca7bc3..8fed74117 100644 --- a/tests/generated/percentage_flex_basis_main_max_width.rs +++ b/tests/generated/percentage_flex_basis_main_max_width.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_main_max_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + max_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ fn percentage_flex_basis_main_max_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_flex_basis_main_min_width.rs b/tests/generated/percentage_flex_basis_main_min_width.rs index 04da65f83..c41112e32 100644 --- a/tests/generated/percentage_flex_basis_main_min_width.rs +++ b/tests/generated/percentage_flex_basis_main_min_width.rs @@ -4,26 +4,20 @@ fn percentage_flex_basis_main_min_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.1f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +25,6 @@ fn percentage_flex_basis_main_min_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs index 88ca693cb..677f4cfc1 100644 --- a/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs +++ b/tests/generated/percentage_margin_should_calculate_based_only_on_width.rs @@ -4,17 +4,13 @@ fn percentage_margin_should_calculate_based_only_on_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -26,7 +22,6 @@ fn percentage_margin_should_calculate_based_only_on_width() { right: taffy::style::LengthPercentageAuto::Percent(0.1f32), top: taffy::style::LengthPercentageAuto::Percent(0.1f32), bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::zero() }, ..Default::default() }, @@ -40,7 +35,6 @@ fn percentage_margin_should_calculate_based_only_on_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs index 3a1edfc14..40161b6d7 100644 --- a/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs +++ b/tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs @@ -4,46 +4,39 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), ..Size::auto() }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.05f32), - right: taffy::style::LengthPercentageAuto::Percent(0.05f32), - top: taffy::style::LengthPercentageAuto::Percent(0.05f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), - ..Rect::zero() - }, - padding: taffy::geometry::Rect { - left: taffy::style::LengthPercentage::Points(3f32), - right: taffy::style::LengthPercentage::Points(3f32), - top: taffy::style::LengthPercentage::Points(3f32), - bottom: taffy::style::LengthPercentage::Points(3f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.45f32), height: auto() }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.05f32), + right: taffy::style::LengthPercentageAuto::Percent(0.05f32), + top: taffy::style::LengthPercentageAuto::Percent(0.05f32), + bottom: taffy::style::LengthPercentageAuto::Percent(0.05f32), }, - &[], - ) + padding: taffy::geometry::Rect { + left: taffy::style::LengthPercentage::Points(3f32), + right: taffy::style::LengthPercentage::Points(3f32), + top: taffy::style::LengthPercentage::Points(3f32), + bottom: taffy::style::LengthPercentage::Points(3f32), + }, + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.5f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Points(5f32), right: taffy::style::LengthPercentageAuto::Points(5f32), top: taffy::style::LengthPercentageAuto::Points(5f32), bottom: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::zero() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Percent(0.03f32), right: taffy::style::LengthPercentage::Percent(0.03f32), top: taffy::style::LengthPercentage::Percent(0.03f32), bottom: taffy::style::LengthPercentage::Percent(0.03f32), - ..Rect::zero() }, ..Default::default() }, @@ -56,20 +49,18 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, flex_basis: taffy::style::Dimension::Percent(0.1f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), ..Size::auto() }, + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.6f32), height: auto() }, margin: taffy::geometry::Rect { left: taffy::style::LengthPercentageAuto::Points(5f32), right: taffy::style::LengthPercentageAuto::Points(5f32), top: taffy::style::LengthPercentageAuto::Points(5f32), bottom: taffy::style::LengthPercentageAuto::Points(5f32), - ..Rect::zero() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(3f32), right: taffy::style::LengthPercentage::Points(3f32), top: taffy::style::LengthPercentage::Points(3f32), bottom: taffy::style::LengthPercentage::Points(3f32), - ..Rect::zero() }, ..Default::default() }, @@ -77,15 +68,12 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Percent(0.15f32), - min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Percent(0.15f32), + min_size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(0.2f32), height: auto() }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -94,7 +82,6 @@ fn percentage_multiple_nested_with_padding_margin_and_percentage_values() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs index 27a06c035..98ddc9b2b 100644 --- a/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs +++ b/tests/generated/percentage_padding_should_calculate_based_only_on_width.rs @@ -4,17 +4,13 @@ fn percentage_padding_should_calculate_based_only_on_width() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -26,7 +22,6 @@ fn percentage_padding_should_calculate_based_only_on_width() { right: taffy::style::LengthPercentage::Percent(0.1f32), top: taffy::style::LengthPercentage::Percent(0.1f32), bottom: taffy::style::LengthPercentage::Percent(0.1f32), - ..Rect::zero() }, ..Default::default() }, @@ -40,7 +35,6 @@ fn percentage_padding_should_calculate_based_only_on_width() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_position_bottom_right.rs b/tests/generated/percentage_position_bottom_right.rs index 43d687011..529aad46b 100644 --- a/tests/generated/percentage_position_bottom_right.rs +++ b/tests/generated/percentage_position_bottom_right.rs @@ -4,22 +4,19 @@ fn percentage_position_bottom_right() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.55f32), - height: taffy::style::Dimension::Percent(0.15f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - right: taffy::style::LengthPercentageAuto::Percent(0.2f32), - bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.55f32), + height: taffy::style::Dimension::Percent(0.15f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: auto(), + right: taffy::style::LengthPercentageAuto::Percent(0.2f32), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Percent(0.1f32), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +24,6 @@ fn percentage_position_bottom_right() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_position_left_top.rs b/tests/generated/percentage_position_left_top.rs index 58d0ae022..bbbcd55ce 100644 --- a/tests/generated/percentage_position_left_top.rs +++ b/tests/generated/percentage_position_left_top.rs @@ -4,22 +4,19 @@ fn percentage_position_left_top() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.45f32), - height: taffy::style::Dimension::Percent(0.55f32), - ..Size::auto() - }, - position: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Percent(0.1f32), - top: taffy::style::LengthPercentageAuto::Percent(0.2f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.45f32), + height: taffy::style::Dimension::Percent(0.55f32), }, - &[], - ) + position: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Percent(0.1f32), + right: auto(), + top: taffy::style::LengthPercentageAuto::Percent(0.2f32), + bottom: auto(), + }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -27,7 +24,6 @@ fn percentage_position_left_top() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_size_based_on_parent_inner_size.rs b/tests/generated/percentage_size_based_on_parent_inner_size.rs index 2820097d8..a581f59cb 100644 --- a/tests/generated/percentage_size_based_on_parent_inner_size.rs +++ b/tests/generated/percentage_size_based_on_parent_inner_size.rs @@ -4,17 +4,13 @@ fn percentage_size_based_on_parent_inner_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -23,14 +19,12 @@ fn percentage_size_based_on_parent_inner_size() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, padding: taffy::geometry::Rect { left: taffy::style::LengthPercentage::Points(20f32), right: taffy::style::LengthPercentage::Points(20f32), top: taffy::style::LengthPercentage::Points(20f32), bottom: taffy::style::LengthPercentage::Points(20f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/percentage_size_of_flex_basis.rs b/tests/generated/percentage_size_of_flex_basis.rs index d8414628f..3dd4485ca 100644 --- a/tests/generated/percentage_size_of_flex_basis.rs +++ b/tests/generated/percentage_size_of_flex_basis.rs @@ -4,17 +4,13 @@ fn percentage_size_of_flex_basis() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(1f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(1f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -25,7 +21,7 @@ fn percentage_size_of_flex_basis() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0], diff --git a/tests/generated/percentage_width_height.rs b/tests/generated/percentage_width_height.rs index 49616baab..dbe9c8166 100644 --- a/tests/generated/percentage_width_height.rs +++ b/tests/generated/percentage_width_height.rs @@ -4,17 +4,13 @@ fn percentage_width_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.3f32), - height: taffy::style::Dimension::Percent(0.3f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.3f32), + height: taffy::style::Dimension::Percent(0.3f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -22,7 +18,6 @@ fn percentage_width_height() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(400f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/percentage_width_height_undefined_parent_size.rs b/tests/generated/percentage_width_height_undefined_parent_size.rs index f56f23642..79ee652e3 100644 --- a/tests/generated/percentage_width_height_undefined_parent_size.rs +++ b/tests/generated/percentage_width_height_undefined_parent_size.rs @@ -4,17 +4,13 @@ fn percentage_width_height_undefined_parent_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Percent(0.5f32), - height: taffy::style::Dimension::Percent(0.5f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Percent(0.5f32), + height: taffy::style::Dimension::Percent(0.5f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( diff --git a/tests/generated/relative_position_should_not_nudge_siblings.rs b/tests/generated/relative_position_should_not_nudge_siblings.rs index aa83d7cd3..2c8e8de36 100644 --- a/tests/generated/relative_position_should_not_nudge_siblings.rs +++ b/tests/generated/relative_position_should_not_nudge_siblings.rs @@ -4,30 +4,28 @@ fn relative_position_should_not_nudge_siblings() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(15f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(15f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -36,7 +34,6 @@ fn relative_position_should_not_nudge_siblings() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs index b1909a9ee..7810293a2 100644 --- a/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs +++ b/tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs @@ -3,18 +3,17 @@ fn rounding_flex_basis_flex_grow_row_prime_number_width() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node2 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node3 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node4 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node3 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node4 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(113f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs index 80cce3f03..29ec8ee8b 100644 --- a/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs +++ b/tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs @@ -3,16 +3,15 @@ fn rounding_flex_basis_flex_grow_row_width_of_100() { #[allow(unused_imports)] use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); - let node0 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node1 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); - let node2 = taffy.new_with_children(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap(); + let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node1 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); + let node2 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap(); let node = taffy .new_with_children( taffy::style::Style { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_flex_basis_flex_shrink_row.rs b/tests/generated/rounding_flex_basis_flex_shrink_row.rs index dc67db524..ecabcd902 100644 --- a/tests/generated/rounding_flex_basis_flex_shrink_row.rs +++ b/tests/generated/rounding_flex_basis_flex_shrink_row.rs @@ -4,26 +4,17 @@ fn rounding_flex_basis_flex_shrink_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Points(100f32), - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Points(100f32), + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }, - &[], - ) + .new_leaf(taffy::style::Style { flex_basis: taffy::style::Dimension::Points(25f32), ..Default::default() }) .unwrap(); let node = taffy .new_with_children( @@ -31,7 +22,6 @@ fn rounding_flex_basis_flex_shrink_row() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(101f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_flex_basis_overrides_main_size.rs b/tests/generated/rounding_flex_basis_overrides_main_size.rs index 6a334218a..61c583098 100644 --- a/tests/generated/rounding_flex_basis_overrides_main_size.rs +++ b/tests/generated/rounding_flex_basis_overrides_main_size.rs @@ -4,35 +4,26 @@ fn rounding_flex_basis_overrides_main_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_flex_basis_overrides_main_size() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_fractial_input_1.rs b/tests/generated/rounding_fractial_input_1.rs index 6d7db5a1a..d8f1575ae 100644 --- a/tests/generated/rounding_fractial_input_1.rs +++ b/tests/generated/rounding_fractial_input_1.rs @@ -4,35 +4,26 @@ fn rounding_fractial_input_1() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_fractial_input_1() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_fractial_input_2.rs b/tests/generated/rounding_fractial_input_2.rs index 14240650b..4792e87fc 100644 --- a/tests/generated/rounding_fractial_input_2.rs +++ b/tests/generated/rounding_fractial_input_2.rs @@ -4,35 +4,26 @@ fn rounding_fractial_input_2() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_fractial_input_2() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.6f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_fractial_input_3.rs b/tests/generated/rounding_fractial_input_3.rs index 6738314d7..d2b251ea5 100644 --- a/tests/generated/rounding_fractial_input_3.rs +++ b/tests/generated/rounding_fractial_input_3.rs @@ -4,35 +4,26 @@ fn rounding_fractial_input_3() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_fractial_input_3() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_fractial_input_4.rs b/tests/generated/rounding_fractial_input_4.rs index 9a2a2b804..260143647 100644 --- a/tests/generated/rounding_fractial_input_4.rs +++ b/tests/generated/rounding_fractial_input_4.rs @@ -4,35 +4,26 @@ fn rounding_fractial_input_4() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(50f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(50f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_fractial_input_4() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_total_fractial.rs b/tests/generated/rounding_total_fractial.rs index 11a8fca73..f9e5e2386 100644 --- a/tests/generated/rounding_total_fractial.rs +++ b/tests/generated/rounding_total_fractial.rs @@ -4,35 +4,26 @@ fn rounding_total_fractial() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 0.7f32, - flex_basis: taffy::style::Dimension::Points(50.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 0.7f32, + flex_basis: taffy::style::Dimension::Points(50.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20.3f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10.7f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -41,7 +32,6 @@ fn rounding_total_fractial() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(87.4f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/rounding_total_fractial_nested.rs b/tests/generated/rounding_total_fractial_nested.rs index e8f3e1d35..0c1c7d8ae 100644 --- a/tests/generated/rounding_total_fractial_nested.rs +++ b/tests/generated/rounding_total_fractial_nested.rs @@ -4,34 +4,32 @@ fn rounding_total_fractial_nested() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_basis: taffy::style::Dimension::Points(0.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(9.9f32), ..Size::auto() }, - position: taffy::geometry::Rect { - bottom: taffy::style::LengthPercentageAuto::Points(13.3f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(9.9f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: auto(), + bottom: taffy::style::LengthPercentageAuto::Points(13.3f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 4f32, - flex_basis: taffy::style::Dimension::Points(0.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(1.1f32), ..Size::auto() }, - position: taffy::geometry::Rect { - top: taffy::style::LengthPercentageAuto::Points(13.3f32), - ..Rect::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 4f32, + flex_basis: taffy::style::Dimension::Points(0.3f32), + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(1.1f32) }, + position: taffy::geometry::Rect { + left: auto(), + right: auto(), + top: taffy::style::LengthPercentageAuto::Points(13.3f32), + bottom: auto(), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -39,31 +37,25 @@ fn rounding_total_fractial_nested() { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 0.7f32, flex_basis: taffy::style::Dimension::Points(50.3f32), - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Size::auto() }, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20.3f32) }, ..Default::default() }, &[node00, node01], ) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.6f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.6f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1.1f32, - size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Size::auto() }, - ..Default::default() - }, - &[], - ) + .new_leaf(taffy::style::Style { + flex_grow: 1.1f32, + size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10.7f32) }, + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -72,7 +64,6 @@ fn rounding_total_fractial_nested() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(87.4f32), height: taffy::style::Dimension::Points(113.4f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/size_defined_by_child.rs b/tests/generated/size_defined_by_child.rs index 135e3b509..1e140678e 100644 --- a/tests/generated/size_defined_by_child.rs +++ b/tests/generated/size_defined_by_child.rs @@ -4,17 +4,13 @@ fn size_defined_by_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap(); diff --git a/tests/generated/size_defined_by_child_with_border.rs b/tests/generated/size_defined_by_child_with_border.rs index 78f10c3b0..daeb7333a 100644 --- a/tests/generated/size_defined_by_child_with_border.rs +++ b/tests/generated/size_defined_by_child_with_border.rs @@ -4,17 +4,13 @@ fn size_defined_by_child_with_border() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ fn size_defined_by_child_with_border() { right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/size_defined_by_child_with_padding.rs b/tests/generated/size_defined_by_child_with_padding.rs index 763f08c7a..28a1487cd 100644 --- a/tests/generated/size_defined_by_child_with_padding.rs +++ b/tests/generated/size_defined_by_child_with_padding.rs @@ -4,17 +4,13 @@ fn size_defined_by_child_with_padding() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(10f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(10f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -24,7 +20,6 @@ fn size_defined_by_child_with_padding() { right: taffy::style::LengthPercentage::Points(10f32), top: taffy::style::LengthPercentage::Points(10f32), bottom: taffy::style::LengthPercentage::Points(10f32), - ..Rect::zero() }, ..Default::default() }, diff --git a/tests/generated/size_defined_by_grand_child.rs b/tests/generated/size_defined_by_grand_child.rs index b2182c4e0..e1ecb4661 100644 --- a/tests/generated/size_defined_by_grand_child.rs +++ b/tests/generated/size_defined_by_grand_child.rs @@ -4,17 +4,13 @@ fn size_defined_by_grand_child() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap(); let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap(); diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs index 36322f1ce..2fea50d46 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs @@ -4,48 +4,40 @@ fn width_smaller_then_content_with_flex_grow_large_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -54,7 +46,7 @@ fn width_smaller_then_content_with_flex_grow_large_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs index 7b43ccc18..e7e9d77ce 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs @@ -4,48 +4,40 @@ fn width_smaller_then_content_with_flex_grow_small_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -54,7 +46,7 @@ fn width_smaller_then_content_with_flex_grow_small_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs index 6270a02df..8efbcf0b3 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs @@ -4,48 +4,40 @@ fn width_smaller_then_content_with_flex_grow_unconstraint_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], diff --git a/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs index 4f24585b3..05a5a9dba 100644 --- a/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs +++ b/tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs @@ -4,48 +4,40 @@ fn width_smaller_then_content_with_flex_grow_very_large_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(70f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(70f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node00], ) .unwrap(); let node10 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(20f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(20f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_grow: 1f32, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(0f32), height: auto() }, ..Default::default() }, &[node10], @@ -54,7 +46,7 @@ fn width_smaller_then_content_with_flex_grow_very_large_size() { let node = taffy .new_with_children( taffy::style::Style { - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: auto() }, ..Default::default() }, &[node0, node1], diff --git a/tests/generated/wrap_column.rs b/tests/generated/wrap_column.rs index dc853278c..6d05f0184 100644 --- a/tests/generated/wrap_column.rs +++ b/tests/generated/wrap_column.rs @@ -4,56 +4,40 @@ fn wrap_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(31f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(32f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(33f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(34f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -63,7 +47,6 @@ fn wrap_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs index a481c46ef..e99dfcc24 100644 --- a/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs +++ b/tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs @@ -4,17 +4,13 @@ fn wrap_nodes_with_content_sizing_margin_cross() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( @@ -23,25 +19,23 @@ fn wrap_nodes_with_content_sizing_margin_cross() { ) .unwrap(); let node010 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, margin: taffy::geometry::Rect { + left: zero(), + right: zero(), top: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() + bottom: zero(), }, ..Default::default() }, @@ -52,7 +46,7 @@ fn wrap_nodes_with_content_sizing_margin_cross() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(70f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -65,7 +59,6 @@ fn wrap_nodes_with_content_sizing_margin_cross() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs index daaa1c5d3..eebfa3eba 100644 --- a/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs +++ b/tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs @@ -4,17 +4,13 @@ fn wrap_nodes_with_content_sizing_overflowing_margin() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node000 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node00 = taffy .new_with_children( @@ -23,25 +19,23 @@ fn wrap_nodes_with_content_sizing_overflowing_margin() { ) .unwrap(); let node010 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(40f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(40f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, margin: taffy::geometry::Rect { + left: zero(), right: taffy::style::LengthPercentageAuto::Points(10f32), - ..Rect::zero() + top: zero(), + bottom: zero(), }, ..Default::default() }, @@ -52,7 +46,7 @@ fn wrap_nodes_with_content_sizing_overflowing_margin() { .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(85f32), height: auto() }, ..Default::default() }, &[node00, node01], @@ -65,7 +59,6 @@ fn wrap_nodes_with_content_sizing_overflowing_margin() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(500f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrap_reverse_column.rs b/tests/generated/wrap_reverse_column.rs index ca309237a..99e0e471d 100644 --- a/tests/generated/wrap_reverse_column.rs +++ b/tests/generated/wrap_reverse_column.rs @@ -4,56 +4,40 @@ fn wrap_reverse_column() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(31f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(31f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(32f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(32f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(33f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(33f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(34f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(34f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( @@ -63,7 +47,6 @@ fn wrap_reverse_column() { size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrap_reverse_column_fixed_size.rs b/tests/generated/wrap_reverse_column_fixed_size.rs index 3c0aa9dfd..9cf0f3511 100644 --- a/tests/generated/wrap_reverse_column_fixed_size.rs +++ b/tests/generated/wrap_reverse_column_fixed_size.rs @@ -4,80 +4,59 @@ fn wrap_reverse_column_fixed_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(100f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrap_reverse_row.rs b/tests/generated/wrap_reverse_row.rs index ac5bbc569..b9f4e146d 100644 --- a/tests/generated/wrap_reverse_row.rs +++ b/tests/generated/wrap_reverse_row.rs @@ -4,62 +4,46 @@ fn wrap_reverse_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(31f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(32f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(33f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(34f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/tests/generated/wrap_reverse_row_align_content_center.rs b/tests/generated/wrap_reverse_row_align_content_center.rs index b5939f7cf..b5323dce8 100644 --- a/tests/generated/wrap_reverse_row_align_content_center.rs +++ b/tests/generated/wrap_reverse_row_align_content_center.rs @@ -4,76 +4,56 @@ fn wrap_reverse_row_align_content_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/tests/generated/wrap_reverse_row_align_content_flex_start.rs b/tests/generated/wrap_reverse_row_align_content_flex_start.rs index b4a8c871b..d33bdb251 100644 --- a/tests/generated/wrap_reverse_row_align_content_flex_start.rs +++ b/tests/generated/wrap_reverse_row_align_content_flex_start.rs @@ -4,76 +4,56 @@ fn wrap_reverse_row_align_content_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::FlexStart, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/tests/generated/wrap_reverse_row_align_content_space_around.rs b/tests/generated/wrap_reverse_row_align_content_space_around.rs index b508dc918..18ccd8c16 100644 --- a/tests/generated/wrap_reverse_row_align_content_space_around.rs +++ b/tests/generated/wrap_reverse_row_align_content_space_around.rs @@ -4,76 +4,56 @@ fn wrap_reverse_row_align_content_space_around() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::SpaceAround, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::SpaceAround), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/tests/generated/wrap_reverse_row_align_content_stretch.rs b/tests/generated/wrap_reverse_row_align_content_stretch.rs index f5b761bfa..5701f4c58 100644 --- a/tests/generated/wrap_reverse_row_align_content_stretch.rs +++ b/tests/generated/wrap_reverse_row_align_content_stretch.rs @@ -4,75 +4,56 @@ fn wrap_reverse_row_align_content_stretch() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Stretch), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/tests/generated/wrap_reverse_row_single_line_different_size.rs b/tests/generated/wrap_reverse_row_single_line_different_size.rs index db6054f7e..4aded9b62 100644 --- a/tests/generated/wrap_reverse_row_single_line_different_size.rs +++ b/tests/generated/wrap_reverse_row_single_line_different_size.rs @@ -4,76 +4,56 @@ fn wrap_reverse_row_single_line_different_size() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(40f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(40f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node4 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(50f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(50f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::WrapReverse, - align_content: taffy::style::AlignContent::FlexStart, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), ..Size::auto() }, + align_content: Some(taffy::style::AlignContent::Start), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(300f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3, node4], diff --git a/tests/generated/wrap_row.rs b/tests/generated/wrap_row.rs index 9c1bfa932..474c6f838 100644 --- a/tests/generated/wrap_row.rs +++ b/tests/generated/wrap_row.rs @@ -4,62 +4,46 @@ fn wrap_row() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(31f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(31f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(32f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(32f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(33f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(33f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(34f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(34f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/tests/generated/wrap_row_align_items_center.rs b/tests/generated/wrap_row_align_items_center.rs index d8f28975c..11b217f5a 100644 --- a/tests/generated/wrap_row_align_items_center.rs +++ b/tests/generated/wrap_row_align_items_center.rs @@ -4,63 +4,47 @@ fn wrap_row_align_items_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::Center), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/tests/generated/wrap_row_align_items_flex_end.rs b/tests/generated/wrap_row_align_items_flex_end.rs index e753ce6f7..fe7b4e311 100644 --- a/tests/generated/wrap_row_align_items_flex_end.rs +++ b/tests/generated/wrap_row_align_items_flex_end.rs @@ -4,63 +4,47 @@ fn wrap_row_align_items_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(10f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(10f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(20f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(20f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node3 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(30f32), - height: taffy::style::Dimension::Points(30f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(30f32), + height: taffy::style::Dimension::Points(30f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::FlexEnd, - size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Size::auto() }, + align_items: Some(taffy::style::AlignItems::End), + size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), height: auto() }, ..Default::default() }, &[node0, node1, node2, node3], diff --git a/tests/generated/wrapped_column_max_height.rs b/tests/generated/wrapped_column_max_height.rs index 03b88cad4..128215955 100644 --- a/tests/generated/wrapped_column_max_height.rs +++ b/tests/generated/wrapped_column_max_height.rs @@ -4,64 +4,50 @@ fn wrapped_column_max_height() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(500f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - right: taffy::style::LengthPercentageAuto::Points(20f32), - top: taffy::style::LengthPercentageAuto::Points(20f32), - bottom: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(20f32), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: taffy::style::LengthPercentageAuto::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - align_content: taffy::style::AlignContent::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(700f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrapped_column_max_height_flex.rs b/tests/generated/wrapped_column_max_height_flex.rs index 504c97f8b..a215424a7 100644 --- a/tests/generated/wrapped_column_max_height_flex.rs +++ b/tests/generated/wrapped_column_max_height_flex.rs @@ -4,70 +4,56 @@ fn wrapped_column_max_height_flex() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node0 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(500f32), - ..Size::auto() - }, - max_size: taffy::geometry::Size { height: taffy::style::Dimension::Points(200f32), ..Size::auto() }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(500f32), }, - &[], - ) + max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(200f32) }, + ..Default::default() + }) .unwrap(); let node1 = taffy - .new_with_children( - taffy::style::Style { - flex_grow: 1f32, - flex_shrink: 1f32, - flex_basis: taffy::style::Dimension::Percent(0f32), - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(200f32), - height: taffy::style::Dimension::Points(200f32), - ..Size::auto() - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::Points(20f32), - right: taffy::style::LengthPercentageAuto::Points(20f32), - top: taffy::style::LengthPercentageAuto::Points(20f32), - bottom: taffy::style::LengthPercentageAuto::Points(20f32), - ..Rect::zero() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + flex_grow: 1f32, + flex_shrink: 1f32, + flex_basis: taffy::style::Dimension::Percent(0f32), + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(200f32), + height: taffy::style::Dimension::Points(200f32), }, - &[], - ) + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::Points(20f32), + right: taffy::style::LengthPercentageAuto::Points(20f32), + top: taffy::style::LengthPercentageAuto::Points(20f32), + bottom: taffy::style::LengthPercentageAuto::Points(20f32), + }, + ..Default::default() + }) .unwrap(); let node2 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(100f32), - height: taffy::style::Dimension::Points(100f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(100f32), + height: taffy::style::Dimension::Points(100f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node = taffy .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, flex_wrap: taffy::style::FlexWrap::Wrap, - align_items: taffy::style::AlignItems::Center, - align_content: taffy::style::AlignContent::Center, - justify_content: taffy::style::JustifyContent::Center, + align_items: Some(taffy::style::AlignItems::Center), + align_content: Some(taffy::style::AlignContent::Center), + justify_content: Some(taffy::style::JustifyContent::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(700f32), height: taffy::style::Dimension::Points(500f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrapped_row_within_align_items_center.rs b/tests/generated/wrapped_row_within_align_items_center.rs index 2eb4dfea2..20ee43efb 100644 --- a/tests/generated/wrapped_row_within_align_items_center.rs +++ b/tests/generated/wrapped_row_within_align_items_center.rs @@ -4,30 +4,22 @@ fn wrapped_row_within_align_items_center() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -39,11 +31,10 @@ fn wrapped_row_within_align_items_center() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::Center, + align_items: Some(taffy::style::AlignItems::Center), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrapped_row_within_align_items_flex_end.rs b/tests/generated/wrapped_row_within_align_items_flex_end.rs index b42c303b5..e8cfaf3a6 100644 --- a/tests/generated/wrapped_row_within_align_items_flex_end.rs +++ b/tests/generated/wrapped_row_within_align_items_flex_end.rs @@ -4,30 +4,22 @@ fn wrapped_row_within_align_items_flex_end() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -39,11 +31,10 @@ fn wrapped_row_within_align_items_flex_end() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexEnd, + align_items: Some(taffy::style::AlignItems::End), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/generated/wrapped_row_within_align_items_flex_start.rs b/tests/generated/wrapped_row_within_align_items_flex_start.rs index 27c8f9e25..08cb49c62 100644 --- a/tests/generated/wrapped_row_within_align_items_flex_start.rs +++ b/tests/generated/wrapped_row_within_align_items_flex_start.rs @@ -4,30 +4,22 @@ fn wrapped_row_within_align_items_flex_start() { use taffy::prelude::*; let mut taffy = taffy::Taffy::new(); let node00 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(150f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(150f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node01 = taffy - .new_with_children( - taffy::style::Style { - size: taffy::geometry::Size { - width: taffy::style::Dimension::Points(80f32), - height: taffy::style::Dimension::Points(80f32), - ..Size::auto() - }, - ..Default::default() + .new_leaf(taffy::style::Style { + size: taffy::geometry::Size { + width: taffy::style::Dimension::Points(80f32), + height: taffy::style::Dimension::Points(80f32), }, - &[], - ) + ..Default::default() + }) .unwrap(); let node0 = taffy .new_with_children( @@ -39,11 +31,10 @@ fn wrapped_row_within_align_items_flex_start() { .new_with_children( taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, - align_items: taffy::style::AlignItems::FlexStart, + align_items: Some(taffy::style::AlignItems::Start), size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), height: taffy::style::Dimension::Points(200f32), - ..Size::auto() }, ..Default::default() }, diff --git a/tests/measure.rs b/tests/measure.rs index 8ff8e8134..99fc7b6cb 100644 --- a/tests/measure.rs +++ b/tests/measure.rs @@ -204,7 +204,7 @@ mod measure { .new_with_children( Style { size: Size { width: Dimension::Points(100.0), height: auto() }, - align_items: AlignItems::FlexStart, + align_items: Some(AlignItems::Start), ..Default::default() }, &[child0, child1], @@ -244,7 +244,7 @@ mod measure { .new_with_children( Style { size: Size { width: Dimension::Points(100.0), height: auto() }, - align_items: AlignItems::FlexStart, + align_items: Some(AlignItems::Start), ..Default::default() }, &[child0, child1], diff --git a/tests/relayout.rs b/tests/relayout.rs index 1eef2539e..067bd2b9a 100644 --- a/tests/relayout.rs +++ b/tests/relayout.rs @@ -1,5 +1,4 @@ -use taffy::layout::AvailableSpace; -use taffy::style::Dimension; +use taffy::style::{AvailableSpace, Dimension}; #[test] fn relayout() { @@ -13,7 +12,7 @@ fn relayout() { let node0 = taffy .new_with_children( taffy::style::Style { - align_self: taffy::prelude::AlignSelf::Center, + align_self: Some(taffy::prelude::AlignSelf::Center), size: taffy::geometry::Size { width: Dimension::Auto, height: Dimension::Auto }, // size: taffy::geometry::Size { width: Dimension::Percent(1.0), height: Dimension::Percent(1.0) }, ..Default::default() diff --git a/tests/root_constraints.rs b/tests/root_constraints.rs index b12ecbc7f..ea588152d 100644 --- a/tests/root_constraints.rs +++ b/tests/root_constraints.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod root_constraints { - use taffy::layout::AvailableSpace; + use taffy::style::AvailableSpace; #[test] fn root_with_percentage_size() { diff --git a/tests/simple_child.rs b/tests/simple_child.rs index 8bee5d748..b53a671d3 100644 --- a/tests/simple_child.rs +++ b/tests/simple_child.rs @@ -1,11 +1,11 @@ -use taffy::{geometry::Point, layout::AvailableSpace, style::Dimension}; +use taffy::{geometry::Point, style::AvailableSpace, style::Dimension}; #[test] fn simple_child() { let mut taffy = taffy::Taffy::new(); let node0_0 = taffy .new_leaf(taffy::style::Style { - align_self: taffy::prelude::AlignSelf::Center, + align_self: Some(taffy::prelude::AlignSelf::Center), size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, ..Default::default() }) @@ -21,14 +21,14 @@ fn simple_child() { .unwrap(); let node1_0 = taffy .new_leaf(taffy::style::Style { - align_self: taffy::prelude::AlignSelf::Center, + align_self: Some(taffy::prelude::AlignSelf::Center), size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, ..Default::default() }) .unwrap(); let node1_1 = taffy .new_leaf(taffy::style::Style { - align_self: taffy::prelude::AlignSelf::Center, + align_self: Some(taffy::prelude::AlignSelf::Center), size: taffy::geometry::Size { width: Dimension::Points(10f32), height: Dimension::Points(10f32) }, ..Default::default() })