11#include " pch.h"
22#include " inspector.h"
33
4-
54void Inspector::RenderHierarchyNode (HierarchyNode& node, const int depth)
65{
76 if (!Core::helper->SafeIsAlive (node.gameObject )) return ;
@@ -22,7 +21,7 @@ void Inspector::RenderHierarchyNode(HierarchyNode& node, const int depth)
2221 if (checkChildren (c)) return true ;
2322 }
2423 return false ;
25- };
24+ };
2625 if (checkChildren (child))
2726 {
2827 matchesSearch = true ;
@@ -39,8 +38,11 @@ void Inspector::RenderHierarchyNode(HierarchyNode& node, const int depth)
3938 const bool hasChildren = !node.children .empty ();
4039 const bool isSelected = (FindTabForObject (node.gameObject ) >= 0 );
4140
42- ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanAvailWidth;
43- if (!hasChildren) flags |= ImGuiTreeNodeFlags_Leaf;
41+ ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_OpenOnArrow |
42+ ImGuiTreeNodeFlags_SpanAvailWidth |
43+ ImGuiTreeNodeFlags_FramePadding;
44+
45+ if (!hasChildren) flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
4446 if (isSelected) flags |= ImGuiTreeNodeFlags_Selected;
4547
4648 bool isActive = true ;
@@ -50,17 +52,14 @@ void Inspector::RenderHierarchyNode(HierarchyNode& node, const int depth)
5052 return ;
5153 }
5254
53- if (!isActive)
54- {
55- ImGui::PushStyleColor (ImGuiCol_Text, ImVec4 (0 .5f , 0 .5f , 0 .5f , 1 .0f ));
56- }
5755
58- const bool nodeOpen = ImGui::TreeNodeEx (node.name .c_str (), flags);
56+ const char * icon = hasChildren ? " " : " " ;
57+ const char * activeIcon = isActive ? " " : " " ;
58+
59+ std::string label = activeIcon + std::string (icon) + node.name ;
60+
61+ const bool nodeOpen = ImGui::TreeNodeEx (label.c_str (), flags);
5962
60- if (!isActive)
61- {
62- ImGui::PopStyleColor ();
63- }
6463
6564 if (ImGui::IsItemClicked () && !ImGui::IsItemToggledOpen ())
6665 {
@@ -69,14 +68,19 @@ void Inspector::RenderHierarchyNode(HierarchyNode& node, const int depth)
6968
7069 if (ImGui::BeginPopupContextItem ())
7170 {
72- if (ImGui::MenuItem (" Inspect" ))
71+ if (ImGui::MenuItem (" Inspect" , nullptr , false , true ))
7372 {
7473 OpenObjectInNewTab (node.gameObject );
7574 }
75+ ImGui::Separator ();
76+ if (ImGui::MenuItem (isActive ? " Deactivate" : " Activate" ))
77+ {
78+ Core::helper->SafeSetActive (node.gameObject , !isActive);
79+ }
7680 ImGui::EndPopup ();
7781 }
7882
79- if (nodeOpen)
83+ if (hasChildren && nodeOpen)
8084 {
8185 for (auto & child : node.children )
8286 {
0 commit comments