Ember
Loading...
Searching...
No Matches
SidePanel Class Referenceabstract

Base class for sidebar panels with shared tab management backend. More...

#include <SidePanel.h>

Inheritance diagram for SidePanel:
Panel IPanel BottomPanel LeftSidePanel RightSidePanel

Public Member Functions

 SidePanel (wxWindow *parent, MainFrame *mainFrame=nullptr, const wxString &panelName="Side Panel", EmberForge::PanelType panelType=EmberForge::PanelType::LeftPanel, EmberForge::PanelDescriptor *parentDescriptor=nullptr)
virtual ~SidePanel ()
void FinishSetup ()
 Complete panel setup after construction.
wxString GetTitle () const override=0
 Get the display title for this panel.
wxString GetPanelType () const override=0
 Get a unique identifier for this panel type.
int AddTab (ITabPtr tab)
 Add a tab to this panel.
ITabPtr RemoveTab (int index)
 Remove a tab by index.
ITab * GetTab (int index) const
 Get a tab by index.
size_t GetTabCount () const
 Get the number of tabs.
bool SetActiveTab (int index)
 Set the active tab by index.
ITab * GetActiveTab () const
 Get the currently active tab.
EmberForge::CustomAuiNotebook * GetNotebook () const
 Get the notebook widget for direct access.
bool HasTabWithName (const wxString &tabName) const
 Check if this panel has a tab with the given name.
void ResetToDefaultTab (EmberForge::TabType defaultTabType)
 Reset the panel to a single default tab Closes all tabs and creates only the specified default tab.
void ResetToDefaultTabs (const std::vector< EmberForge::TabType > &defaultTabTypes)
 Reset the panel to multiple default tabs Closes all tabs and creates the specified default tabs.
void ClearAllTabs ()
 Clear all tabs from the panel Removes all tabs without creating any new ones.
virtual void ApplyPreferences ()
 Apply preferences to the side panel Virtual to allow derived classes to use their specific settings.
virtual void SaveState ()
 Save the current state (last active tab, etc.) Virtual to allow derived classes to use their specific settings.
virtual void RestoreState ()
 Restore state from preferences Virtual to allow derived classes to use their specific settings.
void SetTabBarButtonsEnabled (bool enabled)
 Enable or disable the tab bar buttons (+ and menu)
bool AreTabBarButtonsEnabled () const
 Check if tab bar buttons are enabled.
void ToggleTabBarButtons ()
 Toggle tab bar buttons visibility.
void SetPanelName (const wxString &name)
 Set the panel name (for split panels)
const EmberForge::PanelDescriptor & GetPanelDescriptor () const
 Get the panel descriptor for this panel.
void SetPanelDescriptor (const EmberForge::PanelDescriptor &descriptor)
 Update the panel descriptor (used when creating split panels)
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.
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

Protected Types

enum  BaseEventIDs {
  ID_BASE_NOTEBOOK = wxID_HIGHEST + 1000 , ID_BASE_HIDE_PANEL_MENU_ITEM , ID_BASE_PREFERENCES_MENU_ITEM , ID_BASE_ADD_TAB_BUTTON ,
  ID_BASE_MENU_BUTTON , ID_BASE_LAST
}

Protected Member Functions

void CreateLayout () override
 Create the panel's UI layout Called during initialization.
virtual void CreateNotebook ()
virtual void SetupEventHandlers ()
virtual void OnPanelSpecificSetup ()
virtual bool GetRememberLastTab () const =0
virtual const std::vector< std::string > & GetLastOpenTabs () const =0
virtual std::string GetLastActiveTab () const =0
virtual std::string GetDefaultActiveTab () const =0
void RestoreAndEnsureTabs ()
void DoCreateLayout ()
void DoCreateNotebook ()
void DoSetupEventHandlers ()
virtual void OnAddTabButtonClicked (wxCommandEvent &event)
virtual std::vector< EmberForge::TabType > GetSupportedTabTypes () const
void OnTabChanged (wxAuiNotebookEvent &event)
void OnTabClosed (wxAuiNotebookEvent &event)
void OnAddTabButtonClickedInternal (wxCommandEvent &event)
virtual void OnMenuButtonClicked (wxCommandEvent &event)
void OnHidePanelClicked (wxCommandEvent &event)
void OnPanelPreferencesClicked (wxCommandEvent &event)
void OnTabBarAddButtonClicked (wxCommandEvent &event)
void OnTabBarMenuButtonClicked (wxCommandEvent &event)
void CreateAndAddTab (EmberForge::TabType tabType)
void ShowTabCreationMenu ()
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)

Protected Attributes

MainFrame * m_mainFrame
EmberForge::CustomAuiNotebook * m_notebook
std::vector< ITabPtr > m_tabs
int m_activeTabIndex
wxString m_panelName
bool m_tabBarButtonsEnabled
bool m_isInitializing
EmberForge::PanelDescriptor m_descriptor

Private Member Functions

 wxDECLARE_EVENT_TABLE ()

Detailed Description

Base class for sidebar panels with shared tab management backend.

This class provides all the common functionality for both left and right sidebar panels, including tab management, notebook handling, and event processing. Derived classes can specialize behavior while sharing the same backend implementation.

Design Pattern: Template Method Pattern + Strategy Pattern

  • Template Method: Common algorithms in base class
  • Strategy: Specialized behavior in derived classes

Definition at line 33 of file SidePanel.h.

Member Enumeration Documentation

◆ BaseEventIDs

enum SidePanel::BaseEventIDs
protected
Enumerator
ID_BASE_NOTEBOOK 
ID_BASE_HIDE_PANEL_MENU_ITEM 
ID_BASE_PREFERENCES_MENU_ITEM 
ID_BASE_ADD_TAB_BUTTON 
ID_BASE_MENU_BUTTON 
ID_BASE_LAST 

Definition at line 245 of file SidePanel.h.

Constructor & Destructor Documentation

◆ SidePanel()

SidePanel::SidePanel ( wxWindow * parent,
MainFrame * mainFrame = nullptr,
const wxString & panelName = "Side Panel",
EmberForge::PanelType panelType = EmberForge::PanelType::LeftPanel,
EmberForge::PanelDescriptor * parentDescriptor = nullptr )

◆ ~SidePanel()

SidePanel::~SidePanel ( )
virtual

Definition at line 42 of file SidePanel.cpp.

Member Function Documentation

◆ AddTab()

int SidePanel::AddTab ( ITabPtr tab)

Add a tab to this panel.

Parameters
tabThe tab to add
Returns
int Index of the added tab

Definition at line 204 of file SidePanel.cpp.

◆ ApplyPreferences()

void SidePanel::ApplyPreferences ( )
virtual

Apply preferences to the side panel Virtual to allow derived classes to use their specific settings.

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 711 of file SidePanel.cpp.

◆ AreTabBarButtonsEnabled()

bool SidePanel::AreTabBarButtonsEnabled ( ) const
inline

Check if tab bar buttons are enabled.

Returns
bool True if tab bar buttons are enabled

Definition at line 157 of file SidePanel.h.

◆ ClearAllTabs()

void SidePanel::ClearAllTabs ( )

Clear all tabs from the panel Removes all tabs without creating any new ones.

Definition at line 380 of file SidePanel.cpp.

◆ CreateAndAddTab()

void SidePanel::CreateAndAddTab ( EmberForge::TabType tabType)
protected

Definition at line 577 of file SidePanel.cpp.

◆ CreateLayout()

void SidePanel::CreateLayout ( )
overrideprotectedvirtual

Create the panel's UI layout Called during initialization.

Override in derived classes.

Reimplemented from Panel.

Definition at line 57 of file SidePanel.cpp.

◆ CreateNotebook()

void SidePanel::CreateNotebook ( )
protectedvirtual

Definition at line 98 of file SidePanel.cpp.

◆ DoCreateLayout()

void SidePanel::DoCreateLayout ( )
protected

Definition at line 61 of file SidePanel.cpp.

◆ DoCreateNotebook()

void SidePanel::DoCreateNotebook ( )
protected

Definition at line 102 of file SidePanel.cpp.

◆ DoSetupEventHandlers()

void SidePanel::DoSetupEventHandlers ( )
protected

Definition at line 124 of file SidePanel.cpp.

◆ FinishSetup()

void SidePanel::FinishSetup ( )

Complete panel setup after construction.

This must be called after the derived class is fully constructed to ensure proper virtual dispatch for OnPanelSpecificSetup(). Creates default tabs and applies preferences.

Definition at line 83 of file SidePanel.cpp.

◆ GetActiveTab()

ITab * SidePanel::GetActiveTab ( ) const

Get the currently active tab.

Returns
ITab* Active tab or nullptr if no tabs

Definition at line 303 of file SidePanel.cpp.

◆ GetDefaultActiveTab()

virtual std::string SidePanel::GetDefaultActiveTab ( ) const
protectedpure virtual

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ GetLastActiveTab()

virtual std::string SidePanel::GetLastActiveTab ( ) const
protectedpure virtual

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ GetLastOpenTabs()

virtual const std::vector< std::string > & SidePanel::GetLastOpenTabs ( ) const
protectedpure virtual

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ GetNotebook()

EmberForge::CustomAuiNotebook * SidePanel::GetNotebook ( ) const
inline

Get the notebook widget for direct access.

Returns
EmberForge::CustomAuiNotebook* The notebook containing the tabs

Definition at line 98 of file SidePanel.h.

◆ GetPanelDescriptor()

const EmberForge::PanelDescriptor & SidePanel::GetPanelDescriptor ( ) const
inline

Get the panel descriptor for this panel.

Returns
const EmberForge::PanelDescriptor& Panel descriptor

Definition at line 174 of file SidePanel.h.

◆ GetPanelType()

wxString SidePanel::GetPanelType ( ) const
overridepure virtual

Get a unique identifier for this panel type.

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

Reimplemented from Panel.

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ GetRememberLastTab()

virtual bool SidePanel::GetRememberLastTab ( ) const
protectedpure virtual

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ GetSupportedTabTypes()

virtual std::vector< EmberForge::TabType > SidePanel::GetSupportedTabTypes ( ) const
inlineprotectedvirtual

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 212 of file SidePanel.h.

◆ GetTab()

ITab * SidePanel::GetTab ( int index) const

Get a tab by index.

Parameters
indexIndex of the tab
Returns
ITab* Tab at index or nullptr if invalid

Definition at line 283 of file SidePanel.cpp.

◆ GetTabCount()

size_t SidePanel::GetTabCount ( ) const
inline

Get the number of tabs.

Returns
size_t Number of tabs in the panel

Definition at line 79 of file SidePanel.h.

◆ GetTitle()

wxString SidePanel::GetTitle ( ) const
overridepure virtual

Get the display title for this panel.

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

Reimplemented from Panel.

Implemented in BottomPanel, LeftSidePanel, and RightSidePanel.

◆ HasTabWithName()

bool SidePanel::HasTabWithName ( const wxString & tabName) const

Check if this panel has a tab with the given name.

Parameters
tabNameThe name to check for
Returns
bool True if a tab with that name exists in this panel

Definition at line 568 of file SidePanel.cpp.

◆ OnAddTabButtonClicked()

virtual void SidePanel::OnAddTabButtonClicked ( wxCommandEvent & event)
inlineprotectedvirtual

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 211 of file SidePanel.h.

◆ OnAddTabButtonClickedInternal()

void SidePanel::OnAddTabButtonClickedInternal ( wxCommandEvent & event)
protected

Definition at line 464 of file SidePanel.cpp.

◆ OnHidePanelClicked()

void SidePanel::OnHidePanelClicked ( wxCommandEvent & event)
protected

Definition at line 514 of file SidePanel.cpp.

◆ OnMenuButtonClicked()

void SidePanel::OnMenuButtonClicked ( wxCommandEvent & event)
protectedvirtual

Definition at line 492 of file SidePanel.cpp.

◆ OnPanelPreferencesClicked()

void SidePanel::OnPanelPreferencesClicked ( wxCommandEvent & event)
protected

Definition at line 544 of file SidePanel.cpp.

◆ OnPanelSpecificSetup()

void SidePanel::OnPanelSpecificSetup ( )
protectedvirtual

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 130 of file SidePanel.cpp.

◆ OnTabBarAddButtonClicked()

void SidePanel::OnTabBarAddButtonClicked ( wxCommandEvent & event)
protected

Definition at line 476 of file SidePanel.cpp.

◆ OnTabBarMenuButtonClicked()

void SidePanel::OnTabBarMenuButtonClicked ( wxCommandEvent & event)
protected

Definition at line 484 of file SidePanel.cpp.

◆ OnTabChanged()

void SidePanel::OnTabChanged ( wxAuiNotebookEvent & event)
protected

Definition at line 395 of file SidePanel.cpp.

◆ OnTabClosed()

void SidePanel::OnTabClosed ( wxAuiNotebookEvent & event)
protected

Definition at line 420 of file SidePanel.cpp.

◆ RemoveTab()

ITabPtr SidePanel::RemoveTab ( int index)

Remove a tab by index.

Parameters
indexIndex of the tab to remove
Returns
ITabPtr The removed tab (for moving to another panel)

Definition at line 246 of file SidePanel.cpp.

◆ ResetToDefaultTab()

void SidePanel::ResetToDefaultTab ( EmberForge::TabType defaultTabType)

Reset the panel to a single default tab Closes all tabs and creates only the specified default tab.

Parameters
defaultTabTypeThe tab type to use as the default

Definition at line 310 of file SidePanel.cpp.

◆ ResetToDefaultTabs()

void SidePanel::ResetToDefaultTabs ( const std::vector< EmberForge::TabType > & defaultTabTypes)

Reset the panel to multiple default tabs Closes all tabs and creates the specified default tabs.

Parameters
defaultTabTypesThe tab types to create as defaults

Definition at line 352 of file SidePanel.cpp.

◆ RestoreAndEnsureTabs()

void SidePanel::RestoreAndEnsureTabs ( )
protected

Definition at line 135 of file SidePanel.cpp.

◆ RestoreState()

void SidePanel::RestoreState ( )
virtual

Restore state from preferences Virtual to allow derived classes to use their specific settings.

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 725 of file SidePanel.cpp.

◆ SaveState()

void SidePanel::SaveState ( )
virtual

Save the current state (last active tab, etc.) Virtual to allow derived classes to use their specific settings.

Reimplemented in BottomPanel, LeftSidePanel, and RightSidePanel.

Definition at line 718 of file SidePanel.cpp.

◆ SetActiveTab()

bool SidePanel::SetActiveTab ( int index)

Set the active tab by index.

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

Definition at line 290 of file SidePanel.cpp.

◆ SetPanelDescriptor()

void SidePanel::SetPanelDescriptor ( const EmberForge::PanelDescriptor & descriptor)
inline

Update the panel descriptor (used when creating split panels)

Parameters
descriptorThe new descriptor to use

Definition at line 180 of file SidePanel.h.

◆ SetPanelName()

void SidePanel::SetPanelName ( const wxString & name)
inline

Set the panel name (for split panels)

Parameters
nameThe new panel name

Definition at line 168 of file SidePanel.h.

◆ SetTabBarButtonsEnabled()

void SidePanel::SetTabBarButtonsEnabled ( bool enabled)

Enable or disable the tab bar buttons (+ and menu)

Parameters
enabledTrue to enable, false to disable

Definition at line 691 of file SidePanel.cpp.

◆ SetupEventHandlers()

void SidePanel::SetupEventHandlers ( )
protectedvirtual

Definition at line 120 of file SidePanel.cpp.

◆ ShowTabCreationMenu()

void SidePanel::ShowTabCreationMenu ( )
protected

Definition at line 624 of file SidePanel.cpp.

◆ ToggleTabBarButtons()

void SidePanel::ToggleTabBarButtons ( )

Toggle tab bar buttons visibility.

Definition at line 705 of file SidePanel.cpp.

◆ wxDECLARE_EVENT_TABLE()

SidePanel::wxDECLARE_EVENT_TABLE ( )
private

Member Data Documentation

◆ m_activeTabIndex

int SidePanel::m_activeTabIndex
protected

Definition at line 238 of file SidePanel.h.

◆ m_descriptor

EmberForge::PanelDescriptor SidePanel::m_descriptor
protected

Definition at line 242 of file SidePanel.h.

◆ m_isInitializing

bool SidePanel::m_isInitializing
protected

Definition at line 241 of file SidePanel.h.

◆ m_mainFrame

MainFrame* SidePanel::m_mainFrame
protected

Definition at line 235 of file SidePanel.h.

◆ m_notebook

EmberForge::CustomAuiNotebook* SidePanel::m_notebook
protected

Definition at line 236 of file SidePanel.h.

◆ m_panelName

wxString SidePanel::m_panelName
protected

Definition at line 239 of file SidePanel.h.

◆ m_tabBarButtonsEnabled

bool SidePanel::m_tabBarButtonsEnabled
protected

Definition at line 240 of file SidePanel.h.

◆ m_tabs

std::vector<ITabPtr> SidePanel::m_tabs
protected

Definition at line 237 of file SidePanel.h.


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