#include #include #include #include #include namespace Light { SceneHierarchyPanel::SceneHierarchyPanel() : m_context(nullptr) , m_properties_panel_context(nullptr) , m_selection_context() { } SceneHierarchyPanel:: SceneHierarchyPanel(Ref context, Ref propertiesPanel /* = nullptr */) : m_context(context) , m_properties_panel_context(propertiesPanel) { } void SceneHierarchyPanel::on_user_interface_update() { if (m_context) { ImGui::Begin("Hierarchy"); for (auto entityID : m_context->m_registry.view()) { Entity entity(static_cast(entityID), m_context.get()); const std::string &tag = entity.GetComponent(); draw_node(entity, tag); }; } ImGui::End(); } void SceneHierarchyPanel::set_context(Ref context, Ref propertiesPanel) { if (propertiesPanel) m_properties_panel_context = propertiesPanel; m_context = context; } void SceneHierarchyPanel::draw_node(Entity entity, const std::string &label) { ImGuiTreeNodeFlags flags = (m_selection_context == entity ? ImGuiTreeNodeFlags_Selected : NULL) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth; bool expanded = ImGui::TreeNodeEx((void *)(uint64_t)(uint32_t)(entity), flags, label.c_str()); if (ImGui::IsItemClicked()) { m_selection_context = entity; m_properties_panel_context->set_entity_context(entity); } if (expanded) { ImGui::Text("TEST_OPENED_TREE!"); ImGui::TreePop(); } } } // namespace Light