Struct TableLayout

Source
pub struct TableLayout {
    pub cell_defaults: CellProperties,
    pub row_defaults: BTreeMap<u8, CellProperties>,
    pub column_defaults: BTreeMap<u8, CellProperties>,
    pub opcodes: Vec<LayoutOp>,
    pub row: u8,
    pub column: u8,
}

Fields§

§cell_defaults: CellProperties§row_defaults: BTreeMap<u8, CellProperties>§column_defaults: BTreeMap<u8, CellProperties>§opcodes: Vec<LayoutOp>§row: u8§column: u8

Implementations§

Source§

impl TableLayout

Source

pub fn new() -> TableLayout

Examples found in repository?
examples/barebones.rs (line 6)
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 get_rows_cols(&self) -> (u8, u8)

Calculates the number of rows and columns which exist in this table layout.

Source

pub fn clear(&mut self)

Removes all layout declarations from the table. Does not remove row or column defaults.

Source

pub fn full_clear(&mut self)

Removes all layout declarations and resets ALL settings to factory default.

Source

pub fn with_row(&mut self) -> &mut Self

Adds a new row to the layout.

Examples found in repository?
examples/barebones.rs (line 22)
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_cell(&mut self, properties: CellProperties) -> &mut Self

Hands the cell off to the layout.

Examples found in repository?
examples/barebones.rs (lines 7-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 impose(&mut self, width: f32, height: f32)

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

Trait Implementations§

Source§

impl Default for TableLayout

Source§

fn default() -> TableLayout

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> 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, 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.