use kas::prelude::*;
use kas::theme::{Background, FrameStyle};
#[macro_export]
macro_rules! frame {
( $e:expr ) => {
$crate::Frame::new($e)
};
}
#[impl_self]
mod Frame {
#[derive(Default)]
#[widget]
#[layout(frame!(self.inner).with_style(self.style).with_background(self.bg))]
pub struct Frame<W: Widget> {
core: widget_core!(),
style: FrameStyle,
bg: Background,
#[widget]
pub inner: W,
}
impl Events for Self {
type Data = W::Data;
}
impl Self {
#[inline]
pub fn new(inner: W) -> Self {
Frame {
core: Default::default(),
style: FrameStyle::Frame,
bg: Background::default(),
inner,
}
}
#[inline]
#[must_use]
pub fn with_style(mut self, style: FrameStyle) -> Self {
self.style = style;
self
}
#[inline]
#[must_use]
pub fn with_background(mut self, bg: Background) -> Self {
self.bg = bg;
self
}
}
}