cotis-defaults 0.1.0-alpha.1

Modular Rust UI framework core
Documentation
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::fmt::Debug;

/// Top-level sizing model used by default element configs.
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Sizing {
    /// Width/height are configured independently.
    DoubleAxis(DoubleAxisSizing),
}

/// Width/height sizing pair.
#[derive(Debug, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct DoubleAxisSizing {
    /// Horizontal sizing behavior.
    pub width: AxisSizing,
    /// Vertical sizing behavior.
    pub height: AxisSizing,
}

/// Sizing modes for one axis.
#[derive(Copy, Clone, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum AxisSizing {
    /// Fits the element’s width/height within a min and max constraint.
    Fit(f32, f32),
    /// Expands the element to fill available space within min/max constraints.
    Grow(f32, f32),
    /// Sets a fixed width/height.
    Fixed(f32),
    /// Sets width/height as a percentage of its parent. Value should be between `0.0` and `Inf`.
    Percent(f32),
    /// Sets width/height as a percentage of its parent minus its padding. Value should be between `0.0` and `1.0`.
    InnerPercent(f32),
}