Make alignment a widget property
This commit is contained in:
1 parent
8220a78d4a
commit
d3b0ebf90c
21 files changed
+823
-300
No files matched your search
@@ -13,18 +13,20 @@ impl Widget for Stack {
|
||||
StackSize::Default => None,
|
||||
StackSize::Child(i) => Some(i),
|
||||
};
|
||||
let mut size = Size::default();
|
||||
// Whichever child sizes the stack decides the box every child gets.
|
||||
// The stack reports that size, so a child given a longer box would
|
||||
// draw outside what the stack says it occupies.
|
||||
let size = match sizing.and_then(|i| self.children.get(i)) {
|
||||
Some(child) => painter.widget(child).size(),
|
||||
None => Size::LEFTOVER,
|
||||
};
|
||||
let region = painter.box_of(size);
|
||||
for (i, child) in self.children.iter().enumerate() {
|
||||
match i {
|
||||
0 => painter.child_layer(),
|
||||
_ => painter.next_layer(),
|
||||
}
|
||||
let drawn = painter.widget(child);
|
||||
// Only the child that sizes the stack is read, so the others
|
||||
// changing size does not redraw it.
|
||||
if sizing == Some(i) {
|
||||
size = drawn.size();
|
||||
}
|
||||
painter.widget_aligned(child, region, RegionAlign::NEAR);
|
||||
}
|
||||
size
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user