mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui_demo.cpp # imgui_draw.cpp # imgui_internal.h
This commit is contained in:
@ -2120,6 +2120,8 @@ bool ImGui::DragBehavior(ImGuiID id, ImGuiDataType data_type, void* p_v, float v
|
||||
}
|
||||
if (g.ActiveId != id)
|
||||
return false;
|
||||
if (g.CurrentWindow->DC.ItemFlags & ImGuiItemFlags_ReadOnly)
|
||||
return false;
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
@ -2171,7 +2173,6 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
// Tabbing or CTRL-clicking on Drag turns it into an input box
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
bool temp_input_is_active = TempInputIsActive(id);
|
||||
bool temp_input_start = false;
|
||||
if (!temp_input_is_active)
|
||||
{
|
||||
const bool focus_requested = FocusableItemRegister(window, id);
|
||||
@ -2185,14 +2186,14 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
|
||||
g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
|
||||
if (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id)
|
||||
{
|
||||
temp_input_start = true;
|
||||
temp_input_is_active = true;
|
||||
FocusableItemUnregister(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
if (temp_input_is_active)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
@ -2283,10 +2284,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);
|
||||
|
||||
@ -2328,10 +2336,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);
|
||||
|
||||
@ -2565,6 +2580,10 @@ bool ImGui::SliderBehaviorT(const ImRect& bb, ImGuiID id, ImGuiDataType data_typ
|
||||
// It would be possible to lift that limitation with some work but it doesn't seem to be worth it for sliders.
|
||||
bool ImGui::SliderBehavior(const ImRect& bb, ImGuiID id, ImGuiDataType data_type, void* p_v, const void* p_min, const void* p_max, const char* format, float power, ImGuiSliderFlags flags, ImRect* out_grab_bb)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (g.CurrentWindow->DC.ItemFlags & ImGuiItemFlags_ReadOnly)
|
||||
return false;
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
case ImGuiDataType_S8: { ImS32 v32 = (ImS32)*(ImS8*)p_v; bool r = SliderBehaviorT<ImS32, ImS32, float>(bb, id, ImGuiDataType_S32, &v32, *(const ImS8*)p_min, *(const ImS8*)p_max, format, power, flags, out_grab_bb); if (r) *(ImS8*)p_v = (ImS8)v32; return r; }
|
||||
@ -2625,7 +2644,6 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
// Tabbing or CTRL-clicking on Slider turns it into an input box
|
||||
const bool hovered = ItemHoverable(frame_bb, id);
|
||||
bool temp_input_is_active = TempInputIsActive(id);
|
||||
bool temp_input_start = false;
|
||||
if (!temp_input_is_active)
|
||||
{
|
||||
const bool focus_requested = FocusableItemRegister(window, id);
|
||||
@ -2638,14 +2656,14 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
|
||||
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
|
||||
if (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id)
|
||||
{
|
||||
temp_input_start = true;
|
||||
temp_input_is_active = true;
|
||||
FocusableItemUnregister(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that..
|
||||
if (temp_input_is_active || temp_input_start)
|
||||
if (temp_input_is_active)
|
||||
return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
|
||||
|
||||
// Draw frame
|
||||
|
Reference in New Issue
Block a user