Extract shared editor tree view

This commit is contained in:
2026-03-27 22:05:05 +08:00
parent a51e0f6f88
commit 37a90b39e2
6 changed files with 120 additions and 169 deletions

View File

@@ -14,12 +14,6 @@ struct ComponentSectionResult {
bool open = false;
};
struct HierarchyNodeResult {
bool open = false;
bool clicked = false;
bool doubleClicked = false;
};
struct AssetTileResult {
bool clicked = false;
bool contextRequested = false;
@@ -183,37 +177,6 @@ inline void DrawToolbarBreadcrumbs(
ImGui::PopStyleColor(2);
}
inline HierarchyNodeResult DrawHierarchyNode(
const void* id,
const char* label,
bool selected,
bool leaf) {
ImGuiTreeNodeFlags flags =
ImGuiTreeNodeFlags_OpenOnArrow |
ImGuiTreeNodeFlags_SpanAvailWidth |
ImGuiTreeNodeFlags_FramePadding;
if (leaf) {
flags |= ImGuiTreeNodeFlags_Leaf;
}
if (selected) {
flags |= ImGuiTreeNodeFlags_Selected;
}
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, HierarchyNodeFramePadding());
const bool open = ImGui::TreeNodeEx(id, flags, "%s", label);
ImGui::PopStyleVar();
return HierarchyNodeResult{
open,
ImGui::IsItemClicked() && !ImGui::IsItemToggledOpen(),
ImGui::IsItemHovered() && ImGui::IsMouseDoubleClicked(0)
};
}
inline void EndHierarchyNode() {
ImGui::TreePop();
}
template <typename DrawIconFn>
inline AssetTileResult DrawAssetTile(
const char* label,