mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Rename Sidebar to Dock
This commit is contained in:
parent
1919a826f9
commit
03f8c1206a
18 changed files with 133 additions and 146 deletions
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ impl View for CopilotButton {
|
|||
let style = theme
|
||||
.workspace
|
||||
.status_bar
|
||||
.sidebar_buttons
|
||||
.panel_buttons
|
||||
.item
|
||||
.style_for(state, active);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ impl View for DeployFeedbackButton {
|
|||
let style = &theme
|
||||
.workspace
|
||||
.status_bar
|
||||
.sidebar_buttons
|
||||
.panel_buttons
|
||||
.item
|
||||
.style_for(state, active);
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ impl View for TerminalButton {
|
|||
let style = theme
|
||||
.workspace
|
||||
.status_bar
|
||||
.sidebar_buttons
|
||||
.panel_buttons
|
||||
.item
|
||||
.style_for(state, active);
|
||||
|
||||
|
|
|
@ -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<StatusBarLspStatus>,
|
||||
pub sidebar_buttons: StatusBarSidebarButtons,
|
||||
pub panel_buttons: StatusBarPanelButtons,
|
||||
pub diagnostic_summary: Interactive<StatusBarDiagnosticSummary>,
|
||||
pub diagnostic_message: Interactive<ContainedText>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default)]
|
||||
pub struct StatusBarSidebarButtons {
|
||||
pub struct StatusBarPanelButtons {
|
||||
pub group_left: ContainerStyle,
|
||||
pub group_right: ContainerStyle,
|
||||
pub item: Interactive<SidebarItem>,
|
||||
pub item: Interactive<DockItem>,
|
||||
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,
|
||||
|
|
|
@ -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<AppState>, 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);
|
||||
|
|
|
@ -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<T> SidebarItemHandle for ViewHandle<T>
|
||||
impl<T> DockItemHandle for ViewHandle<T>
|
||||
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<Item>,
|
||||
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<dyn SidebarItemHandle>,
|
||||
view: Rc<dyn DockItemHandle>,
|
||||
_subscriptions: [Subscription; 2],
|
||||
}
|
||||
|
||||
pub struct SidebarButtons {
|
||||
sidebar: ViewHandle<Sidebar>,
|
||||
pub struct PanelButtons {
|
||||
dock: ViewHandle<Dock>,
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
}
|
||||
|
||||
#[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<T: SidebarItem>(
|
||||
pub fn add_item<T: DockItem>(
|
||||
&mut self,
|
||||
icon_path: &'static str,
|
||||
tooltip: String,
|
||||
|
@ -171,7 +171,7 @@ impl Sidebar {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn active_item(&self) -> Option<&Rc<dyn SidebarItemHandle>> {
|
||||
pub fn active_item(&self) -> Option<&Rc<dyn DockItemHandle>> {
|
||||
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<Self>) -> AnyElement<Self> {
|
||||
if let Some(active_item) = self.active_item() {
|
||||
enum ResizeHandleTag {}
|
||||
let style = &cx.global::<Settings>().theme.workspace.sidebar;
|
||||
let style = &cx.global::<Settings>().theme.workspace.dock;
|
||||
ChildView::new(active_item.as_any(), cx)
|
||||
.contained()
|
||||
.with_style(style.container)
|
||||
.with_resize_handle::<ResizeHandleTag>(
|
||||
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<Sidebar>,
|
||||
dock: ViewHandle<Dock>,
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> 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<Self>) -> AnyElement<Self> {
|
||||
let theme = &cx.global::<Settings>().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::<Self, _>::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>,
|
|
@ -766,7 +766,7 @@ impl<T: FollowableItem> FollowableItemHandle for ViewHandle<T> {
|
|||
#[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 {}
|
||||
}
|
||||
|
|
|
@ -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<AppState>, 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<AppState>, 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<client::Subscription>,
|
||||
modal: Option<AnyViewHandle>,
|
||||
center: PaneGroup,
|
||||
left_sidebar: ViewHandle<Sidebar>,
|
||||
right_sidebar: ViewHandle<Sidebar>,
|
||||
left_dock: ViewHandle<Dock>,
|
||||
right_dock: ViewHandle<Dock>,
|
||||
panes: Vec<ViewHandle<Pane>>,
|
||||
panes_by_item: HashMap<usize, WeakViewHandle<Pane>>,
|
||||
active_pane: ViewHandle<Pane>,
|
||||
|
@ -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<Sidebar> {
|
||||
&self.left_sidebar
|
||||
pub fn left_dock(&self) -> &ViewHandle<Dock> {
|
||||
&self.left_dock
|
||||
}
|
||||
|
||||
pub fn right_sidebar(&self) -> &ViewHandle<Sidebar> {
|
||||
&self.right_sidebar
|
||||
pub fn right_dock(&self) -> &ViewHandle<Dock> {
|
||||
&self.right_dock
|
||||
}
|
||||
|
||||
pub fn status_bar(&self) -> &ViewHandle<StatusBar> {
|
||||
|
@ -1306,14 +1306,14 @@ impl Workspace {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn toggle_sidebar(&mut self, sidebar_side: SidebarSide, cx: &mut ViewContext<Self>) {
|
||||
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<Self>) {
|
||||
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<Self>) {
|
||||
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<Self>) {
|
||||
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<Self>,
|
||||
) {
|
||||
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);
|
||||
}
|
||||
})?;
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ pub fn menus() -> Vec<Menu<'static>> {
|
|||
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![
|
||||
|
|
|
@ -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<AppState>, cx: &mut gpui::AppContext) {
|
|||
|workspace: &mut Workspace,
|
||||
_: &project_panel::ToggleFocus,
|
||||
cx: &mut ViewContext<Workspace>| {
|
||||
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::<Vec<_>>(),
|
||||
&[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));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ export default function statusBar(colorScheme: ColorScheme) {
|
|||
},
|
||||
},
|
||||
},
|
||||
sidebarButtons: {
|
||||
panelButtons: {
|
||||
groupLeft: {},
|
||||
groupRight: {},
|
||||
item: {
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue