| 10248 | }; |
| 10249 | |
| 10250 | void ShowExampleAppDocuments(bool* p_open) |
| 10251 | { |
| 10252 | static ExampleAppDocuments app; |
| 10253 | |
| 10254 | // Options |
| 10255 | static bool opt_reorderable = true; |
| 10256 | static ImGuiTabBarFlags opt_fitting_flags = ImGuiTabBarFlags_FittingPolicyDefault_; |
| 10257 | |
| 10258 | bool window_contents_visible = ImGui::Begin("Example: Documents", p_open, ImGuiWindowFlags_MenuBar); |
| 10259 | if (!window_contents_visible) |
| 10260 | { |
| 10261 | ImGui::End(); |
| 10262 | return; |
| 10263 | } |
| 10264 | |
| 10265 | // Menu |
| 10266 | if (ImGui::BeginMenuBar()) |
| 10267 | { |
| 10268 | if (ImGui::BeginMenu("File")) |
| 10269 | { |
| 10270 | int open_count = 0; |
| 10271 | for (MyDocument& doc : app.Documents) |
| 10272 | open_count += doc.Open ? 1 : 0; |
| 10273 | |
| 10274 | if (ImGui::BeginMenu("Open", open_count < app.Documents.Size)) |
| 10275 | { |
| 10276 | for (MyDocument& doc : app.Documents) |
| 10277 | if (!doc.Open && ImGui::MenuItem(doc.Name)) |
| 10278 | doc.DoOpen(); |
| 10279 | ImGui::EndMenu(); |
| 10280 | } |
| 10281 | if (ImGui::MenuItem("Close All Documents", NULL, false, open_count > 0)) |
| 10282 | for (MyDocument& doc : app.Documents) |
| 10283 | app.CloseQueue.push_back(&doc); |
| 10284 | if (ImGui::MenuItem("Exit") && p_open) |
| 10285 | *p_open = false; |
| 10286 | ImGui::EndMenu(); |
| 10287 | } |
| 10288 | ImGui::EndMenuBar(); |
| 10289 | } |
| 10290 | |
| 10291 | // [Debug] List documents with one checkbox for each |
| 10292 | for (int doc_n = 0; doc_n < app.Documents.Size; doc_n++) |
| 10293 | { |
| 10294 | MyDocument& doc = app.Documents[doc_n]; |
| 10295 | if (doc_n > 0) |
| 10296 | ImGui::SameLine(); |
| 10297 | ImGui::PushID(&doc); |
| 10298 | if (ImGui::Checkbox(doc.Name, &doc.Open)) |
| 10299 | if (!doc.Open) |
| 10300 | doc.DoForceClose(); |
| 10301 | ImGui::PopID(); |
| 10302 | } |
| 10303 | |
| 10304 | ImGui::Separator(); |
| 10305 | |
| 10306 | // About the ImGuiWindowFlags_UnsavedDocument / ImGuiTabItemFlags_UnsavedDocument flags. |
| 10307 | // They have multiple effects: |
no test coverage detected