Extract shared editor tree view
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user