mod grid_solver;
mod row_solver;
mod single_solver;
mod size_rules;
mod sizer;
mod storage;
use crate::geom::Size;
pub use grid_solver::{GridChildInfo, GridSetter, GridSolver};
pub use row_solver::{RowPositionSolver, RowSetter, RowSolver};
pub use single_solver::{SingleSetter, SingleSolver};
pub use size_rules::{Margins, SizeRules, StretchPolicy};
pub use sizer::{RulesSetter, RulesSolver, SolveCache};
pub use storage::{
DynGridStorage, DynRowStorage, FixedGridStorage, FixedRowStorage, GridStorage, RowStorage,
RowTemp, Storage,
};
#[derive(Copy, Clone, Debug)]
pub struct AxisInfo {
vertical: bool,
has_fixed: bool,
other_axis: u32,
}
impl AxisInfo {
#[inline]
pub fn new(vertical: bool, fixed: Option<u32>) -> Self {
AxisInfo {
vertical,
has_fixed: fixed.is_some(),
other_axis: fixed.unwrap_or(0),
}
}
#[inline]
pub fn is_vertical(&self) -> bool {
self.vertical
}
#[inline]
pub fn is_horizontal(self) -> bool {
!self.vertical
}
#[inline]
pub fn other(&self) -> Option<u32> {
if self.has_fixed {
Some(self.other_axis)
} else {
None
}
}
#[inline]
pub fn size_other_if_fixed(&self, vertical: bool) -> Option<u32> {
if vertical == self.vertical && self.has_fixed {
Some(self.other_axis)
} else {
None
}
}
#[inline]
pub fn extract_size(&self, size: Size) -> u32 {
if !self.vertical {
size.0
} else {
size.1
}
}
}