mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
Ensure flex_float
works even when re-painting without layout
Previously, we were mutating the remaining space stored on the layout state, which would cause re-paints to always have a `remaining_space` of 0 and therefore not align `flex_float` elements to the right/bottom.
This commit is contained in:
parent
8445eaab85
commit
95d848fe1e
@ -225,7 +225,9 @@ impl Element for Flex {
|
||||
remaining_space: &mut Self::LayoutState,
|
||||
cx: &mut PaintContext,
|
||||
) -> Self::PaintState {
|
||||
let overflowing = *remaining_space < 0.;
|
||||
let mut remaining_space = *remaining_space;
|
||||
|
||||
let overflowing = remaining_space < 0.;
|
||||
if overflowing {
|
||||
cx.scene.push_layer(Some(bounds));
|
||||
}
|
||||
@ -240,14 +242,14 @@ impl Element for Flex {
|
||||
}
|
||||
|
||||
for child in &mut self.children {
|
||||
if *remaining_space > 0. {
|
||||
if remaining_space > 0. {
|
||||
if let Some(metadata) = child.metadata::<FlexParentData>() {
|
||||
if metadata.float {
|
||||
match self.axis {
|
||||
Axis::Horizontal => child_origin += vec2f(*remaining_space, 0.0),
|
||||
Axis::Vertical => child_origin += vec2f(0.0, *remaining_space),
|
||||
Axis::Horizontal => child_origin += vec2f(remaining_space, 0.0),
|
||||
Axis::Vertical => child_origin += vec2f(0.0, remaining_space),
|
||||
}
|
||||
*remaining_space = 0.;
|
||||
remaining_space = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -257,6 +259,7 @@ impl Element for Flex {
|
||||
Axis::Vertical => child_origin += vec2f(0.0, child.size().y()),
|
||||
}
|
||||
}
|
||||
|
||||
if overflowing {
|
||||
cx.scene.pop_layer();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user