Ember
Loading...
Searching...
No Matches
MainPanel.h
Go to the documentation of this file.
1#pragma once
2
3#include "Components/Panel.h" // EmberUI::Panel
4#include "Interfaces/IScene.h"
5#include <functional>
6#include <memory>
7#include <vector>
8#include <wx/aui/auibook.h>
9#include <wx/bmpbuttn.h>
10#include <wx/simplebook.h>
11#include <wx/toolbar.h>
12#include <wx/wx.h>
13
43class MainPanel : public EmberUI::Panel {
44 public:
45 MainPanel(wxWindow *parent);
46
47 // Panel title and type
48 wxString GetTitle() const override { return "Scene"; }
49 wxString GetPanelType() const override { return "Scene"; }
50
51 // Scene management
57 int AddScene(std::unique_ptr<IScene> scene);
58
65 int InsertScene(int index, std::unique_ptr<IScene> scene);
66
73 bool RemoveScene(int index, bool force = false);
74
79 IScene *GetActiveScene() const;
80
86 IScene *GetScene(int index) const;
87
92 size_t GetSceneCount() const { return m_scenes.size(); }
93
97 void SwitchToNextScene();
98
103
109 bool SetActiveScene(int index);
110
115 int CreateNewScene();
116
122 int CreateNewScene(const wxString &customTitle);
123
128 void UpdateActiveSceneTitle(const wxString &newTitle);
129
130 // Get the notebook for creating scenes with correct parent
131 wxAuiNotebook *GetNotebook() const { return m_sceneNotebook; }
132
137 void ApplyCanvasBackgroundColor(const wxColour &color);
138
139 using SceneChangedCallback = std::function<void(IScene *newScene, int newIndex)>;
141
142 using WelcomeActionCallback = std::function<void(const std::string &action, const std::string &param)>;
144
145 void ShowWelcome();
146 void ShowScenes();
147
148 private:
149 enum {
150 ID_NEW_SCENE_BUTTON = wxID_HIGHEST + 1000,
153 ID_OVERLAY_SHOW_ALL = wxID_HIGHEST + 2000,
163 };
164
165 void CreateLayout() override;
166 void CreateToolbar();
167
168 void DoCreateLayout();
169 void DoCreateToolbar();
170 wxPanel *CreateWelcomePanel();
171
172 void OnTabChanged(wxAuiNotebookEvent &event);
173 void OnTabClosed(wxAuiNotebookEvent &event);
174 void OnNewSceneButton(wxCommandEvent &event);
175 void OnOverlayButton(wxCommandEvent &event);
176 void OnOverlayMenuItem(wxCommandEvent &event);
177
180
181 wxString GenerateSceneTitle() const;
182 bool SceneTitleExists(const wxString &title) const;
183
184 wxStaticText *m_title;
185 wxToolBar *m_toolbar;
186 wxSimplebook *m_book = nullptr;
187 wxPanel *m_welcomePanel = nullptr;
188 wxAuiNotebook *m_sceneNotebook;
189
190 std::vector<std::unique_ptr<IScene>> m_scenes;
193 bool m_isClosingTab = false;
196
198};
Base class for all panels with layout, theme, and state management.
Definition Panel.h:11
Interface for scene-based UI components (e.g., views or screens).
Definition IScene.h:7
wxString GetPanelType() const override
Returns the panel type identifier.
Definition MainPanel.h:49
void SetSceneChangedCallback(SceneChangedCallback callback)
Definition MainPanel.h:140
bool SetActiveScene(int index)
Set the active scene by index.
std::function< void(const std::string &action, const std::string &param)> WelcomeActionCallback
Definition MainPanel.h:142
void UpdateActiveSceneTitle(const wxString &newTitle)
Update the title of the active scene.
void DoCreateLayout()
Definition MainPanel.cpp:32
std::vector< std::unique_ptr< IScene > > m_scenes
Definition MainPanel.h:190
@ ID_OVERLAY_HIDE_ALL
Definition MainPanel.h:154
@ ID_OVERLAY_MINIMAP
Definition MainPanel.h:156
@ ID_OVERLAY_BUTTON
Definition MainPanel.h:152
@ ID_OVERLAY_COORDINATE
Definition MainPanel.h:158
@ ID_OVERLAY_SELECTED_NODE
Definition MainPanel.h:159
@ ID_OVERLAY_GRID
Definition MainPanel.h:155
@ ID_OVERLAY_TREE_INFO
Definition MainPanel.h:160
@ ID_SCENE_NOTEBOOK
Definition MainPanel.h:151
@ ID_NEW_SCENE_BUTTON
Definition MainPanel.h:150
@ ID_OVERLAY_FPS
Definition MainPanel.h:161
@ ID_OVERLAY_BREADCRUMB
Definition MainPanel.h:157
@ ID_OVERLAY_SHOW_ALL
Definition MainPanel.h:153
@ ID_OVERLAY_CONTROLS_HELP
Definition MainPanel.h:162
wxPanel * m_welcomePanel
Definition MainPanel.h:187
void DoCreateToolbar()
void OnNewSceneButton(wxCommandEvent &event)
void ShowScenes()
void CreateToolbar()
wxAuiNotebook * GetNotebook() const
Definition MainPanel.h:131
int m_nextSceneNumber
Definition MainPanel.h:192
bool m_isClosingTab
Definition MainPanel.h:193
wxAuiNotebook * m_sceneNotebook
Definition MainPanel.h:188
int m_activeSceneIndex
Definition MainPanel.h:191
SceneChangedCallback m_sceneChangedCallback
Definition MainPanel.h:194
wxString GetTitle() const override
Returns the display title of the panel.
Definition MainPanel.h:48
void UpdateOverlayButtonState()
int AddScene(std::unique_ptr< IScene > scene)
Add a new scene to the panel.
void SwitchToNextScene()
Switch to the next scene (cyclic)
wxSimplebook * m_book
Definition MainPanel.h:186
void ShowWelcome()
MainPanel(wxWindow *parent)
int InsertScene(int index, std::unique_ptr< IScene > scene)
Insert a scene at a specific position.
std::function< void(IScene *newScene, int newIndex)> SceneChangedCallback
Definition MainPanel.h:139
size_t GetSceneCount() const
Get the number of scenes.
Definition MainPanel.h:92
void SetWelcomeActionCallback(WelcomeActionCallback cb)
Definition MainPanel.h:143
void CreateLayout() override
Hook: creates the panel layout. Override to customize.
Definition MainPanel.cpp:28
void OnOverlayMenuItem(wxCommandEvent &event)
bool RemoveScene(int index, bool force=false)
Remove a scene by index.
void OnTabChanged(wxAuiNotebookEvent &event)
wxString GenerateSceneTitle() const
void OnTabClosed(wxAuiNotebookEvent &event)
IScene * GetActiveScene() const
Get the currently active scene.
void ApplyOverlayToActiveCanvas()
wxDECLARE_EVENT_TABLE()
wxPanel * CreateWelcomePanel()
Definition MainPanel.cpp:64
bool SceneTitleExists(const wxString &title) const
void ApplyCanvasBackgroundColor(const wxColour &color)
Apply canvas background color to all scenes.
IScene * GetScene(int index) const
Get a scene by index.
void SwitchToPreviousScene()
Switch to the previous scene (cyclic)
WelcomeActionCallback m_welcomeActionCallback
Definition MainPanel.h:195
wxToolBar * m_toolbar
Definition MainPanel.h:185
wxStaticText * m_title
Definition MainPanel.h:184
int CreateNewScene()
Create a new empty behavior tree scene.
void OnOverlayButton(wxCommandEvent &event)