diff --git a/Cargo.lock b/Cargo.lock index 1b911e961b..a81b8e3e82 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3181,12 +3181,9 @@ dependencies = [ [[package]] name = "grid" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0634107a3a005070dd73e27e74ecb691a94e9e5ba7829f434db7fbf73a6b5c47" -dependencies = [ - "no-std-compat", -] +checksum = "eec1c01eb1de97451ee0d60de7d81cf1e72aabefb021616027f3d1c3ec1c723c" [[package]] name = "h2" @@ -4608,12 +4605,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "no-std-compat" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" - [[package]] name = "node_runtime" version = "0.1.0" @@ -7662,9 +7653,8 @@ dependencies = [ [[package]] name = "taffy" -version = "0.3.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3540ec65df399929a04a485feb50144475735920cc47eaf8eba09c70b1df4055" +version = "0.3.11" +source = "git+https://github.com/DioxusLabs/taffy?rev=dab541d6104d58e2e10ce90c4a1dad0b703160cd#dab541d6104d58e2e10ce90c4a1dad0b703160cd" dependencies = [ "arrayvec 0.7.4", "grid", diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 6ebed0ed97..81b7dbee43 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -47,12 +47,12 @@ serde_derive.workspace = true serde_json.workspace = true smallvec.workspace = true smol.workspace = true +taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "dab541d6104d58e2e10ce90c4a1dad0b703160cd" } time.workspace = true tiny-skia = "0.5" usvg = { version = "0.14", features = [] } uuid = { version = "1.1.2", features = ["v4"] } waker-fn = "1.1.0" -taffy = "0.3.12" [build-dependencies] bindgen = "0.65.1" diff --git a/crates/gpui/playground/Cargo.toml b/crates/gpui/playground/Cargo.toml index 043e916aa1..11f56d230c 100644 --- a/crates/gpui/playground/Cargo.toml +++ b/crates/gpui/playground/Cargo.toml @@ -16,7 +16,7 @@ optional_struct = "0.3.1" serde.workspace = true simplelog = "0.9" smallvec.workspace = true -taffy = "0.3.12" +taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "dab541d6104d58e2e10ce90c4a1dad0b703160cd" } util = { path = "../../util" } [dev-dependencies] diff --git a/crates/gpui/playground/src/frame.rs b/crates/gpui/playground/src/frame.rs index 884b07daa3..327b798669 100644 --- a/crates/gpui/playground/src/frame.rs +++ b/crates/gpui/playground/src/frame.rs @@ -18,8 +18,8 @@ use gpui::{ use length::{Length, Rems}; use log::warn; use optional_struct::*; +use smallvec::SmallVec; use std::{any::Any, borrow::Cow, f32, ops::Range, sync::Arc}; -use taffy::prelude::Style as TaffyStyle; use util::ResultExt; use crate::color::{Hsla, Rgba}; @@ -28,6 +28,7 @@ use self::length::rems; pub struct Frame { style: FrameStyle, + metadata: FrameMetadata, children: Vec>, id: Option>, before_paint: Option)>>, @@ -49,6 +50,7 @@ impl Default for Frame { fn default() -> Self { Self { style: Default::default(), + metadata: Default::default(), children: Default::default(), id: None, before_paint: None, @@ -76,6 +78,25 @@ impl Element for Frame { } } + let mut child_node_ids = SmallVec::<[_; 2]>::new(); + for child in &mut self.children { + child.layout(constraint, view, cx); + child_node_ids.extend( + child + .metadata::() + .and_then(|meta| meta.layout_node_id), + ); + } + + self.metadata.layout_node_id = cx + .layout_engine() + .new_with_children(self.style.layout.clone(), child_node_ids.as_slice()) + .log_err(); + + if pushed_text_style { + cx.pop_text_style(); + } + (todo!(), todo!()) } @@ -196,7 +217,7 @@ impl Element for Frame { } fn metadata(&self) -> Option<&dyn Any> { - Some(&self.style) + Some(&self.metadata) } } @@ -295,6 +316,11 @@ struct Interactive