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

SliderInt, SliderFloat(): support reverse direction (#854)

This commit is contained in:
ocornut 2016-11-27 17:38:33 +01:00
parent 104b381023
commit 61d5b46307

View File

@ -6539,10 +6539,10 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
}
// Calculate slider grab positioning
float v_clamped = (v_min < v_max) ? ImClamp(*v, v_min, v_max) : ImClamp(*v, v_max, v_min);
float grab_t;
if (is_non_linear)
{
float v_clamped = ImClamp(*v, v_min, v_max);
if (v_clamped < 0.0f)
{
const float f = 1.0f - (v_clamped - v_min) / (ImMin(0.0f,v_max) - v_min);
@ -6557,7 +6557,7 @@ bool ImGui::SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v
else
{
// Linear slider
grab_t = (ImClamp(*v, v_min, v_max) - v_min) / (v_max - v_min);
grab_t = (v_clamped - v_min) / (v_max - v_min);
}
// Draw