#![allow(non_snake_case)]
use super::layout::Layout;
use crate::composable;
use crate::layout::policies::FlowRowMeasurePolicy;
use crate::modifier::Modifier;
use cranpose_core::NodeId;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct FlowRowSpec {
pub main_axis_spacing: f32,
pub cross_axis_spacing: f32,
}
impl FlowRowSpec {
pub fn new() -> Self {
Self::default()
}
pub fn main_axis_spacing(mut self, spacing: f32) -> Self {
self.main_axis_spacing = spacing;
self
}
pub fn cross_axis_spacing(mut self, spacing: f32) -> Self {
self.cross_axis_spacing = spacing;
self
}
}
impl Default for FlowRowSpec {
fn default() -> Self {
Self {
main_axis_spacing: 0.0,
cross_axis_spacing: 0.0,
}
}
}
#[composable]
pub fn FlowRow<F>(modifier: Modifier, spec: FlowRowSpec, content: F) -> NodeId
where
F: FnMut() + 'static,
{
let policy = FlowRowMeasurePolicy::new(spec.main_axis_spacing, spec.cross_axis_spacing);
Layout(modifier, policy, content)
}