Ember
Loading...
Searching...
No Matches
UI Components

Overview

EmberForge's user interface is built on a flexible panel and tab system that allows users to customize their workspace. This document explains the component hierarchy and how the pieces fit together.

Component Hierarchy

App (wxApp)
└── MainFrame (wxFrame)
├── wxAuiManager (docking system)
│ ├── LeftSidePanel
│ │ └── wxAuiNotebook
│ │ ├── FileExplorerTab
│ │ └── SceneHierarchyTab
│ ├── MainPanel (center)
│ │ └── SceneContainer
│ │ └── BehaviorTreeScene
│ │ └── TreeVisualization
│ ├── RightSidePanel
│ │ └── wxAuiNotebook
│ │ └── PropertiesTab
│ └── BottomPanel
│ └── wxAuiNotebook
│ └── LogTab
└── Menu/Toolbar

Panel System

IPanel Interface

All panels implement the IPanel interface:

class IPanel {
public:
virtual wxWindow* GetWindow() = 0;
virtual wxString GetTitle() const = 0;
virtual wxString GetPanelType() const = 0;
virtual void Refresh() = 0;
virtual void OnActivated() = 0;
virtual void OnDeactivated() = 0;
};
Abstract interface for all panels in the Ember application.
Definition IPanel.h:13
virtual wxString GetPanelType() const =0
Get a unique identifier for this panel type.
virtual void Refresh()
Called when the panel should refresh its display This should update the panel's content to reflect cu...
Definition IPanel.h:45
virtual void OnActivated()
Called when the panel becomes visible/active.
Definition IPanel.h:50
virtual void OnDeactivated()
Called when the panel becomes hidden/inactive.
Definition IPanel.h:55
virtual wxString GetTitle() const =0
Get the display title for this panel.

Panel Base Class

The Panel base class provides common functionality:

Method Purpose
CreateLayout() Set up panel UI (virtual)
ApplyTheme() Apply color theme
Refresh() Refresh panel content
Save() / Load() Serialize/deserialize state

SidePanel

SidePanel extends Panel for side dock panels with tab support:

class SidePanel : public Panel {
public:
int AddTab(ITabPtr tab);
void RemoveTab(int index);
ITabPtr GetTab(int index);
int GetActiveTabIndex();
void SetActiveTab(int index);
protected:
virtual void CreateToolbar();
virtual void CreateNotebook();
virtual bool ShouldShowToolbar() const;
};
std::unique_ptr< ITab > ITabPtr
Smart pointer type for ITab instances.
Definition ITab.h:145
Base implementation of IPanel interface.
Definition Panel.h:28
Base class for sidebar panels with shared tab management backend.
Definition SidePanel.h:33
ITabPtr RemoveTab(int index)
Remove a tab by index.
int AddTab(ITabPtr tab)
Add a tab to this panel.
virtual void CreateNotebook()
Definition SidePanel.cpp:98
bool SetActiveTab(int index)
Set the active tab by index.
ITab * GetTab(int index) const
Get a tab by index.

Concrete Panels

Panel Location Purpose
MainPanel Center Contains scene visualizations
LeftSidePanel Left dock File explorer, hierarchy
RightSidePanel Right dock Properties editor
BottomPanel Bottom dock Logs, output

Tab System

ITab Interface

Tabs are content components within panels:

class ITab {
public:
virtual wxWindow* GetWidget() = 0;
virtual wxString GetTitle() const = 0;
virtual wxString GetTabType() const = 0;
virtual wxBitmap GetIcon() const = 0;
virtual void Initialize() = 0;
virtual void Refresh() = 0;
virtual void OnActivated() = 0;
virtual void OnDeactivated() = 0;
virtual void OnClosed() = 0;
virtual bool IsValid() const = 0;
virtual bool CanClose() const = 0;
virtual bool CanMove() const = 0;
};
Abstract interface for individual tabs that can be moved between panels.
Definition ITab.h:28
virtual void OnDeactivated()
Called when the tab becomes inactive/hidden.
Definition ITab.h:76
virtual bool CanMove() const
Check if this tab can be moved to other panels.
Definition ITab.h:100
virtual bool CanClose() const
Check if this tab can be closed by the user.
Definition ITab.h:94
virtual wxBitmap GetIcon() const
Get an optional icon for this tab.
Definition ITab.h:54
virtual wxString GetTitle() const =0
Get the display title for this tab.
virtual wxWindow * GetWidget()=0
Get the main widget for this tab.
virtual void OnActivated()
Called when the tab becomes the active/visible tab.
Definition ITab.h:71
virtual void OnClosed()
Called when the tab is about to be closed/removed Use this for cleanup operations.
Definition ITab.h:82
virtual wxString GetTabType() const =0
Get a unique identifier for this tab type.
virtual void Refresh()
Called when the tab should refresh its display This should update the tab's content to reflect curren...
Definition ITab.h:66
virtual bool IsValid() const
Check if the tab is in a valid state.
Definition ITab.h:88
virtual void Initialize()
Initialize the tab after construction Called once after the tab is created and configured.
Definition ITab.h:60

Tab Implementations

Tab Purpose Features
FileExplorerTab Browse project files Tree/grid view, drag-drop, search
SceneHierarchyTab Navigate tree structure Node selection, expand/collapse
PropertiesTab Edit node properties Property grid, blackboard editing
LogTab Display log messages Filtering, search, virtual list
ToolTab Tool palette (Future: node creation tools)

TabFactory

Creates tabs by type name:

auto& factory = EmberForge::TabFactory::GetInstance();
// Create tab by type
auto tab = factory.CreateTab("FileExplorer", parentWindow);
// Get available types
auto types = factory.GetAvailableTabTypes();

TabContainer

Manages a collection of tabs:

class TabContainer {
public:
int AddTab(ITabPtr tab);
void RemoveTab(int index);
void CloseTab(int index);
ITabPtr GetTab(int index);
ITabPtr GetActiveTab();
void SetTabTitle(int index, const wxString& title);
void SetTabState(int index, TabState state);
// Callbacks
void SetTabActivatedCallback(Callback cb);
void SetTabClosedCallback(Callback cb);
};

Scene System

IScene Interface

Scenes are visual content areas in the MainPanel:

class IScene {
public:
virtual wxPanel* GetPanel() = 0;
virtual wxString GetTitle() const = 0;
virtual wxString GetSceneType() const = 0;
virtual void OnActivated() = 0;
virtual void OnDeactivated() = 0;
virtual void Refresh() = 0;
virtual bool HasUnsavedChanges() const = 0;
virtual bool Save() = 0;
};
Abstract interface for different scene types in the MainPanel.
Definition IScene.h:25
virtual bool HasUnsavedChanges() const
Check if this scene has unsaved changes.
Definition IScene.h:66
virtual void OnActivated()
Called when this scene becomes the active tab.
Definition IScene.h:50
virtual wxString GetSceneType() const =0
Get a unique identifier for this scene type.
virtual void Refresh()
Called when the scene should refresh its display.
Definition IScene.h:60
virtual wxString GetTitle() const =0
Get the display title for this scene.
virtual wxPanel * GetPanel()=0
Get the main panel widget for this scene.
virtual bool Save()
Save the scene (if applicable)
Definition IScene.h:72
virtual void OnDeactivated()
Called when this scene is no longer the active tab.
Definition IScene.h:55

BehaviorTreeScene

The primary scene type for visualizing behavior trees:

class BehaviorTreeScene : public IScene {
public:
// Set tree data
void SetBehaviorTree(std::shared_ptr<Node> root);
void SetTreeStructure(std::shared_ptr<ITreeStructure> tree);
// Selection
// Tree selector dropdown
void UpdateTreeSelector(const std::vector<std::string>& names,
const std::string& current);
void SetTreeSelectionCallback(TreeSelectionCallback cb);
};
Scene implementation for behavior tree visualization.
void SetNodeSelectionCallback(NodeSelectionCallback callback)
Set callback for node selection events.
void SetBehaviorTree(std::shared_ptr< EmberCore::Node > root)
Set the behavior tree for this scene using legacy Node interface.
std::function< void(EmberCore::ITreeNode *)> NodeSelectionCallback

SceneContainer

Manages multiple scenes with tabs:

class SceneContainer {
public:
int AddScene(std::unique_ptr<IScene> scene);
void RemoveScene(int index);
IScene* GetActiveScene();
// Scene lifecycle
void SuspendInactiveScenes();
void ResumeAllScenes();
// Callbacks
void SetSceneActivatedCallback(Callback cb);
void SetSceneDeactivatedCallback(Callback cb);
};

TreeVisualization

Canvas component for rendering behavior trees:

class TreeVisualization : public wxPanel {
public:
void SetTreeStructure(std::shared_ptr<ITreeStructure> tree);
// View control
void SetZoom(float zoom);
void CenterView();
void FitToWindow();
// Selection
void SelectNode(ITreeNode* node);
void ClearSelection();
// Configuration
void SetConfig(const VisualizationConfig& config);
};

Dialogs

Common Dialogs

Dialog Purpose
PreferencesDialog Application settings
ParserConfigDialog Parser profile configuration
BehaviorTreeProjectDialog Multi-file project management
ProjectManagerDialog Open/create projects
LoadingDialog Progress indicator

Dialog Pattern

Dialogs typically follow this pattern:

PreferencesDialog dlg(parentWindow);
if (dlg.ShowModal() == wxID_OK) {
// User confirmed, settings already applied
}
// Dialog automatically destroyed
Preferences dialog for configuring EmberForge application settings.

Event Flow

Node Selection

User clicks node in TreeVisualization
│
▼
TreeVisualization::OnMouseDown()
│
▼
NodeSelectionCallback invoked
│
▼
MainFrame::OnNodeSelected()
│
├─► SceneHierarchyTab::SelectNode()
│
└─► PropertiesTab::SetSelectedNode()

File Open

User selects File > Open
│
▼
MainFrame::OnFileOpen()
│
▼
wxFileDialog for file selection
│
▼
LibXMLBehaviorTreeParser::ParseFile()
│
▼
MainFrame::LoadBehaviorTree()
│
├─► Create DirectTreeAdapter
│
├─► BehaviorTreeScene::SetTreeStructure()
│
└─► Update hierarchy and properties

Layout Management

EmberForge uses wxAuiManager for dockable panels:

// In MainFrame initialization
m_auiManager.SetManagedWindow(this);
// Add panels
m_auiManager.AddPane(m_leftPanel, wxAuiPaneInfo()
.Left()
.Caption("Explorer")
.MinSize(200, -1)
.BestSize(250, -1));
m_auiManager.AddPane(m_mainPanel, wxAuiPaneInfo()
.CenterPane()
.Caption("Scene"));
m_auiManager.Update();

Saving/Restoring Layout

// Save perspective
wxString layout = m_auiManager.SavePerspective();
prefs.SetString("window/layout", layout);
// Restore perspective
wxString layout = prefs.GetString("window/layout", "");
if (!layout.empty()) {
m_auiManager.LoadPerspective(layout);
}

Theming

Panels and tabs support theming through AppPreferences:

auto& prefs = AppPreferencesManager::GetInstance();
wxColour bg = prefs.GetPanelBackgroundColor();
wxColour fg = prefs.GetPanelForegroundColor();
SetBackgroundColour(bg);
SetForegroundColour(fg);
}
void Refresh() override
Called when the panel should refresh its display This should update the panel's content to reflect cu...
Definition Panel.cpp:45
virtual void ApplyTheme()
Apply current theme to the panel Called when theme changes.
Definition Panel.cpp:143

See Also