You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The newly added custom_formatter allows for, among other things, displaying numbers in DragValue and Slider in number systems other than decimal. What I didn't consider while adding this feature is that if you type a number into those widgets on keyboard, the input is still always parsed as a decimal number.
Describe the solution you'd like
First of all, get rid of custom_formatter since having separate methods for the input and output allows to specify different number bases on both ends, which can be confusing and difficult to debug.
Add new fields and methods for the DragValue and Slider structs.
/// Sets the number base in which the numeric input is parsed from and displayed to the widget.pubfnnumber_base(mutself,base:NumberBase) -> Self{self.number_base = base;self}/// Sets the minimum number of digits displayed. If the number is shorter than this, it is prefixed with a required number of zeroes.pubfnnumber_width(mutself,zeroes:u32) -> Self{self.number_width = width;self}
Describe alternatives you've considered
Instead of an enum, the number base could be specified as a u8, allowing for more number systems. However, Rust's standard library doesn't provide formatting numbers with an arbitrary radix, so we would need either our own implementation for that or an additional dependency such as the radix_fmt crate.
The deletion of custom_formatter comes with two drawbacks: the API breaks and the number of ways a number can be formatted becomes limited. Instead of completely replacing it with a whole new API, we could only have an additional method specifying the number base for the input. However, as I mentioned earlier, that would allow for having the inconsistency where the e.g. number would be displayed in binary but parsed in hexadecimal on input.
Additional context
--
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The newly added
custom_formatter
allows for, among other things, displaying numbers inDragValue
andSlider
in number systems other than decimal. What I didn't consider while adding this feature is that if you type a number into those widgets on keyboard, the input is still always parsed as a decimal number.Describe the solution you'd like
First of all, get rid of
custom_formatter
since having separate methods for the input and output allows to specify different number bases on both ends, which can be confusing and difficult to debug.Add an enum called
NumberBase
.Add new fields and methods for the
DragValue
andSlider
structs.Describe alternatives you've considered
u8
, allowing for more number systems. However, Rust's standard library doesn't provide formatting numbers with an arbitrary radix, so we would need either our own implementation for that or an additional dependency such as the radix_fmt crate.custom_formatter
comes with two drawbacks: the API breaks and the number of ways a number can be formatted becomes limited. Instead of completely replacing it with a whole new API, we could only have an additional method specifying the number base for the input. However, as I mentioned earlier, that would allow for having the inconsistency where the e.g. number would be displayed in binary but parsed in hexadecimal on input.Additional context
--
The text was updated successfully, but these errors were encountered: