Internals: Drag/Sliders: simplified some code.

This commit is contained in:
omar 2020-07-24 13:00:56 +02:00
parent b8c22bdb28
commit bbd061538c

View File

@ -2166,7 +2166,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 // Tabbing or CTRL-clicking on Drag turns it into an input box
const bool hovered = ItemHoverable(frame_bb, id); const bool hovered = ItemHoverable(frame_bb, id);
bool temp_input_is_active = TempInputIsActive(id); bool temp_input_is_active = TempInputIsActive(id);
bool temp_input_start = false;
if (!temp_input_is_active) if (!temp_input_is_active)
{ {
const bool focus_requested = FocusableItemRegister(window, id); const bool focus_requested = FocusableItemRegister(window, id);
@ -2180,14 +2179,14 @@ bool ImGui::DragScalar(const char* label, ImGuiDataType data_type, void* p_data,
g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); g.ActiveIdUsingNavDirMask = (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
if (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id) if (focus_requested || (clicked && g.IO.KeyCtrl) || double_clicked || g.NavInputId == id)
{ {
temp_input_start = true; temp_input_is_active = true;
FocusableItemUnregister(window); FocusableItemUnregister(window);
} }
} }
} }
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that.. // 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); return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
// Draw frame // Draw frame
@ -2638,7 +2637,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 // Tabbing or CTRL-clicking on Slider turns it into an input box
const bool hovered = ItemHoverable(frame_bb, id); const bool hovered = ItemHoverable(frame_bb, id);
bool temp_input_is_active = TempInputIsActive(id); bool temp_input_is_active = TempInputIsActive(id);
bool temp_input_start = false;
if (!temp_input_is_active) if (!temp_input_is_active)
{ {
const bool focus_requested = FocusableItemRegister(window, id); const bool focus_requested = FocusableItemRegister(window, id);
@ -2651,14 +2649,14 @@ bool ImGui::SliderScalar(const char* label, ImGuiDataType data_type, void* p_dat
g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right); g.ActiveIdUsingNavDirMask |= (1 << ImGuiDir_Left) | (1 << ImGuiDir_Right);
if (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id) if (focus_requested || (clicked && g.IO.KeyCtrl) || g.NavInputId == id)
{ {
temp_input_start = true; temp_input_is_active = true;
FocusableItemUnregister(window); FocusableItemUnregister(window);
} }
} }
} }
// Our current specs do NOT clamp when using CTRL+Click manual input, but we should eventually add a flag for that.. // 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); return TempInputScalar(frame_bb, id, label, data_type, p_data, format);// , p_min, p_max);
// Draw frame // Draw frame