mirror of
https://github.com/danbulant/cushy
synced 2026-06-11 10:30:49 +00:00
While this was a workaround for a docs.rs issue (Px/Lp are not linked), I decided having the shorter import path would look better in the examples. It probably wasn't necessary to update all of the references in the internal code, but I decided it was worth the consistency.
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
use cushy::value::Dynamic;
|
|
use cushy::widget::MakeWidget;
|
|
use cushy::widgets::input::InputValue;
|
|
use cushy::widgets::slider::Slidable;
|
|
use cushy::widgets::Custom;
|
|
use cushy::Run;
|
|
use figures::units::Lp;
|
|
|
|
fn main() -> cushy::Result {
|
|
let allow_blur = Dynamic::new(true);
|
|
"Input Field"
|
|
.and(Dynamic::<String>::default().into_input())
|
|
.and("Range Slider")
|
|
.and(Dynamic::<u8>::default().slider_between(0_u8, 100_u8))
|
|
.and("Range Slider")
|
|
.and(Dynamic::new(10..=30).slider_between(0_u8, 100_u8))
|
|
.and("Allow Custom Widget to Lose Focus".into_checkbox(allow_blur.clone()))
|
|
.and(
|
|
Custom::empty()
|
|
.on_accept_focus(|context| context.enabled())
|
|
.on_redraw(|context| {
|
|
context.fill(context.theme().secondary.color);
|
|
if context.focused(true) {
|
|
context.draw_focus_ring();
|
|
}
|
|
})
|
|
.on_allow_blur(move |_| allow_blur.get())
|
|
.height(Lp::inches(1)),
|
|
)
|
|
.into_rows()
|
|
.run()
|
|
}
|