Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Ignore element offset when manually drawing `AnyElement`

Antonio Scandurra23fd1e19dc4e
diff --git a/crates/gpui2/src/element.rs b/crates/gpui2/src/element.rs
index e7526dfa3a7..9ee9eaa7c33 100644
--- a/crates/gpui2/src/element.rs
+++ b/crates/gpui2/src/element.rs
@@ -246,12 +246,15 @@ where
fn draw(
&mut self,
- origin: Point<Pixels>,
+ mut origin: Point<Pixels>,
available_space: Size<AvailableSpace>,
view_state: &mut V,
cx: &mut ViewContext<V>,
) {
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))
}
}