Skip to content

Commit a317f59

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

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

imgui.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,14 @@ static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
13451345
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
13461346
static void* GImAllocatorUserData = NULL;
13471347

1348+
// [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)
1349+
static bool gIsInNodeEditorCanvas = false;
1350+
void Priv_ImGuiNodeEditor_EnterCanvas() { gIsInNodeEditorCanvas = true; }
1351+
void Priv_ImGuiNodeEditor_ExitCanvas() { gIsInNodeEditorCanvas = false; }
1352+
bool Priv_ImGuiNodeEditor_IsInCanvas() { return gIsInNodeEditorCanvas; }
1353+
// [/ADAPT_IMGUI_BUNDLE]
1354+
1355+
13481356
//-----------------------------------------------------------------------------
13491357
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
13501358
//-----------------------------------------------------------------------------
@@ -6429,6 +6437,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
64296437

64306438
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
64316439
{
6440+
// [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)
6441+
if (Priv_ImGuiNodeEditor_IsInCanvas())
6442+
{
6443+
const char* msg = R"(
6444+
Sorry, some ImGui widgets are incompatible withing imgui-node-editor, and cannot be used while its canvas is active.
6445+
Incompatible widgets are:
6446+
ImGui::InputTextMultiline()
6447+
ImGui::BeginListbox() and ImGui::EndListbox()
6448+
ImGui::BeginChild() and ImGui::EndChild()
6449+
6450+
)";
6451+
if ((name != nullptr) && (strlen(name) > 0))
6452+
fprintf(stderr, "%sImGui::BeginChildEx was called with name=%s\n", msg, name);
6453+
else
6454+
fprintf(stderr, "%s(no name available, please examine the call stack)\n", msg);
6455+
IM_ASSERT(false && "ImGui::BeginChild should not be called inside a node editor canvas");
6456+
}
6457+
// [/ADAPT_IMGUI_BUNDLE]
6458+
64326459
ImGuiContext& g = *GImGui;
64336460
ImGuiWindow* parent_window = g.CurrentWindow;
64346461
IM_ASSERT(id != 0);

0 commit comments

Comments
 (0)