add custom slider as an example

This commit is contained in:
griffi-gh 2024-03-25 02:05:26 +01:00
parent 19ca54b1f3
commit 7b4772ca94

View file

@ -2,7 +2,7 @@ use std::time::Instant;
use glam::vec2;
use hui::{
color, element::{
container::Container, fill_rect::FillRect, text::Text, UiElementExt
container::Container, fill_rect::FillRect, slider::Slider, text::Text, UiElementExt
}, frame::nine_patch::{NinePatchAsset, NinePatchFrame}, frame_rect, layout::{Alignment, Direction}, rect::Rect, size
};
@ -56,6 +56,14 @@ ui_main!(
(0., 0., 1.),
)))
.add_child(ui);
Slider::new(0.33)
.with_size(size!(50%, 30))
.with_track_height(1.)
.with_handle_size((20., 0.9))
.with_handle(NinePatchFrame::from_asset(*asset).with_color(color::CYAN))
.with_track(NinePatchFrame::from_asset(*asset))
.with_track_active(color::TRANSPARENT)
.add_child(ui);
})
.add_root(ui, size);
}