mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	Debug, Internals: Added DebugDrawCursorPos(), DebugDrawLineExtents() helpers.
This commit is contained in:
		
							
								
								
									
										32
									
								
								imgui.cpp
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								imgui.cpp
									
									
									
									
									
								
							| @@ -14689,6 +14689,38 @@ void ImGui::ShowDebugLogWindow(bool* p_open) | ||||
| // [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL) | ||||
| //----------------------------------------------------------------------------- | ||||
|  | ||||
| // Draw a small cross at current CursorPos in current window's DrawList | ||||
| void ImGui::DebugDrawCursorPos(ImU32 col) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|     ImVec2 pos = window->DC.CursorPos; | ||||
|     window->DrawList->AddLine(ImVec2(pos.x, pos.y - 3.0f), ImVec2(pos.x, pos.y + 4.0f), col, 1.0f); | ||||
|     window->DrawList->AddLine(ImVec2(pos.x - 3.0f, pos.y), ImVec2(pos.x + 4.0f, pos.y), col, 1.0f); | ||||
| } | ||||
|  | ||||
| // Draw a 10px wide rectangle around CurposPos.x using Line Y1/Y2 in current window's DrawList | ||||
| void ImGui::DebugDrawLineExtents(ImU32 col) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|     float curr_x = window->DC.CursorPos.x; | ||||
|     float line_y1 = (window->DC.IsSameLine ? window->DC.CursorPosPrevLine.y : window->DC.CursorPos.y); | ||||
|     float line_y2 = line_y1 + (window->DC.IsSameLine ? window->DC.PrevLineSize.y : window->DC.CurrLineSize.y); | ||||
|     window->DrawList->AddLine(ImVec2(curr_x - 5.0f, line_y1), ImVec2(curr_x + 5.0f, line_y1), col, 1.0f); | ||||
|     window->DrawList->AddLine(ImVec2(curr_x - 0.5f, line_y1), ImVec2(curr_x - 0.5f, line_y2), col, 1.0f); | ||||
|     window->DrawList->AddLine(ImVec2(curr_x - 5.0f, line_y2), ImVec2(curr_x + 5.0f, line_y2), col, 1.0f); | ||||
| } | ||||
|  | ||||
| // Draw last item rect in ForegroundDrawList (so it is always visible) | ||||
| void ImGui::DebugDrawItemRect(ImU32 col) | ||||
| { | ||||
|     ImGuiContext& g = *GImGui; | ||||
|     ImGuiWindow* window = g.CurrentWindow; | ||||
|     GetForegroundDrawList(window)->AddRect(g.LastItemData.Rect.Min, g.LastItemData.Rect.Max, col); | ||||
| } | ||||
|  | ||||
| // [DEBUG] Locate item position/rectangle given an ID. | ||||
| static const ImU32 DEBUG_LOCATE_ITEM_COLOR = IM_COL32(0, 255, 0, 255);  // Green | ||||
|  | ||||
| void ImGui::DebugLocateItem(ImGuiID target_id) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user