From 66dcb732637102ed55880f908667f84842b1f2da Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Mon, 22 Mar 2021 21:11:08 -0600 Subject: [PATCH] Respect margins when painting Container --- gpui/src/elements/container.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gpui/src/elements/container.rs b/gpui/src/elements/container.rs index 860270a6f7f393e25ccd0d04770d7c80f15e126e..a4ba5ac2db95463bcfbfd52d91c924d533ce6253 100644 --- a/gpui/src/elements/container.rs +++ b/gpui/src/elements/container.rs @@ -150,16 +150,21 @@ impl Element for Container { _: &mut Self::LayoutState, ctx: &mut PaintContext, ) -> Self::PaintState { + let quad_bounds = RectF::from_points( + bounds.origin() + vec2f(self.margin.left, self.margin.top), + bounds.lower_right() - vec2f(self.margin.right, self.margin.bottom), + ); + if let Some(shadow) = self.shadow.as_ref() { ctx.scene.push_shadow(scene::Shadow { - bounds: bounds + shadow.offset, + bounds: quad_bounds + shadow.offset, corner_radius: self.corner_radius, sigma: shadow.blur, color: shadow.color, }); } ctx.scene.push_quad(Quad { - bounds, + bounds: quad_bounds, background: self.background_color, border: self.border, corner_radius: self.corner_radius,