Allow the project panel to be docked right or left
Co-Authored-By: Joseph Lyons <joseph@zed.dev>
This commit is contained in:
parent
0d78266ddb
commit
6a7feb4c4c
7 changed files with 66 additions and 24 deletions
|
@ -836,10 +836,26 @@ impl Workspace {
|
|||
|
||||
pub fn add_panel<T: Panel>(&mut self, panel: ViewHandle<T>, cx: &mut ViewContext<Self>) {
|
||||
let dock = match panel.position(cx) {
|
||||
DockPosition::Left => &mut self.left_dock,
|
||||
DockPosition::Bottom => &mut self.bottom_dock,
|
||||
DockPosition::Right => &mut self.right_dock,
|
||||
DockPosition::Left => &self.left_dock,
|
||||
DockPosition::Bottom => &self.bottom_dock,
|
||||
DockPosition::Right => &self.right_dock,
|
||||
};
|
||||
|
||||
cx.subscribe(&panel, {
|
||||
let mut dock = dock.clone();
|
||||
move |this, panel, event, cx| {
|
||||
if T::should_change_position_on_event(event) {
|
||||
dock.update(cx, |dock, cx| dock.remove_panel(&panel, cx));
|
||||
dock = match panel.read(cx).position(cx) {
|
||||
DockPosition::Left => &this.left_dock,
|
||||
DockPosition::Bottom => &this.bottom_dock,
|
||||
DockPosition::Right => &this.right_dock,
|
||||
}.clone();
|
||||
dock.update(cx, |dock, cx| dock.add_panel(panel, cx));
|
||||
}
|
||||
}
|
||||
}).detach();
|
||||
|
||||
dock.update(cx, |dock, cx| dock.add_panel(panel, cx));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue