#include #include #include #include #include namespace lt { SceneHierarchyPanel::SceneHierarchyPanel(): m_context(nullptr), m_properties_panel_context(nullptr) { } SceneHierarchyPanel::SceneHierarchyPanel(Ref context, Ref properties_panel) : m_context(std::move(context)) , m_properties_panel_context(std::move(properties_panel)) { } void SceneHierarchyPanel::on_user_interface_update() { if (m_context) { ImGui::Begin("Hierarchy"); for (auto entityID : m_context->m_registry.view()) { auto entity = Entity { static_cast(entityID), m_context.get(), }; const auto &tag = entity.get_component(); draw_node(entity, tag); }; } ImGui::End(); } void SceneHierarchyPanel::set_context(Ref context, Ref properties_panel) { if (properties_panel) { m_properties_panel_context = std::move(properties_panel); } m_context = std::move(context); } void SceneHierarchyPanel::draw_node(Entity entity, const std::string &label) { auto flags = ImGuiTreeNodeFlags { // NOLINTNEXTLINE (m_selection_context == entity ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags {}) | ImGuiTreeNodeFlags_OpenOnArrow | ImGuiTreeNodeFlags_SpanFullWidth }; // NOLINTNEXTLINE const auto expanded = ImGui::TreeNodeEx( std::bit_cast(static_cast(entity)), flags, "%s", label.c_str() ); if (ImGui::IsItemClicked()) { m_selection_context = entity; m_properties_panel_context->set_entity_context(entity); } if (expanded) { ImGui::TextUnformatted("TEST_OPENED_TREE!"); ImGui::TreePop(); } } } // namespace lt