Ember
Loading...
Searching...
No Matches
PropertiesTabBase.cpp
Go to the documentation of this file.
2
3namespace EmberUI {
4
5const wxColour PropertiesTabBase::kBgColor(50, 50, 50);
6const wxColour PropertiesTabBase::kCaptionBgColor(65, 65, 65);
7const wxColour PropertiesTabBase::kTextColor(200, 200, 200);
8const wxColour PropertiesTabBase::kLineColor(60, 60, 60);
9const wxColour PropertiesTabBase::kCellBgColor(50, 50, 50);
10
12 : wxPanel(parent, wxID_ANY), m_stack(nullptr), m_placeholderPanel(nullptr), m_contentPanel(nullptr),
13 m_propertyGrid(nullptr), m_selectedNode(nullptr), m_selectionHighlight(80, 120, 200) {}
14
16 SetBackgroundColour(kBgColor);
17
18 wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
19
20 m_stack = new wxSimplebook(this, wxID_ANY);
21 m_stack->SetBackgroundColour(kBgColor);
22
23 // Page 0: placeholder when nothing is selected
24 m_placeholderPanel = new wxPanel(m_stack, wxID_ANY);
25 m_placeholderPanel->SetBackgroundColour(kBgColor);
26 wxBoxSizer *placeholderSizer = new wxBoxSizer(wxVERTICAL);
27 wxStaticText *statusText = new wxStaticText(m_placeholderPanel, wxID_ANY, GetPlaceholderText());
28 statusText->SetForegroundColour(wxColour(150, 150, 150));
29 placeholderSizer->AddStretchSpacer();
30 placeholderSizer->Add(statusText, 0, wxALIGN_CENTER_HORIZONTAL);
31 placeholderSizer->AddStretchSpacer();
32 m_placeholderPanel->SetSizer(placeholderSizer);
33 m_stack->AddPage(m_placeholderPanel, wxEmptyString);
34
35 // Page 1: content panel (subclasses build their layout here)
36 m_contentPanel = new wxPanel(m_stack, wxID_ANY);
37 m_contentPanel->SetBackgroundColour(kBgColor);
39 m_stack->AddPage(m_contentPanel, wxEmptyString);
40
41 mainSizer->Add(m_stack, 1, wxEXPAND | wxALL, 5);
42 SetSizer(mainSizer);
43
44 m_stack->ChangeSelection(0);
45}
46
48 m_propertyGrid = new wxPropertyGrid(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize,
49 wxPG_SPLITTER_AUTO_CENTER | wxPG_DEFAULT_STYLE);
50
51 m_propertyGrid->SetBackgroundColour(kBgColor);
52 m_propertyGrid->SetForegroundColour(kTextColor);
53 m_propertyGrid->SetCaptionBackgroundColour(kCaptionBgColor);
54 m_propertyGrid->SetCaptionTextColour(kTextColor);
55 m_propertyGrid->SetMarginColour(kBgColor);
56 m_propertyGrid->SetCellBackgroundColour(kCellBgColor);
57 m_propertyGrid->SetCellTextColour(kTextColor);
58 m_propertyGrid->SetLineColour(kLineColor);
59 m_propertyGrid->SetSelectionBackgroundColour(m_selectionHighlight);
60}
61
64 return;
65
66 m_propertyGrid->Append(new wxPropertyCategory("Node Info"));
67 m_propertyGrid->Append(new wxStringProperty("Name", "base_name", m_selectedNode->GetName()));
68 m_propertyGrid->Append(new wxStringProperty("Type", "base_type", m_selectedNode->GetTypeString()));
69 m_propertyGrid->Append(new wxUIntProperty("ID", "base_id", static_cast<unsigned int>(m_selectedNode->GetId())));
70 m_propertyGrid->Append(
71 new wxUIntProperty("Children", "base_children", static_cast<unsigned int>(m_selectedNode->GetChildCount())));
72}
73
75 m_selectedNode = node;
76
77 if (node) {
78 m_propertyGrid->Clear();
80 m_propertyGrid->Refresh();
81 m_stack->ChangeSelection(1);
82 } else {
84 }
85}
86
88 m_selectedNode = nullptr;
89 if (m_propertyGrid) {
90 m_propertyGrid->Clear();
91 }
93 m_stack->ChangeSelection(0);
94 Layout();
95}
96
99 if (m_propertyGrid) {
100 m_propertyGrid->SetSelectionBackgroundColour(color);
101 }
102}
103
104wxString PropertiesTabBase::GetPlaceholderText() const { return "Select a node to view its properties"; }
105
107
108} // namespace EmberUI
Abstract interface for tree nodes that can be visualized.
Definition ITreeNode.h:31
void InitLayout()
Initializes the tab layout (stack, placeholder, content panels).
static const wxColour kLineColor
PropertiesTabBase(wxWindow *parent)
virtual void PopulateProperties()=0
Pure virtual: subclasses populate the property grid from m_selectedNode.
static const wxColour kCellBgColor
void SetSelectedNode(EmberCore::ITreeNode *node)
Sets the node whose properties are displayed.
static const wxColour kBgColor
void SetupPropertyGrid(wxPanel *parent)
Creates and configures the property grid in the given parent.
static const wxColour kTextColor
virtual void CreateContentLayout(wxPanel *contentPanel)=0
Pure virtual: subclasses create their content layout in contentPanel.
EmberCore::ITreeNode * m_selectedNode
void ClearSelection()
Clears the current selection.
void SetSelectionHighlightColor(const wxColour &color)
Sets the highlight color for the selected node.
virtual wxString GetPlaceholderText() const
Returns placeholder text when no node is selected.
static const wxColour kCaptionBgColor
void AddBasicNodeInfo()
Adds basic node info (name, type) to the property grid.
virtual void OnNodeCleared()
Called when selection is cleared; subclasses may override.
Standard layout constants for consistent UI spacing and sizing.
Definition Panel.h:8