Misc: Added IMGUI_DISABLE_METRICS_WINDOW imconfig.h setting to explicitly compile out ShowMetricsWindow(). + Internals: Minor renaming.

This commit is contained in:
omar 2019-07-01 18:48:21 +02:00
parent da29d77253
commit 58c9f8a194
3 changed files with 25 additions and 16 deletions

View File

@ -47,6 +47,7 @@ Other Changes:
of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d). of this, auto-fitting exactly unwrapped text would make it wrap. (fixes initial 1.15 commit, 78645a7d).
- Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco] - Scrolling: Added SetScrollHereX(), SetScrollFromPosX() for completeness. (#1580) [@kevreco]
- Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles. - Style: Attenuated default opacity of ImGuiCol_Separator in Classic and Light styles.
- Misc: Added IMGUI_DISABLE_METRICS_WINDOW imconfig.h setting to explicitly compile out ShowMetricsWindow().
- ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot] - ImDrawList: Fixed CloneOutput() helper crashing. (#1860) [@gviot]
- ImDrawList::ChannelsSplit(), ImDrawListSplitter: Fixed an issue with merging draw commands between - ImDrawList::ChannelsSplit(), ImDrawListSplitter: Fixed an issue with merging draw commands between
channel 0 and 1. (#2624) channel 0 and 1. (#2624)

View File

@ -28,6 +28,7 @@
//---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty) //---- Don't implement demo windows functionality (ShowDemoWindow()/ShowStyleEditor()/ShowUserGuide() methods will be empty)
// It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp. // It is very strongly recommended to NOT disable the demo windows during development. Please read the comments in imgui_demo.cpp.
//#define IMGUI_DISABLE_DEMO_WINDOWS //#define IMGUI_DISABLE_DEMO_WINDOWS
//#define IMGUI_DISABLE_METRICS_WINDOW
//---- Don't implement some functions to reduce linkage requirements. //---- Don't implement some functions to reduce linkage requirements.
//#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc.

View File

@ -9935,6 +9935,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
// [SECTION] METRICS/DEBUG WINDOW // [SECTION] METRICS/DEBUG WINDOW
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#ifndef IMGUI_DISABLE_METRICS_WINDOW
void ImGui::ShowMetricsWindow(bool* p_open) void ImGui::ShowMetricsWindow(bool* p_open)
{ {
if (!ImGui::Begin("Dear ImGui Metrics", p_open)) if (!ImGui::Begin("Dear ImGui Metrics", p_open))
@ -9943,10 +9944,12 @@ void ImGui::ShowMetricsWindow(bool* p_open)
return; return;
} }
enum { RT_OuterRect, RT_OuterRectClipped, RT_InnerRect, RT_InnerClipRect, RT_WorkRect, RT_Contents, RT_ContentsRegionRect, RT_Count }; enum { WRT_OuterRect, WRT_OuterRectClipped, WRT_InnerRect, WRT_InnerClipRect, WRT_WorkRect, WRT_Contents, WRT_ContentsRegionRect, WRT_Count }; // Windows Rect Type
const char* wrt_rects_names[WRT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" };
static bool show_windows_begin_order = false; static bool show_windows_begin_order = false;
static bool show_windows_rects = false; static bool show_windows_rects = false;
static int show_windows_rect_type = RT_WorkRect; static int show_windows_rect_type = WRT_WorkRect;
static bool show_drawcmd_clip_rects = true; static bool show_drawcmd_clip_rects = true;
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
@ -9959,15 +9962,15 @@ void ImGui::ShowMetricsWindow(bool* p_open)
struct Funcs struct Funcs
{ {
static ImRect GetRect(ImGuiWindow* window, int rect_type) static ImRect GetWindowRect(ImGuiWindow* window, int rect_type)
{ {
if (rect_type == RT_OuterRect) { return window->Rect(); } if (rect_type == WRT_OuterRect) { return window->Rect(); }
else if (rect_type == RT_OuterRectClipped) { return window->OuterRectClipped; } else if (rect_type == WRT_OuterRectClipped) { return window->OuterRectClipped; }
else if (rect_type == RT_InnerRect) { return window->InnerRect; } else if (rect_type == WRT_InnerRect) { return window->InnerRect; }
else if (rect_type == RT_InnerClipRect) { return window->InnerClipRect; } else if (rect_type == WRT_InnerClipRect) { return window->InnerClipRect; }
else if (rect_type == RT_WorkRect) { return window->WorkRect; } else if (rect_type == WRT_WorkRect) { return window->WorkRect; }
else if (rect_type == RT_Contents) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); } else if (rect_type == WRT_Contents) { ImVec2 min = window->InnerRect.Min - window->Scroll + window->WindowPadding; return ImRect(min, min + window->ContentSize); }
else if (rect_type == RT_ContentsRegionRect) { return window->ContentsRegionRect; } else if (rect_type == WRT_ContentsRegionRect) { return window->ContentsRegionRect; }
IM_ASSERT(0); IM_ASSERT(0);
return ImRect(); return ImRect();
} }
@ -10174,16 +10177,15 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImGui::Checkbox("Show windows rectangles", &show_windows_rects); ImGui::Checkbox("Show windows rectangles", &show_windows_rects);
ImGui::SameLine(); ImGui::SameLine();
ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12); ImGui::SetNextItemWidth(ImGui::GetFontSize() * 12);
const char* rects_names[RT_Count] = { "OuterRect", "OuterRectClipped", "InnerRect", "InnerClipRect", "WorkRect", "Contents", "ContentsRegionRect" }; show_windows_rects |= ImGui::Combo("##show_windows_rect_type", &show_windows_rect_type, wrt_rects_names, WRT_Count);
show_windows_rects |= ImGui::Combo("##rects_type", &show_windows_rect_type, rects_names, RT_Count);
if (show_windows_rects && g.NavWindow) if (show_windows_rects && g.NavWindow)
{ {
ImGui::BulletText("'%s':", g.NavWindow->Name); ImGui::BulletText("'%s':", g.NavWindow->Name);
ImGui::Indent(); ImGui::Indent();
for (int n = 0; n < RT_Count; n++) for (int rect_n = 0; rect_n < WRT_Count; rect_n++)
{ {
ImRect r = Funcs::GetRect(g.NavWindow, n); ImRect r = Funcs::GetWindowRect(g.NavWindow, rect_n);
ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), rects_names[n]); ImGui::Text("(%6.1f,%6.1f) (%6.1f,%6.1f) Size (%6.1f,%6.1f) %s", r.Min.x, r.Min.y, r.Max.x, r.Max.y, r.GetWidth(), r.GetHeight(), wrt_rects_names[rect_n]);
} }
ImGui::Unindent(); ImGui::Unindent();
} }
@ -10201,7 +10203,7 @@ void ImGui::ShowMetricsWindow(bool* p_open)
ImDrawList* draw_list = GetForegroundDrawList(window); ImDrawList* draw_list = GetForegroundDrawList(window);
if (show_windows_rects) if (show_windows_rects)
{ {
ImRect r = Funcs::GetRect(window, show_windows_rect_type); ImRect r = Funcs::GetWindowRect(window, show_windows_rect_type);
draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255)); draw_list->AddRect(r.Min, r.Max, IM_COL32(255, 0, 128, 255));
} }
if (show_windows_begin_order && !(window->Flags & ImGuiWindowFlags_ChildWindow)) if (show_windows_begin_order && !(window->Flags & ImGuiWindowFlags_ChildWindow))
@ -10216,6 +10218,11 @@ void ImGui::ShowMetricsWindow(bool* p_open)
} }
ImGui::End(); ImGui::End();
} }
#else
void ImGui::ShowMetricsWindow(bool*)
{
}
#endif
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------