Closed Adanos020 closed 2 years ago
I wouldn't like to get rid of custom_formatter
since it supports many interesting scenarios such as displaying time in HH::MM::SS
format, etc.
Instead it can be coupled with a custom_parser
. A NumberBase
API could then be built on top of those two features.
I see. This sounds like a good solution 👍
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
--