Skip to content

Commit 52c093f

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 52c093f

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

imgui.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,6 +1283,14 @@ 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+
bool Priv_ImGuiNodeEditor_IsInCanvas() { return gIsInNodeEditorCanvas; }
1291+
// [/ADAPT_IMGUI_BUNDLE]
1292+
1293+
12861294
//-----------------------------------------------------------------------------
12871295
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
12881296
//-----------------------------------------------------------------------------
@@ -5989,6 +5997,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
59895997

59905998
bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child_flags, ImGuiWindowFlags window_flags)
59915999
{
6000+
// [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)
6001+
if (Priv_ImGuiNodeEditor_IsInCanvas())
6002+
{
6003+
const char* msg = R"(
6004+
Sorry, some ImGui widgets are incompatible withing imgui-node-editor, and cannot be used while its canvas is active.
6005+
Incompatible widgets are:
6006+
ImGui::InputTextMultiline()
6007+
ImGui::BeginListbox() and ImGui::EndListbox()
6008+
ImGui::BeginChild() and ImGui::EndChild()
6009+
6010+
)";
6011+
if ((name != nullptr) && (strlen(name) > 0))
6012+
fprintf(stderr, "%sImGui::BeginChildEx was called with name=%s\n", msg, name);
6013+
else
6014+
fprintf(stderr, "%s(no name available, please examine the call stack)\n", msg);
6015+
IM_ASSERT(false && "ImGui::BeginChild should not be called inside a node editor canvas");
6016+
}
6017+
// [/ADAPT_IMGUI_BUNDLE]
6018+
59926019
ImGuiContext& g = *GImGui;
59936020
ImGuiWindow* parent_window = g.CurrentWindow;
59946021
IM_ASSERT(id != 0);

0 commit comments

Comments
 (0)