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.

Merge branch 'zed2' into zed2-workspace

Antonio Scandurra821fe0f5b584
diff --cc crates/gpui2/src/view.rs
index 66f1a148694,a27faed07de..36f1f5d9cd0
--- a/crates/gpui2/src/view.rs
+++ b/crates/gpui2/src/view.rs
@@@ -1,8 -1,8 +1,8 @@@
use parking_lot::Mutex;
use crate::{
- AnyBox, AnyElement, AnyHandle, BorrowWindow, Bounds, Element, ElementId, Handle,
- IntoAnyElement, LayoutId, Pixels, ViewContext, WindowContext,
- AnyBox, AnyElement, BorrowWindow, Bounds, Component, Element, ElementId, EntityId, Handle,
++ AnyBox, AnyElement, AnyHandle, BorrowWindow, Bounds, Component, Element, ElementId, Handle,
+ LayoutId, Pixels, ViewContext, WindowContext,
};
use std::{marker::PhantomData, sync::Arc};
@@@ -50,11 -50,10 +50,10 @@@ impl<V: 'static, ParentViewState: 'stat
}
}
- impl<V: 'static> Element for View<V> {
- type ViewState = ();
+ impl<V: 'static> Element<()> for View<V> {
type ElementState = AnyElement<V>;
- fn id(&self) -> Option<crate::ElementId> {
+ fn id(&self) -> Option<ElementId> {
Some(ElementId::View(self.state.entity_id))
}
@@@ -105,11 -104,10 +104,10 @@@ impl<V: 'static, ParentV: 'static> Comp
}
}
- impl<V: 'static, ParentV: 'static> Element for EraseViewState<V, ParentV> {
- type ViewState = ParentV;
+ impl<V: 'static, ParentV: 'static> Element<ParentV> for EraseViewState<V, ParentV> {
type ElementState = AnyBox;
- fn id(&self) -> Option<crate::ElementId> {
+ fn id(&self) -> Option<ElementId> {
Element::id(&self.view)
}
@@@ -187,14 -185,8 +185,14 @@@ pub struct AnyView
view: Arc<Mutex<dyn ViewObject>>,
}
+impl AnyView {
+ pub fn entity_handle(&self) -> AnyHandle {
+ self.view.lock().entity_handle().clone()
+ }
+}
+
- impl<ParentV: 'static> IntoAnyElement<ParentV> for AnyView {
- fn into_any(self) -> AnyElement<ParentV> {
+ impl<ParentV: 'static> Component<ParentV> for AnyView {
+ fn render(self) -> AnyElement<ParentV> {
AnyElement::new(EraseAnyViewState {
view: self,
parent_view_state_type: PhantomData,
@@@ -202,12 -194,11 +200,11 @@@
}
}
- impl Element for AnyView {
- type ViewState = ();
+ impl Element<()> for AnyView {
type ElementState = AnyBox;
- fn id(&self) -> Option<crate::ElementId> {
- Some(ElementId::View(self.view.lock().entity_id()))
+ fn id(&self) -> Option<ElementId> {
+ Some(ElementId::View(self.view.lock().entity_handle().entity_id))
}
fn initialize(
@@@ -253,11 -244,10 +250,10 @@@ impl<ParentV: 'static> Component<Parent
}
}
- impl<ParentV: 'static> Element for EraseAnyViewState<ParentV> {
- type ViewState = ParentV;
+ impl<ParentV: 'static> Element<ParentV> for EraseAnyViewState<ParentV> {
type ElementState = AnyBox;
- fn id(&self) -> Option<crate::ElementId> {
+ fn id(&self) -> Option<ElementId> {
Element::id(&self.view)
}