diff --git a/crates/story/src/main.rs b/crates/story/src/main.rs index 3756a317..9bdd2231 100644 --- a/crates/story/src/main.rs +++ b/crates/story/src/main.rs @@ -446,7 +446,7 @@ impl StoryWorkspace { }; self.dock_area.update(cx, |dock_area, cx| { - dock_area.add_panel(panel, action.0, window, cx); + dock_area.add_panel(panel, action.0, None, window, cx); }); } diff --git a/crates/ui/src/dock/dock.rs b/crates/ui/src/dock/dock.rs index a3e3e7dc..893aef32 100644 --- a/crates/ui/src/dock/dock.rs +++ b/crates/ui/src/dock/dock.rs @@ -271,7 +271,8 @@ impl Dock { window: &mut Window, cx: &mut Context, ) { - self.panel.add_panel(panel, &self.dock_area, window, cx); + self.panel + .add_panel(panel, &self.dock_area, None, window, cx); cx.notify(); } diff --git a/crates/ui/src/dock/mod.rs b/crates/ui/src/dock/mod.rs index 1821309d..5f28b2d6 100644 --- a/crates/ui/src/dock/mod.rs +++ b/crates/ui/src/dock/mod.rs @@ -314,6 +314,7 @@ impl DockItem { &mut self, panel: Arc, dock_area: &WeakEntity, + bounds: Option>, window: &mut Window, cx: &mut App, ) { @@ -342,7 +343,13 @@ impl DockItem { stack_panel.add_panel(new_item.view(), None, dock_area.clone(), window, cx); }); } - Self::Tiles { .. } => {} + Self::Tiles { view, .. } => { + view.update(cx, |tiles, cx| { + let bounds = bounds.unwrap_or_else(|| TileMeta::default().bounds); + tiles.add_item(TileItem::new(panel.clone(), bounds), dock_area, window, cx); + cx.notify(); + }); + } Self::Panel { .. } => {} } } @@ -422,6 +429,11 @@ impl DockArea { this } + /// Return the bounds of the dock area. + pub fn bounds(&self) -> Bounds { + self.bounds + } + /// Subscribe to the tiles item drag item drop event fn subscribe_tiles_item_drop( &mut self, @@ -649,6 +661,7 @@ impl DockArea { &mut self, panel: Arc, placement: DockPlacement, + bounds: Option>, window: &mut Window, cx: &mut Context, ) { @@ -695,7 +708,7 @@ impl DockArea { } DockPlacement::Center => { self.items - .add_panel(panel, &cx.entity().downgrade(), window, cx); + .add_panel(panel, &cx.entity().downgrade(), bounds, window, cx); } } } diff --git a/crates/ui/src/lib.rs b/crates/ui/src/lib.rs index 66f8d918..a7ed83dd 100644 --- a/crates/ui/src/lib.rs +++ b/crates/ui/src/lib.rs @@ -62,7 +62,7 @@ pub use styled::*; pub use time::*; pub use title_bar::*; pub use virtual_list::{h_virtual_list, v_virtual_list, VirtualList}; -pub use window_border::{window_border, WindowBorder}; +pub use window_border::{window_border, window_paddings, WindowBorder}; pub use colors::*; pub use icon::*;