Write docs for iced and iced_native
This commit is contained in:
parent
ba56a561b2
commit
a7dba612f0
30 changed files with 877 additions and 214 deletions
|
|
@ -1,16 +1,25 @@
|
|||
use crate::{Align, Rectangle, Size};
|
||||
|
||||
/// The bounds of an element and its children.
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct Node {
|
||||
pub bounds: Rectangle,
|
||||
pub(crate) bounds: Rectangle,
|
||||
children: Vec<Node>,
|
||||
}
|
||||
|
||||
impl Node {
|
||||
/// Creates a new [`Node`] with the given [`Size`].
|
||||
///
|
||||
/// [`Node`]: struct.Node.html
|
||||
/// [`Size`]: ../struct.Size.html
|
||||
pub fn new(size: Size) -> Self {
|
||||
Self::with_children(size, Vec::new())
|
||||
}
|
||||
|
||||
/// Creates a new [`Node`] with the given [`Size`] and children.
|
||||
///
|
||||
/// [`Node`]: struct.Node.html
|
||||
/// [`Size`]: ../struct.Size.html
|
||||
pub fn with_children(size: Size, children: Vec<Node>) -> Self {
|
||||
Node {
|
||||
bounds: Rectangle {
|
||||
|
|
@ -23,19 +32,29 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the [`Size`] of the [`Node`].
|
||||
///
|
||||
/// [`Node`]: struct.Node.html
|
||||
/// [`Size`]: ../struct.Size.html
|
||||
pub fn size(&self) -> Size {
|
||||
Size::new(self.bounds.width, self.bounds.height)
|
||||
}
|
||||
|
||||
/// Returns the bounds of the [`Node`].
|
||||
///
|
||||
/// [`Node`]: struct.Node.html
|
||||
pub fn bounds(&self) -> Rectangle {
|
||||
self.bounds
|
||||
}
|
||||
|
||||
/// Returns the children of the [`Node`].
|
||||
///
|
||||
/// [`Node`]: struct.Node.html
|
||||
pub fn children(&self) -> &[Node] {
|
||||
&self.children
|
||||
}
|
||||
|
||||
pub fn align(
|
||||
pub(crate) fn align(
|
||||
&mut self,
|
||||
horizontal_alignment: Align,
|
||||
vertical_alignment: Align,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue