Skip to content

Commit 8175a47

Browse files
committed
Debug Tools: Renamed ShowStackToolWindow() ("Stack Tool") to ShowIdStackToolWindow() ("ID Stack Tool"). (#4631)
1 parent 204ae8a commit 8175a47

7 files changed

Lines changed: 35 additions & 33 deletions

File tree

‎docs/CHANGELOG.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ HOW TO UPDATE?
4242

4343
Breaking changes:
4444

45+
- Debug Tools: Renamed ShowStackToolWindow() ("Stack Tool") to ShowIdStackToolWindow() ("ID Stack Tool"),
46+
as earlier name was misleading. Kept inline redirection function. (#4631)
4547
- ListBox, Combo: Changed signature of "name getter" callback in old one-liner ListBox()/Combo() apis.
4648
Before:
4749
getter type: bool (*getter)(void* user_data, int idx, const char** out_text)

‎docs/FAQ.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Interactive widgets (such as calls to Button buttons) need a unique ID.
217217
**Unique IDs are used internally to track active widgets and occasionally associate state to widgets.<BR>
218218
Unique IDs are implicitly built from the hash of multiple elements that identify the "path" to the UI element.**
219219

220-
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.
220+
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.
221221

222222
![Stack tool](https://user-images.githubusercontent.com/8225057/136235657-a0ea5665-dcd1-423f-9be6-dc3f8ced8f12.png)
223223

‎imconfig.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// 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.
3535
//#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty.
3636
//#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty.
37-
//#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).
37+
//#define IMGUI_DISABLE_DEBUG_TOOLS // Disable metrics/debugger and other debug tools: ShowMetricsWindow(), ShowDebugLogWindow() and ShowIdStackToolWindow() will be empty.
3838

3939
//---- Don't implement some functions to reduce linkage requirements.
4040
//#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)

‎imgui.cpp‎

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ CODE
8888
// [SECTION] PLATFORM DEPENDENT HELPERS
8989
// [SECTION] METRICS/DEBUGGER WINDOW
9090
// [SECTION] DEBUG LOG WINDOW
91-
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
91+
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, ID STACK TOOL)
9292

9393
*/
9494

@@ -424,6 +424,7 @@ CODE
424424
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.
425425
You can read releases logs https://github.com/ocornut/imgui/releases for more details.
426426

427+
- 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)
427428
- 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).
428429
- old: bool Combo(const char* label, int* current_item, bool (*getter)(void* user_data, int idx, const char** out_text), ...)
429430
- 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)
77987799
}
77997800

78007801
// Helper to avoid a common series of PushOverrideID -> GetID() -> PopID() call
7801-
// (note that when using this pattern, TestEngine's "Stack Tool" will tend to not display the intermediate stack level.
7802+
// (note that when using this pattern, ID Stack Tool will tend to not display the intermediate stack level.
78027803
// for that to work we would need to do PushOverrideID() -> ItemAdd() -> PopID() which would alter widget code a little more)
78037804
ImGuiID ImGui::GetIDWithSeed(const char* str, const char* str_end, ImGuiID seed)
78047805
{
@@ -13702,8 +13703,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
1370213703
ImGuiMetricsConfig* cfg = &g.DebugMetricsConfig;
1370313704
if (cfg->ShowDebugLog)
1370413705
ShowDebugLogWindow(&cfg->ShowDebugLog);
13705-
if (cfg->ShowStackTool)
13706-
ShowStackToolWindow(&cfg->ShowStackTool);
13706+
if (cfg->ShowIdStackTool)
13707+
ShowIdStackToolWindow(&cfg->ShowIdStackTool);
1370713708

1370813709
if (!Begin("Dear ImGui Metrics/Debugger", p_open) || GetCurrentWindow()->BeginCount > 1)
1370913710
{
@@ -13789,15 +13790,13 @@ void ImGui::ShowMetricsWindow(bool* p_open)
1378913790
SameLine();
1379013791
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.");
1379113792

13792-
// Stack Tool is your best friend!
1379313793
Checkbox("Show Debug Log", &cfg->ShowDebugLog);
1379413794
SameLine();
1379513795
MetricsHelpMarker("You can also call ImGui::ShowDebugLogWindow() from your code.");
1379613796

13797-
// Stack Tool is your best friend!
13798-
Checkbox("Show Stack Tool", &cfg->ShowStackTool);
13797+
Checkbox("Show ID Stack Tool", &cfg->ShowIdStackTool);
1379913798
SameLine();
13800-
MetricsHelpMarker("You can also call ImGui::ShowStackToolWindow() from your code.");
13799+
MetricsHelpMarker("You can also call ImGui::ShowIdStackToolWindow() from your code.");
1380113800

1380213801
Checkbox("Show windows begin order", &cfg->ShowWindowsBeginOrder);
1380313802
Checkbox("Show windows rectangles", &cfg->ShowWindowsRects);
@@ -14720,7 +14719,7 @@ void ImGui::ShowDebugLogWindow(bool* p_open)
1472014719
}
1472114720

1472214721
//-----------------------------------------------------------------------------
14723-
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, STACK TOOL)
14722+
// [SECTION] OTHER DEBUG TOOLS (ITEM PICKER, ID STACK TOOL)
1472414723
//-----------------------------------------------------------------------------
1472514724

1472614725
// Draw a small cross at current CursorPos in current window's DrawList
@@ -14821,13 +14820,13 @@ void ImGui::UpdateDebugToolItemPicker()
1482114820
EndTooltip();
1482214821
}
1482314822

14824-
// [DEBUG] Stack Tool: update queries. Called by NewFrame()
14823+
// [DEBUG] ID Stack Tool: update queries. Called by NewFrame()
1482514824
void ImGui::UpdateDebugToolStackQueries()
1482614825
{
1482714826
ImGuiContext& g = *GImGui;
14828-
ImGuiStackTool* tool = &g.DebugStackTool;
14827+
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
1482914828

14830-
// Clear hook when stack tool is not visible
14829+
// Clear hook when id stack tool is not visible
1483114830
g.DebugHookIdInfo = 0;
1483214831
if (g.FrameCount != tool->LastActiveFrame + 1)
1483314832
return;
@@ -14861,12 +14860,12 @@ void ImGui::UpdateDebugToolStackQueries()
1486114860
}
1486214861
}
1486314862

14864-
// [DEBUG] Stack tool: hooks called by GetID() family functions
14863+
// [DEBUG] ID Stack tool: hooks called by GetID() family functions
1486514864
void ImGui::DebugHookIdInfo(ImGuiID id, ImGuiDataType data_type, const void* data_id, const void* data_id_end)
1486614865
{
1486714866
ImGuiContext& g = *GImGui;
1486814867
ImGuiWindow* window = g.CurrentWindow;
14869-
ImGuiStackTool* tool = &g.DebugStackTool;
14868+
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
1487014869

1487114870
// Step 0: stack query
1487214871
// 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
1490914908
info->DataType = data_type;
1491014909
}
1491114910

14912-
static int StackToolFormatLevelInfo(ImGuiStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size)
14911+
static int StackToolFormatLevelInfo(ImGuiIdStackTool* tool, int n, bool format_for_ui, char* buf, size_t buf_size)
1491314912
{
1491414913
ImGuiStackLevelInfo* info = &tool->Results[n];
1491514914
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
1492614925
return ImFormatString(buf, buf_size, "???");
1492714926
}
1492814927

14929-
// Stack Tool: Display UI
14930-
void ImGui::ShowStackToolWindow(bool* p_open)
14928+
// ID Stack Tool: Display UI
14929+
void ImGui::ShowIdStackToolWindow(bool* p_open)
1493114930
{
1493214931
ImGuiContext& g = *GImGui;
1493314932
if (!(g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasSize))
1493414933
SetNextWindowSize(ImVec2(0.0f, GetFontSize() * 8.0f), ImGuiCond_FirstUseEver);
14935-
if (!Begin("Dear ImGui Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
14934+
if (!Begin("Dear ImGui ID Stack Tool", p_open) || GetCurrentWindow()->BeginCount > 1)
1493614935
{
1493714936
End();
1493814937
return;
1493914938
}
1494014939

1494114940
// Display hovered/active status
14942-
ImGuiStackTool* tool = &g.DebugStackTool;
14941+
ImGuiIdStackTool* tool = &g.DebugIdStackTool;
1494314942
const ImGuiID hovered_id = g.HoveredIdPreviousFrame;
1494414943
const ImGuiID active_id = g.ActiveId;
1494514944
#ifdef IMGUI_ENABLE_TEST_ENGINE
@@ -15021,7 +15020,7 @@ void ImGui::DebugNodeViewport(ImGuiViewportP*) {}
1502115020
void ImGui::DebugLog(const char*, ...) {}
1502215021
void ImGui::DebugLogV(const char*, va_list) {}
1502315022
void ImGui::ShowDebugLogWindow(bool*) {}
15024-
void ImGui::ShowStackToolWindow(bool*) {}
15023+
void ImGui::ShowIdStackToolWindow(bool*) {}
1502515024
void ImGui::DebugHookIdInfo(ImGuiID, ImGuiDataType, const void*, const void*) {}
1502615025
void ImGui::UpdateDebugToolItemPicker() {}
1502715026
void ImGui::UpdateDebugToolStackQueries() {}

‎imgui.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ namespace ImGui
307307
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!
308308
IMGUI_API void ShowMetricsWindow(bool* p_open = NULL); // create Metrics/Debugger window. display Dear ImGui internals: windows, draw commands, various internal state, etc.
309309
IMGUI_API void ShowDebugLogWindow(bool* p_open = NULL); // create Debug Log window. display a simplified log of important dear imgui events.
310-
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.
310+
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.
311311
IMGUI_API void ShowAboutWindow(bool* p_open = NULL); // create About window. display Dear ImGui version, credits and build/system information.
312312
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)
313313
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
31003100
namespace ImGui
31013101
{
31023102
// OBSOLETED in 1.90.0 (from September 2023)
3103+
static inline void ShowStackToolWindow(bool* p_open = NULL) { ShowIdStackToolWindow(p_open); }
31033104
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);
31043105
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);
31053106
// OBSOLETED in 1.89.7 (from June 2023)

‎imgui_demo.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,16 +290,16 @@ void ImGui::ShowDemoWindow(bool* p_open)
290290
// Dear ImGui Tools (accessible from the "Tools" menu)
291291
static bool show_tool_metrics = false;
292292
static bool show_tool_debug_log = false;
293-
static bool show_tool_stack_tool = false;
293+
static bool show_tool_id_stack_tool = false;
294294
static bool show_tool_style_editor = false;
295295
static bool show_tool_about = false;
296296

297297
if (show_tool_metrics)
298298
ImGui::ShowMetricsWindow(&show_tool_metrics);
299299
if (show_tool_debug_log)
300300
ImGui::ShowDebugLogWindow(&show_tool_debug_log);
301-
if (show_tool_stack_tool)
302-
ImGui::ShowStackToolWindow(&show_tool_stack_tool);
301+
if (show_tool_id_stack_tool)
302+
ImGui::ShowIdStackToolWindow(&show_tool_id_stack_tool);
303303
if (show_tool_style_editor)
304304
{
305305
ImGui::Begin("Dear ImGui Style Editor", &show_tool_style_editor);
@@ -398,7 +398,7 @@ void ImGui::ShowDemoWindow(bool* p_open)
398398
#endif
399399
ImGui::MenuItem("Metrics/Debugger", NULL, &show_tool_metrics, has_debug_tools);
400400
ImGui::MenuItem("Debug Log", NULL, &show_tool_debug_log, has_debug_tools);
401-
ImGui::MenuItem("Stack Tool", NULL, &show_tool_stack_tool, has_debug_tools);
401+
ImGui::MenuItem("ID Stack Tool", NULL, &show_tool_id_stack_tool, has_debug_tools);
402402
ImGui::MenuItem("Style Editor", NULL, &show_tool_style_editor);
403403
ImGui::MenuItem("About Dear ImGui", NULL, &show_tool_about);
404404
ImGui::EndMenu();

‎imgui_internal.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ enum ImGuiDebugLogFlags_
17841784
struct ImGuiMetricsConfig
17851785
{
17861786
bool ShowDebugLog = false;
1787-
bool ShowStackTool = false;
1787+
bool ShowIdStackTool = false;
17881788
bool ShowWindowsRects = false;
17891789
bool ShowWindowsBeginOrder = false;
17901790
bool ShowTablesRects = false;
@@ -1806,8 +1806,8 @@ struct ImGuiStackLevelInfo
18061806
ImGuiStackLevelInfo() { memset(this, 0, sizeof(*this)); }
18071807
};
18081808

1809-
// State for Stack tool queries
1810-
struct ImGuiStackTool
1809+
// State for ID Stack tool queries
1810+
struct ImGuiIdStackTool
18111811
{
18121812
int LastActiveFrame;
18131813
int StackLevel; // -1: query stack and resize Results, >= 0: individual stack level
@@ -1816,7 +1816,7 @@ struct ImGuiStackTool
18161816
bool CopyToClipboardOnCtrlC;
18171817
float CopyToClipboardLastTime;
18181818

1819-
ImGuiStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
1819+
ImGuiIdStackTool() { memset(this, 0, sizeof(*this)); CopyToClipboardLastTime = -FLT_MAX; }
18201820
};
18211821

18221822
//-----------------------------------------------------------------------------
@@ -1888,7 +1888,7 @@ struct ImGuiContext
18881888
ImVec2 WheelingAxisAvg;
18891889

18901890
// Item/widgets state and tracking information
1891-
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]
1891+
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]
18921892
ImGuiID HoveredId; // Hovered widget, filled during the frame
18931893
ImGuiID HoveredIdPreviousFrame;
18941894
bool HoveredIdAllowOverlap;
@@ -2130,7 +2130,7 @@ struct ImGuiContext
21302130
ImU8 DebugItemPickerMouseButton;
21312131
ImGuiID DebugItemPickerBreakId; // Will call IM_DEBUG_BREAK() when encountering this ID
21322132
ImGuiMetricsConfig DebugMetricsConfig;
2133-
ImGuiStackTool DebugStackTool;
2133+
ImGuiIdStackTool DebugIdStackTool;
21342134

21352135
// Misc
21362136
float FramerateSecPerFrame[60]; // Calculate estimate of framerate for user over the last 60 frames..

0 commit comments

Comments
 (0)
⌂ 换网址