use super::{
number_input::{number_builders, show_drag, NumberOptions},
NumberStyle, Numeric, Response, Ui, Widget,
};
use crate::Id;
use std::{hash::Hash, ops::RangeInclusive, panic::Location};
pub struct DragValue<'a, T: Numeric> {
value: &'a mut T,
options: NumberOptions<'a, T>,
}
impl<'a, T: Numeric> DragValue<'a, T> {
#[track_caller]
pub fn new(value: &'a mut T) -> Self {
Self {
value,
options: NumberOptions::new(Location::caller()),
}
}
number_builders!();
}
impl<T: Numeric> Widget for DragValue<'_, T> {
fn ui(self, ui: &mut Ui<'_>) -> Response {
show_drag(ui, self.value, self.options)
}
}
impl Ui<'_> {
#[track_caller]
pub fn drag_value<T: Numeric>(&mut self, value: &mut T) -> Response {
self.add(DragValue::new(value))
}
}