1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
use crate::{ pre_hooks, widget, widget::{ component::{ containers::flex_box::{flex_box, FlexBoxProps}, interactive::navigation::{ use_nav_container_active, use_nav_item, use_nav_jump_horizontal_step_active, NavContainerActive, NavItemActive, NavJumpActive, }, }, context::WidgetContext, node::WidgetNode, unit::flex::FlexBoxDirection, utils::Transform, }, PropsData, Scalar, }; use serde::{Deserialize, Serialize}; #[derive(PropsData, Debug, Default, Clone, Serialize, Deserialize)] #[props_data(crate::props::PropsData)] #[prefab(crate::Prefab)] pub struct HorizontalBoxProps { #[serde(default)] pub separation: Scalar, #[serde(default)] pub reversed: bool, #[serde(default)] pub transform: Transform, } #[pre_hooks( use_nav_container_active, use_nav_jump_horizontal_step_active, use_nav_item )] pub fn nav_horizontal_box(mut context: WidgetContext) -> WidgetNode { let WidgetContext { key, props, listed_slots, .. } = context; let props = props .clone() .without::<NavContainerActive>() .without::<NavJumpActive>() .without::<NavItemActive>(); widget! { (#{key} horizontal_box: {props} |[listed_slots]|) } } pub fn horizontal_box(context: WidgetContext) -> WidgetNode { let WidgetContext { key, props, listed_slots, .. } = context; let HorizontalBoxProps { separation, reversed, transform, } = props.read_cloned_or_default(); let props = props.clone().with(FlexBoxProps { direction: if reversed { FlexBoxDirection::HorizontalRightToLeft } else { FlexBoxDirection::HorizontalLeftToRight }, separation, wrap: false, transform, }); widget! { (#{key} flex_box: {props} |[ listed_slots ]|) } }