@@ -215,6 +215,13 @@ impl MultiWorkspace {
cx.notify();
}
+ pub fn set_left_dock_expanded_mode(&mut self, agent_mode: bool, cx: &mut Context<Self>) {
+ self.workspace().update(cx, |workspace, cx| {
+ workspace.set_left_dock_expanded_mode(agent_mode, cx);
+ });
+ cx.notify();
+ }
+
pub fn toggle_sidebar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
if !self.multi_workspace_enabled(cx) || self.is_singleton {
return;
@@ -29,8 +29,8 @@ const VERTICAL_MIN_SIZE: f32 = 100.;
pub struct PaneGroup {
pub root: Member,
pub is_center: bool,
- left_item_flexes: Arc<Mutex<Vec<f32>>>,
- left_item_bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
+ root_axis_flexes: Arc<Mutex<Vec<f32>>>,
+ root_axis_bounding_boxes: Arc<Mutex<Vec<Option<Bounds<Pixels>>>>>,
}
pub struct PaneRenderResult {
@@ -43,8 +43,8 @@ impl PaneGroup {
Self {
root,
is_center: false,
- left_item_flexes: Arc::new(Mutex::new(Vec::new())),
- left_item_bounding_boxes: Arc::new(Mutex::new(Vec::new())),
+ root_axis_flexes: Arc::new(Mutex::new(Vec::new())),
+ root_axis_bounding_boxes: Arc::new(Mutex::new(Vec::new())),
}
}
@@ -52,8 +52,8 @@ impl PaneGroup {
Self {
root: Member::Pane(pane),
is_center: false,
- left_item_flexes: Arc::new(Mutex::new(Vec::new())),
- left_item_bounding_boxes: Arc::new(Mutex::new(Vec::new())),
+ root_axis_flexes: Arc::new(Mutex::new(Vec::new())),
+ root_axis_bounding_boxes: Arc::new(Mutex::new(Vec::new())),
}
}
@@ -266,13 +266,13 @@ impl PaneGroup {
let child_count = children.len();
{
- let mut flexes = self.left_item_flexes.lock();
+ let mut flexes = self.root_axis_flexes.lock();
if flexes.len() != child_count {
*flexes = vec![1.0; child_count];
}
}
{
- let mut bounding_boxes = self.left_item_bounding_boxes.lock();
+ let mut bounding_boxes = self.root_axis_bounding_boxes.lock();
if bounding_boxes.len() != child_count {
*bounding_boxes = vec![None; child_count];
}
@@ -281,8 +281,8 @@ impl PaneGroup {
pane_axis(
Axis::Horizontal,
usize::MAX / 2,
- self.left_item_flexes.clone(),
- self.left_item_bounding_boxes.clone(),
+ self.root_axis_flexes.clone(),
+ self.root_axis_bounding_boxes.clone(),
render_cx.workspace().clone(),
)
.with_is_leaf_pane_mask(is_leaf_pane_mask)
@@ -1336,7 +1336,7 @@ pub struct Workspace {
last_open_dock_positions: Vec<DockPosition>,
removing: bool,
_panels_task: Option<Task<Result<()>>>,
- left_item: Option<Arc<dyn PanelHandle>>,
+ left_dock_expanded_mode: bool,
}
impl EventEmitter<Event> for Workspace {}
@@ -1742,7 +1742,6 @@ impl Workspace {
scheduled_tasks: Vec::new(),
last_open_dock_positions: Vec::new(),
removing: false,
- left_item: None,
}
}
@@ -2011,19 +2010,15 @@ impl Workspace {
&self.left_dock
}
- pub fn set_left_item(&mut self, view: Option<Arc<dyn PanelHandle>>, cx: &mut Context<Self>) {
- self.left_item = view;
- cx.notify();
- }
-
- pub fn left_item(&self) -> Option<Arc<dyn PanelHandle>> {
- self.left_item.clone()
- }
-
pub fn bottom_dock(&self) -> &Entity<Dock> {
&self.bottom_dock
}
+ pub fn set_left_dock_expanded_mode(&mut self, is_expanded_mode: bool, cx: &mut Context<Self>) {
+ self.left_dock_expanded_mode = is_expanded_mode;
+ cx.notify();
+ }
+
pub fn set_bottom_dock_layout(
&mut self,
layout: BottomDockLayout,
@@ -7664,8 +7659,13 @@ impl Render for Workspace {
(None, None)
};
let ui_font = theme::setup_ui_font(window, cx);
- let left_item = self.left_item.as_ref().map(|v| v.to_any());
- let render_left_dock = left_item.is_none();
+ let expanded_left_panel = self
+ .left_dock
+ .read(cx)
+ .active_panel()
+ .filter(|_| self.left_dock_expanded_mode)
+ .map(|p| p.to_any());
+ let render_left_dock_with_pixel_width = expanded_left_panel.is_none();
let Self {
ref mut center,
@@ -7681,7 +7681,7 @@ impl Render for Workspace {
let active_call = active_call.as_ref().map(|(call, _)| &*call.0);
let center_element = center.render(
zoomed.as_ref(),
- left_item,
+ expanded_left_panel,
&PaneRenderContext {
follower_states,
active_call,
@@ -7832,7 +7832,7 @@ impl Render for Workspace {
.flex_row()
.flex_1()
.overflow_hidden()
- .when(render_left_dock, |this| {
+ .when(render_left_dock_with_pixel_width, |this| {
this.children(self.render_dock(
DockPosition::Left,
&self.left_dock,
@@ -7890,14 +7890,17 @@ impl Render for Workspace {
.flex()
.flex_row()
.flex_1()
- .when(render_left_dock, |this| {
- this.children(self.render_dock(
- DockPosition::Left,
- &self.left_dock,
- window,
- cx,
- ))
- })
+ .when(
+ render_left_dock_with_pixel_width,
+ |this| {
+ this.children(self.render_dock(
+ DockPosition::Left,
+ &self.left_dock,
+ window,
+ cx,
+ ))
+ },
+ )
.child(
div()
.flex()
@@ -7945,7 +7948,7 @@ impl Render for Workspace {
.flex()
.flex_row()
.h_full()
- .when(render_left_dock, |this| {
+ .when(render_left_dock_with_pixel_width, |this| {
this.children(self.render_dock(
DockPosition::Left,
&self.left_dock,
@@ -8011,7 +8014,7 @@ impl Render for Workspace {
.flex()
.flex_row()
.h_full()
- .when(render_left_dock, |this| {
+ .when(render_left_dock_with_pixel_width, |this| {
this.children(self.render_dock(
DockPosition::Left,
&self.left_dock,
@@ -319,6 +319,7 @@ fn toggle_agent_mode(
}
is_singleton = !is_singleton;
let agent_mode = !is_singleton;
+ multi_workspace.set_left_dock_expanded_mode(agent_mode, cx);
let workspace = multi_workspace.workspace();
workspace.update(cx, |workspace, cx| {
update_panel_positions(workspace, window, agent_mode, cx);
@@ -763,13 +764,6 @@ fn update_panel_positions(
agent_mode: bool,
cx: &mut Context<Workspace>,
) {
- if agent_mode {
- let agent_panel_view = find_agent_panel_view(workspace, cx);
- workspace.set_left_item(agent_panel_view, cx);
- } else {
- workspace.set_left_item(None, cx);
- }
-
let panels_and_positions = workspace.all_panel_ids_and_positions(cx);
for (panel_id, current_position) in panels_and_positions {
let panel_handle = workspace