mod adapt;
mod adapt_cx;
mod adapt_events;
mod adapt_widget;
mod reserve;
mod with_label;
pub use adapt::{Adapt, Map};
pub use adapt_cx::{AdaptConfigCx, AdaptEventCx};
pub use adapt_events::AdaptEvents;
pub use adapt_widget::*;
#[doc(inline)] pub use kas::widgets::adapt::*;
pub use reserve::{Reserve, WithMarginStyle};
pub use with_label::{WithHiddenLabel, WithLabel};
#[allow(unused)] use kas::event::{ConfigCx, EventCx};
use kas::layout::{AxisInfo, SizeRules, Stretch};
use kas::theme::SizeCx;
use kas::{Layout, Widget, impl_self};
#[impl_self]
mod WithStretch {
#[derive_widget]
pub struct WithStretch<W: Widget> {
#[widget]
pub inner: W,
pub horiz: Option<Stretch>,
pub vert: Option<Stretch>,
}
impl Self {
pub fn new(
inner: W,
horiz: impl Into<Option<Stretch>>,
vert: impl Into<Option<Stretch>>,
) -> Self {
WithStretch {
inner,
horiz: horiz.into(),
vert: vert.into(),
}
}
}
impl Layout for Self {
fn size_rules(&mut self, cx: &mut SizeCx, axis: AxisInfo) -> SizeRules {
let mut rules = self.inner.size_rules(cx, axis);
if axis.is_horizontal()
&& let Some(stretch) = self.horiz
{
rules.set_stretch(stretch);
} else if axis.is_vertical()
&& let Some(stretch) = self.vert
{
rules.set_stretch(stretch);
}
rules
}
}
}