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.
| 3269 | // Parse display precision back from the display format string |
| 3270 | // 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. |
| 3271 | int ImParseFormatPrecision(const char* fmt, int default_precision) |
| 3272 | { |
| 3273 | fmt = ImParseFormatFindStart(fmt); |
| 3274 | if (fmt[0] != '%') |
| 3275 | return default_precision; |
| 3276 | fmt++; |
| 3277 | while (*fmt >= '0' && *fmt <= '9') |
| 3278 | fmt++; |
| 3279 | int precision = INT_MAX; |
| 3280 | if (*fmt == '.') |
| 3281 | { |
| 3282 | fmt = ImAtoi<int>(fmt + 1, &precision); |
| 3283 | if (precision < 0 || precision > 99) |
| 3284 | precision = default_precision; |
| 3285 | } |
| 3286 | if (*fmt == 'e' || *fmt == 'E') // Maximum precision with scientific notation |
| 3287 | precision = -1; |
| 3288 | if ((*fmt == 'g' || *fmt == 'G') && precision == INT_MAX) |
| 3289 | precision = -1; |
| 3290 | return (precision == INT_MAX) ? default_precision : precision; |
| 3291 | } |
| 3292 | |
| 3293 | // Create text input in place of another active widget (e.g. used when doing a CTRL+Click on drag/slider widgets) |
| 3294 | // FIXME: Facilitate using this in variety of other situations. |
no test coverage detected