diff --git a/crates/ui/src/dock/dock.rs b/crates/ui/src/dock/dock.rs index 41bf3941..274dfc92 100644 --- a/crates/ui/src/dock/dock.rs +++ b/crates/ui/src/dock/dock.rs @@ -188,6 +188,9 @@ impl Dock { } }); } + DockItem::Panel { .. } => { + // Not supported + } } } @@ -367,6 +370,7 @@ impl Render for Dock { .map(|this| match &self.panel { DockItem::Split { view, .. } => this.child(view.clone()), DockItem::Tabs { view, .. } => this.child(view.clone()), + DockItem::Panel { view, .. } => this.child(view.clone().view()), }) .child(self.render_resize_handle(cx)) .child(DockElement { diff --git a/crates/ui/src/dock/mod.rs b/crates/ui/src/dock/mod.rs index 4f6c13b0..672cceea 100644 --- a/crates/ui/src/dock/mod.rs +++ b/crates/ui/src/dock/mod.rs @@ -68,17 +68,21 @@ pub struct DockArea { /// DockItem is a tree structure that represents the layout of the dock. #[derive(Clone)] pub enum DockItem { + /// Split layout Split { axis: gpui::Axis, items: Vec, sizes: Vec>, view: View, }, + /// Tab layout Tabs { items: Vec>, active_ix: usize, view: View, }, + /// Panel layout + Panel { view: Arc }, } impl DockItem { @@ -140,6 +144,11 @@ impl DockItem { } } + /// Create DockItem with panel layout + pub fn panel(panel: Arc) -> Self { + Self::Panel { view: panel } + } + /// Create DockItem with tabs layout, items are displayed as tabs. /// /// The `active_ix` is the index of the active tab, if `None` the first tab is active. @@ -192,6 +201,7 @@ impl DockItem { match self { Self::Split { view, .. } => Arc::new(view.clone()), Self::Tabs { view, .. } => Arc::new(view.clone()), + Self::Panel { view, .. } => view.clone(), } } @@ -202,6 +212,7 @@ impl DockItem { items.iter().find_map(|item| item.find_panel(panel.clone())) } Self::Tabs { items, .. } => items.iter().find(|item| *item == &panel).cloned(), + Self::Panel { view } => Some(view.clone()), } } @@ -237,6 +248,7 @@ impl DockItem { stack_panel.add_panel(new_item.view(), None, dock_area.clone(), cx); }); } + Self::Panel { .. } => {} } } @@ -253,6 +265,7 @@ impl DockItem { item.set_collapsed(collapsed, cx); } } + DockItem::Panel { .. } => {} } } @@ -261,6 +274,7 @@ impl DockItem { match self { DockItem::Tabs { view, .. } => Some(view.clone()), DockItem::Split { view, .. } => view.read(cx).left_top_tab_panel(true, cx), + DockItem::Panel { .. } => None, } } @@ -269,6 +283,7 @@ impl DockItem { match self { DockItem::Tabs { view, .. } => Some(view.clone()), DockItem::Split { view, .. } => view.read(cx).right_top_tab_panel(true, cx), + DockItem::Panel { .. } => None, } } } @@ -640,6 +655,9 @@ impl DockArea { DockItem::Tabs { .. } => { // We subscribe to the tab panel event in StackPanel's insert_panel } + DockItem::Panel { .. } => { + // Not supported + } } } @@ -707,6 +725,7 @@ impl DockArea { match &self.items { DockItem::Split { view, .. } => view.clone().into_any_element(), DockItem::Tabs { view, .. } => view.clone().into_any_element(), + DockItem::Panel { view, .. } => view.clone().view().into_any_element(), } }