Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SliderInt does not respect the flag ImGuiSliderFlags_Logarithmic #3786

Closed
jamesthomasgriffin opened this issue Feb 4, 2021 · 1 comment
Closed

Comments

@jamesthomasgriffin
Copy link

Version: 1.81 WIP
Branch: master
Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Operating System: Win10

My Issue/Question:

Code such as

static int num_repeats = 100;
ImGui::SliderInt("Number of repeats", &num_repeats, 1, 10000, "%d", ImGuiSliderFlags_Logarithmic);

produces a slider that does not behave logarithmically. However one can get the desired behaviour using

static float num_repeats_fl = 100.0f;
ImGui::SliderFloat("Number of repeats", &num_repeats_fl, 1, 10000, "%.0f", ImGuiSliderFlags_Logarithmic);
int num_repeats = static_cast<int>(num_repeats_fl);

Changing line 6 of SliderBehaviorT to:

const bool is_logarithmic = (flags & ImGuiSliderFlags_Logarithmic);  //&& is_decimal;

fixes the issue for me and behaves as I would expect, however I don't know whether it may introduce any other bugs (presumably anyone who would be affected with their current code has already made a mistake of adding the flag without the expected behaviour).

Another very minor point, the variable name is_decimal should probably be replaced by something else, perhaps is_continuum, or is_real, or is_floating_point (Sorry for being pedantic, it mislead me when meeting it further down the code and I would be letting myself down as a mathematics lecturer if I didn't mention it.)

As always, thank you for the awesome work!

ocornut added a commit that referenced this issue Mar 15, 2021
…rs. Because why not? (#3786)

Renamed is_decimal to is_floating_point.
@ocornut
Copy link
Owner

ocornut commented Mar 15, 2021

Hello James,
Thanks for reporting this.
You are right there's nothing preventing us from supporting the Logarithmic flag there. I enabled it.
I also pushed the rename you suggested.

@ocornut ocornut closed this as completed Mar 15, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants