Introduce useful helpers in layout module
This commit is contained in:
parent
d24e50c1a6
commit
d62bb8193c
26 changed files with 189 additions and 127 deletions
|
|
@ -469,28 +469,25 @@ pub fn layout<Renderer>(
|
|||
direction: &Direction,
|
||||
layout_content: impl FnOnce(&Renderer, &layout::Limits) -> layout::Node,
|
||||
) -> layout::Node {
|
||||
let limits = limits.width(width).height(height);
|
||||
layout::contained(limits, width, height, |limits| {
|
||||
let child_limits = layout::Limits::new(
|
||||
Size::new(limits.min().width, limits.min().height),
|
||||
Size::new(
|
||||
if direction.horizontal().is_some() {
|
||||
f32::INFINITY
|
||||
} else {
|
||||
limits.max().width
|
||||
},
|
||||
if direction.vertical().is_some() {
|
||||
f32::MAX
|
||||
} else {
|
||||
limits.max().height
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
let child_limits = layout::Limits::new(
|
||||
Size::new(limits.min().width, limits.min().height),
|
||||
Size::new(
|
||||
if direction.horizontal().is_some() {
|
||||
f32::INFINITY
|
||||
} else {
|
||||
limits.max().width
|
||||
},
|
||||
if direction.vertical().is_some() {
|
||||
f32::MAX
|
||||
} else {
|
||||
limits.max().height
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
let content = layout_content(renderer, &child_limits);
|
||||
let size = limits.resolve(content.size(), width, height);
|
||||
|
||||
layout::Node::with_children(size, vec![content])
|
||||
layout_content(renderer, &child_limits)
|
||||
})
|
||||
}
|
||||
|
||||
/// Processes an [`Event`] and updates the [`State`] of a [`Scrollable`]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue