summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-30 00:58:14 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-06-30 01:02:28 +0200
commit23f753e59978352292950e706d023ad02a3199bc (patch)
treea9f970b215db6fe75d530f3706e8f9ffba3234ba /native
parentcb530ccf2f0ba82e49be317a14eb61025777a24e (diff)
downloadiced-23f753e59978352292950e706d023ad02a3199bc.tar.gz
iced-23f753e59978352292950e706d023ad02a3199bc.tar.bz2
iced-23f753e59978352292950e706d023ad02a3199bc.zip
Introduce `splits` method in `pane_grid::Node`
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/pane_grid/node.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/native/src/widget/pane_grid/node.rs b/native/src/widget/pane_grid/node.rs
index 823caab1..cbfd8a43 100644
--- a/native/src/widget/pane_grid/node.rs
+++ b/native/src/widget/pane_grid/node.rs
@@ -43,6 +43,30 @@ pub enum Node {
}
impl Node {
+ /// Returns an iterator over each [`Split`] in this [`Node`].
+ ///
+ /// [`Split`]: struct.Split.html
+ /// [`Node`]: enum.Node.html
+ pub fn splits(&self) -> impl Iterator<Item = &Split> {
+ let mut unvisited_nodes = vec![self];
+
+ std::iter::from_fn(move || {
+ while let Some(node) = unvisited_nodes.pop() {
+ match node {
+ Node::Split { id, a, b, .. } => {
+ unvisited_nodes.push(a);
+ unvisited_nodes.push(b);
+
+ return Some(id);
+ }
+ _ => {}
+ }
+ }
+
+ None
+ })
+ }
+
/// Returns the rectangular region for each [`Pane`] in the [`Node`] given
/// the spacing between panes and the total available space.
///