Remove From trait for AnyViewHandle in favor of into_any method
I think it's more explicit.
This commit is contained in:
parent
aed8df96ff
commit
27258a0889
3 changed files with 18 additions and 23 deletions
|
@ -1633,14 +1633,14 @@ impl MutableAppContext {
|
||||||
this.cx.windows.insert(
|
this.cx.windows.insert(
|
||||||
window_id,
|
window_id,
|
||||||
Window {
|
Window {
|
||||||
root_view: root_view.clone().into(),
|
root_view: root_view.clone().into_any(),
|
||||||
focused_view_id: Some(root_view.id()),
|
focused_view_id: Some(root_view.id()),
|
||||||
is_active: false,
|
is_active: false,
|
||||||
invalidation: None,
|
invalidation: None,
|
||||||
is_fullscreen: false,
|
is_fullscreen: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
root_view.update(this, |view, cx| view.focus_in(cx.handle().into(), cx));
|
root_view.update(this, |view, cx| view.focus_in(cx.handle().into_any(), cx));
|
||||||
|
|
||||||
let window =
|
let window =
|
||||||
this.cx
|
this.cx
|
||||||
|
@ -1662,17 +1662,18 @@ impl MutableAppContext {
|
||||||
let root_view = this
|
let root_view = this
|
||||||
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let focused_view_id = root_view.id();
|
||||||
this.cx.windows.insert(
|
this.cx.windows.insert(
|
||||||
window_id,
|
window_id,
|
||||||
Window {
|
Window {
|
||||||
root_view: root_view.clone().into(),
|
root_view: root_view.clone().into_any(),
|
||||||
focused_view_id: Some(root_view.id()),
|
focused_view_id: Some(focused_view_id),
|
||||||
is_active: false,
|
is_active: false,
|
||||||
invalidation: None,
|
invalidation: None,
|
||||||
is_fullscreen: false,
|
is_fullscreen: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
root_view.update(this, |view, cx| view.focus_in(cx.handle().into(), cx));
|
root_view.update(this, |view, cx| view.focus_in(cx.handle().into_any(), cx));
|
||||||
|
|
||||||
let status_item = this.cx.platform.add_status_item();
|
let status_item = this.cx.platform.add_status_item();
|
||||||
this.register_platform_window(window_id, status_item);
|
this.register_platform_window(window_id, status_item);
|
||||||
|
@ -1783,7 +1784,7 @@ impl MutableAppContext {
|
||||||
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
||||||
window.root_view = root_view.clone().into();
|
window.root_view = root_view.clone().into_any();
|
||||||
window.focused_view_id = Some(root_view.id());
|
window.focused_view_id = Some(root_view.id());
|
||||||
root_view
|
root_view
|
||||||
})
|
})
|
||||||
|
@ -3362,7 +3363,7 @@ where
|
||||||
) {
|
) {
|
||||||
let mut cx = ViewContext::new(cx, window_id, view_id);
|
let mut cx = ViewContext::new(cx, window_id, view_id);
|
||||||
let focused_view_handle: AnyViewHandle = if view_id == focused_id {
|
let focused_view_handle: AnyViewHandle = if view_id == focused_id {
|
||||||
cx.handle().into()
|
cx.handle().into_any()
|
||||||
} else {
|
} else {
|
||||||
let focused_type = cx
|
let focused_type = cx
|
||||||
.views
|
.views
|
||||||
|
@ -3384,7 +3385,7 @@ where
|
||||||
) {
|
) {
|
||||||
let mut cx = ViewContext::new(cx, window_id, view_id);
|
let mut cx = ViewContext::new(cx, window_id, view_id);
|
||||||
let blurred_view_handle: AnyViewHandle = if view_id == blurred_id {
|
let blurred_view_handle: AnyViewHandle = if view_id == blurred_id {
|
||||||
cx.handle().into()
|
cx.handle().into_any()
|
||||||
} else {
|
} else {
|
||||||
let blurred_type = cx
|
let blurred_type = cx
|
||||||
.views
|
.views
|
||||||
|
@ -3905,7 +3906,7 @@ impl<'a, T: View> ViewContext<'a, T> {
|
||||||
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
.build_and_insert_view(window_id, ParentId::Root, |cx| Some(build_root_view(cx)))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
let window = this.cx.windows.get_mut(&window_id).unwrap();
|
||||||
window.root_view = root_view.clone().into();
|
window.root_view = root_view.clone().into_any();
|
||||||
window.focused_view_id = Some(root_view.id());
|
window.focused_view_id = Some(root_view.id());
|
||||||
root_view
|
root_view
|
||||||
})
|
})
|
||||||
|
@ -4690,6 +4691,10 @@ impl<T: View> ViewHandle<T> {
|
||||||
WeakViewHandle::new(self.window_id, self.view_id)
|
WeakViewHandle::new(self.window_id, self.view_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_any(self) -> AnyViewHandle {
|
||||||
|
self.any_handle
|
||||||
|
}
|
||||||
|
|
||||||
pub fn window_id(&self) -> usize {
|
pub fn window_id(&self) -> usize {
|
||||||
self.window_id
|
self.window_id
|
||||||
}
|
}
|
||||||
|
@ -4902,12 +4907,6 @@ impl Clone for AnyViewHandle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: View> From<ViewHandle<T>> for AnyViewHandle {
|
|
||||||
fn from(handle: ViewHandle<T>) -> Self {
|
|
||||||
handle.any_handle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> PartialEq<ViewHandle<T>> for AnyViewHandle {
|
impl<T> PartialEq<ViewHandle<T>> for AnyViewHandle {
|
||||||
fn eq(&self, other: &ViewHandle<T>) -> bool {
|
fn eq(&self, other: &ViewHandle<T>) -> bool {
|
||||||
self.window_id == other.window_id && self.view_id == other.view_id
|
self.window_id == other.window_id && self.view_id == other.view_id
|
||||||
|
|
|
@ -1036,12 +1036,8 @@ impl Workspace {
|
||||||
&self.client
|
&self.client
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_titlebar_item(
|
pub fn set_titlebar_item(&mut self, item: AnyViewHandle, cx: &mut ViewContext<Self>) {
|
||||||
&mut self,
|
self.titlebar_item = Some(item);
|
||||||
item: impl Into<AnyViewHandle>,
|
|
||||||
cx: &mut ViewContext<Self>,
|
|
||||||
) {
|
|
||||||
self.titlebar_item = Some(item.into());
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1355,7 +1351,7 @@ impl Workspace {
|
||||||
} else {
|
} else {
|
||||||
let modal = add_view(self, cx);
|
let modal = add_view(self, cx);
|
||||||
cx.focus(&modal);
|
cx.focus(&modal);
|
||||||
self.modal = Some(modal.into());
|
self.modal = Some(modal.into_any());
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,7 +299,7 @@ pub fn initialize_workspace(
|
||||||
|
|
||||||
let collab_titlebar_item =
|
let collab_titlebar_item =
|
||||||
cx.add_view(|cx| CollabTitlebarItem::new(&workspace_handle, &app_state.user_store, cx));
|
cx.add_view(|cx| CollabTitlebarItem::new(&workspace_handle, &app_state.user_store, cx));
|
||||||
workspace.set_titlebar_item(collab_titlebar_item, cx);
|
workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx);
|
||||||
|
|
||||||
let project_panel = ProjectPanel::new(workspace.project().clone(), cx);
|
let project_panel = ProjectPanel::new(workspace.project().clone(), cx);
|
||||||
workspace.left_sidebar().update(cx, |sidebar, cx| {
|
workspace.left_sidebar().update(cx, |sidebar, cx| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue