Cycle through panes spatially rather than in the order in which they created

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-03-23 15:06:25 +01:00
parent 5ac39aa7cd
commit 60b6b0b317
2 changed files with 36 additions and 17 deletions

View file

@ -57,6 +57,12 @@ impl PaneGroup {
) -> ElementBox {
self.root.render(theme, follower_states, collaborators)
}
pub(crate) fn panes(&self) -> Vec<&ViewHandle<Pane>> {
let mut panes = Vec::new();
self.root.collect_panes(&mut panes);
panes
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
@ -122,6 +128,17 @@ impl Member {
Member::Axis(axis) => axis.render(theme, follower_states, collaborators),
}
}
fn collect_panes<'a>(&'a self, panes: &mut Vec<&'a ViewHandle<Pane>>) {
match self {
Member::Axis(axis) => {
for member in &axis.members {
member.collect_panes(panes);
}
}
Member::Pane(pane) => panes.push(pane),
}
}
}
#[derive(Clone, Debug, Eq, PartialEq)]