mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Debug Tools: Renamed ShowStackToolWindow() ("Stack Tool") to ShowIdStackToolWindow() ("ID Stack Tool"). (#4631)
This commit is contained in:
parent
204ae8a407
commit
8175a47881
@ -42,6 +42,8 @@ HOW TO UPDATE?
|
||||
|
||||
Breaking changes:
|
||||
|
||||
- Debug Tools: Renamed ShowStackToolWindow() ("Stack Tool") to ShowIdStackToolWindow() ("ID Stack Tool"),
|
||||
as earlier name was misleading. Kept inline redirection function. (#4631)
|
||||
- ListBox, Combo: Changed signature of "name getter" callback in old one-liner ListBox()/Combo() apis.
|
||||
Before:
|
||||
getter type: bool (*getter)(void* user_data, int idx, const char** out_text)
|
||||
|
@ -217,7 +217,7 @@ Interactive widgets (such as calls to Button buttons) need a unique ID.
|
||||
**Unique IDs are used internally to track active widgets and occasionally associate state to widgets.<BR>
|
||||
Unique IDs are implicitly built from the hash of multiple elements that identify the "path" to the UI element.**
|
||||
|
||||
Since Dear ImGui 1.85, you can use `Demo>Tools>Stack Tool` or call `ImGui::ShowStackToolWindow()`. The tool display intermediate values leading to the creation of a unique ID, making things easier to debug and understand.
|
||||
Since Dear ImGui 1.85, you can use `Demo>Tools>Stack Tool` or call `ImGui::ShowIdStackToolWindow()`. The tool display intermediate values leading to the creation of a unique ID, making things easier to debug and understand.
|
||||
|
||||
![Stack tool](https://user-images.githubusercontent.com/8225057/136235657-a0ea5665-dcd1-423f-9be6-dc3f8ced8f12.png)
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
// It is very strongly recommended to NOT disable the demo windows and debug tool during development. They are extremely useful in day to day work. Please read comments in imgui_demo.cpp.
|
||||
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
|
||||
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
|
||||
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowStackToolWindow() will be empty (this was called IMGUI_DISABLE_METRICS_WINDOW before 1.88).
|
||||
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIdStackToolWindow() will be empty.
|
||||
|
||||
//---- 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. (user32.lib/.a, kernel32.lib/.a)
|
||||
|
39
imgui.cpp
39
imgui.cpp
@ -88,7 +88,7 @@ CODE
|
||||
// [SECTION] PLATFORM DEPENDENT HELPERS
|
||||
// [SECTION] METRICS/DEBUGGER WINDOW
|
||||
// [SECTION] DEBUG LOG WINDOW
|
||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
|
||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, ID STACK TOOL)
|
||||
|
||||
*/
|
||||
|
||||
@ -424,6 +424,7 @@ CODE
|
||||
When you are not sure about an old symbol or function name, try using the Search/Find function of your IDE to look for comments or references in all imgui files.
|
||||
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
|
||||
|
||||
- 2023/09/26 (1.90.0) - debug tools: Renamed ShowStackToolWindow() ("Stack Tool") to ShowIdStackToolWindow() ("ID Stack Tool"), as earlier name was misleading. Kept inline redirection function. (#4631)
|
||||
- 2023/09/15 (1.90.0) - ListBox, Combo: changed signature of "name getter" callback in old one-liner ListBox()/Combo() apis. kept inline redirection function (will obsolete).
|
||||
- old: bool Combo(const char* label, int* current_item, bool (*getter)(void* user_data, int idx, const char** out_text), ...)
|
||||
- new: bool Combo(const char* label, int* current_item, const char* (*getter)(void* user_data, int idx), ...);
|
||||
@ -7798,7 +7799,7 @@ void ImGui::PushOverrideID(ImGuiID id)
|
||||
}
|
||||
|
||||
// Helper to avoid a common series of PushOverrideID -> GetID() -> PopID() call
|
||||
// (note that when using this pattern, TestEngine's "Stack Tool" will tend to not display the intermediate stack level.
|
||||
// (note that when using this pattern, ID Stack Tool will tend to not display the intermediate stack level.
|
||||
// for that to work we would need to do PushOverrideID() -> ItemAdd() -> PopID() which would alter widget code a little more)
|
||||
ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed)
|
||||
{
|
||||
@ -13702,8 +13703,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
|
||||
if (cfg->ShowDebugLog)
|
||||
ShowDebugLogWindow(&cfg->ShowDebugLog);
|
||||
if (cfg->ShowStackTool)
|
||||
ShowStackToolWindow(&cfg->ShowStackTool);
|
||||
if (cfg->ShowIdStackTool)
|
||||
ShowIdStackToolWindow(&cfg->ShowIdStackTool);
|
||||
|
||||
if (!Begin("Dear ImGui Metrics/Debugger", p_open) || GetCurrentWindow()->BeginCount > 1)
|
||||
{
|
||||
@ -13789,15 +13790,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
SameLine();
|
||||
MetricsHelpMarker("Will call the IM_DEBUG_BREAK() macro to break in debugger.\nWarning: If you don't have a debugger attached, this will probably crash.");
|
||||
|
||||
// Stack Tool is your best friend!
|
||||
Checkbox("Show Debug Log", &cfg->ShowDebugLog);
|
||||
SameLine();
|
||||
MetricsHelpMarker("You can also call ImGui::ShowDebugLogWindow() from your code.");
|
||||
|
||||
// Stack Tool is your best friend!
|
||||
Checkbox("Show Stack Tool", &cfg->ShowStackTool);
|
||||
Checkbox("Show ID Stack Tool", &cfg->ShowIdStackTool);
|
||||
SameLine();
|
||||
MetricsHelpMarker("You can also call ImGui::ShowStackToolWindow() from your code.");
|
||||
MetricsHelpMarker("You can also call ImGui::ShowIdStackToolWindow() from your code.");
|
||||
|
||||
Checkbox("Show windows begin order", &cfg->ShowWindowsBeginOrder);
|
||||
Checkbox("Show windows rectangles", &cfg->ShowWindowsRects);
|
||||
@ -14720,7 +14719,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
|
||||
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, ID STACK TOOL)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Draw a small cross at current CursorPos in current window's DrawList
|
||||
@ -14821,13 +14820,13 @@ void ImGui::UpdateDebugToolItemPicker()
|
||||
EndTooltip();
|
||||
}
|
||||
|
||||
// [DEBUG] Stack Tool: update queries. Called by NewFrame()
|
||||
// [DEBUG] ID Stack Tool: update queries. Called by NewFrame()
|
||||
void ImGui::UpdateDebugToolStackQueries()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiStackTool* tool = &g.DebugStackTool;
|
||||
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
|
||||
|
||||
// Clear hook when stack tool is not visible
|
||||
// Clear hook when id stack tool is not visible
|
||||
g.DebugHookIdInfo = 0;
|
||||
if (g.FrameCount != tool->LastActiveFrame + 1)
|
||||
return;
|
||||
@ -14861,12 +14860,12 @@ void ImGui::UpdateDebugToolStackQueries()
|
||||
}
|
||||
}
|
||||
|
||||
// [DEBUG] Stack tool: hooks called by GetID() family functions
|
||||
// [DEBUG] ID Stack tool: hooks called by GetID() family functions
|
||||
void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
ImGuiStackTool* tool = &g.DebugStackTool;
|
||||
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
|
||||
|
||||
// Step 0: stack query
|
||||
// This assumes that the ID was computed with the current ID stack, which tends to be the case for our widget.
|
||||
@ -14909,7 +14908,7 @@ void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* dat
|
||||
info->DataType = data_type;
|
||||
}
|
||||
|
||||
static int StackToolFormatLevelInfo(ImGuiStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size)
|
||||
static int StackToolFormatLevelInfo(ImGuiIdStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size)
|
||||
{
|
||||
ImGuiStackLevelInfo* info = &tool->Results[n];
|
||||
ImGuiWindow* window = (info->Desc[0] == 0 && n == 0) ? ImGui::FindWindowByID(info->ID) : NULL;
|
||||
@ -14926,20 +14925,20 @@ static int StackToolFormatLevelInfo(ImGuiStackTool* tool, int n, bool format_for
|
||||
return ImFormatString(buf, buf_size, "???");
|
||||
}
|
||||
|
||||
// Stack Tool: Display UI
|
||||
void ImGui::ShowStackToolWindow(bool* p_open)
|
||||
// ID Stack Tool: Display UI
|
||||
void ImGui::ShowIdStackToolWindow(bool* p_open)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize))
|
||||
SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver);
|
||||
if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
|
||||
if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
|
||||
{
|
||||
End();
|
||||
return;
|
||||
}
|
||||
|
||||
// Display hovered/active status
|
||||
ImGuiStackTool* tool = &g.DebugStackTool;
|
||||
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
|
||||
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
|
||||
const ImGuiID active_id = g.ActiveId;
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
@ -15021,7 +15020,7 @@ void ImGui::DebugNodeViewport(ImGuiViewportP*) {}
|
||||
void ImGui::DebugLog(const char*, ...) {}
|
||||
void ImGui::DebugLogV(const char*, va_list) {}
|
||||
void ImGui::ShowDebugLogWindow(bool*) {}
|
||||
void ImGui::ShowStackToolWindow(bool*) {}
|
||||
void ImGui::ShowIdStackToolWindow(bool*) {}
|
||||
void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {}
|
||||
void ImGui::UpdateDebugToolItemPicker() {}
|
||||
void ImGui::UpdateDebugToolStackQueries() {}
|
||||
|
3
imgui.h
3
imgui.h
@ -307,7 +307,7 @@ namespace ImGui
|
||||
IMGUI_API void ShowDemoWindow(bool* p_open = NULL); // create Demo window. demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application!
|
||||
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
|
||||
IMGUI_API void ShowDebugLogWindow(bool* p_open = NULL); // create Debug Log window. display a simplified log of important dear imgui events.
|
||||
IMGUI_API void ShowStackToolWindow(bool* p_open = NULL); // create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
|
||||
IMGUI_API void ShowIdStackToolWindow(bool* p_open = NULL); // create Stack Tool window. hover items with mouse to query information about the source of their unique ID.
|
||||
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
|
||||
IMGUI_API void ShowStyleEditor(ImGuiStyle* ref = NULL); // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style)
|
||||
IMGUI_API bool ShowStyleSelector(const char* label); // add style selector block (not a window), essentially a combo listing the default styles.
|
||||
@ -3100,6 +3100,7 @@ namespace ImGui
|
||||
namespace ImGui
|
||||
{
|
||||
// OBSOLETED in 1.90.0 (from September 2023)
|
||||
static inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIdStackToolWindow(p_open); }
|
||||
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int height_in_items = -1);
|
||||
IMGUI_API bool Combo(const char* label, int* current_item, bool (*old_callback)(void* user_data, int idx, const char** out_text), void* user_data, int items_count, int popup_max_height_in_items = -1);
|
||||
// OBSOLETED in 1.89.7 (from June 2023)
|
||||
|
@ -290,7 +290,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
// Dear ImGui Tools (accessible from the "Tools" menu)
|
||||
static bool show_tool_metrics = false;
|
||||
static bool show_tool_debug_log = false;
|
||||
static bool show_tool_stack_tool = false;
|
||||
static bool show_tool_id_stack_tool = false;
|
||||
static bool show_tool_style_editor = false;
|
||||
static bool show_tool_about = false;
|
||||
|
||||
@ -298,8 +298,8 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
ImGui::ShowMetricsWindow(&show_tool_metrics);
|
||||
if (show_tool_debug_log)
|
||||
ImGui::ShowDebugLogWindow(&show_tool_debug_log);
|
||||
if (show_tool_stack_tool)
|
||||
ImGui::ShowStackToolWindow(&show_tool_stack_tool);
|
||||
if (show_tool_id_stack_tool)
|
||||
ImGui::ShowIdStackToolWindow(&show_tool_id_stack_tool);
|
||||
if (show_tool_style_editor)
|
||||
{
|
||||
ImGui::Begin("Dear ImGui Style Editor", &show_tool_style_editor);
|
||||
@ -398,7 +398,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
|
||||
#endif
|
||||
ImGui::MenuItem("Metrics/Debugger", NULL, &show_tool_metrics, has_debug_tools);
|
||||
ImGui::MenuItem("Debug Log", NULL, &show_tool_debug_log, has_debug_tools);
|
||||
ImGui::MenuItem("Stack Tool", NULL, &show_tool_stack_tool, has_debug_tools);
|
||||
ImGui::MenuItem("ID Stack Tool", NULL, &show_tool_id_stack_tool, has_debug_tools);
|
||||
ImGui::MenuItem("Style Editor", NULL, &show_tool_style_editor);
|
||||
ImGui::MenuItem("About Dear ImGui", NULL, &show_tool_about);
|
||||
ImGui::EndMenu();
|
||||
|
@ -1784,7 +1784,7 @@ enum ImGuiDebugLogFlags_
|
||||
struct ImGuiMetricsConfig
|
||||
{
|
||||
bool ShowDebugLog = false;
|
||||
bool ShowStackTool = false;
|
||||
bool ShowIdStackTool = false;
|
||||
bool ShowWindowsRects = false;
|
||||
bool ShowWindowsBeginOrder = false;
|
||||
bool ShowTablesRects = false;
|
||||
@ -1806,8 +1806,8 @@ struct ImGuiStackLevelInfo
|
||||
ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); }
|
||||
};
|
||||
|
||||
// State for Stack tool queries
|
||||
struct ImGuiStackTool
|
||||
// State for ID Stack tool queries
|
||||
struct ImGuiIdStackTool
|
||||
{
|
||||
int LastActiveFrame;
|
||||
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
|
||||
@ -1816,7 +1816,7 @@ struct ImGuiStackTool
|
||||
bool CopyToClipboardOnCtrlC;
|
||||
float CopyToClipboardLastTime;
|
||||
|
||||
ImGuiStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
||||
ImGuiIdStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -1888,7 +1888,7 @@ struct ImGuiContext
|
||||
ImVec2 WheelingAxisAvg;
|
||||
|
||||
// Item/widgets state and tracking information
|
||||
ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
||||
ImGuiID DebugHookIdInfo; // Will call core hooks: DebugHookIdInfo() from GetID functions, used by ID Stack Tool [next HoveredId/ActiveId to not pull in an extra cache-line]
|
||||
ImGuiID HoveredId; // Hovered widget, filled during the frame
|
||||
ImGuiID HoveredIdPreviousFrame;
|
||||
bool HoveredIdAllowOverlap;
|
||||
@ -2130,7 +2130,7 @@ struct ImGuiContext
|
||||
ImU8 DebugItemPickerMouseButton;
|
||||
ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID
|
||||
ImGuiMetricsConfig DebugMetricsConfig;
|
||||
ImGuiStackTool DebugStackTool;
|
||||
ImGuiIdStackTool DebugIdStackTool;
|
||||
|
||||
// Misc
|
||||
float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..
|
||||
|
Loading…
Reference in New Issue
Block a user