| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // This file is part of INSTINCT, the INS Toolkit for Integrated | ||
| 2 | // Navigation Concepts and Training by the Institute of Navigation of | ||
| 3 | // the University of Stuttgart, Germany. | ||
| 4 | // | ||
| 5 | // This Source Code Form is subject to the terms of the Mozilla Public | ||
| 6 | // License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| 7 | // file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
| 8 | |||
| 9 | #include "MainMenuBar.hpp" | ||
| 10 | |||
| 11 | #include "FileMenu.hpp" | ||
| 12 | #include "EditMenu.hpp" | ||
| 13 | #include "RunMenu.hpp" | ||
| 14 | #include "TimeMenu.hpp" | ||
| 15 | #include "DebugMenu.hpp" | ||
| 16 | |||
| 17 | #include "internal/FlowManager.hpp" | ||
| 18 | #include "internal/gui/NodeEditorApplication.hpp" | ||
| 19 | |||
| 20 | #include <imgui.h> | ||
| 21 | #include <fmt/core.h> | ||
| 22 | |||
| 23 | ✗ | void NAV::gui::menus::ShowMainMenuBar(GlobalActions& globalAction) | |
| 24 | { | ||
| 25 | ✗ | auto& io = ImGui::GetIO(); | |
| 26 | |||
| 27 | ✗ | auto cursorPosition = ImGui::GetCursorPos(); | |
| 28 | ✗ | if (ImGui::BeginMainMenuBar()) | |
| 29 | { | ||
| 30 | ✗ | if (ImGui::BeginMenu("File")) | |
| 31 | { | ||
| 32 | ✗ | ShowFileMenu(globalAction); | |
| 33 | ✗ | ImGui::EndMenu(); | |
| 34 | } | ||
| 35 | ✗ | if (ImGui::BeginMenu("Edit")) | |
| 36 | { | ||
| 37 | ✗ | ShowEditMenu(); | |
| 38 | ✗ | ImGui::EndMenu(); | |
| 39 | } | ||
| 40 | ✗ | if (ImGui::BeginMenu("Run")) | |
| 41 | { | ||
| 42 | ✗ | ShowRunMenu(); | |
| 43 | ✗ | ImGui::EndMenu(); | |
| 44 | } | ||
| 45 | ✗ | if (ImGui::BeginMenu("Time")) | |
| 46 | { | ||
| 47 | ✗ | ShowTimeMenu(); | |
| 48 | ✗ | ImGui::EndMenu(); | |
| 49 | } | ||
| 50 | // #ifndef NDEBUG | ||
| 51 | ✗ | if (ImGui::BeginMenu("Debug")) | |
| 52 | { | ||
| 53 | ✗ | ShowDebugMenu(); | |
| 54 | ✗ | ImGui::EndMenu(); | |
| 55 | } | ||
| 56 | // #endif | ||
| 57 | ✗ | if (!NodeEditorApplication::hideFPS) | |
| 58 | { | ||
| 59 | // Move cursor to the right, as ImGui::Spring() is not working inside menu bars | ||
| 60 | ✗ | std::string text = fmt::format("FPS: {:.2f} ({:.2g}ms)", io.Framerate, io.Framerate != 0.0F ? 1000.0F / io.Framerate : 0.0F); | |
| 61 | ✗ | float textPosX = ImGui::GetCursorPosX() + ImGui::GetColumnWidth() - ImGui::CalcTextSize(text.c_str()).x | |
| 62 | ✗ | - ImGui::GetScrollX() - 2 * ImGui::GetStyle().ItemSpacing.x; | |
| 63 | ✗ | ImGui::SetCursorPosX(textPosX); | |
| 64 | ✗ | ImGui::Text("%s", text.c_str()); | |
| 65 | ✗ | } | |
| 66 | |||
| 67 | ✗ | ImGui::EndMainMenuBar(); | |
| 68 | } | ||
| 69 | // Move cursor down, because menu bar does not take up space | ||
| 70 | ✗ | ImGui::SetCursorPos({ cursorPosition.x, cursorPosition.y + ImGui::GetTextLineHeight() + 5 }); | |
| 71 | ✗ | } | |
| 72 |