@@ -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",
@@ -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"
@@ -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<V> {
style: FrameStyle,
+ metadata: FrameMetadata,
children: Vec<AnyElement<V>>,
id: Option<Cow<'static, str>>,
before_paint: Option<Box<dyn FnMut(RectF, &mut FrameLayout, &mut PaintContext<V>)>>,
@@ -49,6 +50,7 @@ impl<V> Default for Frame<V> {
fn default() -> Self {
Self {
style: Default::default(),
+ metadata: Default::default(),
children: Default::default(),
id: None,
before_paint: None,
@@ -76,6 +78,25 @@ impl<V: 'static> Element<V> for Frame<V> {
}
}
+ 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::<FrameMetadata>()
+ .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<V: 'static> Element<V> for Frame<V> {
}
fn metadata(&self) -> Option<&dyn Any> {
- Some(&self.style)
+ Some(&self.metadata)
}
}
@@ -295,6 +316,11 @@ struct Interactive<Style> {
disabled: Style,
}
+#[derive(Default)]
+pub struct FrameMetadata {
+ layout_node_id: Option<taffy::tree::NodeId>,
+}
+
#[derive(Clone, Default)]
pub struct FrameStyle {
text: OptionalTextStyle,
@@ -303,7 +329,7 @@ pub struct FrameStyle {
borders: Borders,
corner_radius: f32,
shadows: Vec<Shadow>,
- layout: TaffyStyle,
+ layout: taffy::style::Style,
}
#[optional_struct]
@@ -1309,28 +1335,6 @@ impl Vector2FExt for Vector2F {
}
}
-trait ElementExt<V: 'static> {
- fn margin_left(self, margin_left: impl Into<Length>) -> Frame<V>
- where
- Self: Element<V> + Sized,
- {
- column().child(self).margin_left(margin_left)
- }
-}
-
-impl<V, E> ElementExt<V> for E
-where
- V: 'static,
- E: Element<V>,
-{
- fn margin_left(self, margin_left: impl Into<Length>) -> Frame<V>
- where
- Self: Sized,
- {
- column().child(self).margin_left(margin_left)
- }
-}
-
pub fn view<F, E>(mut render: F) -> ViewFn
where
F: 'static + FnMut(&mut ViewContext<ViewFn>) -> E,