From 4887bdd7fec6317ab5b89632bc52a26a51c89730 Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Thu, 12 Mar 2026 20:11:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0Project=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E6=8B=96=E6=8B=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/panels/ProjectPanel.cpp | 21 +++++++++++++++++++++ ui/src/panels/ProjectPanel.h | 1 + 2 files changed, 22 insertions(+) diff --git a/ui/src/panels/ProjectPanel.cpp b/ui/src/panels/ProjectPanel.cpp index e1bc072c..8e435170 100644 --- a/ui/src/panels/ProjectPanel.cpp +++ b/ui/src/panels/ProjectPanel.cpp @@ -16,6 +16,13 @@ void ProjectPanel::Initialize(const std::string& projectPath) { } void ProjectPanel::Render() { + const ImGuiPayload* payload = ImGui::GetDragDropPayload(); + if (payload && payload->IsDataType(DRAG_DROP_TYPE)) { + m_draggingPath = (const char*)payload->Data; + } else if (!ImGui::IsMouseDown(0)) { + m_draggingPath.clear(); + } + ImGui::Begin(m_name.c_str(), nullptr, ImGuiWindowFlags_None); auto& manager = ProjectManager::Get(); @@ -74,6 +81,10 @@ void ProjectPanel::Render() { ImGui::PopStyleVar(); + if (ImGui::IsWindowHovered() && ImGui::IsMouseClicked(0) && !ImGui::IsAnyItemHovered()) { + manager.SetSelectedIndex(-1); + } + if (ImGui::BeginPopup("ItemContextMenu")) { if (m_contextMenuIndex >= 0 && m_contextMenuIndex < (int)items.size()) { auto& item = items[m_contextMenuIndex]; @@ -137,6 +148,9 @@ void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) { if (isSelected) { ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.40f, 0.40f, 0.40f, 0.50f)); + } else { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0, 0, 0, 0)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.30f, 0.30f, 0.30f, 0.40f)); } ImVec2 buttonSize(80.0f, 90.0f); @@ -159,11 +173,18 @@ void ProjectPanel::RenderAssetItem(const AssetItemPtr& item, int index) { if (isSelected) { ImGui::PopStyleColor(); + } else { + ImGui::PopStyleColor(2); } ImVec2 min = ImGui::GetItemRectMin(); + ImVec2 max = ImVec2(min.x + buttonSize.x, min.y + buttonSize.y); ImDrawList* drawList = ImGui::GetWindowDrawList(); + if (!m_draggingPath.empty() && item->fullPath == m_draggingPath) { + drawList->AddRectFilled(min, max, IM_COL32(0, 0, 0, 60), 0.0f); + } + ImU32 iconColor; if (item->isFolder) { iconColor = IM_COL32(200, 180, 100, 255); diff --git a/ui/src/panels/ProjectPanel.h b/ui/src/panels/ProjectPanel.h index 803c7cd1..5aea84d7 100644 --- a/ui/src/panels/ProjectPanel.h +++ b/ui/src/panels/ProjectPanel.h @@ -20,6 +20,7 @@ private: bool m_showCreateFolderPopup = false; char m_newFolderName[256] = "NewFolder"; int m_contextMenuIndex = -1; + std::string m_draggingPath; }; } \ No newline at end of file