Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
PanelManager.h
Go to the documentation of this file.
1/*
2Olympe Engine V2 2025
3Nicolas Chereau
4nchereau@gmail.com
5
6Purpose:
7- PanelManager is a singleton responsible for creating and managing
8 lightweight tool windows (log window, object inspector, tree view)
9 using the Win32 API when available. The actual rendering/content of
10 these windows is implemented later; this class provides creation,
11 visibility and lifetime management.
12
13Notes:
14- On non-Windows platforms the implementation is a no-op (stubs), so
15 the engine remains portable.
16*/
17
18#pragma once
19
20#include <string>
21#include <unordered_map>
22#include <mutex>
23#include <vector>
24#include <SDL3/SDL.h>
25#include "system/message.h"
26
27#ifdef _WIN32
28#include <windows.h>
29#endif
30
31#include <SDL3/SDL.h>
32
33
35{
36public:
38 virtual ~PanelManager();
39
40 static PanelManager& GetInstance();
41 static PanelManager& Get() { return GetInstance(); }
42
43 // Initialize/shutdown the manager (register window class on Windows)
44 void Initialize();
45 void Shutdown();
46
47 // Create predefined panels (id is used to reference)
48 void CreateLogWindow();
53
54 // Show/hide panels
55 void ShowPanel(const std::string& id);
56 void HidePanel(const std::string& id);
57 bool IsPanelVisible(const std::string& id) const;
58
59 // Append text to the log window (thread-safe)
60 void AppendLog(const std::string& text);
61
62 // Attach a menu to the SDL main window (Windows only)
64
65 // Process internal tasks (on Windows: pump messages for tool windows)
66 void HandleEvent(const SDL_Event* ev);
67
68 //OnEvent
69 virtual void OnEvent(const Message& msg) ;
70
71 static int LogPanelWidth;
72 static int LogPanelHeight;
73 static int LogPanelPosX;
74 static int LogPanelPosY;
75
80
85
86 private:
87 std::string name;
88
89 struct Panel
90 {
91 std::string id;
92 std::string title;
93 bool visible = false;
94#ifdef _WIN32
95 HWND hwnd = nullptr;
96 HWND hwndChild = nullptr; // child control (e.g. edit for log)
97 HMENU hMenu = nullptr; // optional per-panel menu
98#else
99 void* hwnd = nullptr; // stub
100#endif
101 };
102
103 void CreatePanel(const std::string& id, const std::string& title);
105
106 std::unordered_map<std::string, Panel> m_panels_;
107 std::vector<std::string> m_pendingLogs_; // logs received before the UI control exists
108 mutable std::mutex m_mutex_;
109
110#ifdef _WIN32
112 HWND m_mainHwnd = nullptr;
113 HMENU m_mainMenu = nullptr;
114
116
117 // menu command IDs
118 enum MenuIDs
119 {
120 IDM_PANEL_LOG = 40001,
121 IDM_PANEL_INSPECTOR = 40002,
122 IDM_PANEL_TREE = 40003,
123 IDM_PANEL_INPUTS = 40004,
124 IDM_FILE_NEW = 40100,
125 IDM_FILE_LOAD = 40101,
126 IDM_FILE_SAVE = 40102,
129 IDM_WINDOW_LOG = 40112,
130 IDM_WINDOW_INPUTS = 40113,
131 IDM_ABOUT = 40200
132 };
133#endif
134};
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
void ShowPanel(const std::string &id)
static int LogPanelHeight
void CreateMainMenuWindow()
void UpdateInputsInspectorList()
static int TreeViewPanelPosX
static PanelManager & Get()
virtual ~PanelManager()
static int LogPanelPosX
void AppendLog(const std::string &text)
static int InspectorPanelHeight
void CreateInputsInspectorWindow()
void HidePanel(const std::string &id)
void CreateObjectInspectorWindow()
std::unordered_map< std::string, Panel > m_panels_
bool IsPanelVisible(const std::string &id) const
static int InspectorPanelWidth
static int InspectorPanelPosY
static int LogPanelWidth
std::vector< std::string > m_pendingLogs_
void CreateTreeViewWindow()
void CreateLogWindow()
static int TreeViewPanelPosY
void CreatePanel(const std::string &id, const std::string &title)
std::string name
void AttachToSDLWindow(SDL_Window *sdlWindow)
static int LogPanelPosY
static PanelManager & GetInstance()
void HandleEvent(const SDL_Event *ev)
virtual void OnEvent(const Message &msg)
static int InspectorPanelPosX
static int TreeViewPanelHeight
static int TreeViewPanelWidth
std::mutex m_mutex_