Internal: Added IsMouseDragPastThreshold(). Tweaks. Todo.

Demo: Showing how to use the format parameter of Slider/Drag functions to display the name of an enum value instead of the underlying integer value
This commit is contained in:
omar
2019-07-26 12:08:29 -07:00
parent d057550209
commit 7a26a49f08
5 changed files with 33 additions and 6 deletions

View File

@ -4433,15 +4433,23 @@ bool ImGui::IsMouseDoubleClicked(int button)
return g.IO.MouseDoubleClicked[button];
}
// [Internal] This doesn't test if the button is presed
bool ImGui::IsMouseDragPastThreshold(int button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold;
return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
}
bool ImGui::IsMouseDragging(int button, float lock_threshold)
{
ImGuiContext& g = *GImGui;
IM_ASSERT(button >= 0 && button < IM_ARRAYSIZE(g.IO.MouseDown));
if (!g.IO.MouseDown[button])
return false;
if (lock_threshold < 0.0f)
lock_threshold = g.IO.MouseDragThreshold;
return g.IO.MouseDragMaxDistanceSqr[button] >= lock_threshold * lock_threshold;
return IsMouseDragPastThreshold(button, lock_threshold);
}
ImVec2 ImGui::GetMousePos()
@ -9719,6 +9727,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
if (!node_open)
return;
if (window && !window->WasActive)
ImGui::Text("(Note: owning Window is inactive: DrawList is not being rendered!)");
int elem_offset = 0;
for (const ImDrawCmd* pcmd = draw_list->CmdBuffer.begin(); pcmd < draw_list->CmdBuffer.end(); elem_offset += pcmd->ElemCount, pcmd++)
{