Merge branch 'main' into bounds-for-range

This commit is contained in:
Max Brunsfeld 2023-11-08 17:30:06 -08:00
commit 4350801399
24 changed files with 534 additions and 338 deletions

View file

@ -1437,7 +1437,7 @@ impl VisualContext for WindowContext<'_> {
build_view_state: impl FnOnce(&mut ViewContext<'_, V>) -> V,
) -> Self::Result<View<V>>
where
V: 'static,
V: 'static + Render,
{
let slot = self.app.entities.reserve();
let view = View {
@ -1445,7 +1445,16 @@ impl VisualContext for WindowContext<'_> {
};
let mut cx = ViewContext::new(&mut *self.app, &mut *self.window, &view);
let entity = build_view_state(&mut cx);
self.entities.insert(slot, entity);
cx.entities.insert(slot, entity);
cx.new_view_observers
.clone()
.retain(&TypeId::of::<V>(), |observer| {
let any_view = AnyView::from(view.clone());
(observer)(any_view, self);
true
});
view
}
@ -2219,7 +2228,7 @@ impl<V> Context for ViewContext<'_, V> {
}
impl<V: 'static> VisualContext for ViewContext<'_, V> {
fn build_view<W: 'static>(
fn build_view<W: Render + 'static>(
&mut self,
build_view_state: impl FnOnce(&mut ViewContext<'_, W>) -> W,
) -> Self::Result<View<W>> {