this should fix the gap thing?

This commit is contained in:
griffi-gh 2024-03-25 14:18:14 +01:00
parent c1be9bf22b
commit d8b470d805

View file

@ -225,7 +225,8 @@ impl UiElement for Container {
let last_line = lines.last_mut().unwrap(); let last_line = lines.last_mut().unwrap();
last_line.content_size = line_size; last_line.content_size = line_size;
//HACK: why? - self.gap, may be different for the last element or if it's the only element in the line //HACK: why? - self.gap, may be different for the last element or if it's the only element in the line
last_line.remaining_space = max_line_pri - self.gap - match self.direction { let will_produce_gap = if line_element_count > 1 { self.gap } else { 0. };
last_line.remaining_space = max_line_pri - will_produce_gap - match self.direction {
Direction::Horizontal => line_size.x + self.padding.left + self.padding.right, Direction::Horizontal => line_size.x + self.padding.left + self.padding.right,
Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom, Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom,
}; };
@ -290,7 +291,8 @@ impl UiElement for Container {
//HACK: why? - self.gap, may be different for the last element or if it's the only element in the line //HACK: why? - self.gap, may be different for the last element or if it's the only element in the line
let cur_line = lines.last_mut().unwrap(); let cur_line = lines.last_mut().unwrap();
cur_line.content_size = line_size; cur_line.content_size = line_size;
cur_line.remaining_space = max_line_pri - self.gap - match self.direction { let will_produce_gap = if line_element_count > 1 { self.gap } else { 0. };
cur_line.remaining_space = max_line_pri - will_produce_gap - match self.direction {
Direction::Horizontal => line_size.x + self.padding.left + self.padding.right, Direction::Horizontal => line_size.x + self.padding.left + self.padding.right,
Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom, Direction::Vertical => line_size.y + self.padding.top + self.padding.bottom,
}; };