layout: max_scroll from the unclamped extent; declare dismiss in tests
This commit is contained in:
parent
bafdda9328
commit
571fbe9e0b
2 changed files with 9 additions and 9 deletions
|
|
@ -167,13 +167,15 @@ fn solve<'a>(
|
|||
let (x, y) = (px + laid.location.x, py + laid.location.y);
|
||||
absolute.push((x, y));
|
||||
let (w, h) = (laid.size.width, laid.size.height);
|
||||
let content = entry.scroll.then(|| {
|
||||
// Taffy's content extent is measured from the padding box. `content` is never smaller than
|
||||
// the border box; `max_scroll` is what the content reaches past the padding box.
|
||||
let reached = entry.scroll.then(|| {
|
||||
let overflow = laid.scrollable_overflow_rect.rect();
|
||||
let round = |v: f32| (v + 0.5).floor();
|
||||
(clean(round(overflow.right).max(w)), clean(round(overflow.bottom).max(h)))
|
||||
(round(overflow.right), round(overflow.bottom))
|
||||
});
|
||||
// What the content reaches past the padding box, which is what an offset may scroll.
|
||||
let max_scroll = content.map(|(cw, ch)| {
|
||||
let content = reached.map(|(cw, ch)| (clean(cw.max(w)), clean(ch.max(h))));
|
||||
let max_scroll = reached.map(|(cw, ch)| {
|
||||
let inner_w = w - laid.border.left - laid.border.right;
|
||||
let inner_h = h - laid.border.top - laid.border.bottom;
|
||||
(clean((cw - inner_w).max(0.0)), clean((ch - inner_h).max(0.0)))
|
||||
|
|
|
|||
|
|
@ -238,7 +238,8 @@ fn surface_of(root: Node) -> SurfaceDocument {
|
|||
version: ver(1),
|
||||
title: "inline".into(),
|
||||
root,
|
||||
commands: vec![],
|
||||
// Declared so an overlay can name it as its dismiss.
|
||||
commands: vec![CommandDecl { id: CommandId::new("dismiss"), payload_schema: SchemaId::new("gamecult.thing.test.dismiss.v1"), captures: vec![], confirm: None }],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1156,10 +1157,7 @@ fn scroll_extent_is_measured_from_the_padding_box() {
|
|||
let style = BoxStyle { overflow: Overflow::Scroll, direction: Direction::Column, ..sized(100.0, 100.0) };
|
||||
let laid = lay(bx("root", plain(), vec![bx_paint("list", style, paint, rows)]), 400.0, 300.0);
|
||||
let list = laid.nodes.iter().find(|n| n.id.as_str() == "list").unwrap();
|
||||
println!("PROBE border: content {:?} max_scroll {:?}", list.content, list.max_scroll);
|
||||
let (_, content_h) = list.content.unwrap();
|
||||
let (_, scroll_y) = list.max_scroll.unwrap();
|
||||
assert_eq!(scroll_y, content_h - 92.0);
|
||||
assert_eq!(list.max_scroll, Some((0.0, 158.0)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue