MetaImGUI 1.0.0
ImGui Application Template for C++20
Loading...
Searching...
No Matches
Application.h
Go to the documentation of this file.
1/*
2 MetaImGUI
3 Copyright (C) 2026 A P Nicholson
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21#include "Signal.h"
22#include "UIEvents.h"
23
24#include <memory>
25#include <mutex>
26#include <string>
27#include <vector>
28
29// Forward declarations
30namespace MetaImGUI {
31class WindowManager;
32class UIRenderer;
33class UpdateChecker;
34class ConfigManager;
35class DialogManager;
36class ISSTracker;
37struct UpdateInfo;
38} // namespace MetaImGUI
39
40namespace MetaImGUI {
41
75public:
78
79 // Disable copy and move
80 Application(const Application&) = delete;
84
101 bool Initialize();
102
116 void Run();
117
133 void Shutdown();
134
139 [[nodiscard]] bool ShouldClose() const;
140
141private:
142 // Subsystem managers
143 std::unique_ptr<WindowManager> m_windowManager;
144 std::unique_ptr<UIRenderer> m_uiRenderer;
145 std::unique_ptr<UpdateChecker> m_updateChecker;
146 std::unique_ptr<ConfigManager> m_configManager;
147 std::unique_ptr<DialogManager> m_dialogManager;
148 std::unique_ptr<ISSTracker> m_issTracker;
149
150 // UI event bus: UIRenderer fires, Application reacts via slots in m_uiConnections.
151 UIEvents m_uiEvents;
152 std::vector<Connection> m_uiConnections;
153
154 // Application state
155 bool m_initialized = false;
156 bool m_showAboutWindow = false;
157 bool m_showDemoWindow = false;
158 bool m_showUpdateNotification = false;
159 bool m_updateCheckInProgress = false;
160 bool m_exitDialogActive = false; // re-entry guard so spamming Esc doesn't stack dialogs
161 bool m_showISSTracker = false;
162
163 // Update checking
164 std::unique_ptr<UpdateInfo> m_latestUpdateInfo;
165
166 // Thread-safe handoff of update results from worker thread to main thread
167 std::mutex m_updateResultMutex;
168 std::unique_ptr<UpdateInfo> m_pendingUpdateResult;
169
170 // Status bar state
171 std::string m_statusMessage;
172 float m_lastFrameTime = 0.0f;
173
174 // Private methods
175 void ProcessInput();
176 void Render();
177
178 // Render() helpers — split out so each concern fits on a screen.
179 void PollAsyncResults();
180 void RenderMainViewport();
181 void RenderFloatingWindows();
182 void RenderDialogs();
183
184 void CheckForUpdates();
185 void OnUpdateCheckComplete(const UpdateInfo& updateInfo);
186
187 // Coroutine-driven exit confirmation flow (collapses the previous
188 // OnExit -> set flag -> render-tick -> ShowConfirmation -> callback dance).
189 void StartExitFlow();
190
191 // Context recovery
192 bool OnContextLoss();
193
194 // Input callbacks
195 void OnFramebufferSizeChanged(int width, int height);
196 void OnKeyPressed(int key, int scancode, int action, int mods);
197 void OnWindowCloseRequested();
198
199 // UI event handlers
200 void OnExitRequested();
201 void OnToggleDemoWindow();
202 void OnCheckUpdatesRequested();
203 void OnShowAboutRequested();
204 void OnShowInputDialogRequested();
205 void OnToggleISSTracker();
206
207 // Window size constants
208 static constexpr int DEFAULT_WIDTH = 1200;
209 static constexpr int DEFAULT_HEIGHT = 800;
210 static constexpr const char* WINDOW_TITLE = "MetaImGUI - ImGui Application Template";
211};
212
213} // namespace MetaImGUI
Main application class that orchestrates the application lifecycle.
Definition Application.h:74
void Shutdown()
Shutdown the application and cleanup resources.
bool ShouldClose() const
Check if the application should close.
Application(Application &&)=delete
bool Initialize()
Initialize the application and all subsystems.
Application(const Application &)=delete
Application & operator=(const Application &)=delete
void Run()
Run the main application loop.
Application & operator=(Application &&)=delete
Configuration manager for persistent application settings.
Manager for common UI dialogs.
ISS Tracker that fetches ISS position data asynchronously.
Definition ISSTracker.h:51
Handles all ImGui rendering operations.
Definition UIRenderer.h:40
Manages GLFW window creation, lifecycle, and input handling.
Decoupled UI-event bus shared between UIRenderer and Application.
Definition UIEvents.h:33