2024-03-06 13:39:25 -06:00
|
|
|
use std::time::Instant;
|
2024-03-06 08:44:02 -06:00
|
|
|
use hui::{
|
2024-03-24 16:18:15 -05:00
|
|
|
color, element::{
|
2024-03-06 08:44:02 -06:00
|
|
|
container::Container,
|
2024-04-17 08:47:22 -05:00
|
|
|
frame_view::FrameView,
|
2024-03-06 08:44:02 -06:00
|
|
|
UiElementExt
|
2024-04-17 08:57:46 -05:00
|
|
|
}, rect_frame, layout::{Alignment, Direction}, size
|
2024-03-06 08:44:02 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#[path = "../boilerplate.rs"]
|
|
|
|
#[macro_use]
|
|
|
|
mod boilerplate;
|
|
|
|
|
2024-03-06 13:39:25 -06:00
|
|
|
ui_main!(
|
2024-03-06 18:15:33 -06:00
|
|
|
"hUI: Wrapping demo",
|
2024-03-06 13:39:25 -06:00
|
|
|
init: |_| {
|
|
|
|
Instant::now()
|
|
|
|
},
|
|
|
|
run: |ui, size, instant| {
|
|
|
|
let width_ratio = 0.5 + 0.5 * instant.elapsed().as_secs_f32().sin().powi(2);
|
|
|
|
Container::default()
|
|
|
|
.with_size(size!(width_ratio/, 100%))
|
2024-03-06 19:06:14 -06:00
|
|
|
.with_direction(Direction::Horizontal)
|
2024-03-06 13:39:25 -06:00
|
|
|
.with_align(Alignment::Center)
|
|
|
|
.with_padding(5.)
|
|
|
|
.with_gap(10.)
|
|
|
|
.with_background(color::WHITE)
|
|
|
|
.with_wrap(true)
|
|
|
|
.with_children(|ui| {
|
|
|
|
for i in 0..10 {
|
2024-04-17 08:44:47 -05:00
|
|
|
FrameView::default()
|
2024-03-06 13:39:25 -06:00
|
|
|
.with_size(size!((40 + i * 10)))
|
2024-04-17 08:57:46 -05:00
|
|
|
.with_frame(rect_frame! {
|
2024-03-24 16:18:15 -05:00
|
|
|
color: color::DARK_RED,
|
|
|
|
corner_radius: 8.
|
|
|
|
})
|
2024-03-06 13:39:25 -06:00
|
|
|
.add_child(ui);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.add_root(ui, size);
|
|
|
|
}
|
|
|
|
);
|