From c104f6cc0459e44ce698a65d7dc64863f2831b65 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Mon, 25 Mar 2024 14:18:14 +0100 Subject: [PATCH] this should fix the gap thing? --- hui/src/element/builtin/container.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hui/src/element/builtin/container.rs b/hui/src/element/builtin/container.rs index 2eec01c..6ca2a44 100644 --- a/hui/src/element/builtin/container.rs +++ b/hui/src/element/builtin/container.rs @@ -225,7 +225,8 @@ impl UiElement for Container { let last_line = lines.last_mut().unwrap(); 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 - 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::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 let cur_line = lines.last_mut().unwrap(); 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::Vertical => line_size.y + self.padding.top + self.padding.bottom, };