78 lines
2.5 KiB
C++
78 lines
2.5 KiB
C++
#pragma once
|
|
|
|
#include "Panel.h"
|
|
#include "Core/AssetItem.h"
|
|
#include "UI/PopupState.h"
|
|
#include "UI/SearchText.h"
|
|
#include "UI/TreeView.h"
|
|
|
|
#include <functional>
|
|
|
|
namespace XCEngine {
|
|
namespace Editor {
|
|
|
|
class ProjectPanel : public Panel {
|
|
public:
|
|
ProjectPanel();
|
|
void Render() override;
|
|
void Initialize(const std::string& projectPath);
|
|
|
|
private:
|
|
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();
|
|
}
|
|
};
|
|
|
|
struct AssetItemInteraction {
|
|
bool clicked = false;
|
|
bool openRequested = false;
|
|
};
|
|
|
|
struct ContextMenuTarget {
|
|
AssetItemPtr item;
|
|
std::string subjectPath;
|
|
std::string createFolderPath;
|
|
bool showInExplorerSelect = false;
|
|
};
|
|
|
|
void BeginAssetDragDropFrame();
|
|
void RegisterFolderDropTarget(IProjectManager& manager, const AssetItemPtr& folder);
|
|
void FinalizeAssetDragDrop(IProjectManager& manager);
|
|
void BeginRename(const AssetItemPtr& item);
|
|
bool CommitRename(IProjectManager& manager);
|
|
void CancelRename();
|
|
ContextMenuTarget BuildContextMenuTarget(IProjectManager& manager, const AssetItemPtr& item) const;
|
|
void DrawProjectContextMenu(IProjectManager& manager, const ContextMenuTarget& target);
|
|
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);
|
|
static bool MatchesSearch(const AssetItemPtr& item, const UI::SearchQuery& searchQuery);
|
|
static bool IsCurrentTreeBranch(const std::string& currentFolderPath, const std::string& folderPath);
|
|
|
|
char m_searchBuffer[256] = "";
|
|
float m_navigationWidth = UI::ProjectNavigationDefaultWidth();
|
|
UI::TreeViewState m_folderTreeState;
|
|
UI::InlineTextEditState<std::string, 256> m_renameState;
|
|
AssetDragDropState m_assetDragDropState;
|
|
std::function<void()> m_deferredContextAction;
|
|
};
|
|
|
|
}
|
|
}
|