Struct me3_framework::overlay::DragValue
source · [−]pub struct DragValue<'a> { /* private fields */ }
Expand description
A numeric value that you can change by dragging the number. More compact than a Slider
.
ui.add(egui::DragValue::new(&mut my_f32).speed(0.1));
Implementations
sourceimpl<'a> DragValue<'a>
impl<'a> DragValue<'a>
pub fn new<Num>(value: &'a mut Num) -> DragValue<'a>where
Num: Numeric,
pub fn from_get_set(
get_set_value: impl FnMut(Option<f64>) -> f64 + 'a
) -> DragValue<'a>
sourcepub fn speed(self, speed: impl Into<f64>) -> DragValue<'a>
pub fn speed(self, speed: impl Into<f64>) -> DragValue<'a>
How much the value changes when dragged one point (logical pixel).
sourcepub fn clamp_range<Num>(self, clamp_range: RangeInclusive<Num>) -> DragValue<'a>where
Num: Numeric,
pub fn clamp_range<Num>(self, clamp_range: RangeInclusive<Num>) -> DragValue<'a>where
Num: Numeric,
Clamp incoming and outgoing values to this range.
sourcepub fn prefix(self, prefix: impl ToString) -> DragValue<'a>
pub fn prefix(self, prefix: impl ToString) -> DragValue<'a>
Show a prefix before the number, e.g. “x: “
sourcepub fn suffix(self, suffix: impl ToString) -> DragValue<'a>
pub fn suffix(self, suffix: impl ToString) -> DragValue<'a>
Add a suffix to the number, this can be e.g. a unit (“°” or “ m“)
sourcepub fn min_decimals(self, min_decimals: usize) -> DragValue<'a>
pub fn min_decimals(self, min_decimals: usize) -> DragValue<'a>
Set a minimum number of decimals to display. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.
sourcepub fn max_decimals(self, max_decimals: usize) -> DragValue<'a>
pub fn max_decimals(self, max_decimals: usize) -> DragValue<'a>
Set a maximum number of decimals to display. Values will also be rounded to this number of decimals. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.
pub fn max_decimals_opt(self, max_decimals: Option<usize>) -> DragValue<'a>
sourcepub fn fixed_decimals(self, num_decimals: usize) -> DragValue<'a>
pub fn fixed_decimals(self, num_decimals: usize) -> DragValue<'a>
Set an exact number of decimals to display. Values will also be rounded to this number of decimals. Normally you don’t need to pick a precision, as the slider will intelligently pick a precision for you. Regardless of precision the slider will use “smart aim” to help the user select nice, round values.
sourcepub fn custom_formatter(
self,
formatter: impl Fn(f64, RangeInclusive<usize>) -> String + 'a
) -> DragValue<'a>
pub fn custom_formatter(
self,
formatter: impl Fn(f64, RangeInclusive<usize>) -> String + 'a
) -> DragValue<'a>
Set custom formatter defining how numbers are converted into text.
A custom formatter takes a f64
for the numeric value and a RangeInclusive<usize>
representing
the decimal range i.e. minimum and maximum number of decimal places shown.
ui.add(egui::DragValue::new(&mut my_i64).custom_formatter(|n, _| format!("{:X}", n as i64)));