| 5356 | } |
| 5357 | |
| 5358 | bool ImGui::BeginChildEx(const char* name, ImGuiID id, const ImVec2& size_arg, bool border, ImGuiWindowFlags flags) |
| 5359 | { |
| 5360 | ImGuiContext& g = *GImGui; |
| 5361 | ImGuiWindow* parent_window = g.CurrentWindow; |
| 5362 | |
| 5363 | flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_ChildWindow; |
| 5364 | flags |= (parent_window->Flags & ImGuiWindowFlags_NoMove); // Inherit the NoMove flag |
| 5365 | |
| 5366 | // Size |
| 5367 | const ImVec2 content_avail = GetContentRegionAvail(); |
| 5368 | ImVec2 size = ImFloor(size_arg); |
| 5369 | const int auto_fit_axises = ((size.x == 0.0f) ? (1 << ImGuiAxis_X) : 0x00) | ((size.y == 0.0f) ? (1 << ImGuiAxis_Y) : 0x00); |
| 5370 | if (size.x <= 0.0f) |
| 5371 | size.x = ImMax(content_avail.x + size.x, 4.0f); // Arbitrary minimum child size (0.0f causing too many issues) |
| 5372 | if (size.y <= 0.0f) |
| 5373 | size.y = ImMax(content_avail.y + size.y, 4.0f); |
| 5374 | SetNextWindowSize(size); |
| 5375 | |
| 5376 | // 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. |
| 5377 | const char* temp_window_name; |
| 5378 | if (name) |
| 5379 | ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%s_%08X", parent_window->Name, name, id); |
| 5380 | else |
| 5381 | ImFormatStringToTempBuffer(&temp_window_name, NULL, "%s/%08X", parent_window->Name, id); |
| 5382 | |
| 5383 | const float backup_border_size = g.Style.ChildBorderSize; |
| 5384 | if (!border) |
| 5385 | g.Style.ChildBorderSize = 0.0f; |
| 5386 | bool ret = Begin(temp_window_name, NULL, flags); |
| 5387 | g.Style.ChildBorderSize = backup_border_size; |
| 5388 | |
| 5389 | ImGuiWindow* child_window = g.CurrentWindow; |
| 5390 | child_window->ChildId = id; |
| 5391 | child_window->AutoFitChildAxises = (ImS8)auto_fit_axises; |
| 5392 | |
| 5393 | // Set the cursor to handle case where the user called SetNextWindowPos()+BeginChild() manually. |
| 5394 | // While this is not really documented/defined, it seems that the expected thing to do. |
| 5395 | if (child_window->BeginCount == 1) |
| 5396 | parent_window->DC.CursorPos = child_window->Pos; |
| 5397 | |
| 5398 | // Process navigation-in immediately so NavInit can run on first frame |
| 5399 | // Can enter a child if (A) it has navigatable items or (B) it can be scrolled. |
| 5400 | const ImGuiID temp_id_for_activation = ImHashStr("##Child", 0, id); |
| 5401 | if (g.ActiveId == temp_id_for_activation) |
| 5402 | ClearActiveID(); |
| 5403 | if (g.NavActivateId == id && !(flags & ImGuiWindowFlags_NavFlattened) && (child_window->DC.NavLayersActiveMask != 0 || child_window->DC.NavWindowHasScrollY)) |
| 5404 | { |
| 5405 | FocusWindow(child_window); |
| 5406 | NavInitWindow(child_window, false); |
| 5407 | SetActiveID(temp_id_for_activation, child_window); // Steal ActiveId with another arbitrary id so that key-press won't activate child item |
| 5408 | g.ActiveIdSource = g.NavInputSource; |
| 5409 | } |
| 5410 | return ret; |
| 5411 | } |
| 5412 | |
| 5413 | bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border, ImGuiWindowFlags extra_flags) |
| 5414 | { |
nothing calls this directly
no test coverage detected