fix: Column now restores previous Y position

This patch fixes the bug where positioning is all wonky after having
rendered a Column, because Column didn't restore the previous Y
position. Similar bugs probably will occur but this is the first one I
catched.
This commit is contained in:
TheOddGarlic 2022-05-01 18:29:36 +03:00
parent 3c5c57cf22
commit 88f518f7c1

View file

@ -15,6 +15,7 @@ pub struct Column {
impl Widget for Column { impl Widget for Column {
fn draw(&self, renderer: &mut Renderer) { fn draw(&self, renderer: &mut Renderer) {
let (_, prev_y) = renderer.position();
self.widgets.iter().for_each(|widget| { self.widgets.iter().for_each(|widget| {
let pos = widget.position(renderer); let pos = widget.position(renderer);
renderer.position_at( renderer.position_at(
@ -27,6 +28,8 @@ impl Widget for Column {
renderer.position().1 + pos.height() renderer.position().1 + pos.height()
); );
}); });
renderer.position_at(renderer.position().0, prev_y);
} }
fn position(&self, renderer: &mut Renderer) -> Position { fn position(&self, renderer: &mut Renderer) -> Position {