glyph_ui 0.1.0

TUI library utilizing the Elm architecture
Documentation
//! Layout settings for containers and items

/// Layout settings for containers
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)]
pub struct Container {
    pub(super) align_items: AlignItems,
}

impl Container {
    /// Create a new default container layout
    pub fn new() -> Self {
        Default::default()
    }

    /// Change item alignment strategy
    pub fn align_items(mut self, align_items: AlignItems) -> Self {
        self.align_items = align_items;
        self
    }
}

/// Item alignment strategy
///
/// The default is [`Stretch`](AlignItems::Stretch).
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum AlignItems {
    /// Stretch items to fill the entire cross-axis
    Stretch,

    /// Align items to the start of the container
    Start,
}

impl Default for AlignItems {
    fn default() -> Self {
        Self::Stretch
    }
}

/// Layout settings for items in a container
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Default)]
pub struct Item {
    pub(super) grow: Option<u8>,
}

impl Item {
    /// Create a new default item layout
    pub fn new() -> Self {
        Default::default()
    }

    /// Change grow factor
    ///
    /// The default is `None`, which means the main-axis length will be based on
    /// [`View::layout()`](crate::View)'s notion of "sensible minimums".
    pub fn grow(mut self, factor: Option<u8>) -> Self {
        self.grow = factor;
        self
    }
}