Introduce following for assistant panel (#14479)
Release Notes: - Added support for following into the assistant panel. --------- Co-authored-by: Max <max@zed.dev> Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com> Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
parent
977a1b7a82
commit
decdd3b6ac
13 changed files with 819 additions and 541 deletions
|
@ -1,6 +1,7 @@
|
|||
use crate::persistence::model::DockData;
|
||||
use crate::{status_bar::StatusItemView, Workspace};
|
||||
use crate::{DraggedDock, Event};
|
||||
use crate::{DraggedDock, Event, Pane};
|
||||
use client::proto;
|
||||
use gpui::{
|
||||
deferred, div, px, Action, AnchorCorner, AnyView, AppContext, Axis, Entity, EntityId,
|
||||
EventEmitter, FocusHandle, FocusableView, IntoElement, KeyContext, MouseButton, MouseDownEvent,
|
||||
|
@ -23,6 +24,8 @@ pub enum PanelEvent {
|
|||
Close,
|
||||
}
|
||||
|
||||
pub use proto::PanelId;
|
||||
|
||||
pub trait Panel: FocusableView + EventEmitter<PanelEvent> {
|
||||
fn persistent_name() -> &'static str;
|
||||
fn position(&self, cx: &WindowContext) -> DockPosition;
|
||||
|
@ -44,6 +47,12 @@ pub trait Panel: FocusableView + EventEmitter<PanelEvent> {
|
|||
}
|
||||
fn set_zoomed(&mut self, _zoomed: bool, _cx: &mut ViewContext<Self>) {}
|
||||
fn set_active(&mut self, _active: bool, _cx: &mut ViewContext<Self>) {}
|
||||
fn pane(&self) -> Option<View<Pane>> {
|
||||
None
|
||||
}
|
||||
fn remote_id() -> Option<proto::PanelId> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PanelHandle: Send + Sync {
|
||||
|
@ -55,6 +64,8 @@ pub trait PanelHandle: Send + Sync {
|
|||
fn is_zoomed(&self, cx: &WindowContext) -> bool;
|
||||
fn set_zoomed(&self, zoomed: bool, cx: &mut WindowContext);
|
||||
fn set_active(&self, active: bool, cx: &mut WindowContext);
|
||||
fn remote_id(&self) -> Option<proto::PanelId>;
|
||||
fn pane(&self, cx: &WindowContext) -> Option<View<Pane>>;
|
||||
fn size(&self, cx: &WindowContext) -> Pixels;
|
||||
fn set_size(&self, size: Option<Pixels>, cx: &mut WindowContext);
|
||||
fn icon(&self, cx: &WindowContext) -> Option<ui::IconName>;
|
||||
|
@ -101,6 +112,14 @@ where
|
|||
self.update(cx, |this, cx| this.set_active(active, cx))
|
||||
}
|
||||
|
||||
fn pane(&self, cx: &WindowContext) -> Option<View<Pane>> {
|
||||
self.read(cx).pane()
|
||||
}
|
||||
|
||||
fn remote_id(&self) -> Option<PanelId> {
|
||||
T::remote_id()
|
||||
}
|
||||
|
||||
fn size(&self, cx: &WindowContext) -> Pixels {
|
||||
self.read(cx).size(cx)
|
||||
}
|
||||
|
@ -296,6 +315,12 @@ impl Dock {
|
|||
.position(|entry| entry.panel.persistent_name() == ui_name)
|
||||
}
|
||||
|
||||
pub fn panel_index_for_proto_id(&self, panel_id: PanelId) -> Option<usize> {
|
||||
self.panel_entries
|
||||
.iter()
|
||||
.position(|entry| entry.panel.remote_id() == Some(panel_id))
|
||||
}
|
||||
|
||||
pub fn active_panel_index(&self) -> usize {
|
||||
self.active_panel_index
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue