1mod adapt;
9mod adapt_cx;
10mod adapt_events;
11mod adapt_widget;
12mod reserve;
13mod with_label;
14
15pub use adapt::{Adapt, Map};
16pub use adapt_cx::{AdaptConfigCx, AdaptEventCx};
17pub use adapt_events::AdaptEvents;
18pub use adapt_widget::*;
19#[doc(inline)] pub use kas::widgets::adapt::*;
20pub use reserve::{Reserve, WithMarginStyle};
21pub use with_label::{WithHiddenLabel, WithLabel};
22
23#[allow(unused)] use kas::event::{ConfigCx, EventCx};
24use kas::layout::{AxisInfo, SizeRules, Stretch};
25use kas::theme::SizeCx;
26use kas::{Layout, Widget, impl_self};
27
28#[impl_self]
29mod WithStretch {
30 #[derive_widget]
35 pub struct WithStretch<W: Widget> {
36 #[widget]
37 pub inner: W,
38 pub horiz: Option<Stretch>,
42 pub vert: Option<Stretch>,
46 }
47
48 impl Self {
49 pub fn new(
51 inner: W,
52 horiz: impl Into<Option<Stretch>>,
53 vert: impl Into<Option<Stretch>>,
54 ) -> Self {
55 WithStretch {
56 inner,
57 horiz: horiz.into(),
58 vert: vert.into(),
59 }
60 }
61 }
62
63 impl Layout for Self {
64 fn size_rules(&mut self, cx: &mut SizeCx, axis: AxisInfo) -> SizeRules {
65 let mut rules = self.inner.size_rules(cx, axis);
66 if axis.is_horizontal()
67 && let Some(stretch) = self.horiz
68 {
69 rules.set_stretch(stretch);
70 } else if axis.is_vertical()
71 && let Some(stretch) = self.vert
72 {
73 rules.set_stretch(stretch);
74 }
75 rules
76 }
77 }
78}