Checkpoint
This commit is contained in:
parent
fecb27232e
commit
0e4bd485e0
2 changed files with 33 additions and 15 deletions
|
@ -57,27 +57,34 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn initialize(
|
||||||
|
&mut self,
|
||||||
|
view_state: &mut Self::ViewState,
|
||||||
|
_: Option<Self::ElementState>,
|
||||||
|
cx: &mut gpui3::ViewContext<Self::ViewState>
|
||||||
|
) -> Self::ElementState {
|
||||||
|
use gpui3::IntoAnyElement;
|
||||||
|
|
||||||
|
self.render(view_state, cx).into_any()
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
view_state: &mut Self::ViewState,
|
view_state: &mut Self::ViewState,
|
||||||
element_state: Option<Self::ElementState>,
|
rendered_element: &mut Self::ElementState,
|
||||||
cx: &mut gpui3::ViewContext<Self::ViewState>,
|
cx: &mut gpui3::ViewContext<Self::ViewState>,
|
||||||
) -> (gpui3::LayoutId, Self::ElementState) {
|
) -> gpui3::LayoutId {
|
||||||
use gpui3::IntoAnyElement;
|
rendered_element.layout(view_state, cx)
|
||||||
|
|
||||||
let mut rendered_element = self.render(view_state, cx).into_any();
|
|
||||||
let layout_id = rendered_element.layout(view_state, cx);
|
|
||||||
(layout_id, rendered_element)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(
|
fn paint(
|
||||||
&mut self,
|
&mut self,
|
||||||
bounds: gpui3::Bounds<gpui3::Pixels>,
|
bounds: gpui3::Bounds<gpui3::Pixels>,
|
||||||
view_state: &mut Self::ViewState,
|
view_state: &mut Self::ViewState,
|
||||||
element_state: &mut Self::ElementState,
|
rendered_element: &mut Self::ElementState,
|
||||||
cx: &mut gpui3::ViewContext<Self::ViewState>,
|
cx: &mut gpui3::ViewContext<Self::ViewState>,
|
||||||
) {
|
) {
|
||||||
element_state.paint(view_state, None, cx)
|
rendered_element.paint(view_state, None, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -164,31 +164,42 @@ impl<E: Element> Element for Themed<E> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn initialize(
|
||||||
|
&mut self,
|
||||||
|
view_state: &mut Self::ViewState,
|
||||||
|
element_state: Option<Self::ElementState>,
|
||||||
|
cx: &mut ViewContext<Self::ViewState>,
|
||||||
|
) -> Self::ElementState {
|
||||||
|
cx.with_global(self.theme.clone(), |cx| {
|
||||||
|
self.child.initialize(view_state, element_state, cx)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
fn layout(
|
fn layout(
|
||||||
&mut self,
|
&mut self,
|
||||||
state: &mut E::ViewState,
|
view_state: &mut E::ViewState,
|
||||||
element_state: Option<Self::ElementState>,
|
element_state: &mut Self::ElementState,
|
||||||
cx: &mut ViewContext<E::ViewState>,
|
cx: &mut ViewContext<E::ViewState>,
|
||||||
) -> (LayoutId, Self::ElementState)
|
) -> LayoutId
|
||||||
where
|
where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
cx.with_global(self.theme.clone(), |cx| {
|
cx.with_global(self.theme.clone(), |cx| {
|
||||||
self.child.layout(state, element_state, cx)
|
self.child.layout(view_state, element_state, cx)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paint(
|
fn paint(
|
||||||
&mut self,
|
&mut self,
|
||||||
bounds: Bounds<Pixels>,
|
bounds: Bounds<Pixels>,
|
||||||
state: &mut Self::ViewState,
|
view_state: &mut Self::ViewState,
|
||||||
frame_state: &mut Self::ElementState,
|
frame_state: &mut Self::ElementState,
|
||||||
cx: &mut ViewContext<Self::ViewState>,
|
cx: &mut ViewContext<Self::ViewState>,
|
||||||
) where
|
) where
|
||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
cx.with_global(self.theme.clone(), |cx| {
|
cx.with_global(self.theme.clone(), |cx| {
|
||||||
self.child.paint(bounds, state, frame_state, cx);
|
self.child.paint(bounds, view_state, frame_state, cx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue