1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use super::Drawable;
use crate::primitives::{
AlignContent,
AlignItems,
JustifyContent,
};
/// Capability for configuring alignment behavior of child elements within a
/// container.
pub trait ContainerAlignment: Drawable {
/// Sets how child items are aligned along the cross axis.
///
/// # Arguments
/// - `value`: The [`AlignItems`] behavior.
///
/// # Returns
/// - [`Self`]
fn align_items<T>(mut self, value: T) -> Self
where
T: Into<Option<AlignItems>>,
{
self.layout_mut().align_items = value.into().map(Into::into);
self
}
/// Sets how lines of content are aligned within the container.
///
/// # Arguments
/// - `value`: The [`AlignContent`] behavior.
///
/// # Returns
/// - [`Self`]
fn align_content<T>(mut self, value: T) -> Self
where
T: Into<Option<AlignContent>>,
{
self.layout_mut().align_content = value.into().map(Into::into);
self
}
/// Sets how child items are distributed along the main axis.
///
/// # Arguments
/// - `value`: The [`JustifyContent`] behavior.
///
/// # Returns
/// - [`Self`]
fn justify_content<T>(mut self, value: T) -> Self
where
T: Into<Option<JustifyContent>>,
{
self.layout_mut().justify_content = value.into().map(Into::into);
self
}
}