Parse display precision back from the display format string FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed.
| 3341 | // Parse display precision back from the display format string |
| 3342 | // FIXME: This is still used by some navigation code path to infer a minimum tweak step, but we should aim to rework widgets so it isn't needed. |
| 3343 | int ImParseFormatPrecision(const char* fmt, int default_precision) |
| 3344 | { |
| 3345 | fmt = ImParseFormatFindStart(fmt); |
| 3346 | if (fmt[0] != '%') |
| 3347 | return default_precision; |
| 3348 | fmt++; |
| 3349 | while (*fmt >= '0' && *fmt <= '9') |
| 3350 | fmt++; |
| 3351 | int precision = INT_MAX; |
| 3352 | if (*fmt == '.') |
| 3353 | { |
| 3354 | fmt = ImAtoi<int>(fmt + 1, &precision); |
| 3355 | if (precision < 0 || precision > 99) |
| 3356 | precision = default_precision; |
| 3357 | } |
| 3358 | if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation |
| 3359 | precision = -1; |
| 3360 | if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX) |
| 3361 | precision = -1; |
| 3362 | return (precision == INT_MAX) ? default_precision : precision; |
| 3363 | } |
| 3364 | |
| 3365 | // Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) |
| 3366 | // FIXME: Facilitate using this in variety of other situations. |
no test coverage detected