| 10588 | }; |
| 10589 | |
| 10590 | void ShowExampleAppDocuments(bool* p_open) |
| 10591 | { |
| 10592 | static ExampleAppDocuments app; |
| 10593 | |
| 10594 | // Options |
| 10595 | static bool opt_reorderable = true; |
| 10596 | static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; |
| 10597 | |
| 10598 | bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); |
| 10599 | if (!window_contents_visible) |
| 10600 | { |
| 10601 | ImGui::End(); |
| 10602 | return; |
| 10603 | } |
| 10604 | IMGUI_DEMO_MARKER("Examples/Documents"); |
| 10605 | |
| 10606 | // Menu |
| 10607 | if (ImGui::BeginMenuBar()) |
| 10608 | { |
| 10609 | if (ImGui::BeginMenu("File")) |
| 10610 | { |
| 10611 | int open_count = 0; |
| 10612 | for (MyDocument& doc : app.Documents) |
| 10613 | open_count += doc.Open ? 1 : 0; |
| 10614 | |
| 10615 | if (ImGui::BeginMenu("Open", open_count < app.Documents.Size)) |
| 10616 | { |
| 10617 | for (MyDocument& doc : app.Documents) |
| 10618 | if (!doc.Open && ImGui::MenuItem(doc.Name)) |
| 10619 | doc.DoOpen(); |
| 10620 | ImGui::EndMenu(); |
| 10621 | } |
| 10622 | if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) |
| 10623 | for (MyDocument& doc : app.Documents) |
| 10624 | app.CloseQueue.push_back(&doc); |
| 10625 | if (ImGui::MenuItem("Exit") && p_open) |
| 10626 | *p_open = false; |
| 10627 | ImGui::EndMenu(); |
| 10628 | } |
| 10629 | ImGui::EndMenuBar(); |
| 10630 | } |
| 10631 | |
| 10632 | // [Debug] List documents with one checkbox for each |
| 10633 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 10634 | { |
| 10635 | MyDocument& doc = app.Documents[doc_n]; |
| 10636 | if (doc_n > 0) |
| 10637 | ImGui::SameLine(); |
| 10638 | ImGui::PushID(&doc); |
| 10639 | if (ImGui::Checkbox(doc.Name, &doc.Open)) |
| 10640 | if (!doc.Open) |
| 10641 | doc.DoForceClose(); |
| 10642 | ImGui::PopID(); |
| 10643 | } |
| 10644 | |
| 10645 | ImGui::Separator(); |
| 10646 | |
| 10647 | // About the ImGuiWindowFlags_UnsavedDocument / ImGuiTabItemFlags_UnsavedDocument flags. |
no test coverage detected