update dock
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use dock::{DockArea, DockLayout, DockPlacement, SignedDockSkin, panel_handle};
|
||||
use dock::{DockArea, DockEvent, DockLayout, DockPlacement, SignedDockSkin, panel_handle};
|
||||
use gpui::prelude::*;
|
||||
use gpui::{Context, Entity, Render, Subscription, Window, div, px};
|
||||
use gpui_component::{Root, StyledExt, Theme};
|
||||
@@ -40,6 +40,32 @@ impl Workspace {
|
||||
|
||||
let mut subscriptions = vec![];
|
||||
|
||||
// A bottom/right dock whose last panel was dragged away is removed
|
||||
// entirely: base keeps the emptied region, which would otherwise
|
||||
// linger as a bare strip. Deferred, because the event arrives while
|
||||
// the area is mid-update.
|
||||
let dock_for_pruning = dock.clone();
|
||||
subscriptions.push(cx.subscribe_in(
|
||||
&dock,
|
||||
window,
|
||||
move |_, _, event: &DockEvent, window, cx| {
|
||||
if !matches!(event, DockEvent::LayoutChanged) {
|
||||
return;
|
||||
}
|
||||
let dock = dock_for_pruning.clone();
|
||||
cx.spawn_in(window, async move |_, window| {
|
||||
_ = dock.update_in(window, |area, window, cx| {
|
||||
for placement in [DockPlacement::Bottom, DockPlacement::Right] {
|
||||
if area.is_empty(placement, cx) {
|
||||
area.remove_dock(placement, window, cx);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.detach();
|
||||
},
|
||||
));
|
||||
|
||||
subscriptions.push(cx.observe_window_appearance(window, |_this, window, cx| {
|
||||
Theme::sync_system_appearance(Some(window), cx);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user