From 03f8c1206a3c1f0d9abcbb8dd2745694f32b90f7 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 5 May 2023 16:04:36 -0600 Subject: [PATCH] Rename Sidebar to Dock --- assets/keymaps/atom.json | 4 +- assets/keymaps/default.json | 2 +- assets/keymaps/jetbrains.json | 2 +- assets/keymaps/sublime_text.json | 2 +- assets/keymaps/textmate.json | 2 +- crates/copilot_button/src/copilot_button.rs | 2 +- crates/feedback/src/deploy_feedback_button.rs | 2 +- crates/project_panel/src/project_panel.rs | 2 +- crates/terminal_view/src/terminal_button.rs | 2 +- crates/theme/src/theme.rs | 12 +- crates/welcome/src/welcome.rs | 4 +- crates/workspace/src/{sidebar.rs => dock.rs} | 94 +++++++-------- crates/workspace/src/item.rs | 4 +- crates/workspace/src/workspace.rs | 114 +++++++++--------- crates/zed/src/menus.rs | 2 +- crates/zed/src/zed.rs | 12 +- styles/src/styleTree/statusBar.ts | 2 +- styles/src/styleTree/workspace.ts | 15 +-- 18 files changed, 133 insertions(+), 146 deletions(-) rename crates/workspace/src/{sidebar.rs => dock.rs} (81%) diff --git a/assets/keymaps/atom.json b/assets/keymaps/atom.json index a1e8cf6d9d..634aed322a 100644 --- a/assets/keymaps/atom.json +++ b/assets/keymaps/atom.json @@ -39,8 +39,8 @@ { "context": "Workspace", "bindings": { - "cmd-\\": "workspace::ToggleLeftSidebar", - "cmd-k cmd-b": "workspace::ToggleLeftSidebar", + "cmd-\\": "workspace::ToggleLeftDock", + "cmd-k cmd-b": "workspace::ToggleLeftDock", "cmd-t": "file_finder::Toggle", "cmd-shift-r": "project_symbols::Toggle" } diff --git a/assets/keymaps/default.json b/assets/keymaps/default.json index 6e8b519313..cc36f79e9f 100644 --- a/assets/keymaps/default.json +++ b/assets/keymaps/default.json @@ -349,7 +349,7 @@ "workspace::ActivatePane", 8 ], - "cmd-b": "workspace::ToggleLeftSidebar", + "cmd-b": "workspace::ToggleLeftDock", "cmd-shift-f": "workspace::NewSearch", "cmd-k cmd-t": "theme_selector::Toggle", "cmd-k cmd-s": "zed::OpenKeymap", diff --git a/assets/keymaps/jetbrains.json b/assets/keymaps/jetbrains.json index 0dafe58d32..69a583e1e9 100644 --- a/assets/keymaps/jetbrains.json +++ b/assets/keymaps/jetbrains.json @@ -65,7 +65,7 @@ "bindings": { "cmd-shift-a": "command_palette::Toggle", "cmd-alt-o": "project_symbols::Toggle", - "cmd-1": "workspace::ToggleLeftSidebar", + "cmd-1": "workspace::ToggleLeftDock", "cmd-6": "diagnostics::Deploy" } } diff --git a/assets/keymaps/sublime_text.json b/assets/keymaps/sublime_text.json index 7a285ee824..2d32b77d58 100644 --- a/assets/keymaps/sublime_text.json +++ b/assets/keymaps/sublime_text.json @@ -45,7 +45,7 @@ { "context": "Workspace", "bindings": { - "cmd-k cmd-b": "workspace::ToggleLeftSidebar", + "cmd-k cmd-b": "workspace::ToggleLeftDock", "cmd-t": "file_finder::Toggle", "shift-cmd-r": "project_symbols::Toggle", // Currently busted: https://github.com/zed-industries/feedback/issues/898 diff --git a/assets/keymaps/textmate.json b/assets/keymaps/textmate.json index 738b6603ff..06be727429 100644 --- a/assets/keymaps/textmate.json +++ b/assets/keymaps/textmate.json @@ -68,7 +68,7 @@ { "context": "Workspace", "bindings": { - "cmd-alt-ctrl-d": "workspace::ToggleLeftSidebar", + "cmd-alt-ctrl-d": "workspace::ToggleLeftDock", "cmd-t": "file_finder::Toggle", "cmd-shift-t": "project_symbols::Toggle" } diff --git a/crates/copilot_button/src/copilot_button.rs b/crates/copilot_button/src/copilot_button.rs index 4b0c9b494a..0d6bcc115c 100644 --- a/crates/copilot_button/src/copilot_button.rs +++ b/crates/copilot_button/src/copilot_button.rs @@ -64,7 +64,7 @@ impl View for CopilotButton { let style = theme .workspace .status_bar - .sidebar_buttons + .panel_buttons .item .style_for(state, active); diff --git a/crates/feedback/src/deploy_feedback_button.rs b/crates/feedback/src/deploy_feedback_button.rs index b464d00887..5fdb378eb6 100644 --- a/crates/feedback/src/deploy_feedback_button.rs +++ b/crates/feedback/src/deploy_feedback_button.rs @@ -40,7 +40,7 @@ impl View for DeployFeedbackButton { let style = &theme .workspace .status_bar - .sidebar_buttons + .panel_buttons .item .style_for(state, active); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index 7602ff7db8..4a1d488eaf 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::sidebar::SidebarItem for ProjectPanel { +impl workspace::dock::DockItem 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 7b0da416ff..cacd21c733 100644 --- a/crates/terminal_view/src/terminal_button.rs +++ b/crates/terminal_view/src/terminal_button.rs @@ -52,7 +52,7 @@ impl View for TerminalButton { let style = theme .workspace .status_bar - .sidebar_buttons + .panel_buttons .item .style_for(state, active); diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 8c77295748..c239e0ef40 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -61,7 +61,7 @@ pub struct Workspace { pub pane_divider: Border, pub leader_border_opacity: f32, pub leader_border_width: f32, - pub sidebar: Sidebar, + pub dock: Dock, pub status_bar: StatusBar, pub toolbar: Toolbar, pub breadcrumb_height: f32, @@ -335,16 +335,16 @@ pub struct StatusBar { pub auto_update_progress_message: TextStyle, pub auto_update_done_message: TextStyle, pub lsp_status: Interactive, - pub sidebar_buttons: StatusBarSidebarButtons, + pub panel_buttons: StatusBarPanelButtons, pub diagnostic_summary: Interactive, pub diagnostic_message: Interactive, } #[derive(Deserialize, Default)] -pub struct StatusBarSidebarButtons { +pub struct StatusBarPanelButtons { pub group_left: ContainerStyle, pub group_right: ContainerStyle, - pub item: Interactive, + pub item: Interactive, pub badge: ContainerStyle, } @@ -375,14 +375,14 @@ pub struct StatusBarLspStatus { } #[derive(Deserialize, Default)] -pub struct Sidebar { +pub struct Dock { pub initial_size: f32, #[serde(flatten)] pub container: ContainerStyle, } #[derive(Clone, Deserialize, Default)] -pub struct SidebarItem { +pub struct DockItem { #[serde(flatten)] pub container: ContainerStyle, pub icon_color: Color, diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rs index a3d91adc91..6adcf27bd1 100644 --- a/crates/welcome/src/welcome.rs +++ b/crates/welcome/src/welcome.rs @@ -10,7 +10,7 @@ use gpui::{ use settings::{settings_file::SettingsFile, Settings}; use workspace::{ - item::Item, open_new, sidebar::SidebarSide, AppState, PaneBackdrop, Welcome, Workspace, + item::Item, open_new, dock::DockPosition, AppState, PaneBackdrop, Welcome, Workspace, WorkspaceId, }; @@ -29,7 +29,7 @@ pub fn init(cx: &mut AppContext) { pub fn show_welcome_experience(app_state: &Arc, cx: &mut AppContext) { open_new(&app_state, cx, |workspace, cx| { - workspace.toggle_sidebar(SidebarSide::Left, cx); + workspace.toggle_dock(DockPosition::Left, cx); let welcome_page = cx.add_view(|cx| WelcomePage::new(workspace, cx)); workspace.add_item_to_center(Box::new(welcome_page.clone()), cx); cx.focus(&welcome_page); diff --git a/crates/workspace/src/sidebar.rs b/crates/workspace/src/dock.rs similarity index 81% rename from crates/workspace/src/sidebar.rs rename to crates/workspace/src/dock.rs index 6463ab7d24..88fc9576bd 100644 --- a/crates/workspace/src/sidebar.rs +++ b/crates/workspace/src/dock.rs @@ -7,7 +7,7 @@ use serde::Deserialize; use settings::Settings; use std::rc::Rc; -pub trait SidebarItem: View { +pub trait DockItem: View { fn should_activate_item_on_event(&self, _: &Self::Event, _: &AppContext) -> bool { false } @@ -19,16 +19,16 @@ pub trait SidebarItem: View { } } -pub trait SidebarItemHandle { +pub trait DockItemHandle { 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 SidebarItemHandle for ViewHandle +impl DockItemHandle for ViewHandle where - T: SidebarItem, + T: DockItem, { fn id(&self) -> usize { self.id() @@ -47,26 +47,26 @@ where } } -impl From<&dyn SidebarItemHandle> for AnyViewHandle { - fn from(val: &dyn SidebarItemHandle) -> Self { +impl From<&dyn DockItemHandle> for AnyViewHandle { + fn from(val: &dyn DockItemHandle) -> Self { val.as_any().clone() } } -pub struct Sidebar { - sidebar_side: SidebarSide, +pub struct Dock { + position: DockPosition, items: Vec, is_open: bool, active_item_ix: usize, } #[derive(Clone, Copy, Debug, Deserialize, PartialEq)] -pub enum SidebarSide { +pub enum DockPosition { Left, Right, } -impl SidebarSide { +impl DockPosition { fn to_resizable_side(self) -> Side { match self { Self::Left => Side::Right, @@ -78,27 +78,27 @@ impl SidebarSide { struct Item { icon_path: &'static str, tooltip: String, - view: Rc, + view: Rc, _subscriptions: [Subscription; 2], } -pub struct SidebarButtons { - sidebar: ViewHandle, +pub struct PanelButtons { + dock: ViewHandle, workspace: WeakViewHandle, } #[derive(Clone, Debug, Deserialize, PartialEq)] -pub struct ToggleSidebarItem { - pub sidebar_side: SidebarSide, +pub struct ToggleDockItem { + pub dock_position: DockPosition, pub item_index: usize, } -impl_actions!(workspace, [ToggleSidebarItem]); +impl_actions!(workspace, [ToggleDockItem]); -impl Sidebar { - pub fn new(sidebar_side: SidebarSide) -> Self { +impl Dock { + pub fn new(position: DockPosition) -> Self { Self { - sidebar_side, + position, items: Default::default(), active_item_ix: 0, is_open: false, @@ -126,7 +126,7 @@ impl Sidebar { cx.notify(); } - pub fn add_item( + pub fn add_item( &mut self, icon_path: &'static str, tooltip: String, @@ -171,7 +171,7 @@ impl Sidebar { 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 { @@ -180,25 +180,25 @@ impl Sidebar { } } -impl Entity for Sidebar { +impl Entity for Dock { type Event = (); } -impl View for Sidebar { +impl View for Dock { fn ui_name() -> &'static str { - "Sidebar" + "Dock" } fn render(&mut self, cx: &mut ViewContext) -> AnyElement { if let Some(active_item) = self.active_item() { enum ResizeHandleTag {} - let style = &cx.global::().theme.workspace.sidebar; + let style = &cx.global::().theme.workspace.dock; ChildView::new(active_item.as_any(), cx) .contained() .with_style(style.container) .with_resize_handle::( - self.sidebar_side as usize, - self.sidebar_side.to_resizable_side(), + self.position as usize, + self.position.to_resizable_side(), 4., style.initial_size, cx, @@ -210,43 +210,43 @@ impl View for Sidebar { } } -impl SidebarButtons { +impl PanelButtons { pub fn new( - sidebar: ViewHandle, + dock: ViewHandle, workspace: WeakViewHandle, cx: &mut ViewContext, ) -> Self { - cx.observe(&sidebar, |_, _, cx| cx.notify()).detach(); - Self { sidebar, workspace } + cx.observe(&dock, |_, _, cx| cx.notify()).detach(); + Self { dock, workspace } } } -impl Entity for SidebarButtons { +impl Entity for PanelButtons { type Event = (); } -impl View for SidebarButtons { +impl View for PanelButtons { fn ui_name() -> &'static str { - "SidebarToggleButton" + "DockToggleButton" } fn render(&mut self, cx: &mut ViewContext) -> AnyElement { let theme = &cx.global::().theme; let tooltip_style = theme.tooltip.clone(); - let theme = &theme.workspace.status_bar.sidebar_buttons; - let sidebar = self.sidebar.read(cx); + let theme = &theme.workspace.status_bar.panel_buttons; + let dock = self.dock.read(cx); let item_style = theme.item.clone(); let badge_style = theme.badge; - let active_ix = sidebar.active_item_ix; - let is_open = sidebar.is_open; - let sidebar_side = sidebar.sidebar_side; - let group_style = match sidebar_side { - SidebarSide::Left => theme.group_left, - SidebarSide::Right => theme.group_right, + let active_ix = dock.active_item_ix; + let is_open = dock.is_open; + let dock_position = dock.position; + let group_style = match dock_position { + DockPosition::Left => theme.group_left, + DockPosition::Right => theme.group_right, }; #[allow(clippy::needless_collect)] - let items = sidebar + let items = dock .items .iter() .map(|item| (item.icon_path, item.tooltip.clone(), item.view.clone())) @@ -255,8 +255,8 @@ impl View for SidebarButtons { Flex::row() .with_children(items.into_iter().enumerate().map( |(ix, (icon_path, tooltip, item_view))| { - let action = ToggleSidebarItem { - sidebar_side, + let action = ToggleDockItem { + dock_position, item_index: ix, }; MouseEventHandler::::new(ix, cx, |state, cx| { @@ -291,7 +291,7 @@ impl View for SidebarButtons { let action = action.clone(); cx.window_context().defer(move |cx| { workspace.update(cx, |workspace, cx| { - workspace.toggle_sidebar_item(&action, cx) + workspace.toggle_panel(&action, cx) }); }); } @@ -312,7 +312,7 @@ impl View for SidebarButtons { } } -impl StatusItemView for SidebarButtons { +impl StatusItemView for PanelButtons { fn set_active_pane_item( &mut self, _: Option<&dyn crate::ItemHandle>, diff --git a/crates/workspace/src/item.rs b/crates/workspace/src/item.rs index 43c4544611..49fd882b65 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::{sidebar::SidebarItem, ItemId, ItemNavHistory, Pane, Workspace, WorkspaceId}; + use crate::{dock::DockItem, 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 SidebarItem for TestItem {} + impl DockItem for TestItem {} } diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 84d1832df7..4ab9e07526 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -9,7 +9,7 @@ pub mod pane_group; mod persistence; pub mod searchable; pub mod shared_screen; -pub mod sidebar; +pub mod dock; mod status_bar; mod toolbar; @@ -74,7 +74,7 @@ use project::{Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId}; use serde::Deserialize; use settings::{Autosave, Settings}; use shared_screen::SharedScreen; -use sidebar::{Sidebar, SidebarButtons, SidebarSide, ToggleSidebarItem}; +use dock::{Dock, PanelButtons, DockPosition, ToggleDockItem}; use status_bar::StatusBar; pub use status_bar::StatusItemView; use theme::{Theme, ThemeRegistry}; @@ -114,7 +114,7 @@ actions!( ActivatePreviousPane, ActivateNextPane, FollowNextCollaborator, - ToggleLeftSidebar, + ToggleLeftDock, NewTerminal, NewSearch, Feedback, @@ -229,7 +229,7 @@ pub fn init(app_state: Arc, cx: &mut AppContext) { workspace.save_active_item(true, cx).detach_and_log_err(cx); }, ); - cx.add_action(Workspace::toggle_sidebar_item); + cx.add_action(Workspace::toggle_panel); cx.add_action(Workspace::focus_center); cx.add_action(|workspace: &mut Workspace, _: &ActivatePreviousPane, cx| { workspace.activate_previous_pane(cx) @@ -237,8 +237,8 @@ pub fn init(app_state: Arc, cx: &mut AppContext) { cx.add_action(|workspace: &mut Workspace, _: &ActivateNextPane, cx| { workspace.activate_next_pane(cx) }); - cx.add_action(|workspace: &mut Workspace, _: &ToggleLeftSidebar, cx| { - workspace.toggle_sidebar(SidebarSide::Left, cx); + cx.add_action(|workspace: &mut Workspace, _: &ToggleLeftDock, cx| { + workspace.toggle_dock(DockPosition::Left, cx); }); cx.add_action(Workspace::activate_pane_at_index); @@ -442,8 +442,8 @@ pub struct Workspace { remote_entity_subscription: Option, modal: Option, center: PaneGroup, - left_sidebar: ViewHandle, - right_sidebar: ViewHandle, + left_dock: ViewHandle, + right_dock: ViewHandle, panes: Vec>, panes_by_item: HashMap>, active_pane: ViewHandle, @@ -562,16 +562,16 @@ impl Workspace { cx.emit_global(WorkspaceCreated(weak_handle.clone())); - let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left)); - let right_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Right)); - let left_sidebar_buttons = - cx.add_view(|cx| SidebarButtons::new(left_sidebar.clone(), weak_handle.clone(), cx)); - let right_sidebar_buttons = - cx.add_view(|cx| SidebarButtons::new(right_sidebar.clone(), weak_handle.clone(), cx)); + let left_dock = cx.add_view(|_| Dock::new(DockPosition::Left)); + let right_dock = cx.add_view(|_| Dock::new(DockPosition::Right)); + let left_dock_buttons = + cx.add_view(|cx| PanelButtons::new(left_dock.clone(), weak_handle.clone(), cx)); + let right_dock_buttons = + cx.add_view(|cx| PanelButtons::new(right_dock.clone(), weak_handle.clone(), cx)); let status_bar = cx.add_view(|cx| { let mut status_bar = StatusBar::new(¢er_pane.clone(), cx); - status_bar.add_left_item(left_sidebar_buttons, cx); - status_bar.add_right_item(right_sidebar_buttons, cx); + status_bar.add_left_item(left_dock_buttons, cx); + status_bar.add_right_item(right_dock_buttons, cx); status_bar }); @@ -621,8 +621,8 @@ impl Workspace { titlebar_item: None, notifications: Default::default(), remote_entity_subscription: None, - left_sidebar, - right_sidebar, + left_dock: left_dock, + right_dock: right_dock, project: project.clone(), leader_state: Default::default(), follower_states_by_leader: Default::default(), @@ -813,12 +813,12 @@ impl Workspace { self.weak_self.clone() } - pub fn left_sidebar(&self) -> &ViewHandle { - &self.left_sidebar + pub fn left_dock(&self) -> &ViewHandle { + &self.left_dock } - pub fn right_sidebar(&self) -> &ViewHandle { - &self.right_sidebar + pub fn right_dock(&self) -> &ViewHandle { + &self.right_dock } pub fn status_bar(&self) -> &ViewHandle { @@ -1306,14 +1306,14 @@ impl Workspace { } } - pub fn toggle_sidebar(&mut self, sidebar_side: SidebarSide, cx: &mut ViewContext) { - let sidebar = match sidebar_side { - SidebarSide::Left => &mut self.left_sidebar, - SidebarSide::Right => &mut self.right_sidebar, + pub fn toggle_dock(&mut self, dock_side: DockPosition, cx: &mut ViewContext) { + let dock = match dock_side { + DockPosition::Left => &mut self.left_dock, + DockPosition::Right => &mut self.right_dock, }; - sidebar.update(cx, |sidebar, cx| { - let open = !sidebar.is_open(); - sidebar.set_open(open, cx); + dock.update(cx, |dock, cx| { + let open = !dock.is_open(); + dock.set_open(open, cx); }); self.serialize_workspace(cx); @@ -1322,19 +1322,19 @@ impl Workspace { cx.notify(); } - pub fn toggle_sidebar_item(&mut self, action: &ToggleSidebarItem, cx: &mut ViewContext) { - let sidebar = match action.sidebar_side { - SidebarSide::Left => &mut self.left_sidebar, - SidebarSide::Right => &mut self.right_sidebar, + pub fn toggle_panel(&mut self, action: &ToggleDockItem, cx: &mut ViewContext) { + let dock = match action.dock_position { + DockPosition::Left => &mut self.left_dock, + DockPosition::Right => &mut self.right_dock, }; - let active_item = sidebar.update(cx, move |sidebar, cx| { - if sidebar.is_open() && sidebar.active_item_ix() == action.item_index { - sidebar.set_open(false, cx); + let active_item = dock.update(cx, move |dock, cx| { + if dock.is_open() && dock.active_item_ix() == action.item_index { + dock.set_open(false, cx); None } else { - sidebar.set_open(true, cx); - sidebar.activate_item(action.item_index, cx); - sidebar.active_item().cloned() + dock.set_open(true, cx); + dock.activate_item(action.item_index, cx); + dock.active_item().cloned() } }); @@ -1353,20 +1353,20 @@ impl Workspace { cx.notify(); } - pub fn toggle_sidebar_item_focus( + pub fn toggle_panel_focus( &mut self, - sidebar_side: SidebarSide, - item_index: usize, + dock_position: DockPosition, + panel_index: usize, cx: &mut ViewContext, ) { - let sidebar = match sidebar_side { - SidebarSide::Left => &mut self.left_sidebar, - SidebarSide::Right => &mut self.right_sidebar, + let dock = match dock_position { + DockPosition::Left => &mut self.left_dock, + DockPosition::Right => &mut self.right_dock, }; - let active_item = sidebar.update(cx, |sidebar, cx| { - sidebar.set_open(true, cx); - sidebar.activate_item(item_index, cx); - sidebar.active_item().cloned() + let active_item = dock.update(cx, |dock, cx| { + dock.set_open(true, cx); + dock.activate_item(panel_index, cx); + dock.active_item().cloned() }); if let Some(active_item) = active_item { if active_item.is_focused(cx) { @@ -2452,7 +2452,7 @@ impl Workspace { id: self.database_id, location, center_group, - left_sidebar_open: self.left_sidebar.read(cx).is_open(), + left_sidebar_open: self.left_dock.read(cx).is_open(), bounds: Default::default(), display: Default::default(), }; @@ -2509,10 +2509,10 @@ impl Workspace { } } - if workspace.left_sidebar().read(cx).is_open() + if workspace.left_dock().read(cx).is_open() != serialized_workspace.left_sidebar_open { - workspace.toggle_sidebar(SidebarSide::Left, cx); + workspace.toggle_dock(DockPosition::Left, cx); } cx.notify(); @@ -2596,9 +2596,9 @@ impl View for Workspace { let project = self.project.clone(); Flex::row() .with_children( - if self.left_sidebar.read(cx).active_item().is_some() { + if self.left_dock.read(cx).active_item().is_some() { Some( - ChildView::new(&self.left_sidebar, cx) + ChildView::new(&self.left_dock, cx) .constrained() .dynamically(|constraint, _, cx| { SizeConstraint::new( @@ -2633,9 +2633,9 @@ impl View for Workspace { .flex(1., true), ) .with_children( - if self.right_sidebar.read(cx).active_item().is_some() { + if self.right_dock.read(cx).active_item().is_some() { Some( - ChildView::new(&self.right_sidebar, cx) + ChildView::new(&self.right_dock, cx) .constrained() .dynamically(|constraint, _, cx| { SizeConstraint::new( @@ -2803,7 +2803,7 @@ pub fn open_paths( workspace.update(&mut cx, |workspace, cx| { if contains_directory { - workspace.toggle_sidebar(SidebarSide::Left, cx); + workspace.toggle_dock(DockPosition::Left, cx); } })?; diff --git a/crates/zed/src/menus.rs b/crates/zed/src/menus.rs index 741b61f323..a98147c51b 100644 --- a/crates/zed/src/menus.rs +++ b/crates/zed/src/menus.rs @@ -89,7 +89,7 @@ pub fn menus() -> Vec> { MenuItem::action("Zoom Out", super::DecreaseBufferFontSize), MenuItem::action("Reset Zoom", super::ResetBufferFontSize), MenuItem::separator(), - MenuItem::action("Toggle Left Sidebar", workspace::ToggleLeftSidebar), + MenuItem::action("Toggle Left Dock", workspace::ToggleLeftDock), MenuItem::submenu(Menu { name: "Editor Layout", items: vec![ diff --git a/crates/zed/src/zed.rs b/crates/zed/src/zed.rs index 46443eb77d..b3968e45fc 100644 --- a/crates/zed/src/zed.rs +++ b/crates/zed/src/zed.rs @@ -36,7 +36,7 @@ use util::{channel::ReleaseChannel, paths, ResultExt}; use uuid::Uuid; pub use workspace; use workspace::{ - create_and_open_local_file, open_new, sidebar::SidebarSide, AppState, NewFile, NewWindow, + create_and_open_local_file, open_new, dock::DockPosition, AppState, NewFile, NewWindow, Workspace, }; @@ -242,7 +242,7 @@ pub fn init(app_state: &Arc, cx: &mut gpui::AppContext) { |workspace: &mut Workspace, _: &project_panel::ToggleFocus, cx: &mut ViewContext| { - workspace.toggle_sidebar_item_focus(SidebarSide::Left, 0, cx); + workspace.toggle_panel_focus(DockPosition::Left, 0, cx); }, ); cx.add_global_action({ @@ -312,8 +312,8 @@ pub fn initialize_workspace( workspace.set_titlebar_item(collab_titlebar_item.into_any(), cx); let project_panel = ProjectPanel::new(workspace, cx); - workspace.left_sidebar().update(cx, |sidebar, cx| { - sidebar.add_item( + workspace.left_dock().update(cx, |dock, cx| { + dock.add_item( "icons/folder_tree_16.svg", "Project Panel".to_string(), project_panel, @@ -658,7 +658,7 @@ mod tests { .unwrap(); workspace_1.update(cx, |workspace, cx| { assert_eq!(workspace.worktrees(cx).count(), 2); - assert!(workspace.left_sidebar().read(cx).is_open()); + assert!(workspace.left_dock().read(cx).is_open()); assert!(workspace.active_pane().is_focused(cx)); }); @@ -701,7 +701,7 @@ mod tests { .collect::>(), &[Path::new("/root/c").into(), Path::new("/root/d").into()] ); - assert!(workspace.left_sidebar().read(cx).is_open()); + assert!(workspace.left_dock().read(cx).is_open()); assert!(workspace.active_pane().is_focused(cx)); }); } diff --git a/styles/src/styleTree/statusBar.ts b/styles/src/styleTree/statusBar.ts index c55160c336..8a711992ec 100644 --- a/styles/src/styleTree/statusBar.ts +++ b/styles/src/styleTree/statusBar.ts @@ -93,7 +93,7 @@ export default function statusBar(colorScheme: ColorScheme) { }, }, }, - sidebarButtons: { + panelButtons: { groupLeft: {}, groupRight: {}, item: { diff --git a/styles/src/styleTree/workspace.ts b/styles/src/styleTree/workspace.ts index 9d0c4de9f7..fe359b0501 100644 --- a/styles/src/styleTree/workspace.ts +++ b/styles/src/styleTree/workspace.ts @@ -118,7 +118,7 @@ export default function workspace(colorScheme: ColorScheme) { }, cursor: "Arrow", }, - sidebar: { + dock: { initialSize: 240, border: border(layer, { left: true, right: true }), }, @@ -310,19 +310,6 @@ export default function workspace(colorScheme: ColorScheme) { width: 400, margin: { right: 10, bottom: 10 }, }, - dock: { - initialSizeRight: 640, - initialSizeBottom: 304, - wash_color: withOpacity(background(colorScheme.highest), 0.5), - panel: { - border: border(colorScheme.middle), - }, - maximized: { - margin: 32, - border: border(colorScheme.highest, { overlay: true }), - shadow: colorScheme.modalShadow, - }, - }, dropTargetOverlayColor: withOpacity(foreground(layer, "variant"), 0.5), } }