summaryrefslogtreecommitdiffstats
path: root/native/src/layout.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/layout.rs')
-rw-r--r--native/src/layout.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/native/src/layout.rs b/native/src/layout.rs
index 0a744346..e945706b 100644
--- a/native/src/layout.rs
+++ b/native/src/layout.rs
@@ -1,3 +1,4 @@
+//! Position your widgets properly.
mod limits;
mod node;
@@ -8,6 +9,9 @@ pub use node::Node;
use crate::{Point, Rectangle, Vector};
+/// The bounds of a [`Node`] and its children, using absolute coordinates.
+///
+/// [`Node`]: struct.Node.html
#[derive(Debug, Clone, Copy)]
pub struct Layout<'a> {
position: Point,
@@ -28,6 +32,14 @@ impl<'a> Layout<'a> {
}
}
+ /// Gets the bounds of the [`Layout`].
+ ///
+ /// The returned [`Rectangle`] describes the position and size of a
+ /// [`Node`].
+ ///
+ /// [`Layout`]: struct.Layout.html
+ /// [`Rectangle`]: struct.Rectangle.html
+ /// [`Node`]: struct.Node.html
pub fn bounds(&self) -> Rectangle {
let bounds = self.node.bounds();
@@ -39,6 +51,10 @@ impl<'a> Layout<'a> {
}
}
+ /// Returns an iterator over the [`Layout`] of the children of a [`Node`].
+ ///
+ /// [`Layout`]: struct.Layout.html
+ /// [`Node`]: struct.Node.html
pub fn children(&'a self) -> impl Iterator<Item = Layout<'a>> {
self.node.children().iter().map(move |node| {
Layout::with_offset(