0.4.1
Loading...
Searching...
No Matches
MainMenuBar.cpp
Go to the documentation of this file.
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
19
20#include <imgui.h>
21#include <fmt/core.h>
22
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 {
38 ImGui::EndMenu();
39 }
40 if (ImGui::BeginMenu("Run"))
41 {
43 ImGui::EndMenu();
44 }
45 if (ImGui::BeginMenu("Time"))
46 {
48 ImGui::EndMenu();
49 }
50 // #ifndef NDEBUG
51 if (ImGui::BeginMenu("Debug"))
52 {
54 ImGui::EndMenu();
55 }
56 // #endif
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}
Debug Menu.
Edit Menu.
The File Menu.
Save/Load the Nodes.
GlobalActions
Possible Global Actions to perform in the GUI.
Main Menu Bar.
Run Menu.
Time Menu.
static bool hideFPS
Hide FPS counter.
void ShowFileMenu(GlobalActions &globalAction)
Show the file menu dropdown.
Definition FileMenu.cpp:21
void ShowMainMenuBar(GlobalActions &globalAction)
Shows the main menu bar and moves down the cursor.
void ShowDebugMenu()
Show the debug menu dropdown.
Definition DebugMenu.cpp:19
void ShowEditMenu()
Show the edit menu dropdown.
Definition EditMenu.cpp:15
void ShowTimeMenu()
Show the time menu dropdown.
Definition TimeMenu.cpp:19
void ShowRunMenu()
Show the run menu dropdown.
Definition RunMenu.cpp:19