summaryrefslogtreecommitdiffstats
path: root/native
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-22 22:15:44 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-23 01:51:34 +0200
commit230bd6f7475752352ca9985802db0633e3508d9f (patch)
tree55ba66173ef8b5c34784945609daf5b6dc77d6aa /native
parent2ab7341fa50865d6f0c26da59f945321ef839c5f (diff)
downloadiced-230bd6f7475752352ca9985802db0633e3508d9f.tar.gz
iced-230bd6f7475752352ca9985802db0633e3508d9f.tar.bz2
iced-230bd6f7475752352ca9985802db0633e3508d9f.zip
Write documentation for new `pane_grid` API
Diffstat (limited to 'native')
-rw-r--r--native/src/widget/pane_grid/content.rs18
-rw-r--r--native/src/widget/pane_grid/node.rs36
-rw-r--r--native/src/widget/pane_grid/state.rs4
3 files changed, 58 insertions, 0 deletions
diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs
index 6b0bd99a..8822083e 100644
--- a/native/src/widget/pane_grid/content.rs
+++ b/native/src/widget/pane_grid/content.rs
@@ -1,12 +1,30 @@
use crate::pane_grid::Axis;
+/// The content of a [`PaneGrid`].
+///
+/// [`PaneGrid`]: struct.PaneGrid.html
#[derive(Debug, Clone)]
pub enum Content<T> {
+ /// A split of the available space.
Split {
+ /// The direction of the split.
axis: Axis,
+
+ /// The ratio of the split in [0.0, 1.0].
ratio: f32,
+
+ /// The left/top [`Content`] of the split.
+ ///
+ /// [`Content`]: enum.Node.html
a: Box<Content<T>>,
+
+ /// The right/bottom [`Content`] of the split.
+ ///
+ /// [`Content`]: enum.Node.html
b: Box<Content<T>>,
},
+ /// A [`Pane`].
+ ///
+ /// [`Pane`]: struct.Pane.html
Pane(T),
}
diff --git a/native/src/widget/pane_grid/node.rs b/native/src/widget/pane_grid/node.rs
index 1b6633fa..723ec393 100644
--- a/native/src/widget/pane_grid/node.rs
+++ b/native/src/widget/pane_grid/node.rs
@@ -5,19 +5,49 @@ use crate::{
use std::collections::HashMap;
+/// A layout node of a [`PaneGrid`].
+///
+/// [`PaneGrid`]: struct.PaneGrid.html
#[derive(Debug, Clone)]
pub enum Node {
+ /// The region of this [`Node`] is split into two.
+ ///
+ /// [`Node`]: enum.Node.html
Split {
+ /// The [`Split`] of this [`Node`].
+ ///
+ /// [`Split`]: struct.Split.html
+ /// [`Node`]: enum.Node.html
id: Split,
+
+ /// The direction of the split.
axis: Axis,
+
+ /// The ratio of the split in [0.0, 1.0].
ratio: f32,
+
+ /// The left/top [`Node`] of the split.
+ ///
+ /// [`Node`]: enum.Node.html
a: Box<Node>,
+
+ /// The right/bottom [`Node`] of the split.
+ ///
+ /// [`Node`]: enum.Node.html
b: Box<Node>,
},
+ /// The region of this [`Node`] is taken by a [`Pane`].
+ ///
+ /// [`Pane`]: struct.Pane.html
Pane(Pane),
}
impl Node {
+ /// Returns the rectangular region for each [`Pane`] in the [`Node`] given
+ /// the spacing between panes and the total available space.
+ ///
+ /// [`Pane`]: struct.Pane.html
+ /// [`Node`]: enum.Node.html
pub fn regions(
&self,
spacing: f32,
@@ -39,6 +69,12 @@ impl Node {
regions
}
+ /// Returns the axis, rectangular region, and ratio for each [`Split`] in
+ /// the [`Node`] given the spacing between panes and the total available
+ /// space.
+ ///
+ /// [`Split`]: struct.Split.html
+ /// [`Node`]: enum.Node.html
pub fn splits(
&self,
spacing: f32,
diff --git a/native/src/widget/pane_grid/state.rs b/native/src/widget/pane_grid/state.rs
index 41f3cffd..4b13fb8e 100644
--- a/native/src/widget/pane_grid/state.rs
+++ b/native/src/widget/pane_grid/state.rs
@@ -56,6 +56,10 @@ impl<T> State<T> {
(Self::with_content(Content::Pane(first_pane_state)), Pane(0))
}
+ /// Creates a new [`State`] with the given [`Content`].
+ ///
+ /// [`State`]: struct.State.html
+ /// [`Content`]: enum.Content.html
pub fn with_content(content: impl Into<Content<T>>) -> Self {
let mut panes = HashMap::new();