hUI/hui-examples/examples/ui_test.rs

44 lines
1.1 KiB
Rust
Raw Normal View History

2024-02-29 15:02:05 +00:00
use hui::{
2024-04-17 13:57:46 +00:00
color, size, rect_frame,
2024-03-24 17:32:50 +00:00
element::{container::Container, text::Text, UiElementExt},
2024-04-17 13:57:46 +00:00
frame::RectFrame,
2024-03-24 17:32:50 +00:00
layout::Alignment,
2024-02-29 15:02:05 +00:00
};
#[path = "../boilerplate.rs"]
#[macro_use]
mod boilerplate;
ui_main!(|ui, size, _| {
2024-02-29 15:02:05 +00:00
Container::default()
.with_size(size!(100%, 50%))
.with_align(Alignment::Center)
.with_padding(5.)
.with_gap(10.)
2024-04-17 13:57:46 +00:00
.with_background(rect_frame! {
2024-03-24 17:32:50 +00:00
color: (0.5, 0.5, 0.5, 1.),
corner_radius: 10.,
})
2024-02-29 15:02:05 +00:00
.with_children(|ui| {
Text::default()
.with_text("Hello, world")
.with_text_size(100)
.with_color(color::BLACK)
.add_child(ui);
Container::default()
.with_padding((10., 20.))
2024-04-17 13:57:46 +00:00
.with_background(rect_frame! {
2024-03-24 17:32:50 +00:00
color: color::DARK_RED,
corner_radius: (2.5, 30., 2.5, 2.5),
})
2024-02-29 15:02:05 +00:00
.with_children(|ui| {
Text::default()
.with_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")
.with_text_size(24)
.add_child(ui);
})
.add_child(ui);
})
.add_root(ui, size);
});