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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use super::Drawable;
use crate::primitives::JustifyItems;
use taffy::style::{
GridAutoFlow,
GridTemplateArea,
GridTemplateComponent,
TrackSizingFunction,
};
/// Capability for configuring grid container behavior on a node.
pub trait GridContainer: Drawable {
/// Sets the track sizing functions (heights) of the grid rows.
///
/// # Arguments
/// - `value`: The list describing each row's sizing function.
///
/// # Returns
/// - [`Self`]
fn grid_template_rows(mut self, value: Vec<GridTemplateComponent<String>>) -> Self {
self.layout_mut().grid_template_rows = value;
self
}
/// Sets the track sizing functions (widths) of the grid columns.
///
/// # Arguments
/// - `value`: The list describing each column's sizing function.
///
/// # Returns
/// - [`Self`]
fn grid_template_columns(mut self, value: Vec<GridTemplateComponent<String>>) -> Self {
self.layout_mut().grid_template_columns = value;
self
}
/// Sets the size of implicitly created grid rows.
///
/// # Arguments
/// - `value`: The list used to size rows that are generated automatically.
///
/// # Returns
/// - [`Self`]
fn grid_auto_rows(mut self, value: Vec<TrackSizingFunction>) -> Self {
self.layout_mut().grid_auto_rows = value;
self
}
/// Sets the size of implicitly created grid columns.
///
/// # Arguments
/// - `value`: The list used to size columns that are generated
/// automatically.
///
/// # Returns
/// - [`Self`]
fn grid_auto_columns(mut self, value: Vec<TrackSizingFunction>) -> Self {
self.layout_mut().grid_auto_columns = value;
self
}
/// Sets how auto-placed items are inserted into the grid.
///
/// # Arguments
/// - `value`: The [`GridAutoFlow`] behavior.
///
/// # Returns
/// - [`Self`]
fn grid_auto_flow(mut self, value: GridAutoFlow) -> Self {
self.layout_mut().grid_auto_flow = value;
self
}
/// Sets the rectangular grid template areas.
///
/// # Arguments
/// - `value`: A list describing the named areas.
///
/// # Returns
/// - [`Self`]
fn grid_template_areas(mut self, value: Vec<GridTemplateArea<String>>) -> Self {
self.layout_mut().grid_template_areas = value;
self
}
/// Sets the named grid lines between columns.
///
/// # Arguments
/// - `value`: A list of line names.
///
/// # Returns
/// - [`Self`]
fn grid_template_column_names(mut self, value: Vec<Vec<String>>) -> Self {
self.layout_mut().grid_template_column_names = value;
self
}
/// Sets the named grid lines between rows.
///
/// # Arguments
/// - `value`: A list of line names.
///
/// # Returns
/// - [`Self`]
fn grid_template_row_names(mut self, value: Vec<Vec<String>>) -> Self {
self.layout_mut().grid_template_row_names = value;
self
}
/// Sets how grid items are aligned along the inline axis within their grid
/// areas.
///
/// # Arguments
/// - `value`: The [`JustifyItems`] behavior.
///
/// # Returns
/// - [`Self`]
fn justify_items<T>(mut self, value: T) -> Self
where
T: Into<Option<JustifyItems>>,
{
self.layout_mut().justify_items = value.into().map(Into::into);
self
}
}