mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Internal cleanup ParseFormatPrecision() doesn't take a reference
This commit is contained in:
parent
7650d4cc67
commit
faa609a43c
19
imgui.cpp
19
imgui.cpp
@ -5911,8 +5911,9 @@ static bool InputFloatReplaceWidget(const ImRect& aabb, const char* label, float
|
||||
}
|
||||
|
||||
// Parse display precision back from the display format string
|
||||
static inline void ParseFormatPrecision(const char* fmt, int& decimal_precision)
|
||||
static inline int ParseFormatPrecision(const char* fmt, int default_precision)
|
||||
{
|
||||
int precision = default_precision;
|
||||
while ((fmt = strchr(fmt, '%')) != NULL)
|
||||
{
|
||||
fmt++;
|
||||
@ -5921,12 +5922,13 @@ static inline void ParseFormatPrecision(const char* fmt, int& decimal_precision)
|
||||
fmt++;
|
||||
if (*fmt == '.')
|
||||
{
|
||||
decimal_precision = atoi(fmt + 1);
|
||||
if (decimal_precision < 0 || decimal_precision > 10)
|
||||
decimal_precision = 3;
|
||||
precision = atoi(fmt + 1);
|
||||
if (precision < 0 || precision > 10)
|
||||
precision = default_precision;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return precision;
|
||||
}
|
||||
|
||||
static inline float RoundScalar(float value, int decimal_precision)
|
||||
@ -6107,8 +6109,7 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
int decimal_precision = 3;
|
||||
ParseFormatPrecision(display_format, decimal_precision);
|
||||
int decimal_precision = ParseFormatPrecision(display_format, 3);
|
||||
|
||||
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
||||
bool start_text_input = false;
|
||||
@ -6167,8 +6168,7 @@ bool ImGui::VSliderFloat(const char* label, const ImVec2& size, float* v, float
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
int decimal_precision = 3;
|
||||
ParseFormatPrecision(display_format, decimal_precision);
|
||||
int decimal_precision = ParseFormatPrecision(display_format, 3);
|
||||
|
||||
if (hovered && g.IO.MouseClicked[0])
|
||||
{
|
||||
@ -6410,8 +6410,7 @@ bool ImGui::DragFloat(const char* label, float *v, float v_speed, float v_min, f
|
||||
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
int decimal_precision = 3;
|
||||
ParseFormatPrecision(display_format, decimal_precision);
|
||||
int decimal_precision = ParseFormatPrecision(display_format, 3);
|
||||
|
||||
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
||||
bool start_text_input = false;
|
||||
|
Loading…
Reference in New Issue
Block a user