-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathProjectMGUI.h
137 lines (102 loc) · 3.67 KB
/
ProjectMGUI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#pragma once
#include "AboutWindow.h"
#include "HelpWindow.h"
#include "MainMenu.h"
#include "ToastMessage.h"
#include "SettingsWindow.h"
#include "notifications/DisplayToastNotification.h"
#include <SDL2/SDL.h>
#include <Poco/Logger.h>
#include <Poco/NObserver.h>
#include <Poco/Util/Subsystem.h>
struct ImFont;
class ProjectMWrapper;
class SDLRenderingWindow;
class ProjectMGUI : public Poco::Util::Subsystem
{
public:
const char* name() const override;
void initialize(Poco::Util::Application& app) override;
void uninitialize() override;
/**
* @brief Updates the font size after DPI changes.
*/
void UpdateFontSize();
/**
* @brief Processes SDL input events in Dear ImGui.
* @param event The SDL event.
*/
void ProcessInput(const SDL_Event& event);
/**
* @brief Displays or hides the UI.
*/
void Toggle();
/**
* @brief Sets the visibility of the UI.
* @param visible true if the UI will be rendered, false if not.
*/
void Visible(bool visible);
/**
* @brief Returns the visibiity of the UI.
* @return true if the UI is visible, false if not.
*/
bool Visible() const;
/**
* @brief Draws the UI, including toasts.
* If neither a toast nor the UI are visible, this is basically a no-op.
*/
void Draw();
/**
* @brief Tells the caller whether the UI currently wants the keyboard input.
* @return True if the UI wants the keyboard input, false if the app should process the events.
*/
bool WantsKeyboardInput();
/**
* @brief Tells the caller whether the UI currently wants the mouse input.
* @return True if the UI wants the mouse input, false if the app should process the events.
*/
bool WantsMouseInput();
/**
* @brief Pushes the "toast" font to the render stack
*/
void PushToastFont();
/**
* @brief Pushes the "UI" font to the render stack
*/
void PushUIFont();
/**
* @brief Pops the last font from the stack
*/
void PopFont();
/**
* @brief Displays the settings window.
*/
void ShowSettingsWindow();
/**
* @brief Displays the about window.
*/
void ShowAboutWindow();
/**
* @brief Displays the help window.
*/
void ShowHelpWindow();
private:
float GetScalingFactor();
void DisplayToastNotificationHandler(const Poco::AutoPtr<DisplayToastNotification>& notification);
ProjectMWrapper* _projectMWrapper{nullptr};
Poco::NObserver<ProjectMGUI, DisplayToastNotification> _displayToastNotificationObserver{*this, &ProjectMGUI::DisplayToastNotificationHandler};
std::string _uiIniFileName; //!< Path and filename of the UI configuration (positions etc.)
SDL_Window* _renderingWindow{nullptr}; //!< Pointer to the SDL window used for rendering.
SDL_GLContext _glContext{nullptr}; //!< Pointer to the OpenGL context associated with the window.
ImFont* _uiFont{nullptr}; //!< Main UI font (monospaced).
ImFont* _toastFont{nullptr}; //!< Toast message font (sans-serif, larger).
uint64_t _lastFrameTicks{0}; //!< Tick count of the last frame (see SDL_GetTicks64)
float _textScalingFactor{0.0f}; //!< The text scaling factor.
Poco::Logger& _logger{Poco::Logger::get("ProjectMGUI")}; //!< The class logger.
MainMenu _mainMenu{*this};
SettingsWindow _settingsWindow{*this, _logger}; //!< The settings window.
AboutWindow _aboutWindow{*this}; //!< The about window.
HelpWindow _helpWindow; //!< Help window with shortcuts and tips.
std::unique_ptr<ToastMessage> _toast; //!< Current toast to be displayed.
bool _visible{false}; //!< Flag for settings window visibility.
};