mirror of
https://github.com/griffi-gh/hUI.git
synced 2024-11-25 16:38:42 -06:00
frame_rect
macro
This commit is contained in:
parent
27a75d6c30
commit
04ebfd41e8
|
@ -1,6 +1,17 @@
|
|||
use glam::vec4;
|
||||
use hui::{
|
||||
color, element::{container::Container, progress_bar::ProgressBar, text::Text, UiElementExt}, frame::FrameRect, layout::Alignment, rect::Corners, size, text::FontHandle
|
||||
size, frame_rect,
|
||||
color,
|
||||
element::{
|
||||
container::Container,
|
||||
progress_bar::ProgressBar,
|
||||
text::Text,
|
||||
UiElementExt
|
||||
},
|
||||
frame::FrameRect,
|
||||
layout::Alignment,
|
||||
rect::Corners,
|
||||
text::FontHandle
|
||||
};
|
||||
|
||||
#[path = "../boilerplate.rs"]
|
||||
|
@ -59,10 +70,10 @@ ui_main!(
|
|||
.with_align((Alignment::Center, Alignment::Begin))
|
||||
.with_padding(15.)
|
||||
.with_gap(10.)
|
||||
.with_background(
|
||||
FrameRect::color((0., 0., 0., 0.5))
|
||||
.with_corner_radius(8.)
|
||||
)
|
||||
.with_background(frame_rect! {
|
||||
color: (0., 0., 0., 0.5),
|
||||
corner_radius: 8.,
|
||||
})
|
||||
.with_children(|ui| {
|
||||
Text::default()
|
||||
.with_text("Did you know?")
|
||||
|
|
|
@ -60,3 +60,71 @@ macro_rules! size {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// Helper macro for constructing a `FrameRect`
|
||||
#[macro_export]
|
||||
macro_rules! frame_rect {
|
||||
() => {
|
||||
$crate::frame::FrameRect::default()
|
||||
};
|
||||
|
||||
($expr:expr) => {
|
||||
{
|
||||
let _frame_rect: $crate::frame::FrameRect = $crate::frame::FrameRect::from($expr);
|
||||
_frame_rect
|
||||
}
|
||||
};
|
||||
|
||||
($image:expr, $color:expr) => {
|
||||
$crate::frame::FrameRect::color_image($color, $image)
|
||||
};
|
||||
|
||||
{$($ident:ident : $expr:expr),+$(,)?} => {
|
||||
{
|
||||
// ensure all identifiers are unique
|
||||
#[allow(non_upper_case_globals)]
|
||||
{$(const $ident: () = ();)+}
|
||||
|
||||
// construct the FrameRect
|
||||
{
|
||||
let mut frame_rect = $crate::frame::FrameRect::default();
|
||||
$(
|
||||
let $ident = ($expr).into();
|
||||
frame_rect.$ident = $ident;
|
||||
)+
|
||||
frame_rect
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// {$from:expr, $($ident:ident : $expr:expr),+$(,)?} => {
|
||||
// {
|
||||
// // ensure all identifiers are unique
|
||||
// #[allow(non_upper_case_globals)]
|
||||
// {
|
||||
// $(
|
||||
// const $ident: () = ();
|
||||
// )+
|
||||
// }
|
||||
// // construct the FrameRect
|
||||
// {
|
||||
// let mut _frame_rect: $crate::frame::FrameRect = ($from).into();
|
||||
// $(
|
||||
// let $ident = ($expr).into();
|
||||
// _frame_rect.$ident = $ident;
|
||||
// )+
|
||||
// _frame_rect
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
}
|
||||
|
||||
// #[allow(unused)]
|
||||
// fn test() {
|
||||
// // let _ = frame_rect!(5, 6);
|
||||
|
||||
// let _ = frame_rect! {
|
||||
// color: (0.2, 0.2, 0.3, 1.),
|
||||
// corner_radius: 5.,
|
||||
// };
|
||||
// }
|
||||
|
|
Loading…
Reference in a new issue