Checkpoint
This commit is contained in:
parent
0e4bd485e0
commit
7149f99f02
2 changed files with 13 additions and 4 deletions
|
@ -67,7 +67,11 @@ impl<V: 'static + Send + Sync> Element for View<V> {
|
||||||
_: Option<Self::ElementState>,
|
_: Option<Self::ElementState>,
|
||||||
cx: &mut ViewContext<()>,
|
cx: &mut ViewContext<()>,
|
||||||
) -> Self::ElementState {
|
) -> Self::ElementState {
|
||||||
self.state.update(cx, |state, cx| (self.render)(state, cx))
|
self.state.update(cx, |state, cx| {
|
||||||
|
let mut any_element = (self.render)(state, cx);
|
||||||
|
any_element.initialize(state, cx);
|
||||||
|
any_element
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
|
@ -161,8 +165,11 @@ impl<V: Send + Sync + 'static> ViewObject for View<V> {
|
||||||
|
|
||||||
fn initialize(&mut self, cx: &mut WindowContext) -> AnyBox {
|
fn initialize(&mut self, cx: &mut WindowContext) -> AnyBox {
|
||||||
cx.with_element_id(self.entity_id(), |cx| {
|
cx.with_element_id(self.entity_id(), |cx| {
|
||||||
self.state
|
self.state.update(cx, |state, cx| {
|
||||||
.update(cx, |state, cx| Box::new((self.render)(state, cx)) as AnyBox)
|
let mut any_element = Box::new((self.render)(state, cx));
|
||||||
|
any_element.initialize(state, cx);
|
||||||
|
any_element as AnyBox
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,9 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
|
||||||
) -> Self::ElementState {
|
) -> Self::ElementState {
|
||||||
use gpui3::IntoAnyElement;
|
use gpui3::IntoAnyElement;
|
||||||
|
|
||||||
self.render(view_state, cx).into_any()
|
let mut element = self.render(view_state, cx).into_any();
|
||||||
|
element.initialize(view_state, cx);
|
||||||
|
element
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue