@@ -1336,6 +1336,7 @@ pub struct Workspace {
last_open_dock_positions: Vec<DockPosition>,
removing: bool,
_panels_task: Option<Task<Result<()>>>,
+ left_item: Option<Arc<dyn PanelHandle>>,
}
impl EventEmitter<Event> for Workspace {}
@@ -1741,6 +1742,7 @@ impl Workspace {
scheduled_tasks: Vec::new(),
last_open_dock_positions: Vec::new(),
removing: false,
+ left_item: None,
}
}
@@ -2009,6 +2011,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
}
@@ -7653,6 +7664,35 @@ 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 Self {
+ ref mut center,
+ ref zoomed,
+ ref follower_states,
+ ref active_call,
+ ref active_pane,
+ ref app_state,
+ ref project,
+ ref weak_self,
+ ..
+ } = *self;
+ let active_call = active_call.as_ref().map(|(call, _)| &*call.0);
+ let center_element = center.render(
+ zoomed.as_ref(),
+ left_item,
+ &PaneRenderContext {
+ follower_states,
+ active_call,
+ active_pane,
+ app_state,
+ project,
+ workspace: weak_self,
+ },
+ window,
+ cx,
+ );
let theme = cx.theme().clone();
let colors = theme.colors();
@@ -7670,402 +7710,377 @@ impl Render for Workspace {
.flex_col()
.font(ui_font)
.gap_0()
- .justify_start()
- .items_start()
- .text_color(colors.text)
- .overflow_hidden()
- .children(self.titlebar_item.clone())
- .on_modifiers_changed(move |_, _, cx| {
- for &id in ¬ification_entities {
- cx.notify(id);
- }
- })
- .child(
- div()
- .size_full()
- .relative()
- .flex_1()
- .flex()
- .flex_col()
- .child(
- div()
- .id("workspace")
- .bg(colors.background)
- .relative()
- .flex_1()
- .w_full()
- .flex()
- .flex_col()
- .overflow_hidden()
- .border_t_1()
- .border_b_1()
- .border_color(colors.border)
- .child({
- let this = cx.entity();
- canvas(
- move |bounds, window, cx| {
- this.update(cx, |this, cx| {
- let bounds_changed = this.bounds != bounds;
- this.bounds = bounds;
-
- if bounds_changed {
- this.left_dock.update(cx, |dock, cx| {
- dock.clamp_panel_size(
- bounds.size.width,
- window,
- cx,
- )
- });
-
- this.right_dock.update(cx, |dock, cx| {
- dock.clamp_panel_size(
- bounds.size.width,
- window,
- cx,
- )
- });
-
- this.bottom_dock.update(cx, |dock, cx| {
- dock.clamp_panel_size(
- bounds.size.height,
- window,
- cx,
- )
- });
- }
- })
- },
- |_, _, _, _| {},
- )
- .absolute()
- .size_full()
- })
- .when(self.zoomed.is_none(), |this| {
- this.on_drag_move(cx.listener(
- move |workspace,
- e: &DragMoveEvent<DraggedDock>,
- window,
- cx| {
- if workspace.previous_dock_drag_coordinates
- != Some(e.event.position)
- {
- workspace.previous_dock_drag_coordinates =
- Some(e.event.position);
-
- match e.drag(cx).0 {
- DockPosition::Left => {
- workspace.resize_left_dock(
- e.event.position.x
- - workspace.bounds.left(),
- window,
- cx,
- );
- }
- DockPosition::Right => {
- workspace.resize_right_dock(
- workspace.bounds.right()
- - e.event.position.x,
- window,
- cx,
- );
- }
- DockPosition::Bottom => {
- workspace.resize_bottom_dock(
- workspace.bounds.bottom()
- - e.event.position.y,
- window,
- cx,
- );
- }
- };
- workspace.serialize_workspace(window, cx);
- }
- },
- ))
-
- })
- .child({
- match bottom_dock_layout {
- BottomDockLayout::Full => div()
- .flex()
- .flex_col()
- .h_full()
- .child(
- div()
- .flex()
- .flex_row()
- .flex_1()
- .overflow_hidden()
- .children(self.render_dock(
- DockPosition::Left,
- &self.left_dock,
+ .justify_start()
+ .items_start()
+ .text_color(colors.text)
+ .overflow_hidden()
+ .children(self.titlebar_item.clone())
+ .on_modifiers_changed(move |_, _, cx| {
+ for &id in ¬ification_entities {
+ cx.notify(id);
+ }
+ })
+ .child(
+ div()
+ .size_full()
+ .relative()
+ .flex_1()
+ .flex()
+ .flex_col()
+ .child(
+ div()
+ .id("workspace")
+ .bg(colors.background)
+ .relative()
+ .flex_1()
+ .w_full()
+ .flex()
+ .flex_col()
+ .overflow_hidden()
+ .border_t_1()
+ .border_b_1()
+ .border_color(colors.border)
+ .child({
+ let this = cx.entity();
+ canvas(
+ move |bounds, window, cx| {
+ this.update(cx, |this, cx| {
+ let bounds_changed = this.bounds != bounds;
+ this.bounds = bounds;
+
+ if bounds_changed {
+ this.left_dock.update(cx, |dock, cx| {
+ dock.clamp_panel_size(
+ bounds.size.width,
window,
cx,
- ))
-
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .overflow_hidden()
- .child(
- h_flex()
- .flex_1()
- .when_some(
- paddings.0,
- |this, p| {
- this.child(
- p.border_r_1(),
- )
- },
- )
- .child(self.center.render(
- self.zoomed.as_ref(),
- &PaneRenderContext {
- follower_states:
- &self.follower_states,
- active_call: self.active_call(),
- active_pane: &self.active_pane,
- app_state: &self.app_state,
- project: &self.project,
- workspace: &self.weak_self,
- },
- window,
- cx,
- ))
- .when_some(
- paddings.1,
- |this, p| {
- this.child(
- p.border_l_1(),
- )
- },
- ),
- ),
)
+ });
- .children(self.render_dock(
- DockPosition::Right,
- &self.right_dock,
+ this.right_dock.update(cx, |dock, cx| {
+ dock.clamp_panel_size(
+ bounds.size.width,
window,
cx,
- )),
- )
- .child(div().w_full().children(self.render_dock(
- DockPosition::Bottom,
- &self.bottom_dock,
- window,
- cx
- ))),
-
- BottomDockLayout::LeftAligned => div()
- .flex()
- .flex_row()
- .h_full()
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .h_full()
- .child(
- div()
- .flex()
- .flex_row()
- .flex_1()
- .children(self.render_dock(DockPosition::Left, &self.left_dock, window, cx))
-
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .overflow_hidden()
- .child(
- h_flex()
- .flex_1()
- .when_some(paddings.0, |this, p| this.child(p.border_r_1()))
- .child(self.center.render(
- self.zoomed.as_ref(),
- &PaneRenderContext {
- follower_states:
- &self.follower_states,
- active_call: self.active_call(),
- active_pane: &self.active_pane,
- app_state: &self.app_state,
- project: &self.project,
- workspace: &self.weak_self,
- },
- window,
- cx,
- ))
- .when_some(paddings.1, |this, p| this.child(p.border_l_1())),
- )
- )
-
)
- .child(
- div()
- .w_full()
- .children(self.render_dock(DockPosition::Bottom, &self.bottom_dock, window, cx))
- ),
- )
- .children(self.render_dock(
- DockPosition::Right,
- &self.right_dock,
- window,
- cx,
- )),
+ });
- BottomDockLayout::RightAligned => div()
- .flex()
- .flex_row()
- .h_full()
- .children(self.render_dock(
+ this.bottom_dock.update(cx, |dock, cx| {
+ dock.clamp_panel_size(
+ bounds.size.height,
+ window,
+ cx,
+ )
+ });
+ }
+ })
+ },
+ |_, _, _, _| {},
+ )
+ .absolute()
+ .size_full()
+ })
+ .when(self.zoomed.is_none(), |this| {
+ this.on_drag_move(cx.listener(
+ move |workspace, e: &DragMoveEvent<DraggedDock>, window, cx| {
+ if workspace.previous_dock_drag_coordinates
+ != Some(e.event.position)
+ {
+ workspace.previous_dock_drag_coordinates =
+ Some(e.event.position);
+
+ match e.drag(cx).0 {
+ DockPosition::Left => {
+ workspace.resize_left_dock(
+ e.event.position.x
+ - workspace.bounds.left(),
+ window,
+ cx,
+ );
+ }
+ DockPosition::Right => {
+ workspace.resize_right_dock(
+ workspace.bounds.right()
+ - e.event.position.x,
+ window,
+ cx,
+ );
+ }
+ DockPosition::Bottom => {
+ workspace.resize_bottom_dock(
+ workspace.bounds.bottom()
+ - e.event.position.y,
+ window,
+ cx,
+ );
+ }
+ };
+ workspace.serialize_workspace(window, cx);
+ }
+ },
+ ))
+ })
+ .child({
+ match bottom_dock_layout {
+ BottomDockLayout::Full => div()
+ .flex()
+ .flex_col()
+ .h_full()
+ .child(
+ div()
+ .flex()
+ .flex_row()
+ .flex_1()
+ .overflow_hidden()
+ .when(render_left_dock, |this| {
+ this.children(self.render_dock(
+ DockPosition::Left,
+ &self.left_dock,
+ window,
+ cx,
+ ))
+ })
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .overflow_hidden()
+ .child(
+ h_flex()
+ .flex_1()
+ .when_some(paddings.0, |this, p| {
+ this.child(p.border_r_1())
+ })
+ .child(center_element)
+ .when_some(
+ paddings.1,
+ |this, p| {
+ this.child(p.border_l_1())
+ },
+ ),
+ ),
+ )
+ .children(self.render_dock(
+ DockPosition::Right,
+ &self.right_dock,
+ window,
+ cx,
+ )),
+ )
+ .child(div().w_full().children(self.render_dock(
+ DockPosition::Bottom,
+ &self.bottom_dock,
+ window,
+ cx,
+ ))),
+
+ BottomDockLayout::LeftAligned => div()
+ .flex()
+ .flex_row()
+ .h_full()
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .h_full()
+ .child(
+ div()
+ .flex()
+ .flex_row()
+ .flex_1()
+ .when(render_left_dock, |this| {
+ this.children(self.render_dock(
+ DockPosition::Left,
+ &self.left_dock,
+ window,
+ cx,
+ ))
+ })
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .overflow_hidden()
+ .child(
+ h_flex()
+ .flex_1()
+ .when_some(
+ paddings.0,
+ |this, p| {
+ this.child(
+ p.border_r_1(),
+ )
+ },
+ )
+ .child(center_element)
+ .when_some(
+ paddings.1,
+ |this, p| {
+ this.child(
+ p.border_l_1(),
+ )
+ },
+ ),
+ ),
+ ),
+ )
+ .child(div().w_full().children(self.render_dock(
+ DockPosition::Bottom,
+ &self.bottom_dock,
+ window,
+ cx,
+ ))),
+ )
+ .children(self.render_dock(
+ DockPosition::Right,
+ &self.right_dock,
+ window,
+ cx,
+ )),
+
+ BottomDockLayout::RightAligned => div()
+ .flex()
+ .flex_row()
+ .h_full()
+ .when(render_left_dock, |this| {
+ this.children(self.render_dock(
DockPosition::Left,
&self.left_dock,
window,
cx,
))
-
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .h_full()
- .child(
- div()
- .flex()
- .flex_row()
- .flex_1()
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .overflow_hidden()
- .child(
- h_flex()
- .flex_1()
- .when_some(paddings.0, |this, p| this.child(p.border_r_1()))
- .child(self.center.render(
- self.zoomed.as_ref(),
- &PaneRenderContext {
- follower_states:
- &self.follower_states,
- active_call: self.active_call(),
- active_pane: &self.active_pane,
- app_state: &self.app_state,
- project: &self.project,
- workspace: &self.weak_self,
- },
- window,
- cx,
- ))
- .when_some(paddings.1, |this, p| this.child(p.border_l_1())),
- )
- )
-
- .children(self.render_dock(DockPosition::Right, &self.right_dock, window, cx))
- )
- .child(
- div()
- .w_full()
- .children(self.render_dock(DockPosition::Bottom, &self.bottom_dock, window, cx))
- ),
- ),
-
- BottomDockLayout::Contained => div()
- .flex()
- .flex_row()
- .h_full()
- .children(self.render_dock(
+ })
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .h_full()
+ .child(
+ div()
+ .flex()
+ .flex_row()
+ .flex_1()
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .overflow_hidden()
+ .child(
+ h_flex()
+ .flex_1()
+ .when_some(
+ paddings.0,
+ |this, p| {
+ this.child(
+ p.border_r_1(),
+ )
+ },
+ )
+ .child(center_element)
+ .when_some(
+ paddings.1,
+ |this, p| {
+ this.child(
+ p.border_l_1(),
+ )
+ },
+ ),
+ ),
+ )
+ .children(self.render_dock(
+ DockPosition::Right,
+ &self.right_dock,
+ window,
+ cx,
+ )),
+ )
+ .child(div().w_full().children(self.render_dock(
+ DockPosition::Bottom,
+ &self.bottom_dock,
+ window,
+ cx,
+ ))),
+ ),
+
+ BottomDockLayout::Contained => div()
+ .flex()
+ .flex_row()
+ .h_full()
+ .when(render_left_dock, |this| {
+ this.children(self.render_dock(
DockPosition::Left,
&self.left_dock,
window,
cx,
))
+ })
+ .child(
+ div()
+ .flex()
+ .flex_col()
+ .flex_1()
+ .overflow_hidden()
+ .child(
+ h_flex()
+ .flex_1()
+ .when_some(paddings.0, |this, p| {
+ this.child(p.border_r_1())
+ })
+ .child(center_element)
+ .when_some(paddings.1, |this, p| {
+ this.child(p.border_l_1())
+ }),
+ )
+ .children(self.render_dock(
+ DockPosition::Bottom,
+ &self.bottom_dock,
+ window,
+ cx,
+ )),
+ )
+ .children(self.render_dock(
+ DockPosition::Right,
+ &self.right_dock,
+ window,
+ cx,
+ )),
+ }
+ })
+ .children(self.zoomed.as_ref().and_then(|view| {
+ let zoomed_view = view.upgrade()?;
+ let div = div()
+ .occlude()
+ .absolute()
+ .overflow_hidden()
+ .border_color(colors.border)
+ .bg(colors.background)
+ .child(zoomed_view)
+ .inset_0()
+ .shadow_lg();
+
+ if !WorkspaceSettings::get_global(cx).zoomed_padding {
+ return Some(div);
+ }
- .child(
- div()
- .flex()
- .flex_col()
- .flex_1()
- .overflow_hidden()
- .child(
- h_flex()
- .flex_1()
- .when_some(paddings.0, |this, p| {
- this.child(p.border_r_1())
- })
- .child(self.center.render(
- self.zoomed.as_ref(),
- &PaneRenderContext {
- follower_states:
- &self.follower_states,
- active_call: self.active_call(),
- active_pane: &self.active_pane,
- app_state: &self.app_state,
- project: &self.project,
- workspace: &self.weak_self,
- },
- window,
- cx,
- ))
- .when_some(paddings.1, |this, p| {
- this.child(p.border_l_1())
- }),
- )
- .children(self.render_dock(
- DockPosition::Bottom,
- &self.bottom_dock,
- window,
- cx,
- )),
- )
-
- .children(self.render_dock(
- DockPosition::Right,
- &self.right_dock,
- window,
- cx,
- )),
- }
+ Some(match self.zoomed_position {
+ Some(DockPosition::Left) => div.right_2().border_r_1(),
+ Some(DockPosition::Right) => div.left_2().border_l_1(),
+ Some(DockPosition::Bottom) => div.top_2().border_t_1(),
+ None => div.top_2().bottom_2().left_2().right_2().border_1(),
})
- .children(self.zoomed.as_ref().and_then(|view| {
- let zoomed_view = view.upgrade()?;
- let div = div()
- .occlude()
- .absolute()
- .overflow_hidden()
- .border_color(colors.border)
- .bg(colors.background)
- .child(zoomed_view)
- .inset_0()
- .shadow_lg();
-
- if !WorkspaceSettings::get_global(cx).zoomed_padding {
- return Some(div);
- }
-
- Some(match self.zoomed_position {
- Some(DockPosition::Left) => div.right_2().border_r_1(),
- Some(DockPosition::Right) => div.left_2().border_l_1(),
- Some(DockPosition::Bottom) => div.top_2().border_t_1(),
- None => {
- div.top_2().bottom_2().left_2().right_2().border_1()
- }
- })
- }))
- .children(self.render_notifications(window, cx)),
- )
- .when(self.status_bar_visible(cx), |parent| {
- parent.child(self.status_bar.clone())
- })
- .child(self.toast_layer.clone()),
- )
+ }))
+ .children(self.render_notifications(window, cx)),
+ )
+ .when(self.status_bar_visible(cx), |parent| {
+ parent.child(self.status_bar.clone())
+ })
+ .child(self.toast_layer.clone()),
+ )
}
}