#[macro_export]
macro_rules! size {
(auto) => {
$crate::layout::Size::Auto
};
($x:literal) => {
$crate::layout::Size::Absolute($x as f32)
};
($x:literal %) => {
$crate::layout::Size::Relative($x as f32 / 100.)
};
($x:literal /) => {
$crate::layout::Size::Relative($x as f32)
};
($x:literal %=) => {
$crate::layout::Size::Remaining($x as f32 / 100.)
};
($x:literal /=) => {
$crate::layout::Size::Remaining($x as f32)
};
($x:ident) => {
$crate::layout::Size::Absolute($x as f32)
};
($x:ident /) => {
$crate::layout::Size::Relative($x as f32)
};
($x:ident /=) => {
$crate::layout::Size::Remaining($x as f32)
};
(($x:expr)) => {
$crate::layout::Size::Absolute(($x) as f32)
};
(($x:expr) /) => {
$crate::layout::Size::Relative(($x) as f32)
};
(($x:expr) /=) => {
$crate::layout::Size::Remaining(($x) as f32)
};
($x:tt , $y:tt $($ys:tt)?) => {
$crate::layout::Size2d {
width: $crate::size!($x),
height: $crate::size!($y $($ys)?),
}
};
($x:tt $($xs:tt)? , $y:tt $($ys:tt)?) => {
$crate::layout::Size2d {
width: $crate::size!($x $($xs)?),
height: $crate::size!($y $($ys)?),
}
};
}
#[macro_export]
macro_rules! rect_frame {
{} => {
$crate::frame::RectFrame::default()
};
($expr:expr) => {
{
let __frame: $crate::frame::RectFrame = $crate::frame::RectFrame::from($expr);
__frame
}
};
($image:expr, $color:expr) => {
$crate::frame::RectFrame::color_image($color, $image)
};
{$($ident:ident : $expr:expr),+$(,)?} => {
{
#[allow(non_upper_case_globals)]
{$(const $ident: () = ();)+}
{
let mut _frame = $crate::frame::RectFrame::default();
let mut _color_is_set = false;
let mut _image_is_set = false;
$(
{
_frame.$ident = ($expr).into();
_image_is_set |= stringify!($ident) == "image";
_color_is_set |= stringify!($ident) == "color";
}
)+
if _frame.image.is_some() && _image_is_set && !_color_is_set {
_frame.color = (1., 1., 1., 1.).into();
}
_frame
}
}
};
}