NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this.
| 2476 | |
| 2477 | // NB: You likely want to specify the ImGuiSliderFlags_AlwaysClamp when using this. |
| 2478 | bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_current_max, float v_speed, float v_min, float v_max, const char* format, const char* format_max, ImGuiSliderFlags flags) |
| 2479 | { |
| 2480 | ImGuiWindow* window = GetCurrentWindow(); |
| 2481 | if (window->SkipItems) |
| 2482 | return false; |
| 2483 | |
| 2484 | ImGuiContext& g = *GImGui; |
| 2485 | PushID(label); |
| 2486 | BeginGroup(); |
| 2487 | PushMultiItemsWidths(2, CalcItemWidth()); |
| 2488 | |
| 2489 | float min_min = (v_min >= v_max) ? -FLT_MAX : v_min; |
| 2490 | float min_max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max); |
| 2491 | ImGuiSliderFlags min_flags = flags | ((min_min == min_max) ? ImGuiSliderFlags_ReadOnly : 0); |
| 2492 | bool value_changed = DragScalar("##min", ImGuiDataType_Float, v_current_min, v_speed, &min_min, &min_max, format, min_flags); |
| 2493 | PopItemWidth(); |
| 2494 | SameLine(0, g.Style.ItemInnerSpacing.x); |
| 2495 | |
| 2496 | float max_min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min); |
| 2497 | float max_max = (v_min >= v_max) ? FLT_MAX : v_max; |
| 2498 | ImGuiSliderFlags max_flags = flags | ((max_min == max_max) ? ImGuiSliderFlags_ReadOnly : 0); |
| 2499 | value_changed |= DragScalar("##max", ImGuiDataType_Float, v_current_max, v_speed, &max_min, &max_max, format_max ? format_max : format, max_flags); |
| 2500 | PopItemWidth(); |
| 2501 | SameLine(0, g.Style.ItemInnerSpacing.x); |
| 2502 | |
| 2503 | TextEx(label, FindRenderedTextEnd(label)); |
| 2504 | EndGroup(); |
| 2505 | PopID(); |
| 2506 | |
| 2507 | return value_changed; |
| 2508 | } |
| 2509 | |
| 2510 | // NB: v_speed is float to allow adjusting the drag speed with more precision |
| 2511 | bool ImGui::DragInt(const char* label, int* v, float v_speed, int v_min, int v_max, const char* format, ImGuiSliderFlags flags) |
nothing calls this directly
no test coverage detected