mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-14 17:07:01 +00:00
DragFloatRange2, DragIntRange2: Fixed an issue allowing to drag out of bounds when both min and max value are on the same value. (#1441)
This commit is contained in:
parent
fdc526e8f8
commit
b8c22bdb28
@ -40,6 +40,8 @@ Other Changes:
|
||||
- Nav: Fixed clicking on void (behind any windows) from not clearing the focused window.
|
||||
This would be problematic e.g. in situation where the application relies on io.WantCaptureKeyboard
|
||||
flag being cleared accordingly. (bug introduced in 1.77 WIP on 2020/06/16) (#3344, #2880)
|
||||
- DragFloatRange2, DragIntRange2: Fixed an issue allowing to drag out of bounds when both
|
||||
min and max value are on the same value. (#1441)
|
||||
- InputText, ImDrawList: Fixed assert triggering when drawing single line of text with more
|
||||
than ~16 KB characters. (Note that current code is going to show corrupted display if after
|
||||
clipping, more than 16 KB characters are visible in the same low-level ImDrawList::RenderText
|
||||
|
@ -1491,7 +1491,8 @@ static void ShowDemoWindowWidgets()
|
||||
{
|
||||
static float begin = 10, end = 90;
|
||||
static int begin_i = 100, end_i = 1000;
|
||||
ImGui::DragFloatRange2("range", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
|
||||
ImGui::DragFloatRange2("range float", &begin, &end, 0.25f, 0.0f, 100.0f, "Min: %.1f %%", "Max: %.1f %%");
|
||||
ImGui::DragIntRange2("range int", &begin_i, &end_i, 5, 0, 1000, "Min: %d units", "Max: %d units");
|
||||
ImGui::DragIntRange2("range int (no bounds)", &begin_i, &end_i, 5, 0, 0, "Min: %d units", "Max: %d units");
|
||||
ImGui::TreePop();
|
||||
}
|
||||
|
@ -2278,10 +2278,17 @@ bool ImGui::DragFloatRange2(const char* label, float* v_current_min, float* v_cu
|
||||
BeginGroup();
|
||||
PushMultiItemsWidths(2, CalcItemWidth());
|
||||
|
||||
bool value_changed = DragFloat("##min", v_current_min, v_speed, (v_min >= v_max) ? -FLT_MAX : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format, power);
|
||||
float min = (v_min >= v_max) ? -FLT_MAX : v_min;
|
||||
float max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max);
|
||||
if (min == max) { min = FLT_MAX; max = -FLT_MAX; } // Lock edit
|
||||
bool value_changed = DragScalar("##min", ImGuiDataType_Float, v_current_min, v_speed, &min, &max, format, power);
|
||||
PopItemWidth();
|
||||
SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
value_changed |= DragFloat("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? FLT_MAX : v_max, format_max ? format_max : format, power);
|
||||
|
||||
min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min);
|
||||
max = (v_min >= v_max) ? FLT_MAX : v_max;
|
||||
if (min == max) { min = FLT_MAX; max = -FLT_MAX; } // Lock edit
|
||||
value_changed |= DragScalar("##max", ImGuiDataType_Float, v_current_max, v_speed, &min, &max, format_max ? format_max : format, power);
|
||||
PopItemWidth();
|
||||
SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
@ -2323,10 +2330,17 @@ bool ImGui::DragIntRange2(const char* label, int* v_current_min, int* v_current_
|
||||
BeginGroup();
|
||||
PushMultiItemsWidths(2, CalcItemWidth());
|
||||
|
||||
bool value_changed = DragInt("##min", v_current_min, v_speed, (v_min >= v_max) ? INT_MIN : v_min, (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max), format);
|
||||
int min = (v_min >= v_max) ? INT_MIN : v_min;
|
||||
int max = (v_min >= v_max) ? *v_current_max : ImMin(v_max, *v_current_max);
|
||||
if (min == max) { min = INT_MAX; max = INT_MIN; } // Lock edit
|
||||
bool value_changed = DragInt("##min", v_current_min, v_speed, min, max, format);
|
||||
PopItemWidth();
|
||||
SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
value_changed |= DragInt("##max", v_current_max, v_speed, (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min), (v_min >= v_max) ? INT_MAX : v_max, format_max ? format_max : format);
|
||||
|
||||
min = (v_min >= v_max) ? *v_current_min : ImMax(v_min, *v_current_min);
|
||||
max = (v_min >= v_max) ? INT_MAX : v_max;
|
||||
if (min == max) { min = INT_MAX; max = INT_MIN; } // Lock edit
|
||||
value_changed |= DragInt("##max", v_current_max, v_speed, min, max, format_max ? format_max : format);
|
||||
PopItemWidth();
|
||||
SameLine(0, g.Style.ItemInnerSpacing.x);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user