pub struct CellProperties {
pub size: SizeGrouping,
pub flags: CellFlags,
pub colspan: u8,
pub padding: Rectangle,
pub callback: Option<Box<PositioningFn>>,
}
Expand description
Encapsulates all properties for a cell; contributes to eventual layout decisions.
Fields§
§size: SizeGrouping
Controls the desired sizes for this cell.
flags: CellFlags
Controls various binary flags for the cell.
colspan: u8
Controls how many columns this cell will occupy.
padding: Rectangle
Controls how many pixels are intentionally wasted around this cell.
callback: Option<Box<PositioningFn>>
Applies positioning updates for this cell. Note that this
value always becomes None
when cloned, so you cannot set
default callbacks for cell policies.
Implementations§
Source§impl CellProperties
impl CellProperties
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
Sourcepub fn with_defaults(layout: &TableLayout) -> Self
pub fn with_defaults(layout: &TableLayout) -> Self
Inherits the default settings as determined by a
TableLayout
. Will first try to match the defaults for the
column this would be added to, then the row, then the fallback
defaults. Note that these defaults apply only if the cell
was added next and if the defaults have not been changed
since. The correct use of with_defaults
is to initialize
CellProperties
for immediate insertion to a layout.
pub fn minimum_size(self, minimum: Size) -> Self
pub fn maximum_size(self, maximum: Size) -> Self
Sourcepub fn preferred_size(self, preferred: Size) -> Self
pub fn preferred_size(self, preferred: Size) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
pub fn expand(self) -> Self
Sourcepub fn expand_horizontal(self) -> Self
pub fn expand_horizontal(self) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
Sourcepub fn expand_vertical(self) -> Self
pub fn expand_vertical(self) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
pub fn fill(self) -> Self
Sourcepub fn fill_horizontal(self) -> Self
pub fn fill_horizontal(self) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
pub fn fill_vertical(self) -> Self
pub fn anchor_top(self) -> Self
Sourcepub fn anchor_bottom(self) -> Self
pub fn anchor_bottom(self) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
pub fn anchor_left(self) -> Self
Sourcepub fn anchor_right(self) -> Self
pub fn anchor_right(self) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
pub fn anchor_center(self) -> Self
pub fn anchor_horizontal_center(self) -> Self
pub fn anchor_vertical_center(self) -> Self
pub fn uniform(self) -> Self
Sourcepub fn colspan(self, span: u8) -> Self
pub fn colspan(self, span: u8) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
Sourcepub fn callback(self, fun: Box<PositioningFn>) -> Self
pub fn callback(self, fun: Box<PositioningFn>) -> Self
Examples found in repository?
5fn main() {
6 let mut engine = TableLayout::new();
7 engine.with_cell(CellProperties::new()
8 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
9 .anchor_right()
10 .preferred_size(Size{width: 64.0, height: 64.0}));
11 engine.with_cell(CellProperties::new()
12 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
13 .anchor_right()
14 .expand_horizontal()
15 .preferred_size(Size{width: 64.0, height: 64.0}));
16 engine.with_cell(CellProperties::new()
17 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
18 .anchor_right()
19 .expand_horizontal()
20 .fill_horizontal()
21 .preferred_size(Size{width: 64.0, height: 64.0}));
22 engine.with_row();
23 engine.with_cell(CellProperties::new()
24 .callback(Box::new(|x, y, w, h| println!("{} {} {} {}", x, y, w, h)))
25 .colspan(3)
26 .expand_vertical()
27 .anchor_bottom()
28 .fill_horizontal()
29 .preferred_size(Size{width: 64.0, height: 64.0}));
30 engine.impose(320.0, 240.0);
31}
Sourcepub fn padding(self, pad: &Rectangle) -> Self
pub fn padding(self, pad: &Rectangle) -> Self
Sets the padding around this cell to the supplied top, left, right and bottom values as specified by a rectangle struct.
pub fn padding_all(self, pad: f32) -> Self
Sourcepub fn padding_top(self, pad: f32) -> Self
pub fn padding_top(self, pad: f32) -> Self
Sets the padding on the top side of this cell.
Sourcepub fn padding_left(self, pad: f32) -> Self
pub fn padding_left(self, pad: f32) -> Self
Sets the padding on the left side of this cell.
Sourcepub fn padding_bottom(self, pad: f32) -> Self
pub fn padding_bottom(self, pad: f32) -> Self
Sets the padding on the bottom side of this cell.
Sourcepub fn padding_right(self, pad: f32) -> Self
pub fn padding_right(self, pad: f32) -> Self
Sets the padding on the right side of this cell.