WIP
This commit is contained in:
parent
89d8bb1425
commit
f2ad17dbc0
3 changed files with 56 additions and 73 deletions
|
@ -20,7 +20,6 @@ use model::{
|
||||||
|
|
||||||
use self::model::DockStructure;
|
use self::model::DockStructure;
|
||||||
|
|
||||||
|
|
||||||
define_connection! {
|
define_connection! {
|
||||||
// Current schema shape using pseudo-rust syntax:
|
// Current schema shape using pseudo-rust syntax:
|
||||||
//
|
//
|
||||||
|
@ -158,11 +157,11 @@ define_connection! {
|
||||||
// Add panels related information
|
// Add panels related information
|
||||||
sql!(
|
sql!(
|
||||||
ALTER TABLE workspaces ADD COLUMN left_dock_visible INTEGER; //bool
|
ALTER TABLE workspaces ADD COLUMN left_dock_visible INTEGER; //bool
|
||||||
ALTER TABLE workspaces ADD COLUMN left_dock_size REAL;
|
ALTER TABLE workspaces ADD COLUMN left_dock_active_panel TEXT;
|
||||||
ALTER TABLE workspaces ADD COLUMN right_dock_visible INTEGER; //bool
|
ALTER TABLE workspaces ADD COLUMN right_dock_visible INTEGER; //bool
|
||||||
ALTER TABLE workspaces ADD COLUMN right_dock_size REAL;
|
ALTER TABLE workspaces ADD COLUMN right_dock_active_panel TEXT;
|
||||||
ALTER TABLE workspaces ADD COLUMN bottom_dock_visible INTEGER; //bool
|
ALTER TABLE workspaces ADD COLUMN bottom_dock_visible INTEGER; //bool
|
||||||
ALTER TABLE workspaces ADD COLUMN bottom_dock_size REAL;
|
ALTER TABLE workspaces ADD COLUMN bottom_dock_active_panel TEXT;
|
||||||
)];
|
)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,19 +177,17 @@ impl WorkspaceDb {
|
||||||
|
|
||||||
// Note that we re-assign the workspace_id here in case it's empty
|
// Note that we re-assign the workspace_id here in case it's empty
|
||||||
// and we've grabbed the most recent workspace
|
// and we've grabbed the most recent workspace
|
||||||
let (workspace_id, workspace_location, left_sidebar_open, bounds, display, docks): (
|
let (workspace_id, workspace_location, bounds, display, docks): (
|
||||||
WorkspaceId,
|
WorkspaceId,
|
||||||
WorkspaceLocation,
|
WorkspaceLocation,
|
||||||
bool,
|
|
||||||
Option<WindowBounds>,
|
Option<WindowBounds>,
|
||||||
Option<Uuid>,
|
Option<Uuid>,
|
||||||
DockStructure
|
DockStructure,
|
||||||
) = self
|
) = self
|
||||||
.select_row_bound(sql! {
|
.select_row_bound(sql! {
|
||||||
SELECT
|
SELECT
|
||||||
workspace_id,
|
workspace_id,
|
||||||
workspace_location,
|
workspace_location,
|
||||||
left_sidebar_open,
|
|
||||||
window_state,
|
window_state,
|
||||||
window_x,
|
window_x,
|
||||||
window_y,
|
window_y,
|
||||||
|
@ -198,11 +195,11 @@ impl WorkspaceDb {
|
||||||
window_height,
|
window_height,
|
||||||
display,
|
display,
|
||||||
left_dock_visible,
|
left_dock_visible,
|
||||||
left_dock_size,
|
left_dock_active_panel,
|
||||||
right_dock_visible,
|
right_dock_visible,
|
||||||
right_dock_size,
|
right_dock_active_panel,
|
||||||
bottom_dock_visible,
|
bottom_dock_visible,
|
||||||
bottom_dock_size
|
bottom_dock_active_panel
|
||||||
FROM workspaces
|
FROM workspaces
|
||||||
WHERE workspace_location = ?
|
WHERE workspace_location = ?
|
||||||
})
|
})
|
||||||
|
@ -218,10 +215,9 @@ impl WorkspaceDb {
|
||||||
.get_center_pane_group(workspace_id)
|
.get_center_pane_group(workspace_id)
|
||||||
.context("Getting center group")
|
.context("Getting center group")
|
||||||
.log_err()?,
|
.log_err()?,
|
||||||
left_sidebar_open,
|
|
||||||
bounds,
|
bounds,
|
||||||
display,
|
display,
|
||||||
docks
|
docks,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,28 +242,26 @@ impl WorkspaceDb {
|
||||||
INSERT INTO workspaces(
|
INSERT INTO workspaces(
|
||||||
workspace_id,
|
workspace_id,
|
||||||
workspace_location,
|
workspace_location,
|
||||||
left_sidebar_open,
|
|
||||||
left_dock_visible,
|
left_dock_visible,
|
||||||
left_dock_size,
|
left_dock_active_panel,
|
||||||
right_dock_visible,
|
right_dock_visible,
|
||||||
right_dock_size,
|
right_dock_active_panel,
|
||||||
bottom_dock_visible,
|
bottom_dock_visible,
|
||||||
bottom_dock_size,
|
bottom_dock_active_panel,
|
||||||
timestamp
|
timestamp
|
||||||
)
|
)
|
||||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, CURRENT_TIMESTAMP)
|
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, CURRENT_TIMESTAMP)
|
||||||
ON CONFLICT DO
|
ON CONFLICT DO
|
||||||
UPDATE SET
|
UPDATE SET
|
||||||
workspace_location = ?2,
|
workspace_location = ?2,
|
||||||
left_sidebar_open = ?3,
|
left_dock_visible = ?3,
|
||||||
left_dock_visible = ?4,
|
left_dock_active_panel = ?4,
|
||||||
left_dock_size = ?5,
|
right_dock_visible = ?5,
|
||||||
right_dock_visible = ?6,
|
right_dock_active_panel = ?6,
|
||||||
right_dock_size = ?7,
|
bottom_dock_visible = ?7,
|
||||||
bottom_dock_visible = ?8,
|
bottom_dock_active_panel = ?8,
|
||||||
bottom_dock_size = ?9,
|
|
||||||
timestamp = CURRENT_TIMESTAMP
|
timestamp = CURRENT_TIMESTAMP
|
||||||
))?((workspace.id, &workspace.location, workspace.left_sidebar_open, workspace.docks))
|
))?((workspace.id, &workspace.location, workspace.docks))
|
||||||
.context("Updating workspace")?;
|
.context("Updating workspace")?;
|
||||||
|
|
||||||
// Save center pane group
|
// Save center pane group
|
||||||
|
@ -581,22 +575,19 @@ mod tests {
|
||||||
let mut workspace_1 = SerializedWorkspace {
|
let mut workspace_1 = SerializedWorkspace {
|
||||||
id: 1,
|
id: 1,
|
||||||
location: (["/tmp", "/tmp2"]).into(),
|
location: (["/tmp", "/tmp2"]).into(),
|
||||||
left_sidebar_open: true,
|
|
||||||
center_group: Default::default(),
|
center_group: Default::default(),
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut _workspace_2 = SerializedWorkspace {
|
let mut _workspace_2 = SerializedWorkspace {
|
||||||
id: 2,
|
id: 2,
|
||||||
location: (["/tmp"]).into(),
|
location: (["/tmp"]).into(),
|
||||||
left_sidebar_open: false,
|
|
||||||
center_group: Default::default(),
|
center_group: Default::default(),
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
db.save_workspace(workspace_1.clone()).await;
|
db.save_workspace(workspace_1.clone()).await;
|
||||||
|
@ -691,10 +682,9 @@ mod tests {
|
||||||
id: 5,
|
id: 5,
|
||||||
location: (["/tmp", "/tmp2"]).into(),
|
location: (["/tmp", "/tmp2"]).into(),
|
||||||
center_group,
|
center_group,
|
||||||
left_sidebar_open: true,
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
db.save_workspace(workspace.clone()).await;
|
db.save_workspace(workspace.clone()).await;
|
||||||
|
@ -720,20 +710,18 @@ mod tests {
|
||||||
id: 1,
|
id: 1,
|
||||||
location: (["/tmp", "/tmp2"]).into(),
|
location: (["/tmp", "/tmp2"]).into(),
|
||||||
center_group: Default::default(),
|
center_group: Default::default(),
|
||||||
left_sidebar_open: true,
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut workspace_2 = SerializedWorkspace {
|
let mut workspace_2 = SerializedWorkspace {
|
||||||
id: 2,
|
id: 2,
|
||||||
location: (["/tmp"]).into(),
|
location: (["/tmp"]).into(),
|
||||||
center_group: Default::default(),
|
center_group: Default::default(),
|
||||||
left_sidebar_open: false,
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
db.save_workspace(workspace_1.clone()).await;
|
db.save_workspace(workspace_1.clone()).await;
|
||||||
|
@ -767,10 +755,9 @@ mod tests {
|
||||||
id: 3,
|
id: 3,
|
||||||
location: (&["/tmp", "/tmp2"]).into(),
|
location: (&["/tmp", "/tmp2"]).into(),
|
||||||
center_group: Default::default(),
|
center_group: Default::default(),
|
||||||
left_sidebar_open: false,
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
};
|
};
|
||||||
|
|
||||||
db.save_workspace(workspace_3.clone()).await;
|
db.save_workspace(workspace_3.clone()).await;
|
||||||
|
@ -801,10 +788,9 @@ mod tests {
|
||||||
id: 4,
|
id: 4,
|
||||||
location: workspace_id.into(),
|
location: workspace_id.into(),
|
||||||
center_group: center_group.clone(),
|
center_group: center_group.clone(),
|
||||||
left_sidebar_open: true,
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks: Default::default()
|
docks: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@ pub struct SerializedWorkspace {
|
||||||
pub id: WorkspaceId,
|
pub id: WorkspaceId,
|
||||||
pub location: WorkspaceLocation,
|
pub location: WorkspaceLocation,
|
||||||
pub center_group: SerializedPaneGroup,
|
pub center_group: SerializedPaneGroup,
|
||||||
pub left_sidebar_open: bool,
|
|
||||||
pub bounds: Option<WindowBounds>,
|
pub bounds: Option<WindowBounds>,
|
||||||
pub display: Option<Uuid>,
|
pub display: Option<Uuid>,
|
||||||
pub docks: DockStructure,
|
pub docks: DockStructure,
|
||||||
|
@ -100,17 +99,17 @@ impl Bind for DockStructure {
|
||||||
#[derive(Debug, PartialEq, Clone, Default)]
|
#[derive(Debug, PartialEq, Clone, Default)]
|
||||||
pub struct DockData {
|
pub struct DockData {
|
||||||
pub(crate) visible: bool,
|
pub(crate) visible: bool,
|
||||||
pub(crate) size: Option<f32>,
|
pub(crate) active_panel: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Column for DockData {
|
impl Column for DockData {
|
||||||
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
fn column(statement: &mut Statement, start_index: i32) -> Result<(Self, i32)> {
|
||||||
let (visible, next_index) = Option::<bool>::column(statement, start_index)?;
|
let (visible, next_index) = Option::<bool>::column(statement, start_index)?;
|
||||||
let (size, next_index) = Option::<f32>::column(statement, next_index)?;
|
let (active_panel, next_index) = Option::<String>::column(statement, next_index)?;
|
||||||
Ok((
|
Ok((
|
||||||
DockData {
|
DockData {
|
||||||
visible: visible.unwrap_or(false),
|
visible: visible.unwrap_or(false),
|
||||||
size,
|
active_panel,
|
||||||
},
|
},
|
||||||
next_index,
|
next_index,
|
||||||
))
|
))
|
||||||
|
@ -120,7 +119,7 @@ impl Column for DockData {
|
||||||
impl Bind for DockData {
|
impl Bind for DockData {
|
||||||
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
fn bind(&self, statement: &Statement, start_index: i32) -> Result<i32> {
|
||||||
let next_index = statement.bind(&self.visible, start_index)?;
|
let next_index = statement.bind(&self.visible, start_index)?;
|
||||||
statement.bind(&self.size, next_index)
|
statement.bind(&self.active_panel, next_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2580,39 +2580,45 @@ impl Workspace {
|
||||||
fn build_serialized_docks(this: &Workspace, cx: &AppContext) -> DockStructure {
|
fn build_serialized_docks(this: &Workspace, cx: &AppContext) -> DockStructure {
|
||||||
let left_dock = this.left_dock.read(cx);
|
let left_dock = this.left_dock.read(cx);
|
||||||
let left_visible = left_dock.is_open();
|
let left_visible = left_dock.is_open();
|
||||||
let left_size = left_dock
|
let left_active_panel = left_dock.active_panel().and_then(|panel| {
|
||||||
.active_panel()
|
Some(
|
||||||
.map(|panel| left_dock.panel_size(panel.as_ref()))
|
cx.view_ui_name(panel.as_any().window_id(), panel.id())?
|
||||||
.flatten();
|
.to_string(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let right_dock = this.right_dock.read(cx);
|
let right_dock = this.right_dock.read(cx);
|
||||||
let right_visible = right_dock.is_open();
|
let right_visible = right_dock.is_open();
|
||||||
let right_size = right_dock
|
let right_active_panel = right_dock.active_panel().and_then(|panel| {
|
||||||
.active_panel()
|
Some(
|
||||||
.map(|panel| right_dock.panel_size(panel.as_ref()))
|
cx.view_ui_name(panel.as_any().window_id(), panel.id())?
|
||||||
.flatten();
|
.to_string(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
let bottom_dock = this.bottom_dock.read(cx);
|
let bottom_dock = this.bottom_dock.read(cx);
|
||||||
let bottom_visible = bottom_dock.is_open();
|
let bottom_visible = bottom_dock.is_open();
|
||||||
let bottom_size = bottom_dock
|
let bottom_active_panel = bottom_dock.active_panel().and_then(|panel| {
|
||||||
.active_panel()
|
Some(
|
||||||
.map(|panel| bottom_dock.panel_size(panel.as_ref()))
|
cx.view_ui_name(panel.as_any().window_id(), panel.id())?
|
||||||
.flatten();
|
.to_string(),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
DockStructure {
|
dbg!(DockStructure {
|
||||||
left: DockData {
|
left: DockData {
|
||||||
visible: left_visible,
|
visible: left_visible,
|
||||||
size: left_size,
|
active_panel: left_active_panel,
|
||||||
},
|
},
|
||||||
right: DockData {
|
right: DockData {
|
||||||
visible: right_visible,
|
visible: right_visible,
|
||||||
size: right_size,
|
active_panel: right_active_panel,
|
||||||
},
|
},
|
||||||
bottom: DockData {
|
bottom: DockData {
|
||||||
visible: bottom_visible,
|
visible: bottom_visible,
|
||||||
size: bottom_size,
|
active_panel: bottom_active_panel,
|
||||||
},
|
},
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(location) = self.location(cx) {
|
if let Some(location) = self.location(cx) {
|
||||||
|
@ -2627,7 +2633,6 @@ impl Workspace {
|
||||||
id: self.database_id,
|
id: self.database_id,
|
||||||
location,
|
location,
|
||||||
center_group,
|
center_group,
|
||||||
left_sidebar_open: self.left_dock.read(cx).is_open(),
|
|
||||||
bounds: Default::default(),
|
bounds: Default::default(),
|
||||||
display: Default::default(),
|
display: Default::default(),
|
||||||
docks,
|
docks,
|
||||||
|
@ -2686,22 +2691,15 @@ impl Workspace {
|
||||||
|
|
||||||
let docks = serialized_workspace.docks;
|
let docks = serialized_workspace.docks;
|
||||||
workspace.left_dock.update(cx, |dock, cx| {
|
workspace.left_dock.update(cx, |dock, cx| {
|
||||||
|
dbg!(docks.left.visible);
|
||||||
dock.set_open(docks.left.visible, cx);
|
dock.set_open(docks.left.visible, cx);
|
||||||
if let Some(size) = docks.left.size {
|
dbg!(dock.is_open());
|
||||||
dock.resize_active_panel(size, cx);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
workspace.right_dock.update(cx, |dock, cx| {
|
workspace.right_dock.update(cx, |dock, cx| {
|
||||||
dock.set_open(docks.right.visible, cx);
|
dock.set_open(docks.right.visible, cx);
|
||||||
if let Some(size) = docks.right.size {
|
|
||||||
dock.resize_active_panel(size, cx);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
workspace.bottom_dock.update(cx, |dock, cx| {
|
workspace.bottom_dock.update(cx, |dock, cx| {
|
||||||
dock.set_open(docks.bottom.visible, cx);
|
dock.set_open(docks.bottom.visible, cx);
|
||||||
if let Some(size) = docks.bottom.size {
|
|
||||||
dock.resize_active_panel(size, cx);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue