From 94c77edfa52c64431d6731377b7f2e65b27b4f50 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 28 Nov 2016 11:03:48 +0100 Subject: [PATCH] SliderInt, SliderFloat() Better display support for v_min==v_max range. (#919) --- imgui.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imgui.cpp b/imgui.cpp index 1f34d15d..42396eeb 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -6448,6 +6448,9 @@ float ImGui::RoundScalar(float value, int decimal_precision) static inline float SliderBehaviorCalcRatioFromValue(float v, float v_min, float v_max, float power, float linear_zero_pos) { + if (v_min == v_max) + return 0.0f; + const bool is_non_linear = (power < 1.0f-0.00001f) || (power > 1.0f+0.00001f); const float v_clamped = (v_min < v_max) ? ImClamp(v, v_min, v_max) : ImClamp(v, v_max, v_min); if (is_non_linear)