Skip to content

Commit 02a1e65

Browse files
committed
[Bundle] inform that child windows are incompatible with imgui-node-editor
cf thedmd/imgui-node-editor#242 (comment)
1 parent 1942772 commit 02a1e65

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

imgui.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,13 @@ static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
12831283
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
12841284
static void* GImAllocatorUserData = NULL;
12851285

1286+
// [ADAPT_IMGUI_BUNDLE] inform that child windows are incompatible with imgui-node-editor (cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-2404714757)
1287+
static bool gIsInNodeEditorCanvas = false;
1288+
void Priv_ImGuiNodeEditor_EnterCanvas() { gIsInNodeEditorCanvas = true; }
1289+
void Priv_ImGuiNodeEditor_ExitCanvas() { gIsInNodeEditorCanvas = false; }
1290+
// [/ADAPT_IMGUI_BUNDLE]
1291+
1292+
12861293
//-----------------------------------------------------------------------------
12871294
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
12881295
//-----------------------------------------------------------------------------
@@ -5989,6 +5996,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
59895996

59905997
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
59915998
{
5999+
// [ADAPT_IMGUI_BUNDLE] inform that child windows are incompatible with imgui-node-editor (cf https://github.com/thedmd/imgui-node-editor/issues/242#issuecomment-2404714757)
6000+
if (gIsInNodeEditorCanvas)
6001+
{
6002+
const char* msg = R"(
6003+
Sorry, some ImGui widgets are incompatible withing imgui-node-editor, and cannot be used while its canvas is active.
6004+
Incompatible widgets are:
6005+
ImGui::InputTextMultiline()
6006+
ImGui::BeginListbox() and ImGui::EndListbox()
6007+
ImGui::BeginChild() and ImGui::EndChild()
6008+
6009+
)";
6010+
if ((name != nullptr) && (strlen(name) > 0))
6011+
fprintf(stderr, "%sImGui::BeginChildEx was called with name=%s\n", msg, name);
6012+
else
6013+
fprintf(stderr, "%s(no name available, please examine the call stack)\n", msg);
6014+
IM_ASSERT(false && "ImGui::BeginChild should not be called inside a node editor canvas");
6015+
}
6016+
// [/ADAPT_IMGUI_BUNDLE]
6017+
59926018
ImGuiContext& g = *GImGui;
59936019
ImGuiWindow* parent_window = g.CurrentWindow;
59946020
IM_ASSERT(id != 0);

0 commit comments

Comments
 (0)