mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 12:27:51 +02:00
Stepped sliders
This commit is contained in:
@ -481,6 +481,7 @@ namespace ImGui
|
||||
// - CTRL+Click on any slider to turn them into an input box. Manually input values aren't clamped and can go off-bounds.
|
||||
// - Adjust format string to decorate the value with a prefix, a suffix, or adapt the editing and display precision e.g. "%.3f" -> 1.234; "%5.2f secs" -> 01.23 secs; "Biscuit: %.0f" -> Biscuit: 1; etc.
|
||||
IMGUI_API bool SliderFloat(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f); // adjust format to decorate the value with a prefix or a suffix for in-slider labels or unit display. Use power!=1.0 for power curve sliders
|
||||
IMGUI_API bool SliderFloatWithSteps(const char* label, float* v, float v_min, float v_max, float v_step, const char* display_format = "%.3f");
|
||||
IMGUI_API bool SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
||||
IMGUI_API bool SliderFloat3(const char* label, float v[3], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
||||
IMGUI_API bool SliderFloat4(const char* label, float v[4], float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
||||
|
@ -2702,6 +2702,25 @@ bool ImGui::SliderFloat(const char* label, float* v, float v_min, float v_max, c
|
||||
return SliderScalar(label, ImGuiDataType_Float, v, &v_min, &v_max, format, power);
|
||||
}
|
||||
|
||||
bool ImGui::SliderFloatWithSteps(const char* label, float* v, float v_min, float v_max, float v_step, const char* display_format)
|
||||
{
|
||||
if (!display_format)
|
||||
display_format = "%.3f";
|
||||
|
||||
char text_buf[64] = {};
|
||||
ImFormatString(text_buf, IM_ARRAYSIZE(text_buf), display_format, *v);
|
||||
|
||||
// Map from [v_min,v_max] to [0,N]
|
||||
const int countValues = int((v_max-v_min)/v_step);
|
||||
int v_i = int((*v - v_min)/v_step);
|
||||
const bool value_changed = ImGui::SliderInt(label, &v_i, 0, countValues, text_buf);
|
||||
|
||||
// Remap from [0,N] to [v_min,v_max]
|
||||
*v = v_min + float(v_i) * v_step;
|
||||
return value_changed;
|
||||
}
|
||||
|
||||
|
||||
bool ImGui::SliderFloat2(const char* label, float v[2], float v_min, float v_max, const char* format, float power)
|
||||
{
|
||||
return SliderScalarN(label, ImGuiDataType_Float, v, 2, &v_min, &v_max, format, power);
|
||||
|
Reference in New Issue
Block a user