WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit c36162f

Browse files
committed
Internals: add SetContextName() helper. (#9097)
Amend 37c243b.
1 parent f0699ef commit c36162f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

imgui.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4443,6 +4443,13 @@ void ImGui::Shutdown()
44434443
g.Initialized = false;
44444444
}
44454445

4446+
// When using multiple context it can be helpful to give name a name.
4447+
// (A) Will be visible in debugger, (B) Will be included in all IMGUI_DEBUG_LOG() calls, (C) Should be <= 15 characters long.
4448+
void ImGui::SetContextName(ImGuiContext* ctx, const char* name)
4449+
{
4450+
ImStrncpy(ctx->ContextName, name, IM_ARRAYSIZE(ctx->ContextName));
4451+
}
4452+
44464453
// No specific ordering/dependency support, will see as needed
44474454
ImGuiID ImGui::AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook)
44484455
{

imgui_internal.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3193,6 +3193,12 @@ namespace ImGui
31933193
IMGUI_API void Initialize();
31943194
IMGUI_API void Shutdown(); // Since 1.60 this is a _private_ function. You can call DestroyContext() to destroy the context created by CreateContext().
31953195

3196+
// Context name & generic context hooks
3197+
IMGUI_API void SetContextName(ImGuiContext* ctx, const char* name);
3198+
IMGUI_API ImGuiID AddContextHook(ImGuiContext* ctx, const ImGuiContextHook* hook);
3199+
IMGUI_API void RemoveContextHook(ImGuiContext* ctx, ImGuiID hook_to_remove);
3200+
IMGUI_API void CallContextHooks(ImGuiContext* ctx, ImGuiContextHookType type);
3201+
31963202
// NewFrame
31973203
IMGUI_API void UpdateInputEvents(bool trickle_fast_inputs);
31983204
IMGUI_API void UpdateHoveredWindowAndCaptureFlags(const ImVec2& mouse_pos);
@@ -3202,11 +3208,6 @@ namespace ImGui
32023208
IMGUI_API void UpdateMouseMovingWindowNewFrame();
32033209
IMGUI_API void UpdateMouseMovingWindowEndFrame();
32043210

3205-
// Generic context hooks
3206-
IMGUI_API ImGuiID AddContextHook(ImGuiContext* context, const ImGuiContextHook* hook);
3207-
IMGUI_API void RemoveContextHook(ImGuiContext* context, ImGuiID hook_to_remove);
3208-
IMGUI_API void CallContextHooks(ImGuiContext* context, ImGuiContextHookType type);
3209-
32103211
// Viewports
32113212
IMGUI_API void ScaleWindowsInViewport(ImGuiViewportP* viewport, float scale);
32123213
IMGUI_API void SetWindowViewport(ImGuiWindow* window, ImGuiViewportP* viewport);

0 commit comments

Comments
 (0)