2026-03-20 17:08:06 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "Panel.h"
|
|
|
|
|
#include "Core/AssetItem.h"
|
2026-03-26 21:18:33 +08:00
|
|
|
#include "UI/PopupState.h"
|
2026-04-01 16:40:54 +08:00
|
|
|
#include "UI/SearchText.h"
|
2026-03-27 23:21:43 +08:00
|
|
|
#include "UI/TreeView.h"
|
2026-03-20 17:08:06 +08:00
|
|
|
|
2026-03-29 15:12:38 +08:00
|
|
|
#include <functional>
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
namespace XCEngine {
|
|
|
|
|
namespace Editor {
|
2026-03-20 17:08:06 +08:00
|
|
|
|
|
|
|
|
class ProjectPanel : public Panel {
|
|
|
|
|
public:
|
|
|
|
|
ProjectPanel();
|
|
|
|
|
void Render() override;
|
|
|
|
|
void Initialize(const std::string& projectPath);
|
|
|
|
|
|
|
|
|
|
private:
|
2026-03-29 01:36:53 +08:00
|
|
|
struct AssetDragDropState {
|
|
|
|
|
bool dragging = false;
|
|
|
|
|
bool hoveredTarget = false;
|
|
|
|
|
bool hoveredValidTarget = false;
|
|
|
|
|
std::string sourcePath;
|
|
|
|
|
std::string deliveredSourcePath;
|
|
|
|
|
AssetItemPtr deliveredTarget;
|
|
|
|
|
|
|
|
|
|
void Reset() {
|
|
|
|
|
dragging = false;
|
|
|
|
|
hoveredTarget = false;
|
|
|
|
|
hoveredValidTarget = false;
|
|
|
|
|
sourcePath.clear();
|
|
|
|
|
deliveredSourcePath.clear();
|
|
|
|
|
deliveredTarget.reset();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-27 21:55:14 +08:00
|
|
|
struct AssetItemInteraction {
|
|
|
|
|
bool clicked = false;
|
|
|
|
|
bool openRequested = false;
|
|
|
|
|
};
|
|
|
|
|
|
2026-04-03 13:22:30 +08:00
|
|
|
struct ContextMenuTarget {
|
|
|
|
|
AssetItemPtr item;
|
|
|
|
|
std::string subjectPath;
|
|
|
|
|
std::string createFolderPath;
|
|
|
|
|
bool showInExplorerSelect = false;
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-29 01:36:53 +08:00
|
|
|
void BeginAssetDragDropFrame();
|
|
|
|
|
void RegisterFolderDropTarget(IProjectManager& manager, const AssetItemPtr& folder);
|
|
|
|
|
void FinalizeAssetDragDrop(IProjectManager& manager);
|
|
|
|
|
void BeginRename(const AssetItemPtr& item);
|
|
|
|
|
bool CommitRename(IProjectManager& manager);
|
|
|
|
|
void CancelRename();
|
2026-04-03 13:22:30 +08:00
|
|
|
ContextMenuTarget BuildContextMenuTarget(IProjectManager& manager, const AssetItemPtr& item) const;
|
|
|
|
|
void DrawProjectContextMenu(IProjectManager& manager, const ContextMenuTarget& target);
|
2026-03-27 21:55:14 +08:00
|
|
|
void RenderToolbar();
|
|
|
|
|
void RenderFolderTreePane(IProjectManager& manager);
|
|
|
|
|
void RenderFolderTreeNode(IProjectManager& manager, const AssetItemPtr& folder, const std::string& currentFolderPath);
|
|
|
|
|
void RenderBrowserPane(IProjectManager& manager);
|
|
|
|
|
void RenderBrowserHeader(IProjectManager& manager);
|
|
|
|
|
AssetItemInteraction RenderAssetItem(const AssetItemPtr& item, bool isSelected);
|
2026-04-01 16:40:54 +08:00
|
|
|
static bool MatchesSearch(const AssetItemPtr& item, const UI::SearchQuery& searchQuery);
|
2026-03-27 21:55:14 +08:00
|
|
|
static bool IsCurrentTreeBranch(const std::string& currentFolderPath, const std::string& folderPath);
|
2026-03-20 17:08:06 +08:00
|
|
|
|
|
|
|
|
char m_searchBuffer[256] = "";
|
2026-03-27 21:55:14 +08:00
|
|
|
float m_navigationWidth = UI::ProjectNavigationDefaultWidth();
|
2026-03-27 23:21:43 +08:00
|
|
|
UI::TreeViewState m_folderTreeState;
|
2026-03-29 01:36:53 +08:00
|
|
|
UI::InlineTextEditState<std::string, 256> m_renameState;
|
|
|
|
|
AssetDragDropState m_assetDragDropState;
|
2026-03-29 15:12:38 +08:00
|
|
|
std::function<void()> m_deferredContextAction;
|
2026-03-20 17:08:06 +08:00
|
|
|
};
|
|
|
|
|
|
2026-03-24 20:02:38 +08:00
|
|
|
}
|
2026-03-26 21:18:33 +08:00
|
|
|
}
|