update most examples to new ugly api

This commit is contained in:
griffi-gh 2024-03-24 01:28:03 +01:00
parent 2e49ea443a
commit 27a75d6c30
4 changed files with 32 additions and 30 deletions

View file

@ -1,13 +1,11 @@
use std::time::Instant; use std::time::Instant;
use hui::{ use hui::{
size,
layout::{Alignment, Direction},
element::{ element::{
container::Container, container::Container,
progress_bar::ProgressBar, progress_bar::ProgressBar,
text::Text, text::Text,
UiElementExt, UiElementExt,
}, }, frame::FrameRect, layout::{Alignment, Direction}, size
}; };
#[path = "../boilerplate.rs"] #[path = "../boilerplate.rs"]
@ -33,8 +31,10 @@ ui_main!{
.with_gap(5.) .with_gap(5.)
.with_padding(10.) .with_padding(10.)
.with_size(size!(450, auto)) .with_size(size!(450, auto))
.with_background((0.2, 0.2, 0.5)) .with_background(
FrameRect::color((0.2, 0.2, 0.5))
.with_corner_radius(8.) .with_corner_radius(8.)
)
.with_children(|ui| { .with_children(|ui| {
if instant.elapsed().as_secs_f32() < 5. { if instant.elapsed().as_secs_f32() < 5. {
Text::default() Text::default()

View file

@ -1,7 +1,5 @@
use hui::{ use hui::{
color, size, color, element::{container::Container, text::Text, UiElementExt}, frame::FrameRect, layout::Alignment, size
layout::Alignment,
element::{UiElementExt, container::Container, text::Text},
}; };
#[path = "../boilerplate.rs"] #[path = "../boilerplate.rs"]
@ -14,8 +12,10 @@ ui_main!(|ui, size, _| {
.with_align(Alignment::Center) .with_align(Alignment::Center)
.with_padding(5.) .with_padding(5.)
.with_gap(10.) .with_gap(10.)
.with_background(
FrameRect::color(color::WHITE)
.with_corner_radius(10.) .with_corner_radius(10.)
.with_background(color::WHITE) )
.with_children(|ui| { .with_children(|ui| {
Text::default() Text::default()
.with_text("Hello, world") .with_text("Hello, world")
@ -24,8 +24,10 @@ ui_main!(|ui, size, _| {
.add_child(ui); .add_child(ui);
Container::default() Container::default()
.with_padding((10., 20.)) .with_padding((10., 20.))
.with_background(
FrameRect::color(color::DARK_RED)
.with_corner_radius((2.5, 30., 2.5, 2.5)) .with_corner_radius((2.5, 30., 2.5, 2.5))
.with_background(color::DARK_RED) )
.with_children(|ui| { .with_children(|ui| {
Text::default() Text::default()
.with_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.") .with_text("Lorem ipsum dolor sit amet, consectetur adipiscing elit.")

View file

@ -1,10 +1,6 @@
use glam::vec4; use glam::vec4;
use hui::{ use hui::{
color, size, color, element::{container::Container, progress_bar::ProgressBar, text::Text, UiElementExt}, frame::FrameRect, layout::Alignment, rect::Corners, size, text::FontHandle
element::{container::Container, progress_bar::ProgressBar, text::Text, UiElementExt},
layout::Alignment,
rect::Corners,
text::FontHandle,
}; };
#[path = "../boilerplate.rs"] #[path = "../boilerplate.rs"]
@ -38,8 +34,10 @@ ui_main!(
.with_children(|ui| { .with_children(|ui| {
Container::default() Container::default()
.with_padding((10., 15.)) .with_padding((10., 15.))
.with_background(
FrameRect::color((0., 0., 0., 0.5))
.with_corner_radius(8.) .with_corner_radius(8.)
.with_background((0., 0., 0., 0.5)) )
.with_children(|ui| { .with_children(|ui| {
let flash = 1. - 0.5 * (4. * instant.elapsed().as_secs_f32()).sin().powi(2); let flash = 1. - 0.5 * (4. * instant.elapsed().as_secs_f32()).sin().powi(2);
Text::default() Text::default()
@ -61,8 +59,10 @@ ui_main!(
.with_align((Alignment::Center, Alignment::Begin)) .with_align((Alignment::Center, Alignment::Begin))
.with_padding(15.) .with_padding(15.)
.with_gap(10.) .with_gap(10.)
.with_background(
FrameRect::color((0., 0., 0., 0.5))
.with_corner_radius(8.) .with_corner_radius(8.)
.with_background((0., 0., 0., 0.5)) )
.with_children(|ui| { .with_children(|ui| {
Text::default() Text::default()
.with_text("Did you know?") .with_text("Did you know?")
@ -100,8 +100,10 @@ ui_main!(
.with_children(|ui| { .with_children(|ui| {
Container::default() Container::default()
.with_padding(10.) .with_padding(10.)
.with_background(
FrameRect::color((0., 0., 0., 0.5))
.with_corner_radius(8.) .with_corner_radius(8.)
.with_background((0., 0., 0., 0.5)) )
.with_children(|ui| { .with_children(|ui| {
Text::default() Text::default()
.with_text("Level 5") .with_text("Level 5")

View file

@ -7,11 +7,7 @@ use hui::{
text::Text, text::Text,
transformer::ElementTransformExt, transformer::ElementTransformExt,
UiElementExt UiElementExt
}, }, frame::FrameRect, layout::Alignment, rect::Corners, size, text::FontHandle
layout::Alignment,
rect::Corners,
text::FontHandle,
size,
}; };
#[path = "../boilerplate.rs"] #[path = "../boilerplate.rs"]
@ -41,8 +37,10 @@ ui_main!(
.with_align((Alignment::Center, Alignment::Begin)) .with_align((Alignment::Center, Alignment::Begin))
.with_padding(15.) .with_padding(15.)
.with_gap(10.) .with_gap(10.)
.with_background(
FrameRect::color((0., 0., 0., 0.5))
.with_corner_radius(8.) .with_corner_radius(8.)
.with_background((0., 0., 0., 0.5)) )
.with_children(|ui| { .with_children(|ui| {
Text::default() Text::default()
.with_text("Did you know?") .with_text("Did you know?")