8#include <wx/srchctrl.h>
9#include <wx/treectrl.h>
58 wxString
GetTitle()
const override {
return "Hierarchy"; }
59 wxString
GetTabType()
const override {
return "Hierarchy"; }
62 void SetTree(std::shared_ptr<EmberCore::ITreeStructure> tree);
108 std::shared_ptr<EmberCore::ITreeStructure>
GetTree()
const {
return m_tree; }
112 wxTreeItemId
FindItemById(
size_t nodeId,
const wxTreeItemId &start = wxTreeItemId());
118 void SelectRange(
const wxTreeItemId &from,
const wxTreeItemId &to);
144 std::shared_ptr<EmberCore::ITreeStructure>
m_tree;
Abstract interface for tree nodes that can be visualized.
std::function< void(EmberCore::ITreeNode *)> SelectionCallback
EmberCore::ITreeNode * GetSelectedNode() const
Returns the currently selected node, or nullptr.
void SelectNodeById(size_t nodeId)
Selects the tree item with the given node ID.
wxTreeItemId ExpandPathToNode(EmberCore::ITreeNode *node)
Expands path from root to node and returns its item ID.
virtual void OnSelectionChanged(EmberCore::ITreeNode *node)
Called when selection changes; subclasses may override.
virtual void OnNodeActivated(EmberCore::ITreeNode *node)
Hook called when a node is double-clicked/activated.
SelectionCallback m_selectionCallback
void AddFilteredNodes(const wxTreeItemId &parentItem, EmberCore::ITreeNode *node)
TreeHierarchyTab(wxWindow *parent, const TreeHierarchyConfig &config={})
void ExpandTreeToDepth(const wxTreeItemId &item, int remainingDepth)
virtual void OnContextMenuCommand(int id, EmberCore::ITreeNode *node)
Hook to handle context menu command.
~TreeHierarchyTab() override=default
wxTreeCtrl * GetTreeCtrl() const
Returns the tree control widget.
wxSearchCtrl * m_searchCtrl
wxString GetTitle() const override
Returns the display title of the tab.
void SetSelectionCallback(SelectionCallback cb)
Sets callback invoked when selection changes.
wxWindow * GetWidget() override
Returns the wxWidgets window used as the tab content.
wxSearchCtrl * GetSearchCtrl() const
Returns the search control widget.
void SetLayoutInvalidationCallback(LayoutInvalidationCallback cb)
Sets callback invoked when layout needs invalidation (e.g. canvas sync).
const TreeHierarchyConfig & GetConfig() const
Returns the current configuration.
void CollapseAll()
Collapses all tree items.
virtual wxString GetNodeDisplayText(EmberCore::ITreeNode *node) const
Returns display text for a node; subclasses may override.
virtual void OnNodeExpanding(EmberCore::ITreeNode *node)
Called when a node is expanding; used for lazy loading.
void RefreshTree()
Rebuilds the tree from the current structure.
std::function< void()> LayoutInvalidationCallback
void ScrollToItemHorizontally(const wxTreeItemId &item)
Scrolls horizontally so the item is visible.
void OnTreeItemCollapsing(wxTreeEvent &event)
void ClearTree()
Clears the tree and removes all items.
EmberCore::ITreeNode * GetNodeFromItem(const wxTreeItemId &item) const
Extracts ITreeNode from a tree item (or nullptr if DummyTreeItemData).
void ApplyConfig(const TreeHierarchyConfig &config)
Applies new configuration and refreshes the tree.
void OnTreeItemRightClick(wxTreeEvent &event)
void OnTreeItemExpanding(wxTreeEvent &event)
virtual void OnNodeCollapsing(EmberCore::ITreeNode *node)
Called when a node is collapsing.
LayoutInvalidationCallback m_layoutInvalidationCb
void OnSearchTextChanged(wxCommandEvent &event)
wxTreeItemId m_lastSelectedItem
void ExpandTreeByVisibility(const wxTreeItemId &item)
wxTreeItemId FindItemById(size_t nodeId, const wxTreeItemId &start=wxTreeItemId())
Finds tree item by node ID, optionally starting from given item.
virtual void OnPopulateContextMenu(EmberCore::ITreeNode *node, wxMenu &menu)
Hook to populate context menu for a node.
std::shared_ptr< EmberCore::ITreeStructure > m_tree
TreeHierarchyConfig m_config
void ExpandAll()
Expands all tree items.
wxString GetTabType() const override
Returns the tab type identifier.
void OnSearchEnter(wxCommandEvent &event)
void AddChildrenToItem(const wxTreeItemId &parentItem, EmberCore::ITreeNode *node)
void OnTreeItemActivated(wxTreeEvent &event)
void SelectRange(const wxTreeItemId &from, const wxTreeItemId &to)
Selects a range of items from from to to.
void OnTreeSelectionChanged(wxTreeEvent &event)
std::shared_ptr< EmberCore::ITreeStructure > GetTree() const
Returns the current tree structure.
void SetTree(std::shared_ptr< EmberCore::ITreeStructure > tree)
Sets the tree structure to display.
Interface for tab-based UI components in the application.
DummyTreeItemData()=default
Configuration for TreeHierarchyTab appearance and behavior.
wxColour foregroundColour
Tree text.
int treeIndentationSize
Indentation per level (pixels)
bool autoExpandOnLoad
Auto-expand tree on load.
bool syncSelectionWithCanvas
Sync selection with canvas.
bool showTreeLines
Show connecting lines between nodes.
bool showNodeIcons
Show icons for node types.
bool showSearchBar
Show search bar above tree.
int autoExpandDepth
Depth to auto-expand.
bool liveSearch
Filter as user types.
int fontSize
Tree font size.
wxColour backgroundColour
Tree background.
wxColour panelColour
Panel background.
EmberCore::ITreeNode * node
TreeNodeItemData(EmberCore::ITreeNode *n)