mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-26 13:37:00 +00:00
InputFloat() fixed explicit precision modifier, both display and input were broken.
This commit is contained in:
parent
572bf91006
commit
a76b75c2d5
@ -5814,7 +5814,7 @@ static void DataTypeApplyOpFromText(const char* buf, const char* initial_value_b
|
||||
}
|
||||
else if (data_type == ImGuiDataType_Float)
|
||||
{
|
||||
if (!scalar_format)
|
||||
// For floats we have to ignore format with precision (e.g. "%.2f") because sscanf doesn't take them in
|
||||
scalar_format = "%f";
|
||||
float* v = (float*)data_ptr;
|
||||
float ref_v = *v;
|
||||
@ -7642,7 +7642,7 @@ bool ImGui::InputFloat(const char* label, float* v, float step, float step_fast,
|
||||
if (decimal_precision < 0)
|
||||
strcpy(display_format, "%f"); // Ideally we'd have a minimum decimal precision of 1 to visually denote that this is a float, while hiding non-significant digits? %f doesn't have a minimum of 1
|
||||
else
|
||||
ImFormatString(display_format, 16, "%%%df", decimal_precision);
|
||||
ImFormatString(display_format, 16, "%%.%df", decimal_precision);
|
||||
return InputScalarEx(label, ImGuiDataType_Float, (void*)v, (void*)(step>0.0f ? &step : NULL), (void*)(step_fast>0.0f ? &step_fast : NULL), display_format, extra_flags);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user