MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / ShowMetricsWindow

Method ShowMetricsWindow

ImGUI GLFW Tutorial/imgui/imgui.cpp:10909–11269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10907}
10908
10909void ImGui::ShowMetricsWindow(bool* p_open)
10910{
10911 if (!Begin("Dear ImGui Metrics/Debugger", p_open))
10912 {
10913 End();
10914 return;
10915 }
10916
10917 ImGuiContext& g = *GImGui;
10918 ImGuiIO& io = g.IO;
10919 ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
10920
10921 // Basic info
10922 Text("Dear ImGui %s", GetVersion());
10923 Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
10924 Text("%d vertices, %d indices (%d triangles)", io.MetricsRenderVertices, io.MetricsRenderIndices, io.MetricsRenderIndices / 3);
10925 Text("%d active windows (%d visible)", io.MetricsActiveWindows, io.MetricsRenderWindows);
10926 Text("%d active allocations", io.MetricsActiveAllocations);
10927 //SameLine(); if (SmallButton("GC")) { g.GcCompactAll = true; }
10928
10929 Separator();
10930
10931 // Debugging enums
10932 enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Content, WRT_ContentIdeal, WRT_ContentRegionRect, WRT_Count }; // Windows Rect Type
10933 const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Content", "ContentIdeal", "ContentRegionRect" };
10934 enum { TRT_OuterRect, TRT_InnerRect, TRT_WorkRect, TRT_HostClipRect, TRT_InnerClipRect, TRT_BackgroundClipRect, TRT_ColumnsRect, TRT_ColumnsWorkRect, TRT_ColumnsClipRect, TRT_ColumnsContentHeadersUsed, TRT_ColumnsContentHeadersIdeal, TRT_ColumnsContentFrozen, TRT_ColumnsContentUnfrozen, TRT_Count }; // Tables Rect Type
10935 const char* trt_rects_names[TRT_Count] = { "OuterRect", "InnerRect", "WorkRect", "HostClipRect", "InnerClipRect", "BackgroundClipRect", "ColumnsRect", "ColumnsWorkRect", "ColumnsClipRect", "ColumnsContentHeadersUsed", "ColumnsContentHeadersIdeal", "ColumnsContentFrozen", "ColumnsContentUnfrozen" };
10936 if (cfg->ShowWindowsRectsType < 0)
10937 cfg->ShowWindowsRectsType = WRT_WorkRect;
10938 if (cfg->ShowTablesRectsType < 0)
10939 cfg->ShowTablesRectsType = TRT_WorkRect;
10940
10941 struct Funcs
10942 {
10943 static ImRect GetTableRect(ImGuiTable* table, int rect_type, int n)
10944 {
10945 if (rect_type == TRT_OuterRect) { return table->OuterRect; }
10946 else if (rect_type == TRT_InnerRect) { return table->InnerRect; }
10947 else if (rect_type == TRT_WorkRect) { return table->WorkRect; }
10948 else if (rect_type == TRT_HostClipRect) { return table->HostClipRect; }
10949 else if (rect_type == TRT_InnerClipRect) { return table->InnerClipRect; }
10950 else if (rect_type == TRT_BackgroundClipRect) { return table->BgClipRect; }
10951 else if (rect_type == TRT_ColumnsRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->MinX, table->InnerClipRect.Min.y, c->MaxX, table->InnerClipRect.Min.y + table->LastOuterHeight); }
10952 else if (rect_type == TRT_ColumnsWorkRect) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->WorkRect.Min.y, c->WorkMaxX, table->WorkRect.Max.y); }
10953 else if (rect_type == TRT_ColumnsClipRect) { ImGuiTableColumn* c = &table->Columns[n]; return c->ClipRect; }
10954 else if (rect_type == TRT_ColumnsContentHeadersUsed){ ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersUsed, table->InnerClipRect.Min.y + table->LastFirstRowHeight); } // Note: y1/y2 not always accurate
10955 else if (rect_type == TRT_ColumnsContentHeadersIdeal){ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXHeadersIdeal, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10956 else if (rect_type == TRT_ColumnsContentFrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y, c->ContentMaxXFrozen, table->InnerClipRect.Min.y + table->LastFirstRowHeight); }
10957 else if (rect_type == TRT_ColumnsContentUnfrozen) { ImGuiTableColumn* c = &table->Columns[n]; return ImRect(c->WorkMinX, table->InnerClipRect.Min.y + table->LastFirstRowHeight, c->ContentMaxXUnfrozen, table->InnerClipRect.Max.y); }
10958 IM_ASSERT(0);
10959 return ImRect();
10960 }
10961
10962 static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
10963 {
10964 if (rect_type == WRT_OuterRect) { return window->Rect(); }
10965 else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; }
10966 else if (rect_type == WRT_InnerRect) { return window->InnerRect; }

Callers

nothing calls this directly

Calls 13

DebugStartItemPickerFunction · 0.70
MetricsHelpMarkerFunction · 0.70
GetForegroundDrawListFunction · 0.70
ImVec2Function · 0.70
ImFormatStringFunction · 0.70
AddRectMethod · 0.45
GetDrawListCountMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
c_strMethod · 0.45
AddRectFilledMethod · 0.45

Tested by

no test coverage detected