mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-25 21:17:01 +00:00
Metrics: Added a node showing windows in submission order and showing the Begin() stack.
This commit is contained in:
parent
c5db276521
commit
f087a5b856
@ -71,6 +71,7 @@ Other Changes:
|
|||||||
(an additional ItemSpacing.y was declared, affecting scrollbar range).
|
(an additional ItemSpacing.y was declared, affecting scrollbar range).
|
||||||
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceAllowNullID doesn't lose
|
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceAllowNullID doesn't lose
|
||||||
tooltip when scrolling. (#143)
|
tooltip when scrolling. (#143)
|
||||||
|
- Metrics: Added a node showing windows in submission order and showing the Begin() stack.
|
||||||
- Misc: Added missing ImGuiMouseCursor_NotAllowed cursor for software rendering (when the
|
- Misc: Added missing ImGuiMouseCursor_NotAllowed cursor for software rendering (when the
|
||||||
io.MouseDrawCursor flag is enabled). (#4713) [@nobody-special666]
|
io.MouseDrawCursor flag is enabled). (#4713) [@nobody-special666]
|
||||||
- Misc: Fix MinGW DLL build issue (when IMGUI_API is defined). [@rokups]
|
- Misc: Fix MinGW DLL build issue (when IMGUI_API is defined). [@rokups]
|
||||||
|
50
imgui.cpp
50
imgui.cpp
@ -1946,7 +1946,7 @@ void ImGuiStorage::BuildSortByKey()
|
|||||||
{
|
{
|
||||||
struct StaticFunc
|
struct StaticFunc
|
||||||
{
|
{
|
||||||
static int IMGUI_CDECL PairCompareByID(const void* lhs, const void* rhs)
|
static int IMGUI_CDECL PairComparerByID(const void* lhs, const void* rhs)
|
||||||
{
|
{
|
||||||
// We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
|
// We can't just do a subtraction because qsort uses signed integers and subtracting our ID doesn't play well with that.
|
||||||
if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1;
|
if (((const ImGuiStoragePair*)lhs)->key > ((const ImGuiStoragePair*)rhs)->key) return +1;
|
||||||
@ -1954,7 +1954,7 @@ void ImGuiStorage::BuildSortByKey()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairCompareByID);
|
ImQsort(Data.Data, (size_t)Data.Size, sizeof(ImGuiStoragePair), StaticFunc::PairComparerByID);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
|
int ImGuiStorage::GetInt(ImGuiID key, int default_val) const
|
||||||
@ -5872,7 +5872,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
|
|
||||||
// Update ->RootWindow and others pointers (before any possible call to FocusWindow)
|
// Update ->RootWindow and others pointers (before any possible call to FocusWindow)
|
||||||
if (first_begin_of_the_frame)
|
if (first_begin_of_the_frame)
|
||||||
|
{
|
||||||
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
UpdateWindowParentAndRootLinks(window, flags, parent_window);
|
||||||
|
window->ParentWindowInBeginStack = parent_window_in_stack;
|
||||||
|
}
|
||||||
|
|
||||||
// Process SetNextWindow***() calls
|
// Process SetNextWindow***() calls
|
||||||
// (FIXME: Consider splitting the HasXXX flags into X/Y components
|
// (FIXME: Consider splitting the HasXXX flags into X/Y components
|
||||||
@ -11314,6 +11317,7 @@ static void ImeSetInputScreenPosFn_DefaultImpl(int, int) {}
|
|||||||
// - DebugNodeWindow() [Internal]
|
// - DebugNodeWindow() [Internal]
|
||||||
// - DebugNodeWindowSettings() [Internal]
|
// - DebugNodeWindowSettings() [Internal]
|
||||||
// - DebugNodeWindowsList() [Internal]
|
// - DebugNodeWindowsList() [Internal]
|
||||||
|
// - DebugNodeWindowsListByBeginStackParent() [Internal]
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifndef IMGUI_DISABLE_METRICS_WINDOW
|
#ifndef IMGUI_DISABLE_METRICS_WINDOW
|
||||||
@ -11536,8 +11540,27 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Windows
|
// Windows
|
||||||
DebugNodeWindowsList(&g.Windows, "Windows");
|
if (TreeNode("Windows", "Windows (%d)", g.Windows.Size))
|
||||||
//DebugNodeWindowsList(&g.WindowsFocusOrder, "WindowsFocusOrder");
|
{
|
||||||
|
//SetNextItemOpen(true, ImGuiCond_Once);
|
||||||
|
DebugNodeWindowsList(&g.Windows, "By display order");
|
||||||
|
DebugNodeWindowsList(&g.WindowsFocusOrder, "By focus order (root windows)");
|
||||||
|
if (TreeNode("By submission order (begin stack)"))
|
||||||
|
{
|
||||||
|
// Here we display windows in their submitted order/hierarchy, however note that the Begin stack doesn't constitute a Parent<>Child relationship!
|
||||||
|
ImVector<ImGuiWindow*>& temp_buffer = g.WindowsTempSortBuffer;
|
||||||
|
temp_buffer.resize(0);
|
||||||
|
for (int i = 0; i < g.Windows.Size; i++)
|
||||||
|
if (g.Windows[i]->LastFrameActive + 1 >= g.FrameCount)
|
||||||
|
temp_buffer.push_back(g.Windows[i]);
|
||||||
|
struct Func { static int IMGUI_CDECL WindowComparerByBeginOrder(const void* lhs, const void* rhs) { return ((int)(*(const ImGuiWindow* const *)lhs)->BeginOrderWithinContext - (*(const ImGuiWindow* const*)rhs)->BeginOrderWithinContext); } };
|
||||||
|
ImQsort(temp_buffer.Data, (size_t)temp_buffer.Size, sizeof(ImGuiWindow*), Func::WindowComparerByBeginOrder);
|
||||||
|
DebugNodeWindowsListByBeginStackParent(temp_buffer.Data, temp_buffer.Size, NULL);
|
||||||
|
TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
|
TreePop();
|
||||||
|
}
|
||||||
|
|
||||||
// DrawLists
|
// DrawLists
|
||||||
int drawlist_count = 0;
|
int drawlist_count = 0;
|
||||||
@ -12161,7 +12184,6 @@ void ImGui::DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* la
|
|||||||
{
|
{
|
||||||
if (!TreeNode(label, "%s (%d)", label, windows->Size))
|
if (!TreeNode(label, "%s (%d)", label, windows->Size))
|
||||||
return;
|
return;
|
||||||
Text("(In front-to-back order:)");
|
|
||||||
for (int i = windows->Size - 1; i >= 0; i--) // Iterate front to back
|
for (int i = windows->Size - 1; i >= 0; i--) // Iterate front to back
|
||||||
{
|
{
|
||||||
PushID((*windows)[i]);
|
PushID((*windows)[i]);
|
||||||
@ -12171,6 +12193,24 @@ void ImGui::DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* la
|
|||||||
TreePop();
|
TreePop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME-OPT: This is technically suboptimal, but it is simpler this way.
|
||||||
|
void ImGui::DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < windows_size; i++)
|
||||||
|
{
|
||||||
|
ImGuiWindow* window = windows[i];
|
||||||
|
if (window->ParentWindowInBeginStack != parent_in_begin_stack)
|
||||||
|
continue;
|
||||||
|
char buf[20];
|
||||||
|
ImFormatString(buf, IM_ARRAYSIZE(buf), "[%04d] Window", window->BeginOrderWithinContext);
|
||||||
|
//BulletText("[%04d] Window '%s'", window->BeginOrderWithinContext, window->Name);
|
||||||
|
DebugNodeWindow(window, buf);
|
||||||
|
Indent();
|
||||||
|
DebugNodeWindowsListByBeginStackParent(windows + i + 1, windows_size - i - 1, window);
|
||||||
|
Unindent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
|
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -2026,6 +2026,7 @@ struct IMGUI_API ImGuiWindow
|
|||||||
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
ImDrawList* DrawList; // == &DrawListInst (for backward compatibility reason with code using imgui_internal.h we keep this a pointer)
|
||||||
ImDrawList DrawListInst;
|
ImDrawList DrawListInst;
|
||||||
ImGuiWindow* ParentWindow; // If we are a child _or_ popup _or_ docked window, this is pointing to our parent. Otherwise NULL.
|
ImGuiWindow* ParentWindow; // If we are a child _or_ popup _or_ docked window, this is pointing to our parent. Otherwise NULL.
|
||||||
|
ImGuiWindow* ParentWindowInBeginStack;
|
||||||
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
|
ImGuiWindow* RootWindow; // Point to ourself or first ancestor that is not a child window. Doesn't cross through popups/dock nodes.
|
||||||
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
ImGuiWindow* RootWindowPopupTree; // Point to ourself or first ancestor that is not a child window. Cross through popups parent<>child.
|
||||||
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
ImGuiWindow* RootWindowForTitleBarHighlight; // Point to ourself or first ancestor which will display TitleBgActive color when this window is active.
|
||||||
@ -2784,6 +2785,7 @@ namespace ImGui
|
|||||||
IMGUI_API void DebugNodeWindow(ImGuiWindow* window, const char* label);
|
IMGUI_API void DebugNodeWindow(ImGuiWindow* window, const char* label);
|
||||||
IMGUI_API void DebugNodeWindowSettings(ImGuiWindowSettings* settings);
|
IMGUI_API void DebugNodeWindowSettings(ImGuiWindowSettings* settings);
|
||||||
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
|
IMGUI_API void DebugNodeWindowsList(ImVector<ImGuiWindow*>* windows, const char* label);
|
||||||
|
IMGUI_API void DebugNodeWindowsListByBeginStackParent(ImGuiWindow** windows, int windows_size, ImGuiWindow* parent_in_begin_stack);
|
||||||
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
|
IMGUI_API void DebugNodeViewport(ImGuiViewportP* viewport);
|
||||||
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);
|
IMGUI_API void DebugRenderViewportThumbnail(ImDrawList* draw_list, ImGuiViewportP* viewport, const ImRect& bb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user