Struct CellProperties

Source
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

Source

pub fn new() -> Self

Examples found in repository?
examples/barebones.rs (line 7)
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}
Source

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.

Source

pub fn minimum_size(self, minimum: Size) -> Self

Source

pub fn maximum_size(self, maximum: Size) -> Self

Source

pub fn preferred_size(self, preferred: Size) -> Self

Examples found in repository?
examples/barebones.rs (line 10)
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}
Source

pub fn expand(self) -> Self

Source

pub fn expand_horizontal(self) -> Self

Examples found in repository?
examples/barebones.rs (line 14)
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}
Source

pub fn expand_vertical(self) -> Self

Examples found in repository?
examples/barebones.rs (line 26)
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}
Source

pub fn fill(self) -> Self

Source

pub fn fill_horizontal(self) -> Self

Examples found in repository?
examples/barebones.rs (line 20)
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}
Source

pub fn fill_vertical(self) -> Self

Source

pub fn anchor_top(self) -> Self

Source

pub fn anchor_bottom(self) -> Self

Examples found in repository?
examples/barebones.rs (line 27)
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}
Source

pub fn anchor_left(self) -> Self

Source

pub fn anchor_right(self) -> Self

Examples found in repository?
examples/barebones.rs (line 9)
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}
Source

pub fn anchor_center(self) -> Self

Source

pub fn anchor_horizontal_center(self) -> Self

Source

pub fn anchor_vertical_center(self) -> Self

Source

pub fn uniform(self) -> Self

Source

pub fn colspan(self, span: u8) -> Self

Examples found in repository?
examples/barebones.rs (line 25)
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}
Source

pub fn callback(self, fun: Box<PositioningFn>) -> Self

Examples found in repository?
examples/barebones.rs (line 8)
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}
Source

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.

Source

pub fn padding_all(self, pad: f32) -> Self

Source

pub fn padding_top(self, pad: f32) -> Self

Sets the padding on the top side of this cell.

Source

pub fn padding_left(self, pad: f32) -> Self

Sets the padding on the left side of this cell.

Source

pub fn padding_bottom(self, pad: f32) -> Self

Sets the padding on the bottom side of this cell.

Source

pub fn padding_right(self, pad: f32) -> Self

Sets the padding on the right side of this cell.

Trait Implementations§

Source§

impl Clone for CellProperties

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for CellProperties

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.