Skip to content

Commit 69a8b51

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

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
@@ -1317,6 +1317,14 @@ static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
13171317
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
13181318
static void* GImAllocatorUserData = NULL;
13191319

1320+
// [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)
1321+
static bool gIsInNodeEditorCanvas = false;
1322+
void Priv_ImGuiNodeEditor_EnterCanvas() { gIsInNodeEditorCanvas = true; }
1323+
void Priv_ImGuiNodeEditor_ExitCanvas() { gIsInNodeEditorCanvas = false; }
1324+
bool Priv_ImGuiNodeEditor_IsInCanvas() { return gIsInNodeEditorCanvas; }
1325+
// [/ADAPT_IMGUI_BUNDLE]
1326+
1327+
13201328
//-----------------------------------------------------------------------------
13211329
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
13221330
//-----------------------------------------------------------------------------
@@ -6242,6 +6250,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
62426250

62436251
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
62446252
{
6253+
// [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)
6254+
if (Priv_ImGuiNodeEditor_IsInCanvas())
6255+
{
6256+
const char* msg = R"(
6257+
Sorry, some ImGui widgets are incompatible withing imgui-node-editor, and cannot be used while its canvas is active.
6258+
Incompatible widgets are:
6259+
ImGui::InputTextMultiline()
6260+
ImGui::BeginListbox() and ImGui::EndListbox()
6261+
ImGui::BeginChild() and ImGui::EndChild()
6262+
6263+
)";
6264+
if ((name != nullptr) && (strlen(name) > 0))
6265+
fprintf(stderr, "%sImGui::BeginChildEx was called with name=%s\n", msg, name);
6266+
else
6267+
fprintf(stderr, "%s(no name available, please examine the call stack)\n", msg);
6268+
IM_ASSERT(false && "ImGui::BeginChild should not be called inside a node editor canvas");
6269+
}
6270+
// [/ADAPT_IMGUI_BUNDLE]
6271+
62456272
ImGuiContext& g = *GImGui;
62466273
ImGuiWindow* parent_window = g.CurrentWindow;
62476274
IM_ASSERT(id != 0);

0 commit comments

Comments
 (0)