This commit is contained in:
K Simmons 2022-10-20 16:24:33 -07:00 committed by Mikayla Maki
parent 0c466f806c
commit 73f0459a0f
5 changed files with 25 additions and 21 deletions

View File

@ -14,6 +14,7 @@ use parking_lot::Mutex;
use rusqlite::Connection;
use migrations::MIGRATIONS;
pub use workspace::*;
#[derive(Clone)]
pub enum Db {

View File

@ -30,13 +30,13 @@ CREATE TABLE pane_items(
) STRICT;
";
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct PaneId {
workspace_id: WorkspaceId,
pane_id: usize,
}
#[derive(Debug, PartialEq, Eq)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub struct PaneGroupId {
workspace_id: WorkspaceId,
group_id: usize,
@ -58,6 +58,16 @@ pub struct SerializedPaneGroup {
children: Vec<PaneGroupChild>,
}
impl SerializedPaneGroup {
pub(crate) fn empty_root(workspace_id: WorkspaceId) -> Self {
Self {
group_id: PaneGroupId::root(workspace_id),
axis: Default::default(),
children: Default::default(),
}
}
}
struct PaneGroupChildRow {
child_pane_id: Option<usize>,
child_group_id: Option<usize>,
@ -99,7 +109,7 @@ impl Db {
));
}
}
children.sort_by_key(|(index, _)| index);
children.sort_by_key(|(index, _)| *index);
SerializedPaneGroup {
group_id: pane_group_id,
@ -108,18 +118,18 @@ impl Db {
}
}
pub fn get_pane_group_children(
fn get_pane_group_children(
&self,
pane_group_id: PaneGroupId,
) -> impl Iterator<Item = PaneGroupChildRow> {
unimplemented!()
Vec::new().into_iter()
}
pub fn get_pane_group_axis(&self, pane_group_id: PaneGroupId) -> Axis {
fn get_pane_group_axis(&self, pane_group_id: PaneGroupId) -> Axis {
unimplemented!();
}
pub fn save_center_pane_group(&self, center_pane_group: SerializedPaneGroup) {
pub fn save_pane_splits(&self, center_pane_group: SerializedPaneGroup) {
// Delete the center pane group for this workspace and any of its children
// Generate new pane group IDs as we go through
// insert them

View File

@ -36,7 +36,6 @@ CREATE TABLE worktree_roots(
pub struct WorkspaceId(usize);
struct WorkspaceRow {
pub workspace_id: WorkspaceId,
pub center_group_id: PaneGroupId,
pub dock_pane_id: PaneId,
}
@ -67,15 +66,10 @@ impl Db {
}
} else {
let workspace_id = self.get_next_workspace_id();
let center_group = SerializedPaneGroup {
group_id: PaneGroupId::root(workspace_id),
axis: Default::default(),
children: Default::default(),
};
SerializedWorkspace {
workspace_id,
center_group,
center_group: SerializedPaneGroup::empty_root(workspace_id),
dock_pane: None,
}
}

View File

@ -137,11 +137,7 @@ pub struct Dock {
}
impl Dock {
pub fn new(
serialized_pane: SerializedPane,
default_item_factory: DefaultItemFactory,
cx: &mut ViewContext<Workspace>,
) -> Self {
pub fn new(default_item_factory: DefaultItemFactory, cx: &mut ViewContext<Workspace>) -> Self {
let anchor = cx.global::<Settings>().default_dock_anchor;
let pane = cx.add_view(|cx| Pane::new(Some(anchor), cx));
pane.update(cx, |pane, cx| {

View File

@ -15,6 +15,7 @@ use anyhow::{anyhow, Context, Result};
use call::ActiveCall;
use client::{proto, Client, PeerId, TypedEnvelope, UserStore};
use collections::{hash_map, HashMap, HashSet};
use db::{SerializedWorkspace, WorkspaceId};
use dock::{DefaultItemFactory, Dock, ToggleDockButton};
use drag_and_drop::DragAndDrop;
use fs::{self, Fs};
@ -1064,6 +1065,7 @@ pub enum Event {
pub struct Workspace {
weak_self: WeakViewHandle<Self>,
db_id: WorkspaceId,
client: Arc<Client>,
user_store: ModelHandle<client::UserStore>,
remote_entity_subscription: Option<client::Subscription>,
@ -1110,8 +1112,8 @@ enum FollowerItem {
impl Workspace {
pub fn new(
serialized_workspace: SerializedWorkspace,
project: ModelHandle<Project>,
serialized_workspace: SerializedWorkspace,
dock_default_factory: DefaultItemFactory,
cx: &mut ViewContext<Self>,
) -> Self {
@ -1175,7 +1177,7 @@ impl Workspace {
cx.emit_global(WorkspaceCreated(weak_handle.clone()));
let dock = Dock::new(cx, dock_default_factory);
let dock = Dock::new(dock_default_factory, cx);
let dock_pane = dock.pane().clone();
let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left));
@ -1207,6 +1209,7 @@ impl Workspace {
let mut this = Workspace {
modal: None,
weak_self: weak_handle,
db_id: serialized_workspace.workspace_id,
center: PaneGroup::new(center_pane.clone()),
dock,
// When removing an item, the last element remaining in this array