1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-01 02:37:24 +01:00

SliderInt, SliderFloat(): Fixed edge case where style.GrabMinSize being bigger than slider width can lead to a division by zero (#919)

This commit is contained in:
ocornut 2016-11-29 21:07:26 +01:00
parent ca9a918535
commit 9235e0da46

View File

@ -6516,7 +6516,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
if (g.IO.MouseDown[0]) if (g.IO.MouseDown[0])
{ {
const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y; const float mouse_abs_pos = is_horizontal ? g.IO.MousePos.x : g.IO.MousePos.y;
float clicked_t = ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f); float clicked_t = (slider_usable_sz > 0.0f) ? ImClamp((mouse_abs_pos - slider_usable_pos_min) / slider_usable_sz, 0.0f, 1.0f) : 0.0f;
if (!is_horizontal) if (!is_horizontal)
clicked_t = 1.0f - clicked_t; clicked_t = 1.0f - clicked_t;