use crate::*; pub use self::spatial::*; mod spatial { use crate::*; /// A widget that tracks its rendered width and height. /// /// ``` /// let measure = tengri::Measure::::default(); /// ``` #[derive(Default)] pub struct Measure { pub x: Arc, pub y: Arc, pub __: PhantomData, } /// Increment X and/or Y coordinate. /// /// ``` /// let pushed = tengri::Push::XY(2, 2, "Hello"); /// ``` pub enum Push { X(U, A), Y(U, A), XY(U, U, A), } /// Decrement X and/or Y coordinate. /// /// ``` /// let pulled = tengri::Pull::XY(2, 2, "Hello"); /// ``` pub enum Pull { X(U, A), Y(U, A), XY(U, U, A), } /// Set the content to fill the container. /// /// ``` /// let filled = tengri::Fill::XY("Hello"); /// ``` pub enum Fill { X(A), Y(A), XY(A) } /// Set fixed size for content. /// /// ``` /// let fixed = tengri::Fixed::XY(3, 5, "Hello"); // 3x5 /// ``` pub enum Fixed { X(U, A), Y(U, A), XY(U, U, A), } /// Decrease the width and/or height of the content. /// /// ``` /// let shrunk = tengri::Shrink::XY(2, 0, "Hello"); // 1x1 /// ``` pub enum Shrink { X(U, A), Y(U, A), XY(U, U, A), } /// Increaase the width and/or height of the content. /// /// ``` /// let expanded = tengri::Expand::XY(5, 3, "HELLO"); // 15x3 /// ``` pub enum Expand { X(U, A), Y(U, A), XY(U, U, A), } /// Align position of inner area to middle, side, or corner of outer area. /// /// /// ``` /// use ::tengri::*; /// let area = XYWH(10u16, 10, 20, 20); /// fn test (area: XYWH, item: &impl Draw, expected: [u16;4]) { /// //assert_eq!(Lay::layout(item, area), expected); /// //assert_eq!(Draw::layout(item, area), expected); /// }; /// /// let four = ||Fixed::XY(4, 4, ""); /// test(area, &Align::nw(four()), [10, 10, 4, 4]); /// test(area, &Align::n(four()), [18, 10, 4, 4]); /// test(area, &Align::ne(four()), [26, 10, 4, 4]); /// test(area, &Align::e(four()), [26, 18, 4, 4]); /// test(area, &Align::se(four()), [26, 26, 4, 4]); /// test(area, &Align::s(four()), [18, 26, 4, 4]); /// test(area, &Align::sw(four()), [10, 26, 4, 4]); /// test(area, &Align::w(four()), [10, 18, 4, 4]); /// /// let two_by_four = ||Fixed::XY(4, 2, ""); /// test(area, &Align::nw(two_by_four()), [10, 10, 4, 2]); /// test(area, &Align::n(two_by_four()), [18, 10, 4, 2]); /// test(area, &Align::ne(two_by_four()), [26, 10, 4, 2]); /// test(area, &Align::e(two_by_four()), [26, 19, 4, 2]); /// test(area, &Align::se(two_by_four()), [26, 28, 4, 2]); /// test(area, &Align::s(two_by_four()), [18, 28, 4, 2]); /// test(area, &Align::sw(two_by_four()), [10, 28, 4, 2]); /// test(area, &Align::w(two_by_four()), [10, 19, 4, 2]); /// ``` pub struct Align(pub Alignment, pub T); // TODO DOCUMENTME pub enum Pad { X(U, A), Y(U, A), XY(U, U, A), } // TODO DOCUMENTME pub struct Bordered(pub bool, pub S, pub W); // TODO DOCUMENTME pub struct Border(pub bool, pub S); /// TODO DOCUMENTME /// /// ``` /// use tengri::{Bounded, XYWH}; /// let bounded: Bounded = Bounded(0, 0 ,0 ,0 ,""); /// ``` pub struct Bounded(N, N, N, N, pub D); /// Draws items from an iterator. /// /// ``` /// // FIXME let map = tengri::Map(||[].iter(), |_|{}); /// ``` pub struct Map where I: Iterator + Send + Sync, F: Fn() -> I + Send + Sync, { /// Function that returns iterator over stacked components pub get_iter: F, /// Function that returns each stacked component pub get_item: G, pub __: PhantomData<(O, B)>, } /// A color in OKHSL and RGB representations. #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct ItemColor { pub okhsl: Okhsl, #[cfg(feature = "tui")] pub rgb: Color, } /// A color in OKHSL and RGB with lighter and darker variants. #[derive(Debug, Default, Copy, Clone, PartialEq)] pub struct ItemTheme { pub base: ItemColor, pub light: ItemColor, pub lighter: ItemColor, pub lightest: ItemColor, pub dark: ItemColor, pub darker: ItemColor, pub darkest: ItemColor, } // TODO DOCUMENTME pub struct FieldH(pub Theme, pub Label, pub Value); // TODO DOCUMENTME pub struct FieldV(pub Theme, pub Label, pub Value); // TODO: pub struct Field { pub direction: Direction, pub label: Option, pub label_fg: Option, pub label_bg: Option, pub label_align: Option, pub value: Option, pub value_fg: Option, pub value_bg: Option, pub value_align: Option, } } :wqa #[cfg(feature = "tui")] pub use self::terminal::*; #[cfg(feature = "tui")] mod terminal { use crate::*; /// TUI input loop event. #[derive(Debug, Clone, Eq, PartialEq, PartialOrd)] pub struct TuiEvent(pub Event); /// TUI key spec. #[derive(Debug, Clone, Eq, PartialEq, PartialOrd)] pub struct TuiKey(pub Option, pub KeyModifiers); /// TUI buffer sized by `usize` instead of `u16`. #[derive(Default)] pub struct BigBuffer { pub width: usize, pub height: usize, pub content: Vec } pub struct Foreground(pub Color, pub Item); pub struct Background(pub Color, pub Item); pub struct Modify(pub bool, pub Modifier, pub T); pub struct Styled(pub Option