Move layout metrics into theme and apply audit cleanups
This commit is contained in:
@@ -192,10 +192,8 @@ impl DockState {
|
||||
}
|
||||
|
||||
/// Registers a panel descriptor, replacing any earlier one with its id.
|
||||
pub fn register_panel(&mut self, panel: PanelDescriptor, cx: &mut Context<Self>) {
|
||||
if self.panels.insert(panel.id.clone(), panel).is_none() {
|
||||
cx.notify();
|
||||
}
|
||||
pub fn register_panel(&mut self, panel: PanelDescriptor) {
|
||||
self.panels.insert(panel.id.clone(), panel);
|
||||
}
|
||||
|
||||
/// Opens a panel into the active pane and activates its tab.
|
||||
@@ -330,6 +328,17 @@ impl DockState {
|
||||
};
|
||||
|
||||
if changed {
|
||||
// The kept tab may have no right view, show the first remaining one.
|
||||
self.right_view = self
|
||||
.locate(id)
|
||||
.and_then(|(pane_key, _)| self.pane(pane_key))
|
||||
.and_then(|pane| {
|
||||
pane.active.as_deref().and_then(|active| {
|
||||
pane.tabs.iter().find(|tab| tab.panel.as_ref() == active)
|
||||
})
|
||||
})
|
||||
.and_then(|tab| tab.right_view.clone())
|
||||
.or_else(|| first_right_view(&self.root));
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
@@ -354,10 +363,14 @@ impl DockState {
|
||||
}
|
||||
|
||||
self.detach_pane(pane_key);
|
||||
|
||||
if self.active_pane == pane_key {
|
||||
self.active_pane = self.first_pane_key().unwrap_or(0);
|
||||
}
|
||||
|
||||
// The closed pane's views are gone; show the first remaining one.
|
||||
self.right_view = first_right_view(&self.root);
|
||||
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@@ -526,6 +539,19 @@ impl DockState {
|
||||
}
|
||||
}
|
||||
|
||||
fn pane(&self, key: u64) -> Option<&Pane> {
|
||||
Self::pane_in(&self.root, key)
|
||||
}
|
||||
|
||||
fn pane_in(node: &Node, key: u64) -> Option<&Pane> {
|
||||
match node {
|
||||
Node::Pane(pane) => (pane.key == key).then_some(pane),
|
||||
Node::Split(split) => {
|
||||
Self::pane_in(&split.a, key).or_else(|| Self::pane_in(&split.b, key))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn pane_mut(&mut self, key: u64) -> Option<&mut Pane> {
|
||||
Self::pane_mut_in(&mut self.root, key)
|
||||
}
|
||||
@@ -1071,7 +1097,7 @@ fn render_pane(
|
||||
.h(titlebar.height)
|
||||
.items_center()
|
||||
.pl(if titlebar.traffic_light_pad {
|
||||
px(TRAFFIC_LIGHT_PAD)
|
||||
TRAFFIC_LIGHT_PAD
|
||||
} else {
|
||||
padding_x
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user