| 7532 | } |
| 7533 | |
| 7534 | void ShowExampleAppDocuments(bool* p_open) |
| 7535 | { |
| 7536 | static ExampleAppDocuments app; |
| 7537 | |
| 7538 | // Options |
| 7539 | static bool opt_reorderable = true; |
| 7540 | static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; |
| 7541 | |
| 7542 | bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); |
| 7543 | if (!window_contents_visible) |
| 7544 | { |
| 7545 | ImGui::End(); |
| 7546 | return; |
| 7547 | } |
| 7548 | |
| 7549 | // Menu |
| 7550 | if (ImGui::BeginMenuBar()) |
| 7551 | { |
| 7552 | if (ImGui::BeginMenu("File")) |
| 7553 | { |
| 7554 | int open_count = 0; |
| 7555 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 7556 | open_count += app.Documents[doc_n].Open ? 1 : 0; |
| 7557 | |
| 7558 | if (ImGui::BeginMenu("Open", open_count < app.Documents.Size)) |
| 7559 | { |
| 7560 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 7561 | { |
| 7562 | MyDocument* doc = &app.Documents[doc_n]; |
| 7563 | if (!doc->Open) |
| 7564 | if (ImGui::MenuItem(doc->Name)) |
| 7565 | doc->DoOpen(); |
| 7566 | } |
| 7567 | ImGui::EndMenu(); |
| 7568 | } |
| 7569 | if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) |
| 7570 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 7571 | app.Documents[doc_n].DoQueueClose(); |
| 7572 | if (ImGui::MenuItem("Exit", "Alt+F4")) {} |
| 7573 | ImGui::EndMenu(); |
| 7574 | } |
| 7575 | ImGui::EndMenuBar(); |
| 7576 | } |
| 7577 | |
| 7578 | // [Debug] List documents with one checkbox for each |
| 7579 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 7580 | { |
| 7581 | MyDocument* doc = &app.Documents[doc_n]; |
| 7582 | if (doc_n > 0) |
| 7583 | ImGui::SameLine(); |
| 7584 | ImGui::PushID(doc); |
| 7585 | if (ImGui::Checkbox(doc->Name, &doc->Open)) |
| 7586 | if (!doc->Open) |
| 7587 | doc->DoForceClose(); |
| 7588 | ImGui::PopID(); |
| 7589 | } |
| 7590 | |
| 7591 | ImGui::Separator(); |
no test coverage detected