hUI/hui-examples/examples/ui_test_7_9patch.rs

39 lines
840 B
Rust
Raw Normal View History

2024-03-24 21:18:15 +00:00
use std::time::Instant;
use hui::{
color, element::{
container::Container,
fill_rect::FillRect,
UiElementExt
}, frame_rect, layout::{Alignment, Direction}, size
};
#[path = "../boilerplate.rs"]
#[macro_use]
mod boilerplate;
ui_main!(
"hUI: 9-Patch demo",
init: |_| {
2024-03-24 21:55:15 +00:00
2024-03-24 21:18:15 +00:00
},
2024-03-24 21:55:15 +00:00
run: |ui, size, _| {
2024-03-24 21:18:15 +00:00
Container::default()
2024-03-24 21:55:15 +00:00
.with_size(size!(100%))
2024-03-24 21:18:15 +00:00
.with_direction(Direction::Horizontal)
.with_align(Alignment::Center)
.with_padding(5.)
.with_gap(10.)
.with_background(color::WHITE)
.with_wrap(true)
.with_children(|ui| {
FillRect::default()
.with_size(size!(300, 100))
.with_frame(frame_rect! {
2024-03-24 21:55:15 +00:00
color: color::RED
2024-03-24 21:18:15 +00:00
})
.add_child(ui);
})
.add_root(ui, size);
}
);