MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ImParseFormatPrecision

Function ImParseFormatPrecision

KBotExt/imgui/imgui_widgets.cpp:3343–3363  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

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.
3343int 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.

Callers 2

DragBehaviorTMethod · 0.85
SliderBehaviorTMethod · 0.85

Calls 1

ImParseFormatFindStartFunction · 0.85

Tested by

no test coverage detected