MCPcopy Create free account
hub / github.com/RenderKit/embree / BeginChildEx

Method BeginChildEx

tutorials/common/imgui/imgui.cpp:5488–5537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5486}
5487
5488bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags)
5489{
5490 ImGuiContext& g = *GImGui;
5491 ImGuiWindow* parent_window = g.CurrentWindow;
5492
5493 flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow;
5494 flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag
5495
5496 // Size
5497 const ImVec2 content_avail = GetContentRegionAvail();
5498 ImVec2 size = ImFloor(size_arg);
5499 const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00);
5500 if (size.x <= 0.0f)
5501 size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues)
5502 if (size.y <= 0.0f)
5503 size.y = ImMax(content_avail.y + size.y, 4.0f);
5504 SetNextWindowSize(size);
5505
5506 // Build up name. If you need to append to a same child from multiple location in the ID stack, use BeginChild(ImGuiID id) with a stable value.
5507 const char* temp_window_name;
5508 if (name)
5509 ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id);
5510 else
5511 ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%08X", parent_window->Name, id);
5512
5513 const float backup_border_size = g.Style.ChildBorderSize;
5514 if (!border)
5515 g.Style.ChildBorderSize = 0.0f;
5516 bool ret = Begin(temp_window_name, NULL, flags);
5517 g.Style.ChildBorderSize = backup_border_size;
5518
5519 ImGuiWindow* child_window = g.CurrentWindow;
5520 child_window->ChildId = id;
5521 child_window->AutoFitChildAxises = (ImS8)auto_fit_axises;
5522
5523 // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually.
5524 // While this is not really documented/defined, it seems that the expected thing to do.
5525 if (child_window->BeginCount == 1)
5526 parent_window->DC.CursorPos = child_window->Pos;
5527
5528 // Process navigation-in immediately so NavInit can run on first frame
5529 if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavHasScroll))
5530 {
5531 FocusWindow(child_window);
5532 NavInitWindow(child_window, false);
5533 SetActiveID(id + 1, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item
5534 g.ActiveIdSource = ImGuiInputSource_Nav;
5535 }
5536 return ret;
5537}
5538
5539bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags)
5540{

Callers

nothing calls this directly

Calls 3

ImFloorFunction · 0.85
ImMaxFunction · 0.85

Tested by

no test coverage detected