Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Sliders broken for scientific notation + small values + logarithmic format #8299

Open
chrismile opened this issue Jan 8, 2025 · 0 comments

Comments

@chrismile
Copy link

Version/Branch of Dear ImGui:

Branch: master (at latest commit)

Back-ends:

any

Compiler, OS:

Ubuntu 22.04 + GCC

Full config/build information:

No response

Details:

When using ImGui::SliderScalar with a combination of scientific notation (e.g., "%.1e") plus ImGuiSliderFlags_Logarithmic plus small values, the dragging behavior is incorrect. It jumps between the values min, 1e+1 and max, which can be seen from the verifiable example.

This is probably highly related to #4341, but there the problem was simply described as losing "numbers from range (min, 10>". When the maximum is small, too, it seems like the problem is even greater, as not only a small amount of values is lost, but the slider will also assume values outside the min-max range.

I can also confirm, like #4341, that logarithmic_zero_epsilon is likely also the culprit here, too. It is set to 10, as ImParseFormatPrecision returns -1 for the scientific notation.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

static float test_val = 1e-4f;
float test_lower = 1e-6f;
float test_higher = 1e-2f;
ImGui::SliderScalar("slider e", ImGuiDataType_Float, &test_val, &test_lower, &test_higher, "%e", ImGuiSliderFlags_Logarithmic);
ImGui::SliderScalar("slider .1e", ImGuiDataType_Float, &test_val, &test_lower, &test_higher, "%.1e", ImGuiSliderFlags_Logarithmic);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants