MCPcopy Create free account
hub / github.com/OpenImageDebugger/OpenImageDebugger / draw_menu_bar

Function draw_menu_bar

src/host/ui/panels/menu_bar.cpp:32–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace oid::host {
31
32void draw_menu_bar(bool& request_quit) {
33 bool open_about = false;
34
35 if (ImGui::BeginMainMenuBar()) {
36 if (ImGui::BeginMenu("File")) {
37 if (ImGui::MenuItem("Quit")) {
38 request_quit = true;
39 }
40 ImGui::EndMenu();
41 }
42 if (ImGui::BeginMenu("Help")) {
43 if (ImGui::MenuItem("About")) {
44 open_about = true;
45 }
46 ImGui::EndMenu();
47 }
48 ImGui::EndMainMenuBar();
49 }
50
51 if (open_about) {
52 ImGui::OpenPopup("About");
53 }
54
55 // Centered on the viewport rather than wherever the menu happened to
56 // be, since the trigger is a top-of-screen menu click.
57 const ImGuiViewport* vp = ImGui::GetMainViewport();
58 ImGui::SetNextWindowPos(ImVec2(vp->WorkPos.x + vp->WorkSize.x * 0.5f,
59 vp->WorkPos.y + vp->WorkSize.y * 0.5f),
60 ImGuiCond_Appearing,
61 ImVec2(0.5f, 0.5f));
62 if (ImGui::BeginPopupModal(
63 "About", nullptr, ImGuiWindowFlags_AlwaysAutoResize)) {
64 ImGui::TextUnformatted("OpenImageDebugger (ImGui frontend)");
65 if (ImGui::Button("Close")) {
66 ImGui::CloseCurrentPopup();
67 }
68 ImGui::EndPopup();
69 }
70}
71
72} // namespace oid::host

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected