mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-24 15:58:43 -06:00
clean up code
This commit is contained in:
parent
d0c75d9397
commit
83e187769a
|
@ -31,9 +31,11 @@ fn checkbox(
|
||||||
value: bool,
|
value: bool,
|
||||||
signal: impl Fn(bool) -> SettingsSignal + 'static,
|
signal: impl Fn(bool) -> SettingsSignal + 'static,
|
||||||
) {
|
) {
|
||||||
const WIDTH: f32 = 50.;
|
const WIDTH_PX: f32 = 50.;
|
||||||
const HEIGHT: f32 = WIDTH / 2.;
|
const HEIGHT_PX: f32 = WIDTH_PX / 2.;
|
||||||
|
const HANDLE_PX: f32 = HEIGHT_PX;
|
||||||
const TRACK_HEIGHT_RATIO: f32 = 0.75;
|
const TRACK_HEIGHT_RATIO: f32 = 0.75;
|
||||||
|
const TRACK_HEIGHT_PX: f32 = HEIGHT_PX * TRACK_HEIGHT_RATIO;
|
||||||
|
|
||||||
Container::default()
|
Container::default()
|
||||||
.with_direction(Direction::Horizontal)
|
.with_direction(Direction::Horizontal)
|
||||||
|
@ -43,20 +45,20 @@ fn checkbox(
|
||||||
Text::new(text)
|
Text::new(text)
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
Slider::new(value as u32 as f32)
|
Slider::new(value as u32 as f32)
|
||||||
.with_size(size!(WIDTH, HEIGHT))
|
.with_size(size!(WIDTH_PX, HEIGHT_PX))
|
||||||
.with_track_height(TRACK_HEIGHT_RATIO)
|
.with_track_height(TRACK_HEIGHT_RATIO)
|
||||||
.with_track(rect_frame! {
|
.with_track(rect_frame! {
|
||||||
color: (0.5, 0.5, 0.5),
|
color: (0.5, 0.5, 0.5),
|
||||||
corner_radius: TRACK_HEIGHT_RATIO * HEIGHT * 0.5,
|
corner_radius: TRACK_HEIGHT_PX * 0.5,
|
||||||
})
|
})
|
||||||
.with_track_active(rect_frame! {
|
.with_track_active(rect_frame! {
|
||||||
color: (0., 0., 0.75),
|
color: (0., 0., 0.75),
|
||||||
corner_radius: TRACK_HEIGHT_RATIO * HEIGHT * 0.5,
|
corner_radius: TRACK_HEIGHT_PX * 0.5,
|
||||||
})
|
})
|
||||||
.with_handle_size((25., 1.))
|
.with_handle_size((HANDLE_PX, 1.))
|
||||||
.with_handle(rect_frame! {
|
.with_handle(rect_frame! {
|
||||||
color: (0., 0., 1.),
|
color: (0., 0., 1.),
|
||||||
corner_radius: HEIGHT * 0.5,
|
corner_radius: HANDLE_PX * 0.5,
|
||||||
})
|
})
|
||||||
.on_change(move |f| signal(f >= 0.5))
|
.on_change(move |f| signal(f >= 0.5))
|
||||||
.add_child(ui);
|
.add_child(ui);
|
||||||
|
|
Loading…
Reference in a new issue