use std::fmt::Debug;
use r3bl_rs_utils_core::*;
use serde::{Deserialize, Serialize};
use crate::*;
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub enum Direction {
Horizontal,
Vertical,
}
pub type FlexBoxIdType = u8;
impl Default for Direction {
fn default() -> Direction { Direction::Horizontal }
}
#[derive(Clone, Default, PartialEq, Eq, Serialize, Deserialize, Hash)]
pub struct FlexBox {
pub id: FlexBoxIdType,
pub dir: Direction,
pub origin_pos: Position,
pub bounds_size: Size,
pub style_adjusted_origin_pos: Position,
pub style_adjusted_bounds_size: Size,
pub requested_size_percent: RequestedSizePercent,
pub insertion_pos_for_next_box: Option<Position>,
pub maybe_computed_style: Option<Style>,
}
impl FlexBox {
pub fn get_computed_style(&self) -> Option<Style> { self.maybe_computed_style.clone() }
}
impl Debug for FlexBox {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FlexBox")
.field("id", &self.id)
.field("dir", &self.dir)
.field("origin_pos", &self.origin_pos)
.field("bounds_size", &self.bounds_size)
.field("style_adjusted_origin_pos", &self.style_adjusted_origin_pos)
.field("style_adjusted_bounds_size", &self.style_adjusted_bounds_size)
.field("requested_size_percent", &self.requested_size_percent)
.field(
"insertion_pos_for_next_box",
format_option!(&self.insertion_pos_for_next_box),
)
.field("maybe_computed_style", format_option!(&self.maybe_computed_style))
.finish()
}
}