feat: separate 2d scenes viewports and explicit cameras
This commit is contained in:
+18
-3
@@ -209,7 +209,10 @@ pub fn child_constraints(node: &UiNode, parent: [f32; 4]) -> [f32; 4] {
|
||||
content_limit(parent[3], padding.vertical()),
|
||||
];
|
||||
}
|
||||
if matches!(node.kind, UiKind::Canvas { .. }) {
|
||||
if matches!(
|
||||
node.kind,
|
||||
UiKind::Canvas { .. } | UiKind::Scene2D { .. } | UiKind::CanvasViewport { .. }
|
||||
) {
|
||||
return root_constraints(None);
|
||||
}
|
||||
if let UiKind::Scroll { width, height, .. } = node.kind {
|
||||
@@ -429,7 +432,8 @@ fn shape(node: &UiNode, children: Vec<Size>, constraints: [f32; 4]) -> Result<Sh
|
||||
size.height + padding.vertical(),
|
||||
)
|
||||
}
|
||||
UiKind::Canvas { positions, .. } => {
|
||||
UiKind::CanvasViewport { width, height, .. } => Shape::Rect(*width, *height),
|
||||
UiKind::Canvas { positions, .. } | UiKind::Scene2D { positions, .. } => {
|
||||
let mut size = Size::default();
|
||||
for (position, child) in positions.iter().zip(children) {
|
||||
size.width = size.width.max(position[0] + child.width);
|
||||
@@ -770,7 +774,15 @@ pub fn arrange_native(
|
||||
})
|
||||
.collect();
|
||||
}
|
||||
if let UiKind::Canvas { positions, .. } = &node.kind {
|
||||
if matches!(node.kind, UiKind::CanvasViewport { .. }) {
|
||||
let inset = insets(node);
|
||||
return Ok(node
|
||||
.children()
|
||||
.iter()
|
||||
.map(|_| (x + inset.left, y + inset.top))
|
||||
.collect());
|
||||
}
|
||||
if let UiKind::Canvas { positions, .. } | UiKind::Scene2D { positions, .. } = &node.kind {
|
||||
return Ok(positions
|
||||
.iter()
|
||||
.map(|point| (x + point[0], y + point[1]))
|
||||
@@ -996,6 +1008,9 @@ impl LayoutRuntime {
|
||||
coordinate(x + size.width)?;
|
||||
coordinate(y + size.height)?;
|
||||
mounts.push(MountGeometry {
|
||||
canvas_viewport: matches!(item.node.kind, UiKind::CanvasViewport { .. }),
|
||||
viewport_clip: None,
|
||||
view: None,
|
||||
id: item.id,
|
||||
clip: None,
|
||||
scroll: None,
|
||||
|
||||
Reference in New Issue
Block a user