Browse Source

Apply fix from data_types branch, some widgets broken when format string doesn't contains a %. Broken by 92f0165f8540b7294db864877c614bc728ff51d7. Data_types branch fix c5fb92955524204d4aff7c9fe850645b8a37fa2a.

omar 7 years ago
parent
commit
ad2927888b
1 changed files with 3 additions and 0 deletions
  1. 3 0
      imgui.cpp

+ 3 - 0
imgui.cpp

@@ -8681,6 +8681,9 @@ static float GetMinimumStepAtDecimalPrecision(int decimal_precision)
 
 float ImGui::RoundScalarWithFormat(const char* format, float value)
 {
+    const char* fmt_start = ParseFormatTrimDecorationsLeading(format);
+    if (fmt_start[0] != '%' || fmt_start[1] == '%') // Don't apply if the value is not visible in the format string
+        return value;
     char buf[64];
     ImFormatString(buf, IM_ARRAYSIZE(buf), ParseFormatTrimDecorationsLeading(format), value);
     return (float)atof(buf);