-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de9123e
commit 8936790
Showing
496 changed files
with
11,712 additions
and
11,902 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[package] | ||
name = "sprawl" | ||
name = "taffy" | ||
version = "0.1.0" | ||
authors = [ | ||
"Alice Cecile <[email protected]>", | ||
|
@@ -8,7 +8,7 @@ authors = [ | |
edition = "2021" | ||
include = ["src/**/*", "Cargo.toml"] | ||
description = "A flexible UI layout library" | ||
repository = "https://github.com/DioxusLabs/sprawl" | ||
repository = "https://github.com/DioxusLabs/taffy" | ||
keywords = ["cross-platform", "layout", "flexbox"] | ||
categories = ["gui"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# sprawl | ||
# taffy | ||
|
||
[![GitHub CI](https://github.com/DioxusLabs/sprawl/actions/workflows/ci.yml/badge.svg)](https://github.com/DioxusLabs/sprawl/actions/workflows/ci.yml) | ||
[![crates.io](https://img.shields.io/crates/v/sprawl.svg)](https://crates.io/crates/sprawl) | ||
[![GitHub CI](https://github.com/DioxusLabs/taffy/actions/workflows/ci.yml/badge.svg)](https://github.com/DioxusLabs/taffy/actions/workflows/ci.yml) | ||
[![crates.io](https://img.shields.io/crates/v/taffy.svg)](https://crates.io/crates/taffy) | ||
|
||
`sprawl` is a flexible, high-performance, cross-platform UI layout library written in [Rust](https://www.rust-lang.org). | ||
`taffy` is a flexible, high-performance, cross-platform UI layout library written in [Rust](https://www.rust-lang.org). | ||
|
||
Currently, we only support a [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm, but support for other paradigms [is planned](https://github.com/DioxusLabs/sprawl/issues/28). | ||
Currently, we only support a [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm, but support for other paradigms [is planned](https://github.com/DioxusLabs/taffy/issues/28). | ||
|
||
This crate is a collaborative, cross-team project, and is designed to be used as a dependency for other UI and GUI libraries. | ||
Right now, it powers: | ||
|
||
- [Dioxus](https://dioxuslabs.com/): a React-like library for building fast, portable, and beautiful user interfaces with Rust | ||
- [Bevy](https://bevyengine.org/): an ergonomic, ECS-first Rust game engine | ||
|
||
[Contributions welcome](https://github.com/DioxusLabs/sprawl/blob/main/CONTRIBUTING.md): | ||
if you'd like to use, improve or build `sprawl`, feel free to join the conversation, open an [issue](https://github.com/DioxusLabs/sprawl/issues) or submit a [PR](https://github.com/DioxusLabs/sprawl/pulls). | ||
If you have questions about how to use `sprawl`, open a [discussion](https://github.com/DioxusLabs/sprawl/discussions) so we can answer your questions in a way that others can find. | ||
[Contributions welcome](https://github.com/DioxusLabs/taffy/blob/main/CONTRIBUTING.md): | ||
if you'd like to use, improve or build `taffy`, feel free to join the conversation, open an [issue](https://github.com/DioxusLabs/taffy/issues) or submit a [PR](https://github.com/DioxusLabs/taffy/pulls). | ||
If you have questions about how to use `taffy`, open a [discussion](https://github.com/DioxusLabs/taffy/discussions) so we can answer your questions in a way that others can find. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,144 +1,144 @@ | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
|
||
fn build_deep_hierarchy(sprawl: &mut sprawl::node::Sprawl) -> sprawl::node::Node { | ||
let node111 = sprawl | ||
fn build_deep_hierarchy(taffy: &mut taffy::node::Taffy) -> taffy::node::Node { | ||
let node111 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
let node112 = sprawl | ||
let node112 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
|
||
let node121 = sprawl | ||
let node121 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
let node122 = sprawl | ||
let node122 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
|
||
let node11 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node111, node112]).unwrap(); | ||
let node12 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node121, node122]).unwrap(); | ||
let node1 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node11, node12]).unwrap(); | ||
let node11 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node111, node112]).unwrap(); | ||
let node12 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node121, node122]).unwrap(); | ||
let node1 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node11, node12]).unwrap(); | ||
|
||
let node211 = sprawl | ||
let node211 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
let node212 = sprawl | ||
let node212 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
|
||
let node221 = sprawl | ||
let node221 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
let node222 = sprawl | ||
let node222 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(10.0), | ||
height: sprawl::style::Dimension::Points(10.0), | ||
taffy::style::Style { | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(10.0), | ||
height: taffy::style::Dimension::Points(10.0), | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
|
||
let node21 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node211, node212]).unwrap(); | ||
let node22 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node221, node222]).unwrap(); | ||
let node21 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node211, node212]).unwrap(); | ||
let node22 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node221, node222]).unwrap(); | ||
|
||
let node2 = sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node21, node22]).unwrap(); | ||
let node2 = taffy.new_node(taffy::style::Style { ..Default::default() }, &[node21, node22]).unwrap(); | ||
|
||
sprawl.new_node(sprawl::style::Style { ..Default::default() }, &[node1, node2]).unwrap() | ||
taffy.new_node(taffy::style::Style { ..Default::default() }, &[node1, node2]).unwrap() | ||
} | ||
|
||
fn sprawl_benchmarks(c: &mut Criterion) { | ||
fn taffy_benchmarks(c: &mut Criterion) { | ||
c.bench_function("deep hierarchy - build", |b| { | ||
b.iter(|| { | ||
let mut sprawl = sprawl::node::Sprawl::new(); | ||
build_deep_hierarchy(&mut sprawl); | ||
let mut taffy = taffy::node::Taffy::new(); | ||
build_deep_hierarchy(&mut taffy); | ||
}) | ||
}); | ||
|
||
c.bench_function("deep hierarchy - single", |b| { | ||
b.iter(|| { | ||
let mut sprawl = sprawl::node::Sprawl::new(); | ||
let root = build_deep_hierarchy(&mut sprawl); | ||
sprawl.compute_layout(root, sprawl::geometry::Size::undefined()).unwrap() | ||
let mut taffy = taffy::node::Taffy::new(); | ||
let root = build_deep_hierarchy(&mut taffy); | ||
taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap() | ||
}) | ||
}); | ||
|
||
c.bench_function("deep hierarchy - relayout", |b| { | ||
let mut sprawl = sprawl::node::Sprawl::new(); | ||
let root = build_deep_hierarchy(&mut sprawl); | ||
let mut taffy = taffy::node::Taffy::new(); | ||
let root = build_deep_hierarchy(&mut taffy); | ||
|
||
b.iter(|| { | ||
sprawl.mark_dirty(root).unwrap(); | ||
sprawl.compute_layout(root, sprawl::geometry::Size::undefined()).unwrap() | ||
taffy.mark_dirty(root).unwrap(); | ||
taffy.compute_layout(root, taffy::geometry::Size::undefined()).unwrap() | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, sprawl_benchmarks); | ||
criterion_group!(benches, taffy_benchmarks); | ||
criterion_main!(benches); |
30 changes: 15 additions & 15 deletions
30
benches/generated/absolute_layout_align_items_and_justify_content_center.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,33 @@ | ||
pub fn compute() { | ||
let mut sprawl = sprawl::Sprawl::new(); | ||
let node0 = sprawl | ||
let mut taffy = taffy::Taffy::new(); | ||
let node0 = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
position_type: sprawl::style::PositionType::Absolute, | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(60f32), | ||
height: sprawl::style::Dimension::Points(40f32), | ||
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() | ||
}, | ||
..Default::default() | ||
}, | ||
&[], | ||
) | ||
.unwrap(); | ||
let node = sprawl | ||
let node = taffy | ||
.new_node( | ||
sprawl::style::Style { | ||
align_items: sprawl::style::AlignItems::Center, | ||
justify_content: sprawl::style::JustifyContent::Center, | ||
size: sprawl::geometry::Size { | ||
width: sprawl::style::Dimension::Points(110f32), | ||
height: sprawl::style::Dimension::Points(100f32), | ||
taffy::style::Style { | ||
align_items: taffy::style::AlignItems::Center, | ||
justify_content: taffy::style::JustifyContent::Center, | ||
size: taffy::geometry::Size { | ||
width: taffy::style::Dimension::Points(110f32), | ||
height: taffy::style::Dimension::Points(100f32), | ||
..Default::default() | ||
}, | ||
..Default::default() | ||
}, | ||
&[node0], | ||
) | ||
.unwrap(); | ||
sprawl.compute_layout(node, sprawl::geometry::Size::undefined()).unwrap(); | ||
taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap(); | ||
} |
Oops, something went wrong.