Ember
Loading...
Searching...
No Matches
MainPanel.h
Go to the documentation of this file.
1#pragma once
2
3#include "Components/Panel.h"
4#include "Scenes/IScene.h"
5#include <functional>
6#include <memory>
7#include <vector>
8#include <wx/aui/auibook.h>
9#include <wx/toolbar.h>
10#include <wx/wx.h>
11
41class MainPanel : public Panel {
42 public:
43 MainPanel(wxWindow *parent);
44
45 // Panel title and type
46 wxString GetTitle() const override { return "Scene"; }
47 wxString GetPanelType() const override { return "Scene"; }
48
49 // Scene management
55 int AddScene(std::unique_ptr<IScene> scene);
56
62 bool RemoveScene(int index);
63
68 IScene *GetActiveScene() const;
69
75 IScene *GetScene(int index) const;
76
81 size_t GetSceneCount() const { return m_scenes.size(); }
82
86 void SwitchToNextScene();
87
92
98 bool SetActiveScene(int index);
99
104 int CreateNewScene();
105
111 int CreateNewScene(const wxString &customTitle);
112
117 void UpdateActiveSceneTitle(const wxString &newTitle);
118
119 // Get the notebook for creating scenes with correct parent
120 wxAuiNotebook *GetNotebook() const { return m_sceneNotebook; }
121
126 void ApplyCanvasBackgroundColor(const wxColour &color);
127
128 using SceneChangedCallback = std::function<void(IScene *newScene, int newIndex)>;
130
131 private:
132 // UI event IDs
133 enum { ID_NEW_SCENE_BUTTON = wxID_HIGHEST + 1000, ID_SCENE_NOTEBOOK };
134
135 void CreateLayout() override;
136 void CreateToolbar();
137
138 // Non-virtual helpers safe to call from constructor
139 void DoCreateLayout();
140 void DoCreateToolbar();
141
142 // Event handlers
143 void OnTabChanged(wxAuiNotebookEvent &event);
144 void OnTabClosed(wxAuiNotebookEvent &event);
145 void OnNewSceneButton(wxCommandEvent &event);
146
147 // Helper methods
148 wxString GenerateSceneTitle() const;
149 bool SceneTitleExists(const wxString &title) const;
150
151 wxStaticText *m_title;
152 wxToolBar *m_toolbar;
153 wxAuiNotebook *m_sceneNotebook;
154
155 // Scene management
156 std::vector<std::unique_ptr<IScene>> m_scenes;
160
162};
Abstract interface for different scene types in the MainPanel.
Definition IScene.h:25
wxString GetPanelType() const override
Get a unique identifier for this panel type.
Definition MainPanel.h:47
void SetSceneChangedCallback(SceneChangedCallback callback)
Definition MainPanel.h:129
bool SetActiveScene(int index)
Set the active scene by index.
void UpdateActiveSceneTitle(const wxString &newTitle)
Update the title of the active scene.
void DoCreateLayout()
Definition MainPanel.cpp:25
bool RemoveScene(int index)
Remove a scene by index.
Definition MainPanel.cpp:99
std::vector< std::unique_ptr< IScene > > m_scenes
Definition MainPanel.h:156
@ ID_SCENE_NOTEBOOK
Definition MainPanel.h:133
@ ID_NEW_SCENE_BUTTON
Definition MainPanel.h:133
void DoCreateToolbar()
Definition MainPanel.cpp:51
void OnNewSceneButton(wxCommandEvent &event)
void CreateToolbar()
Definition MainPanel.cpp:47
wxAuiNotebook * GetNotebook() const
Definition MainPanel.h:120
int m_nextSceneNumber
Definition MainPanel.h:158
wxAuiNotebook * m_sceneNotebook
Definition MainPanel.h:153
int m_activeSceneIndex
Definition MainPanel.h:157
SceneChangedCallback m_sceneChangedCallback
Definition MainPanel.h:159
wxString GetTitle() const override
Get the display title for this panel.
Definition MainPanel.h:46
int AddScene(std::unique_ptr< IScene > scene)
Add a new scene to the panel.
Definition MainPanel.cpp:63
void SwitchToNextScene()
Switch to the next scene (cyclic)
MainPanel(wxWindow *parent)
std::function< void(IScene *newScene, int newIndex)> SceneChangedCallback
Definition MainPanel.h:128
size_t GetSceneCount() const
Get the number of scenes.
Definition MainPanel.h:81
void CreateLayout() override
Create the panel's UI layout Called during initialization.
Definition MainPanel.cpp:21
void OnTabChanged(wxAuiNotebookEvent &event)
wxString GenerateSceneTitle() const
void OnTabClosed(wxAuiNotebookEvent &event)
IScene * GetActiveScene() const
Get the currently active scene.
wxDECLARE_EVENT_TABLE()
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)
wxToolBar * m_toolbar
Definition MainPanel.h:152
wxStaticText * m_title
Definition MainPanel.h:151
int CreateNewScene()
Create a new empty behavior tree scene.
Panel(wxWindow *parent, const wxString &name="Panel", long style=wxTAB_TRAVERSAL)
Constructor.