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