Add axis-aware scroll constraints and per-mount limits
Verify Tessera GUI / verify (push) Failing after 7m38s

This commit is contained in:
2026-10-22 19:35:38 +08:00
parent 2b20976658
commit 1885693f7c
13 changed files with 277 additions and 14 deletions
+28 -2
View File
@@ -65,8 +65,12 @@ pub fn root_constraints(viewport: Option<Size>) -> [f32; 4] {
[0.0, 0.0, size.width, size.height]
}
pub fn child_constraints(node: &UiNode, parent: [f32; 4]) -> [f32; 4] {
if matches!(node.kind, UiKind::Scroll { .. }) {
return [0.0, 0.0, MAX_DIMENSION as f32, MAX_DIMENSION as f32];
if let UiKind::Scroll { width, height, .. } = node.kind {
return arranged_child_constraints(
node,
parent,
constrained(Size { width, height }, parent),
);
}
match container(node) {
Some((true, padding, _)) => [
@@ -84,6 +88,28 @@ pub fn child_constraints(node: &UiNode, parent: [f32; 4]) -> [f32; 4] {
None => parent,
}
}
/// Scroll cross-axis constraints come from this occurrence's actual viewport,
/// including a source parent's allocation rather than only constructor size.
pub fn arranged_child_constraints(node: &UiNode, available: [f32; 4], bounds: Size) -> [f32; 4] {
if let UiKind::Scroll { padding, axis, .. } = node.kind {
return [
0.0,
0.0,
if axis.horizontal() {
MAX_DIMENSION as f32
} else {
(bounds.width - padding * 2.0).max(0.0)
},
if axis.vertical() {
MAX_DIMENSION as f32
} else {
(bounds.height - padding * 2.0).max(0.0)
},
];
}
child_constraints(node, available)
}
pub fn constrained(size: Size, constraints: [f32; 4]) -> Size {
Size {
width: size.width.clamp(constraints[0], constraints[2]),