WIP: Allow panels to be moved

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2023-05-09 18:57:25 +02:00
parent 45df09245b
commit 8f12489937
6 changed files with 157 additions and 92 deletions

View file

@ -60,7 +60,7 @@ use crate::{
notifications::simple_message_notification::MessageNotification,
persistence::model::{SerializedPane, SerializedPaneGroup, SerializedWorkspace},
};
use dock::{Dock, DockPosition, PanelButtons, TogglePanel};
use dock::{Dock, DockPosition, Panel, PanelButtons, PanelHandle, TogglePanel};
use lazy_static::lazy_static;
use notifications::{NotificationHandle, NotifyResultExt};
pub use pane::*;
@ -834,6 +834,15 @@ impl Workspace {
&self.right_dock
}
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,
};
dock.update(cx, |dock, cx| dock.add_panel(panel, cx));
}
pub fn status_bar(&self) -> &ViewHandle<StatusBar> {
&self.status_bar
}