修复HierarchyPanel:空白区域右键菜单和拖拽到根目录功能
- 将右键菜单移到Child窗口内部,修复空白区域右键不弹出菜单的问题 - 添加InvisibleButton作为拖放目标,支持将实体拖到根级别
This commit is contained in:
@@ -28,11 +28,6 @@ void HierarchyPanel::Render() {
|
||||
|
||||
std::string filter = m_searchBuffer;
|
||||
|
||||
if (ImGui::BeginPopupContextWindow("HierarchyContextMenu", ImGuiPopupFlags_MouseButtonRight | ImGuiPopupFlags_NoOpenOverItems)) {
|
||||
RenderCreateMenu(INVALID_ENTITY);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::BeginChild("EntityList");
|
||||
|
||||
for (EntityID id : SceneManager::Get().GetRootEntities()) {
|
||||
@@ -45,6 +40,25 @@ void HierarchyPanel::Render() {
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui::BeginPopupContextWindow("HierarchyContextMenu", ImGuiPopupFlags_MouseButtonRight | ImGuiPopupFlags_NoOpenOverItems)) {
|
||||
RenderCreateMenu(INVALID_ENTITY);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::InvisibleButton("##DragTarget", ImVec2(-1, -1));
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("ENTITY_ID")) {
|
||||
EntityID sourceId = *(const EntityID*)payload->Data;
|
||||
if (sourceId != INVALID_ENTITY) {
|
||||
const Entity* sourceEntity = SceneManager::Get().GetEntity(sourceId);
|
||||
if (sourceEntity && sourceEntity->parent != INVALID_ENTITY) {
|
||||
SceneManager::Get().MoveEntity(sourceId, INVALID_ENTITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::End();
|
||||
|
||||
Reference in New Issue
Block a user