Add MultiBufferItemHandle
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ca697e1bba
commit
b67be5ded3
5 changed files with 74 additions and 16 deletions
|
@ -279,7 +279,7 @@ impl Pane {
|
|||
item_view.added_to_pane(cx);
|
||||
let item_idx = cmp::min(self.active_item_index + 1, self.item_views.len());
|
||||
self.item_views
|
||||
.insert(item_idx, (item_view.item_handle(cx).id(), item_view));
|
||||
.insert(item_idx, (item_view.item_id(cx), item_view));
|
||||
self.activate_item(item_idx, cx);
|
||||
cx.notify();
|
||||
}
|
||||
|
|
|
@ -150,11 +150,9 @@ pub trait Item: Entity + Sized {
|
|||
}
|
||||
|
||||
pub trait ItemView: View {
|
||||
type ItemHandle: ItemHandle;
|
||||
|
||||
fn deactivated(&mut self, _: &mut ViewContext<Self>) {}
|
||||
fn navigate(&mut self, _: Box<dyn Any>, _: &mut ViewContext<Self>) {}
|
||||
fn item_handle(&self, cx: &AppContext) -> Self::ItemHandle;
|
||||
fn item_id(&self, cx: &AppContext) -> usize;
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn clone_on_split(&self, _: &mut ViewContext<Self>) -> Option<Self>
|
||||
|
@ -222,7 +220,7 @@ pub trait WeakItemHandle {
|
|||
}
|
||||
|
||||
pub trait ItemViewHandle: 'static {
|
||||
fn item_handle(&self, cx: &AppContext) -> Box<dyn ItemHandle>;
|
||||
fn item_id(&self, cx: &AppContext) -> usize;
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox;
|
||||
fn project_path(&self, cx: &AppContext) -> Option<ProjectPath>;
|
||||
fn boxed_clone(&self) -> Box<dyn ItemViewHandle>;
|
||||
|
@ -354,8 +352,8 @@ impl dyn ItemViewHandle {
|
|||
}
|
||||
|
||||
impl<T: ItemView> ItemViewHandle for ViewHandle<T> {
|
||||
fn item_handle(&self, cx: &AppContext) -> Box<dyn ItemHandle> {
|
||||
Box::new(self.read(cx).item_handle(cx))
|
||||
fn item_id(&self, cx: &AppContext) -> usize {
|
||||
self.read(cx).item_id(cx)
|
||||
}
|
||||
|
||||
fn tab_content(&self, style: &theme::Tab, cx: &AppContext) -> ElementBox {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue