Răsfoiți Sursa

Drags, Sliders, Inputs: Specifying a NULL format to Float functions default them to "%.3f" to be consistent with the compile-time default. (#3922)

ocornut 4 ani în urmă
părinte
comite
4bf646e4b0
2 a modificat fișierele cu 4 adăugiri și 1 ștergeri
  1. 2 0
      docs/CHANGELOG.txt
  2. 2 1
      imgui_widgets.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -39,6 +39,8 @@ Breaking Changes:
 
 
 Other Changes:
 Other Changes:
 
 
+- Drags, Sliders, Inputs: Specifying a NULL format to Float functions default them to "%.3f" to be
+  consistent with the compile-time default. (#3922)
 - DragScalar: Add default value for v_speed argument to match higher-level functions. (#3922) [@eliasdaler]
 - DragScalar: Add default value for v_speed argument to match higher-level functions. (#3922) [@eliasdaler]
 - Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
 - Docs: Improvements to minor mistakes in documentation comments (#3923) [@ANF-Studios]
 
 

+ 2 - 1
imgui_widgets.cpp

@@ -1790,7 +1790,7 @@ static const ImGuiDataTypeInfo GDataTypeInfo[] =
     { sizeof(ImS64),            "S64",  "%lld", "%lld"  },  // ImGuiDataType_S64
     { sizeof(ImS64),            "S64",  "%lld", "%lld"  },  // ImGuiDataType_S64
     { sizeof(ImU64),            "U64",  "%llu", "%llu"  },
     { sizeof(ImU64),            "U64",  "%llu", "%llu"  },
 #endif
 #endif
-    { sizeof(float),            "float", "%f",  "%f"    },  // ImGuiDataType_Float (float are promoted to double in va_arg)
+    { sizeof(float),            "float", "%.3f","%f"    },  // ImGuiDataType_Float (float are promoted to double in va_arg)
     { sizeof(double),           "double","%f",  "%lf"   },  // ImGuiDataType_Double
     { sizeof(double),           "double","%f",  "%lf"   },  // ImGuiDataType_Double
 };
 };
 IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
 IM_STATIC_ASSERT(IM_ARRAYSIZE(GDataTypeInfo) == ImGuiDataType_COUNT);
@@ -2302,6 +2302,7 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
     const ImGuiStyle& style = g.Style;
     const ImGuiStyle& style = g.Style;
     const ImGuiID id = window->GetID(label);
     const ImGuiID id = window->GetID(label);
     const float w = CalcItemWidth();
     const float w = CalcItemWidth();
+
     const ImVec2 label_size = CalcTextSize(label, NULL, true);
     const ImVec2 label_size = CalcTextSize(label, NULL, true);
     const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
     const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(w, label_size.y + style.FramePadding.y * 2.0f));
     const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));
     const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f, 0.0f));