From 12665ace20a6e6a8dd14a9121d6ab82381bf6997 Mon Sep 17 00:00:00 2001 From: Bryan Hyland Date: Sun, 17 Nov 2024 13:05:37 -0800 Subject: [PATCH] Added a standard_spin_button function --- src/widget/spin_button/mod.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/widget/spin_button/mod.rs b/src/widget/spin_button/mod.rs index fb98b2ed..e5ef2f12 100644 --- a/src/widget/spin_button/mod.rs +++ b/src/widget/spin_button/mod.rs @@ -59,7 +59,7 @@ impl<'a, T, M> SpinButton<'a, T, M> where T: Add + Sub + PartialEq + PartialOrd + Display + Copy { - /// Create a new default spin button + /// Create a new new button pub fn new( label: impl Into, step: T, @@ -82,7 +82,7 @@ where } } -/// Shorthand function to create a default spin button +/// Shorthand function to create a new spin button pub fn spin_button<'a, T, M>( label: impl Into, step: T, @@ -98,6 +98,21 @@ where SpinButton::new(label, step, value, min, max, orientation, on_press) } +/// Shorthand to create a standard (horizontal) spin button widget +pub fn spin_button_standard<'a, T, M>( + label: impl Into, + step: T, + value: T, + min: T, + max: T, + on_press: impl Fn(T) -> M + 'static, +) -> SpinButton<'a, T, M> +where + T: Add + Sub + PartialEq + PartialOrd + Display + Copy +{ + SpinButton::new(label, step, value, min, max, None, on_press) +} + fn increment(step: T, value: T, min: T, max: T) -> T where T: Add + Sub + PartialEq + PartialOrd + Display + Copy