#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum FlexFlow {
Row = 0,
Column = 1,
RowWrap = 4,
RowReverse = 8,
RowWrapReverse = 12,
ColumnWrap = 5,
ColumnReverse = 9,
ColumnWrapReverse = 13,
}
#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum FlexAlign {
Start = 0,
End = 1,
Center = 2,
SpaceEvenly = 3,
SpaceAround = 4,
SpaceBetween = 5,
}
#[repr(u32)]
#[derive(Clone, Copy, Debug)]
pub enum GridAlign {
Start = 0,
Center = 1,
End = 2,
Stretch = 3,
SpaceEvenly = 4,
SpaceAround = 5,
SpaceBetween = 6,
}
#[repr(u32)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Layout {
Flex = oxivgl_sys::lv_layout_t_LV_LAYOUT_FLEX,
Grid = oxivgl_sys::lv_layout_t_LV_LAYOUT_GRID,
}
#[derive(Clone, Copy, Debug)]
pub struct GridCell {
pub align: GridAlign,
pub pos: i32,
pub span: i32,
}
impl GridCell {
pub fn new(align: GridAlign, pos: i32, span: i32) -> Self {
Self { align, pos, span }
}
pub fn at(pos: i32) -> Self {
Self {
align: GridAlign::Start,
pos,
span: 1,
}
}
}
pub const GRID_TEMPLATE_LAST: i32 = oxivgl_sys::LV_COORD_MAX as i32;
pub const fn grid_fr(x: i32) -> i32 {
oxivgl_sys::LV_COORD_MAX as i32 - 100 + x
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn at_defaults_to_start_span1() {
let c = GridCell::at(2);
assert_eq!(c.pos, 2);
assert_eq!(c.span, 1);
assert!(format!("{:?}", c.align).contains("Start"));
}
#[test]
fn new_preserves_fields() {
let c = GridCell::new(GridAlign::Center, 3, 2);
assert_eq!(c.pos, 3);
assert_eq!(c.span, 2);
}
#[test]
fn layout_discriminants() {
assert_eq!(
Layout::Flex as u32,
oxivgl_sys::lv_layout_t_LV_LAYOUT_FLEX
);
assert_eq!(
Layout::Grid as u32,
oxivgl_sys::lv_layout_t_LV_LAYOUT_GRID
);
}
}