Skip to content

Commit b3cec31

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

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
@@ -1362,6 +1362,14 @@ static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
13621362
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
13631363
static void* GImAllocatorUserData = NULL;
13641364

1365+
// [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)
1366+
static bool gIsInNodeEditorCanvas = false;
1367+
void Priv_ImGuiNodeEditor_EnterCanvas() { gIsInNodeEditorCanvas = true; }
1368+
void Priv_ImGuiNodeEditor_ExitCanvas() { gIsInNodeEditorCanvas = false; }
1369+
bool Priv_ImGuiNodeEditor_IsInCanvas() { return gIsInNodeEditorCanvas; }
1370+
// [/ADAPT_IMGUI_BUNDLE]
1371+
1372+
13651373
//-----------------------------------------------------------------------------
13661374
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
13671375
//-----------------------------------------------------------------------------
@@ -6456,6 +6464,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
64566464

64576465
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
64586466
{
6467+
// [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)
6468+
if (Priv_ImGuiNodeEditor_IsInCanvas())
6469+
{
6470+
const char* msg = R"(
6471+
Sorry, some ImGui widgets are incompatible withing imgui-node-editor, and cannot be used while its canvas is active.
6472+
Incompatible widgets are:
6473+
ImGui::InputTextMultiline()
6474+
ImGui::BeginListbox() and ImGui::EndListbox()
6475+
ImGui::BeginChild() and ImGui::EndChild()
6476+
6477+
)";
6478+
if ((name != nullptr) && (strlen(name) > 0))
6479+
fprintf(stderr, "%sImGui::BeginChildEx was called with name=%s\n", msg, name);
6480+
else
6481+
fprintf(stderr, "%s(no name available, please examine the call stack)\n", msg);
6482+
IM_ASSERT(false && "ImGui::BeginChild should not be called inside a node editor canvas");
6483+
}
6484+
// [/ADAPT_IMGUI_BUNDLE]
6485+
64596486
ImGuiContext& g = *GImGui;
64606487
ImGuiWindow* parent_window = g.CurrentWindow;
64616488
IM_ASSERT(id != 0);

0 commit comments

Comments
 (0)