Skip to content

Commit

Permalink
SliderInt, SliderFloat(): Fixed edge case where style.GrabMinSize bei…
Browse files Browse the repository at this point in the history
…ng bigger than slider width can lead to a division by zero (#919)
  • Loading branch information
ocornut committed Nov 29, 2016
1 parent ca9a918 commit 9235e0d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6516,7 +6516,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
if (g.IO.MouseDown[0])
{
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)
clicked_t = 1.0f - clicked_t;

Expand Down

0 comments on commit 9235e0d

Please sign in to comment.