From de9d9dfa1c152dcc5a745832fd5092c08dbb781c Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Thu, 12 Mar 2026 20:17:43 +0800 Subject: [PATCH] Add drag preview icon in Project panel --- ui/src/panels/ProjectPanel.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ui/src/panels/ProjectPanel.cpp b/ui/src/panels/ProjectPanel.cpp index 8e435170..c2c10c8a 100644 --- a/ui/src/panels/ProjectPanel.cpp +++ b/ui/src/panels/ProjectPanel.cpp @@ -232,6 +232,26 @@ void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) { if (!item->fullPath.empty()) { if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) { ImGui::SetDragDropPayload(DRAG_DROP_TYPE, item->fullPath.c_str(), item->fullPath.length() + 1); + + ImU32 iconColor; + if (item->isFolder) { + iconColor = IM_COL32(200, 180, 100, 100); + } else if (item->type == "Texture") { + iconColor = IM_COL32(150, 200, 150, 100); + } else if (item->type == "Model") { + iconColor = IM_COL32(150, 150, 200, 100); + } else if (item->type == "Script") { + iconColor = IM_COL32(200, 150, 150, 100); + } else if (item->type == "Scene") { + iconColor = IM_COL32(200, 200, 150, 100); + } else { + iconColor = IM_COL32(100, 150, 200, 100); + } + + ImVec2 previewMin = ImGui::GetMousePos(); + ImVec2 previewMax = ImVec2(previewMin.x + 40, previewMin.y + 40); + ImGui::GetForegroundDrawList()->AddRectFilled(previewMin, previewMax, iconColor, 4.0f); + ImGui::EndDragDropSource(); } }