diff --git a/egui_extras/src/layout.rs b/egui_extras/src/layout.rs index ab402dad..21b4ab4e 100644 --- a/egui_extras/src/layout.rs +++ b/egui_extras/src/layout.rs @@ -121,11 +121,11 @@ impl<'l> StripLayout<'l> { pub fn end_line(&mut self) { match self.direction { CellDirection::Horizontal => { - self.cursor.y = self.max.y; + self.cursor.y = self.max.y + self.ui.spacing().item_spacing.y; self.cursor.x = self.rect.left(); } CellDirection::Vertical => { - self.cursor.x = self.max.x; + self.cursor.x = self.max.x + self.ui.spacing().item_spacing.x; self.cursor.y = self.rect.top(); } } @@ -135,10 +135,7 @@ impl<'l> StripLayout<'l> { let mut child_ui = self.ui.child_ui(rect, *self.ui.layout()); if self.clip { - let mut clip_rect = child_ui.clip_rect(); - clip_rect.min = clip_rect.min.max(rect.min); - clip_rect.max = clip_rect.max.min(rect.max); - child_ui.set_clip_rect(clip_rect); + child_ui.set_clip_rect(child_ui.clip_rect().intersect(rect)); } add_contents(&mut child_ui); diff --git a/egui_extras/src/strip.rs b/egui_extras/src/strip.rs index 235a2a1e..7b984f59 100644 --- a/egui_extras/src/strip.rs +++ b/egui_extras/src/strip.rs @@ -86,7 +86,7 @@ impl<'a> StripBuilder<'a> { F: for<'b> FnOnce(Strip<'a, 'b>), { let widths = self.sizing.to_lengths( - self.ui.available_rect_before_wrap().width() - self.ui.spacing().item_spacing.x, + self.ui.available_rect_before_wrap().width(), self.ui.spacing().item_spacing.x, ); let mut layout = StripLayout::new(self.ui, CellDirection::Horizontal, self.clip); @@ -107,7 +107,7 @@ impl<'a> StripBuilder<'a> { F: for<'b> FnOnce(Strip<'a, 'b>), { let heights = self.sizing.to_lengths( - self.ui.available_rect_before_wrap().height() - self.ui.spacing().item_spacing.y, + self.ui.available_rect_before_wrap().height(), self.ui.spacing().item_spacing.y, ); let mut layout = StripLayout::new(self.ui, CellDirection::Vertical, self.clip);