Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/agent_ui/src/agent_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1395,6 +1395,10 @@ impl Panel for AgentPanel {
"AgentPanel"
}

fn panel_key() -> &'static str {
AGENT_PANEL_KEY
}

fn position(&self, _window: &Window, cx: &App) -> DockPosition {
agent_panel_dock_position(cx)
}
Expand Down
4 changes: 4 additions & 0 deletions crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3037,6 +3037,10 @@ impl Panel for CollabPanel {
"CollabPanel"
}

fn panel_key() -> &'static str {
COLLABORATION_PANEL_KEY
}

fn activation_priority(&self) -> u32 {
6
}
Expand Down
4 changes: 4 additions & 0 deletions crates/collab_ui/src/notification_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,10 @@ impl Panel for NotificationPanel {
"NotificationPanel"
}

fn panel_key() -> &'static str {
NOTIFICATION_PANEL_KEY
}

fn position(&self, _: &Window, cx: &App) -> DockPosition {
NotificationPanelSettings::get_global(cx).dock
}
Expand Down
6 changes: 6 additions & 0 deletions crates/debugger_ui/src/debugger_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ use workspace::{
};
use zed_actions::ToggleFocus;

const DEBUG_PANEL_KEY: &str = "DebugPanel";

pub struct DebugPanel {
size: Pixels,
active_session: Option<Entity<DebugSession>>,
Expand Down Expand Up @@ -1414,6 +1416,10 @@ impl Panel for DebugPanel {
"DebugPanel"
}

fn panel_key() -> &'static str {
DEBUG_PANEL_KEY
}

fn position(&self, _window: &Window, cx: &App) -> DockPosition {
DebuggerSettings::get_global(cx).dock.into()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4419,6 +4419,10 @@ impl Panel for GitPanel {
"GitPanel"
}

fn panel_key() -> &'static str {
GIT_PANEL_KEY
}

fn position(&self, _: &Window, cx: &App) -> DockPosition {
GitPanelSettings::get_global(cx).dock
}
Expand Down
4 changes: 4 additions & 0 deletions crates/outline_panel/src/outline_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4838,6 +4838,10 @@ impl Panel for OutlinePanel {
"Outline Panel"
}

fn panel_key() -> &'static str {
OUTLINE_PANEL_KEY
}

fn position(&self, _: &Window, cx: &App) -> DockPosition {
match OutlinePanelSettings::get_global(cx).dock {
DockSide::Left => DockPosition::Left,
Expand Down
4 changes: 4 additions & 0 deletions crates/project_panel/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6011,6 +6011,10 @@ impl Panel for ProjectPanel {
"Project Panel"
}

fn panel_key() -> &'static str {
PROJECT_PANEL_KEY
}

fn starts_open(&self, _: &Window, cx: &App) -> bool {
if !ProjectPanelSettings::get_global(cx).starts_open {
return false;
Expand Down
4 changes: 4 additions & 0 deletions crates/terminal_view/src/terminal_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,10 @@ impl Panel for TerminalPanel {
"TerminalPanel"
}

fn panel_key() -> &'static str {
TERMINAL_PANEL_KEY
}

fn icon(&self, _window: &Window, cx: &App) -> Option<IconName> {
if (self.is_enabled(cx) || !self.has_no_terminals(cx))
&& TerminalSettings::get_global(cx).button
Expand Down
10 changes: 10 additions & 0 deletions crates/workspace/src/dock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub use proto::PanelId;

pub trait Panel: Focusable + EventEmitter<PanelEvent> + Render + Sized {
fn persistent_name() -> &'static str;
fn panel_key() -> &'static str;
fn position(&self, window: &Window, cx: &App) -> DockPosition;
fn position_is_valid(&self, position: DockPosition) -> bool;
fn set_position(&mut self, position: DockPosition, window: &mut Window, cx: &mut Context<Self>);
Expand Down Expand Up @@ -61,6 +62,7 @@ pub trait Panel: Focusable + EventEmitter<PanelEvent> + Render + Sized {
pub trait PanelHandle: Send + Sync {
fn panel_id(&self) -> EntityId;
fn persistent_name(&self) -> &'static str;
fn panel_key(&self) -> &'static str;
fn position(&self, window: &Window, cx: &App) -> DockPosition;
fn position_is_valid(&self, position: DockPosition, cx: &App) -> bool;
fn set_position(&self, position: DockPosition, window: &mut Window, cx: &mut App);
Expand Down Expand Up @@ -108,6 +110,10 @@ where
T::persistent_name()
}

fn panel_key(&self) -> &'static str {
T::panel_key()
}

fn position(&self, window: &Window, cx: &App) -> DockPosition {
self.read(cx).position(window, cx)
}
Expand Down Expand Up @@ -1016,6 +1022,10 @@ pub mod test {
"TestPanel"
}

fn panel_key() -> &'static str {
"TestPanel"
}

fn position(&self, _window: &Window, _: &App) -> super::DockPosition {
self.position
}
Expand Down
18 changes: 18 additions & 0 deletions crates/workspace/src/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6367,6 +6367,24 @@ impl Render for Workspace {
}
}

if self.left_dock.read(cx).is_open() {
if let Some(active_panel) = self.left_dock.read(cx).active_panel() {
context.set("left_dock", active_panel.panel_key());
}
}

if self.right_dock.read(cx).is_open() {
if let Some(active_panel) = self.right_dock.read(cx).active_panel() {
context.set("right_dock", active_panel.panel_key());
}
}

if self.bottom_dock.read(cx).is_open() {
if let Some(active_panel) = self.bottom_dock.read(cx).active_panel() {
context.set("bottom_dock", active_panel.panel_key());
}
}

let centered_layout = self.centered_layout
&& self.center.panes().len() == 1
&& self.active_item(cx).is_some();
Expand Down
Loading