1use maycoon_core::state::{State, Val};
2use maycoon_core::widget::Widget;
3
4pub trait WidgetChildExt<S: State, W: Widget<S> + 'static> {
6 fn set_child(&mut self, child: impl Into<Val<S, W>>);
8
9 fn with_child(mut self, child: impl Into<Val<S, W>>) -> Self
11 where
12 Self: Sized,
13 {
14 self.set_child(child);
15 self
16 }
17}
18
19pub trait WidgetChildrenExt<S: State> {
21 fn set_children(&mut self, children: Vec<Val<S, impl Widget<S> + 'static>>);
23
24 fn with_children(mut self, children: Vec<Val<S, impl Widget<S> + 'static>>) -> Self
26 where
27 Self: Sized,
28 {
29 self.set_children(children);
30 self
31 }
32
33 fn add_child<W: Widget<S> + 'static>(&mut self, child: impl Into<Val<S, W>>);
35
36 fn with_child<W: Widget<S> + 'static>(mut self, child: impl Into<Val<S, W>>) -> Self
38 where
39 Self: Sized,
40 {
41 self.add_child(child);
42 self
43 }
44}
45
46pub trait WidgetLayoutExt<S: State> {
48 fn set_layout_style(
50 &mut self,
51 layout_style: impl Into<Val<S, maycoon_core::layout::LayoutStyle>>,
52 );
53
54 fn with_layout_style(
56 mut self,
57 layout_style: impl Into<Val<S, maycoon_core::layout::LayoutStyle>>,
58 ) -> Self
59 where
60 Self: Sized,
61 {
62 self.set_layout_style(layout_style);
63 self
64 }
65}