wip
This commit is contained in:
parent
0c466f806c
commit
73f0459a0f
5 changed files with 25 additions and 21 deletions
|
@ -14,6 +14,7 @@ use parking_lot::Mutex;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
|
|
||||||
use migrations::MIGRATIONS;
|
use migrations::MIGRATIONS;
|
||||||
|
pub use workspace::*;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum Db {
|
pub enum Db {
|
||||||
|
|
|
@ -30,13 +30,13 @@ CREATE TABLE pane_items(
|
||||||
) STRICT;
|
) STRICT;
|
||||||
";
|
";
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
pub struct PaneId {
|
pub struct PaneId {
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
pane_id: usize,
|
pane_id: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
pub struct PaneGroupId {
|
pub struct PaneGroupId {
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
group_id: usize,
|
group_id: usize,
|
||||||
|
@ -58,6 +58,16 @@ pub struct SerializedPaneGroup {
|
||||||
children: Vec<PaneGroupChild>,
|
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 {
|
struct PaneGroupChildRow {
|
||||||
child_pane_id: Option<usize>,
|
child_pane_id: Option<usize>,
|
||||||
child_group_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 {
|
SerializedPaneGroup {
|
||||||
group_id: pane_group_id,
|
group_id: pane_group_id,
|
||||||
|
@ -108,18 +118,18 @@ impl Db {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_pane_group_children(
|
fn get_pane_group_children(
|
||||||
&self,
|
&self,
|
||||||
pane_group_id: PaneGroupId,
|
pane_group_id: PaneGroupId,
|
||||||
) -> impl Iterator<Item = PaneGroupChildRow> {
|
) -> 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!();
|
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
|
// Delete the center pane group for this workspace and any of its children
|
||||||
// Generate new pane group IDs as we go through
|
// Generate new pane group IDs as we go through
|
||||||
// insert them
|
// insert them
|
||||||
|
|
|
@ -36,7 +36,6 @@ CREATE TABLE worktree_roots(
|
||||||
pub struct WorkspaceId(usize);
|
pub struct WorkspaceId(usize);
|
||||||
|
|
||||||
struct WorkspaceRow {
|
struct WorkspaceRow {
|
||||||
pub workspace_id: WorkspaceId,
|
|
||||||
pub center_group_id: PaneGroupId,
|
pub center_group_id: PaneGroupId,
|
||||||
pub dock_pane_id: PaneId,
|
pub dock_pane_id: PaneId,
|
||||||
}
|
}
|
||||||
|
@ -67,15 +66,10 @@ impl Db {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let workspace_id = self.get_next_workspace_id();
|
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 {
|
SerializedWorkspace {
|
||||||
workspace_id,
|
workspace_id,
|
||||||
center_group,
|
center_group: SerializedPaneGroup::empty_root(workspace_id),
|
||||||
dock_pane: None,
|
dock_pane: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,7 @@ pub struct Dock {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Dock {
|
impl Dock {
|
||||||
pub fn new(
|
pub fn new(default_item_factory: DefaultItemFactory, cx: &mut ViewContext<Workspace>) -> Self {
|
||||||
serialized_pane: SerializedPane,
|
|
||||||
default_item_factory: DefaultItemFactory,
|
|
||||||
cx: &mut ViewContext<Workspace>,
|
|
||||||
) -> Self {
|
|
||||||
let anchor = cx.global::<Settings>().default_dock_anchor;
|
let anchor = cx.global::<Settings>().default_dock_anchor;
|
||||||
let pane = cx.add_view(|cx| Pane::new(Some(anchor), cx));
|
let pane = cx.add_view(|cx| Pane::new(Some(anchor), cx));
|
||||||
pane.update(cx, |pane, cx| {
|
pane.update(cx, |pane, cx| {
|
||||||
|
|
|
@ -15,6 +15,7 @@ use anyhow::{anyhow, Context, Result};
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
use client::{proto, Client, PeerId, TypedEnvelope, UserStore};
|
use client::{proto, Client, PeerId, TypedEnvelope, UserStore};
|
||||||
use collections::{hash_map, HashMap, HashSet};
|
use collections::{hash_map, HashMap, HashSet};
|
||||||
|
use db::{SerializedWorkspace, WorkspaceId};
|
||||||
use dock::{DefaultItemFactory, Dock, ToggleDockButton};
|
use dock::{DefaultItemFactory, Dock, ToggleDockButton};
|
||||||
use drag_and_drop::DragAndDrop;
|
use drag_and_drop::DragAndDrop;
|
||||||
use fs::{self, Fs};
|
use fs::{self, Fs};
|
||||||
|
@ -1064,6 +1065,7 @@ pub enum Event {
|
||||||
|
|
||||||
pub struct Workspace {
|
pub struct Workspace {
|
||||||
weak_self: WeakViewHandle<Self>,
|
weak_self: WeakViewHandle<Self>,
|
||||||
|
db_id: WorkspaceId,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
user_store: ModelHandle<client::UserStore>,
|
user_store: ModelHandle<client::UserStore>,
|
||||||
remote_entity_subscription: Option<client::Subscription>,
|
remote_entity_subscription: Option<client::Subscription>,
|
||||||
|
@ -1110,8 +1112,8 @@ enum FollowerItem {
|
||||||
|
|
||||||
impl Workspace {
|
impl Workspace {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
serialized_workspace: SerializedWorkspace,
|
|
||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
|
serialized_workspace: SerializedWorkspace,
|
||||||
dock_default_factory: DefaultItemFactory,
|
dock_default_factory: DefaultItemFactory,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -1175,7 +1177,7 @@ impl Workspace {
|
||||||
|
|
||||||
cx.emit_global(WorkspaceCreated(weak_handle.clone()));
|
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 dock_pane = dock.pane().clone();
|
||||||
|
|
||||||
let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left));
|
let left_sidebar = cx.add_view(|_| Sidebar::new(SidebarSide::Left));
|
||||||
|
@ -1207,6 +1209,7 @@ impl Workspace {
|
||||||
let mut this = Workspace {
|
let mut this = Workspace {
|
||||||
modal: None,
|
modal: None,
|
||||||
weak_self: weak_handle,
|
weak_self: weak_handle,
|
||||||
|
db_id: serialized_workspace.workspace_id,
|
||||||
center: PaneGroup::new(center_pane.clone()),
|
center: PaneGroup::new(center_pane.clone()),
|
||||||
dock,
|
dock,
|
||||||
// When removing an item, the last element remaining in this array
|
// When removing an item, the last element remaining in this array
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue