fix root node layout
This commit is contained in:
1 parent
e6a11f50dd
commit
a823b45af9
3 files changed
+19
-16
No files matched your search
@@ -23,8 +23,8 @@ fn Button(cx: Scope<ButtonProps>) -> Element {
|
|||||||
|
|
||||||
cx.render(rsx! {
|
cx.render(rsx! {
|
||||||
div{
|
div{
|
||||||
width: "20px",
|
width: "100%",
|
||||||
height: "5px",
|
height: "100%",
|
||||||
background_color: "{color}",
|
background_color: "{color}",
|
||||||
tabindex: "{cx.props.layer}",
|
tabindex: "{cx.props.layer}",
|
||||||
onkeydown: |e| {
|
onkeydown: |e| {
|
||||||
@@ -70,8 +70,8 @@ fn app(cx: Scope) -> Element {
|
|||||||
if (x + y) % 2 == 0{
|
if (x + y) % 2 == 0{
|
||||||
rsx!{
|
rsx!{
|
||||||
div{
|
div{
|
||||||
width: "20px",
|
width: "100%",
|
||||||
height: "5px",
|
height: "100%",
|
||||||
background_color: "rgb(100, 100, 100)",
|
background_color: "rgb(100, 100, 100)",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use dioxus_core::*;
|
|
||||||
use dioxus_native_core::layout_attributes::apply_layout_attributes;
|
use dioxus_native_core::layout_attributes::apply_layout_attributes;
|
||||||
use dioxus_native_core::node::OwnedAttributeView;
|
use dioxus_native_core::node::OwnedAttributeView;
|
||||||
use dioxus_native_core::node_ref::{AttributeMask, NodeMask, NodeView};
|
use dioxus_native_core::node_ref::{AttributeMask, NodeMask, NodeView};
|
||||||
@@ -98,12 +97,6 @@ impl ChildDepState for TaffyLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// the root node fills the entire area
|
|
||||||
if node.id() == Some(ElementId(0)) {
|
|
||||||
apply_layout_attributes("width", "100%", &mut style);
|
|
||||||
apply_layout_attributes("height", "100%", &mut style);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set all direct nodes as our children
|
// Set all direct nodes as our children
|
||||||
let mut child_layout = vec![];
|
let mut child_layout = vec![];
|
||||||
for (l,) in children {
|
for (l,) in children {
|
||||||
|
|||||||
+15
-5
@@ -153,13 +153,23 @@ fn render_vdom(
|
|||||||
let height = dims.height;
|
let height = dims.height;
|
||||||
let root_node = rdom[NodeId(0)].state.layout.node.unwrap();
|
let root_node = rdom[NodeId(0)].state.layout.node.unwrap();
|
||||||
|
|
||||||
taffy
|
// the root node fills the entire area
|
||||||
|
|
||||||
|
let mut style=*taffy.style(root_node).unwrap();
|
||||||
|
style.size=Size {
|
||||||
|
width: Dimension::Points(width as f32),
|
||||||
|
height: Dimension::Points(height as f32),
|
||||||
|
};
|
||||||
|
taffy.set_style(root_node, style).unwrap();
|
||||||
|
|
||||||
|
let size =Size {
|
||||||
|
width: AvailableSpace::Definite(width as f32),
|
||||||
|
height: AvailableSpace::Definite(height as f32),
|
||||||
|
};
|
||||||
|
taffy
|
||||||
.compute_layout(
|
.compute_layout(
|
||||||
root_node,
|
root_node,
|
||||||
Size {
|
size
|
||||||
width: AvailableSpace::Definite((width - 1) as f32),
|
|
||||||
height: AvailableSpace::Definite((height - 1) as f32),
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user