Ignore element offset when manually drawing AnyElement

This commit is contained in:
Antonio Scandurra
2023-11-10 11:35:57 +01:00
parent a0987f1121
commit 23fd1e19dc
+4 -1
View File
@@ -246,12 +246,15 @@ where
fn draw( fn draw(
&mut self, &mut self,
origin: Point<Pixels>, mut origin: Point<Pixels>,
available_space: Size<AvailableSpace>, available_space: Size<AvailableSpace>,
view_state: &mut V, view_state: &mut V,
cx: &mut ViewContext<V>, cx: &mut ViewContext<V>,
) { ) {
self.measure(available_space, view_state, cx); 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)) cx.with_element_offset(Some(origin), |cx| self.paint(view_state, cx))
} }
} }