From 23fd1e19dc4e083d50661e1b2aa64b85e4cd21d1 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 10 Nov 2023 11:35:57 +0100 Subject: [PATCH] Ignore element offset when manually drawing `AnyElement` --- crates/gpui2/src/element.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs index e7526dfa3a..9ee9eaa7c3 100644 --- a/crates/gpui2/src/element.rs +++ b/crates/gpui2/src/element.rs @@ -246,12 +246,15 @@ where fn draw( &mut self, - origin: Point, + mut origin: Point, available_space: Size, view_state: &mut V, cx: &mut ViewContext, ) { self.measure(available_space, view_state, cx); + // Ignore the element offset when drawing this element, as the origin is already specified + // in absolute terms. + origin -= cx.element_offset(); cx.with_element_offset(Some(origin), |cx| self.paint(view_state, cx)) } }