add custom slider as an example

This commit is contained in:
griffi-gh 2024-03-25 02:05:26 +01:00
parent 1666b08873
commit bfb5bfaa0a

View file

@ -2,7 +2,7 @@ use std::time::Instant;
use glam::vec2; use glam::vec2;
use hui::{ use hui::{
color, element::{ 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 }, frame::nine_patch::{NinePatchAsset, NinePatchFrame}, frame_rect, layout::{Alignment, Direction}, rect::Rect, size
}; };
@ -56,6 +56,14 @@ ui_main!(
(0., 0., 1.), (0., 0., 1.),
))) )))
.add_child(ui); .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); .add_root(ui, size);
} }