diff --git a/crates/copilot_button/src/copilot_button.rs b/crates/copilot_button/src/copilot_button.rs index 0d6bcc115c..884d1358f7 100644 --- a/crates/copilot_button/src/copilot_button.rs +++ b/crates/copilot_button/src/copilot_button.rs @@ -65,7 +65,7 @@ impl View for CopilotButton { .workspace .status_bar .panel_buttons - .item + .button .style_for(state, active); Flex::row() diff --git a/crates/feedback/src/deploy_feedback_button.rs b/crates/feedback/src/deploy_feedback_button.rs index 5fdb378eb6..fc90b38750 100644 --- a/crates/feedback/src/deploy_feedback_button.rs +++ b/crates/feedback/src/deploy_feedback_button.rs @@ -41,7 +41,7 @@ impl View for DeployFeedbackButton { .workspace .status_bar .panel_buttons - .item + .button .style_for(state, active); Svg::new("icons/feedback_16.svg") diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 4a1d488eaf..35ab314f3a 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1327,7 +1327,7 @@ impl Entity for ProjectPanel { type Event = Event; } -impl workspace::dock::DockItem for ProjectPanel { +impl workspace::dock::Panel for ProjectPanel { fn should_show_badge(&self, _: &AppContext) -> bool { false } diff --git a/crates/terminal_view/src/terminal_button.rs b/crates/terminal_view/src/terminal_button.rs index cacd21c733..0747f86d2d 100644 --- a/crates/terminal_view/src/terminal_button.rs +++ b/crates/terminal_view/src/terminal_button.rs @@ -53,7 +53,7 @@ impl View for TerminalButton { .workspace .status_bar .panel_buttons - .item + .button .style_for(state, active); Flex::row() diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index c239e0ef40..bc6d639447 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -344,7 +344,7 @@ pub struct StatusBar { pub struct StatusBarPanelButtons { pub group_left: ContainerStyle, pub group_right: ContainerStyle, - pub item: Interactive, + pub button: Interactive, pub badge: ContainerStyle, } @@ -382,7 +382,7 @@ pub struct Dock { } #[derive(Clone, Deserialize, Default)] -pub struct DockItem { +pub struct PanelButton { #[serde(flatten)] pub container: ContainerStyle, pub icon_color: Color, diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 88fc9576bd..432ca646c8 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -7,7 +7,7 @@ use serde::Deserialize; use settings::Settings; use std::rc::Rc; -pub trait DockItem: View { +pub trait Panel: View { fn should_activate_item_on_event(&self, _: &Self::Event, _: &AppContext) -> bool { false } @@ -19,16 +19,17 @@ pub trait DockItem: View { } } -pub trait DockItemHandle { +pub trait PanelHandle { + fn id(&self) -> usize; fn should_show_badge(&self, cx: &WindowContext) -> bool; fn is_focused(&self, cx: &WindowContext) -> bool; fn as_any(&self) -> &AnyViewHandle; } -impl DockItemHandle for ViewHandle +impl PanelHandle for ViewHandle where - T: DockItem, + T: Panel, { fn id(&self) -> usize { self.id() @@ -47,8 +48,8 @@ where } } -impl From<&dyn DockItemHandle> for AnyViewHandle { - fn from(val: &dyn DockItemHandle) -> Self { +impl From<&dyn PanelHandle> for AnyViewHandle { + fn from(val: &dyn PanelHandle) -> Self { val.as_any().clone() } } @@ -78,7 +79,7 @@ impl DockPosition { struct Item { icon_path: &'static str, tooltip: String, - view: Rc, + view: Rc, _subscriptions: [Subscription; 2], } @@ -88,12 +89,12 @@ pub struct PanelButtons { } #[derive(Clone, Debug, Deserialize, PartialEq)] -pub struct ToggleDockItem { +pub struct TogglePanel { pub dock_position: DockPosition, pub item_index: usize, } -impl_actions!(workspace, [ToggleDockItem]); +impl_actions!(workspace, [TogglePanel]); impl Dock { pub fn new(position: DockPosition) -> Self { @@ -126,7 +127,7 @@ impl Dock { cx.notify(); } - pub fn add_item( + pub fn add_item( &mut self, icon_path: &'static str, tooltip: String, @@ -171,7 +172,7 @@ impl Dock { cx.notify(); } - pub fn active_item(&self) -> Option<&Rc> { + pub fn active_item(&self) -> Option<&Rc> { if self.is_open { self.items.get(self.active_item_ix).map(|item| &item.view) } else { @@ -235,7 +236,7 @@ impl View for PanelButtons { let tooltip_style = theme.tooltip.clone(); let theme = &theme.workspace.status_bar.panel_buttons; let dock = self.dock.read(cx); - let item_style = theme.item.clone(); + let item_style = theme.button.clone(); let badge_style = theme.badge; let active_ix = dock.active_item_ix; let is_open = dock.is_open; @@ -255,7 +256,7 @@ impl View for PanelButtons { Flex::row() .with_children(items.into_iter().enumerate().map( |(ix, (icon_path, tooltip, item_view))| { - let action = ToggleDockItem { + let action = TogglePanel { dock_position, item_index: ix, }; diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 49fd882b65..e7571c1bf6 100644 --- a/crates/workspace/src/item.rs +++ b/crates/workspace/src/item.rs @@ -766,7 +766,7 @@ impl FollowableItemHandle for ViewHandle { #[cfg(test)] pub(crate) mod test { use super::{Item, ItemEvent}; - use crate::{dock::DockItem, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId}; + use crate::{dock::Panel, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId}; use gpui::{ elements::Empty, AnyElement, AppContext, Element, Entity, ModelHandle, Task, View, ViewContext, ViewHandle, WeakViewHandle, @@ -1060,5 +1060,5 @@ pub(crate) mod test { } } - impl DockItem for TestItem {} + impl Panel for TestItem {} } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 4ab9e07526..f1bcb3928f 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -74,7 +74,7 @@ use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId}; use serde::Deserialize; use settings::{Autosave, Settings}; use shared_screen::SharedScreen; -use dock::{Dock, PanelButtons, DockPosition, ToggleDockItem}; +use dock::{Dock, PanelButtons, DockPosition, TogglePanel}; use status_bar::StatusBar; pub use status_bar::StatusItemView; use theme::{Theme, ThemeRegistry}; @@ -1322,7 +1322,7 @@ impl Workspace { cx.notify(); } - pub fn toggle_panel(&mut self, action: &ToggleDockItem, cx: &mut ViewContext) { + pub fn toggle_panel(&mut self, action: &TogglePanel, cx: &mut ViewContext) { let dock = match action.dock_position { DockPosition::Left => &mut self.left_dock, DockPosition::Right => &mut self.right_dock, diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index 8a711992ec..614b6ab34d 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -96,7 +96,7 @@ export default function statusBar(colorScheme: ColorScheme) { panelButtons: { groupLeft: {}, groupRight: {}, - item: { + button: { ...statusContainer, iconSize: 16, iconColor: foreground(layer, "variant"),