dock: Implement core panel addition logic for tiling layout (#644)
This commit is contained in:
parent
06f9178ec4
commit
03d5f83a83
4 changed files with 19 additions and 5 deletions
|
|
@ -446,7 +446,7 @@ impl StoryWorkspace {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.dock_area.update(cx, |dock_area, cx| {
|
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);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -271,7 +271,8 @@ impl Dock {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
self.panel.add_panel(panel, &self.dock_area, window, cx);
|
self.panel
|
||||||
|
.add_panel(panel, &self.dock_area, None, window, cx);
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -314,6 +314,7 @@ impl DockItem {
|
||||||
&mut self,
|
&mut self,
|
||||||
panel: Arc<dyn PanelView>,
|
panel: Arc<dyn PanelView>,
|
||||||
dock_area: &WeakEntity<DockArea>,
|
dock_area: &WeakEntity<DockArea>,
|
||||||
|
bounds: Option<Bounds<Pixels>>,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) {
|
) {
|
||||||
|
|
@ -342,7 +343,13 @@ impl DockItem {
|
||||||
stack_panel.add_panel(new_item.view(), None, dock_area.clone(), window, cx);
|
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 { .. } => {}
|
Self::Panel { .. } => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -422,6 +429,11 @@ impl DockArea {
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the bounds of the dock area.
|
||||||
|
pub fn bounds(&self) -> Bounds<Pixels> {
|
||||||
|
self.bounds
|
||||||
|
}
|
||||||
|
|
||||||
/// Subscribe to the tiles item drag item drop event
|
/// Subscribe to the tiles item drag item drop event
|
||||||
fn subscribe_tiles_item_drop(
|
fn subscribe_tiles_item_drop(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
@ -649,6 +661,7 @@ impl DockArea {
|
||||||
&mut self,
|
&mut self,
|
||||||
panel: Arc<dyn PanelView>,
|
panel: Arc<dyn PanelView>,
|
||||||
placement: DockPlacement,
|
placement: DockPlacement,
|
||||||
|
bounds: Option<Bounds<Pixels>>,
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
|
|
@ -695,7 +708,7 @@ impl DockArea {
|
||||||
}
|
}
|
||||||
DockPlacement::Center => {
|
DockPlacement::Center => {
|
||||||
self.items
|
self.items
|
||||||
.add_panel(panel, &cx.entity().downgrade(), window, cx);
|
.add_panel(panel, &cx.entity().downgrade(), bounds, window, cx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ pub use styled::*;
|
||||||
pub use time::*;
|
pub use time::*;
|
||||||
pub use title_bar::*;
|
pub use title_bar::*;
|
||||||
pub use virtual_list::{h_virtual_list, v_virtual_list, VirtualList};
|
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 colors::*;
|
||||||
pub use icon::*;
|
pub use icon::*;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue