use crate::*;
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum LineWrap {
None,
Overflow,
}
impl LineWrap {
pub const DEFAULT: LineWrap = LineWrap::None;
}
impl Default for LineWrap {
fn default() -> Self {
LineWrap::DEFAULT
}
}
#[derive(Copy, Clone, Debug)]
pub(crate) struct Layout {
pub layout_size: LayoutSize,
pub padding: Padding,
pub direction: Direction,
pub line_wrap: LineWrap,
pub absolute: bool,
pub abs_size: Option<Vec2>,
}
impl Layout {
pub const DEFAULT: Layout = Layout {
layout_size: LayoutSize::DEFAULT,
padding: Padding::DEFAULT,
direction: Direction::DEFAULT,
line_wrap: LineWrap::DEFAULT,
absolute: false,
abs_size: None,
};
}
impl Default for Layout {
fn default() -> Self {
Layout::DEFAULT
}
}
#[derive(Copy, Clone, Debug)]
pub struct LayoutSize {
pub width: Width,
pub height: Height,
}
impl LayoutSize {
pub const DEFAULT: LayoutSize = LayoutSize { width: Width::DEFAULT, height: Height::DEFAULT };
pub const FILL: LayoutSize = LayoutSize { width: Width::Fill, height: Height::Fill };
pub const fn new(w: Width, h: Height) -> Self {
Self { width: w, height: h }
}
}
impl Default for LayoutSize {
fn default() -> Self {
LayoutSize::DEFAULT
}
}
#[derive(Clone, Copy, Debug)]
pub struct Padding {
pub l: f32,
pub t: f32,
pub r: f32,
pub b: f32,
}
impl Padding {
pub const ZERO: Padding = Padding { l: 0.0, t: 0.0, r: 0.0, b: 0.0 };
pub const DEFAULT: Padding = Padding::ZERO;
pub const fn all(v: f32) -> Padding {
Padding { l: v, t: v, r: v, b: v }
}
pub const fn left(v: f32) -> Padding {
Padding { l: v, ..Padding::ZERO }
}
pub const fn top(v: f32) -> Padding {
Padding { t: v, ..Padding::ZERO }
}
pub const fn right(v: f32) -> Padding {
Padding { r: v, ..Padding::ZERO }
}
pub const fn bottom(v: f32) -> Padding {
Padding { b: v, ..Padding::ZERO }
}
}
impl Default for Padding {
fn default() -> Self {
Padding::DEFAULT
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Direction {
Right,
Down,
}
impl Direction {
pub const DEFAULT: Direction = Direction::Right;
}
impl Default for Direction {
fn default() -> Self {
Direction::DEFAULT
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Width {
Fill,
Fix(f32),
Compute,
FillUntil(f32),
}
impl Width {
pub const DEFAULT: Width = Width::Fill;
}
impl Default for Width {
fn default() -> Self {
Width::Fill
}
}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum Height {
Fill,
Fix(f32),
Compute,
FillUntil(f32),
}
impl Height {
pub const DEFAULT: Height = Height::Fill;
}
impl Default for Height {
fn default() -> Self {
Height::Fill
}
}
pub(crate) struct AlignX(pub f32);
impl AlignX {
pub(crate) const CENTER: AlignX = AlignX(0.5);
#[allow(dead_code)]
pub(crate) const RIGHT: AlignX = AlignX(1.0);
}
pub(crate) struct AlignY(pub f32);
impl AlignY {
pub(crate) const CENTER: AlignY = AlignY(0.5);
#[allow(dead_code)]
pub(crate) const BOTTOM: AlignY = AlignY(1.0);
}