Add persistent shared editor tree interactions
This commit is contained in:
@@ -14,6 +14,26 @@
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
|
||||
namespace {
|
||||
|
||||
void DrawProjectFolderTreePrefix(const UI::TreeNodePrefixContext& context) {
|
||||
if (!context.drawList) {
|
||||
return;
|
||||
}
|
||||
|
||||
const float iconWidth = 14.0f;
|
||||
const float iconHeight = 11.0f;
|
||||
const float minX = context.min.x + ((context.max.x - context.min.x) - iconWidth) * 0.5f;
|
||||
const float minY = context.min.y + ((context.max.y - context.min.y) - iconHeight) * 0.5f;
|
||||
UI::DrawAssetIcon(
|
||||
context.drawList,
|
||||
ImVec2(minX, minY),
|
||||
ImVec2(minX + iconWidth, minY + iconHeight),
|
||||
UI::AssetIconKind::Folder);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ProjectPanel::ProjectPanel() : Panel("Project") {
|
||||
}
|
||||
|
||||
@@ -118,19 +138,24 @@ void ProjectPanel::RenderFolderTreeNode(
|
||||
}
|
||||
}
|
||||
|
||||
UI::TreeNodeOptions nodeOptions;
|
||||
nodeOptions.selected = folder->fullPath == currentFolderPath;
|
||||
nodeOptions.leaf = !hasChildFolders;
|
||||
nodeOptions.defaultOpen = IsCurrentTreeBranch(currentFolderPath, folder->fullPath);
|
||||
UI::TreeNodeDefinition nodeDefinition;
|
||||
nodeDefinition.options.selected = folder->fullPath == currentFolderPath;
|
||||
nodeDefinition.options.leaf = !hasChildFolders;
|
||||
nodeDefinition.options.defaultOpen = IsCurrentTreeBranch(currentFolderPath, folder->fullPath);
|
||||
nodeDefinition.persistenceKey = folder->fullPath;
|
||||
nodeDefinition.prefix.width = UI::NavigationTreePrefixWidth();
|
||||
nodeDefinition.prefix.draw = DrawProjectFolderTreePrefix;
|
||||
nodeDefinition.callbacks.onInteraction = [&manager, folder](const UI::TreeNodeResult& node) {
|
||||
if (node.clicked) {
|
||||
manager.NavigateToFolder(folder);
|
||||
}
|
||||
};
|
||||
|
||||
const UI::TreeNodeResult node = UI::DrawTreeNode(
|
||||
&m_folderTreeState,
|
||||
(void*)folder.get(),
|
||||
folder->name.c_str(),
|
||||
nodeOptions);
|
||||
|
||||
if (node.clicked) {
|
||||
manager.NavigateToFolder(folder);
|
||||
}
|
||||
nodeDefinition);
|
||||
|
||||
if (node.open) {
|
||||
for (const auto& child : folder->children) {
|
||||
|
||||
Reference in New Issue
Block a user