[DEBUG] ID Stack Tool: update queries. Called by NewFrame()
| 17653 | |
| 17654 | // [DEBUG] ID Stack Tool: update queries. Called by NewFrame() |
| 17655 | void ImGui::UpdateDebugToolStackQueries() |
| 17656 | { |
| 17657 | ImGuiContext& g = *GImGui; |
| 17658 | ImGuiIDStackTool* tool = &g.DebugIDStackTool; |
| 17659 | |
| 17660 | // Clear hook when id stack tool is not visible |
| 17661 | g.DebugHookIdInfo = 0; |
| 17662 | if (g.FrameCount != tool->LastActiveFrame + 1) |
| 17663 | return; |
| 17664 | |
| 17665 | // Update queries. The steps are: -1: query Stack, >= 0: query each stack item |
| 17666 | // We can only perform 1 ID Info query every frame. This is designed so the GetID() tests are cheap and constant-time |
| 17667 | const ImGuiID query_id = g.HoveredIdPreviousFrame ? g.HoveredIdPreviousFrame : g.ActiveId; |
| 17668 | if (tool->QueryId != query_id) |
| 17669 | { |
| 17670 | tool->QueryId = query_id; |
| 17671 | tool->StackLevel = -1; |
| 17672 | tool->Results.resize(0); |
| 17673 | tool->ResultPathsBuf.resize(0); |
| 17674 | } |
| 17675 | if (query_id == 0) |
| 17676 | return; |
| 17677 | |
| 17678 | // Advance to next stack level when we got our result, or after 2 frames (in case we never get a result) |
| 17679 | int stack_level = tool->StackLevel; |
| 17680 | if (stack_level >= 0 && stack_level < tool->Results.Size) |
| 17681 | if (tool->Results[stack_level].QuerySuccess || tool->Results[stack_level].QueryFrameCount > 2) |
| 17682 | tool->StackLevel++; |
| 17683 | |
| 17684 | // Update hook |
| 17685 | stack_level = tool->StackLevel; |
| 17686 | if (stack_level == -1) |
| 17687 | g.DebugHookIdInfo = query_id; |
| 17688 | if (stack_level >= 0 && stack_level < tool->Results.Size) |
| 17689 | { |
| 17690 | g.DebugHookIdInfo = tool->Results[stack_level].ID; |
| 17691 | tool->Results[stack_level].QueryFrameCount++; |
| 17692 | } |
| 17693 | } |
| 17694 | |
| 17695 | // [DEBUG] ID Stack tool: hooks called by GetID() family functions |
| 17696 | void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end) |