Constrain offered boxes with independent widget size bounds
This commit is contained in:
1 parent
4cb6f6882a
commit
2ac0843cb2
18 files changed
+554
-379
No files matched your search
@@ -51,15 +51,33 @@ fn relative_intrinsic_bounds_agree_warm_and_cold() {
|
||||
grown.walk_mut(&mut |node| {
|
||||
if let Some(rules) = &mut node.size {
|
||||
for axis in Axis::BOTH {
|
||||
rules[axis] = match rules[axis] {
|
||||
SizeRule::Min(_) => SizeRule::Min(Len::rel(0.25)),
|
||||
SizeRule::Max(_) => SizeRule::Max(Len::rel(0.75)),
|
||||
SizeRule::Clamp { .. } => SizeRule::Clamp {
|
||||
min: Len::rel(0.25),
|
||||
max: Len::rel(0.75),
|
||||
},
|
||||
ref rule => rule.clone(),
|
||||
};
|
||||
let bound = &mut rules[axis].bound;
|
||||
if bound.min.is_some() {
|
||||
bound.min = Some(Len::rel(0.25));
|
||||
}
|
||||
if bound.max.is_some() {
|
||||
bound.max = Some(Len::rel(0.75));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preferred_requests_with_independent_bounds_agree_warm_and_cold() {
|
||||
check_requests(|grown| {
|
||||
let mut index = 0;
|
||||
grown.walk_mut(&mut |node| {
|
||||
if let Some(rules) = &mut node.size {
|
||||
for axis in Axis::BOTH {
|
||||
index += 1;
|
||||
rules[axis].request = Some(match index % 4 {
|
||||
0 => leftover(1).into(),
|
||||
1 => rel(0.5).into(),
|
||||
2 => px(80).into(),
|
||||
_ => (leftover(1) + px(30)).min(leftover(2)),
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user