Ember
Loading...
Searching...
No Matches
MainPanel Class Reference

Central panel for managing and displaying behavior tree scenes. More...

#include <MainPanel.h>

Inheritance diagram for MainPanel:
Panel IPanel

Public Types

using SceneChangedCallback = std::function<void(IScene *newScene, int newIndex)>

Public Member Functions

 MainPanel (wxWindow *parent)
wxString GetTitle () const override
 Get the display title for this panel.
wxString GetPanelType () const override
 Get a unique identifier for this panel type.
int AddScene (std::unique_ptr< IScene > scene)
 Add a new scene to the panel.
bool RemoveScene (int index)
 Remove a scene by index.
IScene * GetActiveScene () const
 Get the currently active scene.
IScene * GetScene (int index) const
 Get a scene by index.
size_t GetSceneCount () const
 Get the number of scenes.
void SwitchToNextScene ()
 Switch to the next scene (cyclic)
void SwitchToPreviousScene ()
 Switch to the previous scene (cyclic)
bool SetActiveScene (int index)
 Set the active scene by index.
int CreateNewScene ()
 Create a new empty behavior tree scene.
int CreateNewScene (const wxString &customTitle)
 Create a new empty behavior tree scene with custom title.
void UpdateActiveSceneTitle (const wxString &newTitle)
 Update the title of the active scene.
wxAuiNotebook * GetNotebook () const
void ApplyCanvasBackgroundColor (const wxColour &color)
 Apply canvas background color to all scenes.
void SetSceneChangedCallback (SceneChangedCallback callback)
Public Member Functions inherited from Panel
 Panel (wxWindow *parent, const wxString &name="Panel", long style=wxTAB_TRAVERSAL)
 Constructor.
virtual ~Panel ()
 Destructor.
wxPanel * GetPanel () override
 Get the main panel widget.
wxString GetTitle () const override
 Get the display title for this panel.
wxString GetPanelType () const override
 Get a unique identifier for this panel type.
void Initialize () override
 Initialize the panel after construction Called once after the panel is created and configured.
void Refresh () override
 Called when the panel should refresh its display This should update the panel's content to reflect current state.
void OnActivated () override
 Called when the panel becomes visible/active.
void OnDeactivated () override
 Called when the panel becomes hidden/inactive.
void Cleanup () override
 Called when the panel is about to be destroyed Use this for cleanup operations.
bool IsValid () const override
 Check if the panel is in a valid state.
wxString SerializeState () const override
 Serialize the panel's current state to a string.
void DeserializeState (const wxString &state) override
 Restore the panel's state from serialized data.
bool HasUnsavedChanges () const override
 Check if this panel has unsaved changes.
bool Save () override
 Save the panel's data (if applicable)
bool SupportsOperation (const wxString &operation) const override
 Check if this panel supports the given operation.
bool ExecuteOperation (const wxString &operation, const wxString &parameter="") override
 Execute a named operation on this panel.
wxString GetName () const override
void SetName (const wxString &name) override
void SetTitle (const wxString &title)
void SetPanelType (const wxString &type)
Public Member Functions inherited from IPanel
virtual ~IPanel ()=default

Private Types

enum  { ID_NEW_SCENE_BUTTON = wxID_HIGHEST + 1000 , ID_SCENE_NOTEBOOK }

Private Member Functions

void CreateLayout () override
 Create the panel's UI layout Called during initialization.
void CreateToolbar ()
void DoCreateLayout ()
void DoCreateToolbar ()
void OnTabChanged (wxAuiNotebookEvent &event)
void OnTabClosed (wxAuiNotebookEvent &event)
void OnNewSceneButton (wxCommandEvent &event)
wxString GenerateSceneTitle () const
bool SceneTitleExists (const wxString &title) const
 wxDECLARE_EVENT_TABLE ()

Private Attributes

wxStaticText * m_title
wxToolBar * m_toolbar
wxAuiNotebook * m_sceneNotebook
std::vector< std::unique_ptr< IScene > > m_scenes
int m_activeSceneIndex
int m_nextSceneNumber
SceneChangedCallback m_sceneChangedCallback

Additional Inherited Members

Protected Member Functions inherited from Panel
virtual void ApplyTheme ()
 Apply current theme to the panel Called when theme changes.
virtual void UpdateContent ()
 Update panel content Called during refresh.
virtual void HandleActivation ()
 Handle panel activation Called when panel becomes active.
virtual void HandleDeactivation ()
 Handle panel deactivation Called when panel becomes inactive.
virtual bool ValidateState () const
 Validate panel state Override to provide custom validation logic.
void MarkChanged ()
 Mark panel as having unsaved changes.
void MarkSaved ()
 Mark panel as saved (no unsaved changes)
wxSizer * GetMainSizer () const
 Get the main sizer for layout management.
void SetMainSizer (wxSizer *sizer)
 Set the main sizer (takes ownership)
virtual void OnPanelSize (wxSizeEvent &event)
virtual void OnPanelPaint (wxPaintEvent &event)
virtual void OnPanelRightClick (wxContextMenuEvent &event)

Detailed Description

Central panel for managing and displaying behavior tree scenes.

MainPanel is the primary workspace area in EmberForge where behavior trees are visualized and edited. It manages multiple scenes using a tabbed notebook interface, allowing users to work with several behavior trees simultaneously.

Features

  • Multi-scene support: Open and edit multiple behavior trees in tabs
  • Scene navigation: Switch between scenes with keyboard shortcuts or buttons
  • Dynamic scene creation: Create new scenes on-the-fly
  • Tab management: Close, rename, and reorder scene tabs

Usage

// Create and add a scene
auto scene = std::make_unique<BehaviorTreeScene>(mainPanel->GetNotebook());
int index = mainPanel->AddScene(std::move(scene));
// Get the active scene
IScene* active = mainPanel->GetActiveScene();
// Navigate between scenes
mainPanel->SwitchToNextScene();
Abstract interface for different scene types in the MainPanel.
Definition IScene.h:25
See also
IScene, BehaviorTreeScene, Panel

Definition at line 41 of file MainPanel.h.

Member Typedef Documentation

◆ SceneChangedCallback

using MainPanel::SceneChangedCallback = std::function<void(IScene *newScene, int newIndex)>

Definition at line 128 of file MainPanel.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NEW_SCENE_BUTTON 
ID_SCENE_NOTEBOOK 

Definition at line 133 of file MainPanel.h.

Constructor & Destructor Documentation

◆ MainPanel()

MainPanel::MainPanel ( wxWindow * parent)

Member Function Documentation

◆ AddScene()

int MainPanel::AddScene ( std::unique_ptr< IScene > scene)

Add a new scene to the panel.

Parameters
sceneThe scene to add
Returns
int Index of the added scene

Definition at line 63 of file MainPanel.cpp.

◆ ApplyCanvasBackgroundColor()

void MainPanel::ApplyCanvasBackgroundColor ( const wxColour & color)

Apply canvas background color to all scenes.

Parameters
colorBackground color to apply

Definition at line 393 of file MainPanel.cpp.

◆ CreateLayout()

void MainPanel::CreateLayout ( )
overrideprivatevirtual

Create the panel's UI layout Called during initialization.

Override in derived classes.

Reimplemented from Panel.

Definition at line 21 of file MainPanel.cpp.

◆ CreateNewScene() [1/2]

int MainPanel::CreateNewScene ( )

Create a new empty behavior tree scene.

Returns
int Index of the created scene

Definition at line 189 of file MainPanel.cpp.

◆ CreateNewScene() [2/2]

int MainPanel::CreateNewScene ( const wxString & customTitle)

Create a new empty behavior tree scene with custom title.

Parameters
customTitleThe title for the new scene
Returns
int Index of the created scene

Definition at line 239 of file MainPanel.cpp.

◆ CreateToolbar()

void MainPanel::CreateToolbar ( )
private

Definition at line 47 of file MainPanel.cpp.

◆ DoCreateLayout()

void MainPanel::DoCreateLayout ( )
private

Definition at line 25 of file MainPanel.cpp.

◆ DoCreateToolbar()

void MainPanel::DoCreateToolbar ( )
private

Definition at line 51 of file MainPanel.cpp.

◆ GenerateSceneTitle()

wxString MainPanel::GenerateSceneTitle ( ) const
private

Definition at line 205 of file MainPanel.cpp.

◆ GetActiveScene()

IScene * MainPanel::GetActiveScene ( ) const

Get the currently active scene.

Returns
IScene* Active scene or nullptr if no scenes

Definition at line 153 of file MainPanel.cpp.

◆ GetNotebook()

wxAuiNotebook * MainPanel::GetNotebook ( ) const
inline

Definition at line 120 of file MainPanel.h.

◆ GetPanelType()

wxString MainPanel::GetPanelType ( ) const
inlineoverridevirtual

Get a unique identifier for this panel type.

Returns
wxString Identifier like "Properties", "SceneHierarchy", etc.

Implements IPanel.

Definition at line 47 of file MainPanel.h.

◆ GetScene()

IScene * MainPanel::GetScene ( int index) const

Get a scene by index.

Parameters
indexIndex of the scene
Returns
IScene* Scene at index or nullptr if invalid index

Definition at line 160 of file MainPanel.cpp.

◆ GetSceneCount()

size_t MainPanel::GetSceneCount ( ) const
inline

Get the number of scenes.

Returns
size_t Number of scenes in the panel

Definition at line 81 of file MainPanel.h.

◆ GetTitle()

wxString MainPanel::GetTitle ( ) const
inlineoverridevirtual

Get the display title for this panel.

Returns
wxString The title to show in tabs, captions, etc.

Implements IPanel.

Definition at line 46 of file MainPanel.h.

◆ OnNewSceneButton()

void MainPanel::OnNewSceneButton ( wxCommandEvent & event)
private

Definition at line 295 of file MainPanel.cpp.

◆ OnTabChanged()

void MainPanel::OnTabChanged ( wxAuiNotebookEvent & event)
private

Definition at line 271 of file MainPanel.cpp.

◆ OnTabClosed()

void MainPanel::OnTabClosed ( wxAuiNotebookEvent & event)
private

Definition at line 321 of file MainPanel.cpp.

◆ RemoveScene()

bool MainPanel::RemoveScene ( int index)

Remove a scene by index.

Parameters
indexIndex of the scene to remove
Returns
bool True if removal was successful

Definition at line 99 of file MainPanel.cpp.

◆ SceneTitleExists()

bool MainPanel::SceneTitleExists ( const wxString & title) const
private

Definition at line 230 of file MainPanel.cpp.

◆ SetActiveScene()

bool MainPanel::SetActiveScene ( int index)

Set the active scene by index.

Parameters
indexIndex of the scene to activate
Returns
bool True if activation was successful

Definition at line 167 of file MainPanel.cpp.

◆ SetSceneChangedCallback()

void MainPanel::SetSceneChangedCallback ( SceneChangedCallback callback)
inline

Definition at line 129 of file MainPanel.h.

◆ SwitchToNextScene()

void MainPanel::SwitchToNextScene ( )

Switch to the next scene (cyclic)

Definition at line 405 of file MainPanel.cpp.

◆ SwitchToPreviousScene()

void MainPanel::SwitchToPreviousScene ( )

Switch to the previous scene (cyclic)

Definition at line 414 of file MainPanel.cpp.

◆ UpdateActiveSceneTitle()

void MainPanel::UpdateActiveSceneTitle ( const wxString & newTitle)

Update the title of the active scene.

Parameters
newTitleThe new title for the scene

Definition at line 254 of file MainPanel.cpp.

◆ wxDECLARE_EVENT_TABLE()

MainPanel::wxDECLARE_EVENT_TABLE ( )
private

Member Data Documentation

◆ m_activeSceneIndex

int MainPanel::m_activeSceneIndex
private

Definition at line 157 of file MainPanel.h.

◆ m_nextSceneNumber

int MainPanel::m_nextSceneNumber
private

Definition at line 158 of file MainPanel.h.

◆ m_sceneChangedCallback

SceneChangedCallback MainPanel::m_sceneChangedCallback
private

Definition at line 159 of file MainPanel.h.

◆ m_sceneNotebook

wxAuiNotebook* MainPanel::m_sceneNotebook
private

Definition at line 153 of file MainPanel.h.

◆ m_scenes

std::vector<std::unique_ptr<IScene> > MainPanel::m_scenes
private

Definition at line 156 of file MainPanel.h.

◆ m_title

wxStaticText* MainPanel::m_title
private

Definition at line 151 of file MainPanel.h.

◆ m_toolbar

wxToolBar* MainPanel::m_toolbar
private

Definition at line 152 of file MainPanel.h.


The documentation for this class was generated from the following files: