Skip to content

Commit ecadf3a

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

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
@@ -1303,6 +1303,14 @@ static ImGuiMemAllocFunc GImAllocatorAllocFunc = MallocWrapper;
13031303
static ImGuiMemFreeFunc GImAllocatorFreeFunc = FreeWrapper;
13041304
static void* GImAllocatorUserData = NULL;
13051305

1306+
// [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)
1307+
static bool gIsInNodeEditorCanvas = false;
1308+
void Priv_ImGuiNodeEditor_EnterCanvas() { gIsInNodeEditorCanvas = true; }
1309+
void Priv_ImGuiNodeEditor_ExitCanvas() { gIsInNodeEditorCanvas = false; }
1310+
bool Priv_ImGuiNodeEditor_IsInCanvas() { return gIsInNodeEditorCanvas; }
1311+
// [/ADAPT_IMGUI_BUNDLE]
1312+
1313+
13061314
//-----------------------------------------------------------------------------
13071315
// [SECTION] USER FACING STRUCTURES (ImGuiStyle, ImGuiIO, ImGuiPlatformIO)
13081316
//-----------------------------------------------------------------------------
@@ -6247,6 +6255,25 @@ bool ImGui::BeginChild(ImGuiID id, const ImVec2& size_arg, ImGuiChildFlags child
62476255

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

0 commit comments

Comments
 (0)