diff --git a/crates/agent_ui/src/sidebar.rs b/crates/agent_ui/src/sidebar.rs index 3b767f685380807b58a3f4b1f719045595007a6e..1e0ad2cd4689ac48c5deb42c5a5d23129238294d 100644 --- a/crates/agent_ui/src/sidebar.rs +++ b/crates/agent_ui/src/sidebar.rs @@ -2026,9 +2026,8 @@ impl Panel for Sidebar { self.set_width(size, cx); } - fn icon(&self, _window: &Window, cx: &App) -> Option { - let settings = AgentSettings::get_global(cx); - (settings.enabled(cx) && settings.button).then_some(IconName::ThreadsSidebarLeftClosed) + fn icon(&self, _window: &Window, _cx: &App) -> IconName { + IconName::ThreadsSidebarLeftClosed } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { @@ -2044,7 +2043,8 @@ impl Panel for Sidebar { } fn enabled(&self, cx: &App) -> bool { - AgentSettings::get_global(cx).enabled(cx) + let settings = AgentSettings::get_global(cx); + settings.enabled(cx) && settings.button } fn starts_open(&self, _window: &Window, _cx: &App) -> bool { diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rs index 8d48370a27c7a50323d2dfa1ad95a8284491d81d..0b9ca9d921e18ec00184abf63b50cd1b260d6fe6 100644 --- a/crates/collab_ui/src/collab_panel.rs +++ b/crates/collab_ui/src/collab_panel.rs @@ -3191,16 +3191,18 @@ impl Panel for CollabPanel { }); } - fn icon(&self, _window: &Window, cx: &App) -> Option { - CollaborationPanelSettings::get_global(cx) - .button - .then_some(ui::IconName::UserGroup) + fn icon(&self, _window: &Window, _cx: &App) -> ui::IconName { + ui::IconName::UserGroup } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { "Collab Panel" } + fn enabled(&self, cx: &App) -> bool { + CollaborationPanelSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/collab_ui/src/notification_panel.rs b/crates/collab_ui/src/notification_panel.rs index e6d1ecd9471339d6d4014b04433e9824ebe0fd4e..d417d843feee0216cd3b10fa4bfa0f0ba420428a 100644 --- a/crates/collab_ui/src/notification_panel.rs +++ b/crates/collab_ui/src/notification_panel.rs @@ -659,23 +659,22 @@ impl Panel for NotificationPanel { } } - fn icon(&self, _: &Window, cx: &App) -> Option { - let show_button = NotificationPanelSettings::get_global(cx).button; - if !show_button { - return None; - } - + fn icon(&self, _: &Window, _cx: &App) -> IconName { if self.unseen_notifications.is_empty() { - return Some(IconName::Bell); + IconName::Bell + } else { + IconName::BellDot } - - Some(IconName::BellDot) } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { "Notification Panel" } + fn enabled(&self, cx: &App) -> bool { + NotificationPanelSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 9750fd360f564a3b74b7f868a7e5e02f675a5bc9..148a6ec63eccb2f8e71982b4dd4137e96f53e85e 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -1579,16 +1579,18 @@ impl Panel for DebugPanel { Some(proto::PanelId::DebugPanel) } - fn icon(&self, _window: &Window, cx: &App) -> Option { - DebuggerSettings::get_global(cx) - .button - .then_some(IconName::Debug) + fn icon(&self, _window: &Window, _cx: &App) -> IconName { + IconName::Debug } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { "Debug Panel" } + fn enabled(&self, cx: &App) -> bool { + DebuggerSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs index 8a8a900df1ddff361d144c0b71c4637205f9ef0d..ba6ce7f99df231f32a5c0bc2359928e4248873cd 100644 --- a/crates/git_ui/src/git_panel.rs +++ b/crates/git_ui/src/git_panel.rs @@ -5730,14 +5730,18 @@ impl Panel for GitPanel { cx.notify(); } - fn icon(&self, _: &Window, cx: &App) -> Option { - Some(ui::IconName::GitBranchAlt).filter(|_| GitPanelSettings::get_global(cx).button) + fn icon(&self, _: &Window, _cx: &App) -> ui::IconName { + ui::IconName::GitBranchAlt } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { "Git Panel" } + fn enabled(&self, cx: &App) -> bool { + GitPanelSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index eca4d92ed6a762d68506d752cd0aacc241eb9b67..1f2ec6f07a0e84c6130290d3c8767e9aec4e9e03 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -5017,16 +5017,18 @@ impl Panel for OutlinePanel { }); } - fn icon(&self, _: &Window, cx: &App) -> Option { - OutlinePanelSettings::get_global(cx) - .button - .then_some(IconName::ListTree) + fn icon(&self, _: &Window, _cx: &App) -> IconName { + IconName::ListTree } fn icon_tooltip(&self, _window: &Window, _: &App) -> &'static str { "Outline Panel" } + fn enabled(&self, cx: &App) -> bool { + OutlinePanelSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 2a72a58db828f6caec66a1b114e4baba84f44e34..f9315c3f28cb399c80bd563f79260a7988dff350 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -7057,16 +7057,18 @@ impl Panel for ProjectPanel { }); } - fn icon(&self, _: &Window, cx: &App) -> Option { - ProjectPanelSettings::get_global(cx) - .button - .then_some(IconName::FileTree) + fn icon(&self, _: &Window, _cx: &App) -> IconName { + IconName::FileTree } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { "Project Panel" } + fn enabled(&self, cx: &App) -> bool { + ProjectPanelSettings::get_global(cx).button + } + fn toggle_action(&self) -> Box { Box::new(ToggleFocus) } diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rs index 23b9aee7e159fcf9e9245c000c5a3bf8d69cbc71..bf25e9eeb93d26466ac98067a13800951084709f 100644 --- a/crates/terminal_view/src/terminal_panel.rs +++ b/crates/terminal_view/src/terminal_panel.rs @@ -1613,14 +1613,8 @@ impl Panel for TerminalPanel { TERMINAL_PANEL_KEY } - fn icon(&self, _window: &Window, cx: &App) -> Option { - if (self.is_enabled(cx) || !self.has_no_terminals(cx)) - && TerminalSettings::get_global(cx).button - { - Some(IconName::TerminalAlt) - } else { - None - } + fn icon(&self, _window: &Window, _cx: &App) -> IconName { + IconName::TerminalAlt } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str { @@ -1638,6 +1632,11 @@ impl Panel for TerminalPanel { fn activation_priority(&self) -> u32 { 1 } + + fn enabled(&self, cx: &App) -> bool { + (self.is_enabled(cx) || !self.has_no_terminals(cx)) + && TerminalSettings::get_global(cx).button + } } struct TerminalProvider(Entity); diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 45a1b222bb84213c646e5ccd41bdefce552301c8..4bfab25f42aeb0210f29ff9e677a36d70d6302e9 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -34,7 +34,7 @@ pub trait Panel: Focusable + EventEmitter + Render + Sized { fn set_position(&mut self, position: DockPosition, window: &mut Window, cx: &mut Context); fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&mut self, size: Option, window: &mut Window, cx: &mut Context); - fn icon(&self, window: &Window, cx: &App) -> Option; + fn icon(&self, window: &Window, cx: &App) -> ui::IconName; fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str; fn toggle_action(&self) -> Box; fn is_zoomed(&self, _window: &Window, _cx: &App) -> bool { @@ -71,7 +71,7 @@ pub trait PanelHandle: Send + Sync { fn pane(&self, cx: &App) -> Option>; fn size(&self, window: &Window, cx: &App) -> Pixels; fn set_size(&self, size: Option, window: &mut Window, cx: &mut App); - fn icon(&self, window: &Window, cx: &App) -> Option; + fn icon(&self, window: &Window, cx: &App) -> ui::IconName; fn icon_tooltip(&self, window: &Window, cx: &App) -> &'static str; fn toggle_action(&self, window: &Window, cx: &App) -> Box; fn panel_focus_handle(&self, cx: &App) -> FocusHandle; @@ -151,7 +151,7 @@ where self.update(cx, |this, cx| this.set_size(size, window, cx)) } - fn icon(&self, window: &Window, cx: &App) -> Option { + fn icon(&self, window: &Window, cx: &App) -> ui::IconName { self.read(cx).icon(window, cx) } @@ -905,7 +905,10 @@ impl Render for PanelButtons { .iter() .enumerate() .filter_map(|(i, entry)| { - let icon = entry.panel.icon(window, cx)?; + if !entry.panel.enabled(cx) { + return None; + } + let icon = entry.panel.icon(window, cx); let icon_tooltip = entry.panel.icon_tooltip(window, cx); let name = entry.panel.persistent_name(); let panel = entry.panel.clone(); @@ -1070,8 +1073,8 @@ pub mod test { self.size = size.unwrap_or(px(300.)); } - fn icon(&self, _window: &Window, _: &App) -> Option { - None + fn icon(&self, _window: &Window, _: &App) -> ui::IconName { + ui::IconName::Cog } fn icon_tooltip(&self, _window: &Window, _cx: &App) -> &'static str {