|
|
|
@ -26,6 +26,7 @@ namespace editor
|
|
|
|
: Panel("Asset Browser", PanelDockZone::DDZ_BOTTOM, true, (ImGuiWindowFlags)ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar),
|
|
|
|
: Panel("Asset Browser", PanelDockZone::DDZ_BOTTOM, true, (ImGuiWindowFlags)ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar),
|
|
|
|
mAssetDirectory(dir), mpEditor(pEditor), mNewFolder(false), mSyncTree(false)
|
|
|
|
mAssetDirectory(dir), mpEditor(pEditor), mNewFolder(false), mSyncTree(false)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
DefinePopups();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::SetAssetDirectory(std::filesystem::path dir)
|
|
|
|
void AssetBrowser::SetAssetDirectory(std::filesystem::path dir)
|
|
|
|
@ -39,6 +40,10 @@ namespace editor
|
|
|
|
return mSelectedDir;
|
|
|
|
return mSelectedDir;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// DO FRAME DO FRAME DO FRAME
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::DoFrame()
|
|
|
|
void AssetBrowser::DoFrame()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
@ -63,9 +68,15 @@ namespace editor
|
|
|
|
// Contents
|
|
|
|
// Contents
|
|
|
|
DoContentArea(wind_size);
|
|
|
|
DoContentArea(wind_size);
|
|
|
|
|
|
|
|
|
|
|
|
HandlePopupActions();
|
|
|
|
//HandlePopupActions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// FRAME HELPERS FRAME HELPERS
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// DIRECTORY TREE
|
|
|
|
void AssetBrowser::DoDirTree(std::filesystem::path dir)
|
|
|
|
void AssetBrowser::DoDirTree(std::filesystem::path dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if ("" == dir)
|
|
|
|
if ("" == dir)
|
|
|
|
@ -115,6 +126,8 @@ namespace editor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// CONTENT AREA
|
|
|
|
void AssetBrowser::DoContentArea(ImVec2 wind_size)
|
|
|
|
void AssetBrowser::DoContentArea(ImVec2 wind_size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ImGui::BeginChild("Contents", ImVec2(wind_size.x * 0.85f, wind_size.y), true, ImGuiWindowFlags_NoCollapse))
|
|
|
|
if (ImGui::BeginChild("Contents", ImVec2(wind_size.x * 0.85f, wind_size.y), true, ImGuiWindowFlags_NoCollapse))
|
|
|
|
@ -141,7 +154,7 @@ namespace editor
|
|
|
|
ImVec2(DataManager::mNewFolderIcon->GetWidth(), DataManager::mNewFolderIcon->GetHeight()),
|
|
|
|
ImVec2(DataManager::mNewFolderIcon->GetWidth(), DataManager::mNewFolderIcon->GetHeight()),
|
|
|
|
ImVec2(0, 0), ImVec2(1, 1), 4))
|
|
|
|
ImVec2(0, 0), ImVec2(1, 1), 4))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mNewFolder = true;
|
|
|
|
OpenPopup(PopUp::NEW_FOLDER).LogIfFailed(Editor::LogCat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::EndChild();
|
|
|
|
@ -197,7 +210,7 @@ namespace editor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DoContextMenu();
|
|
|
|
DoContentContextMenu();
|
|
|
|
|
|
|
|
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -205,13 +218,16 @@ namespace editor
|
|
|
|
ImGui::EndChild();
|
|
|
|
ImGui::EndChild();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::DoContextMenu()
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// CONTEXT MENUS
|
|
|
|
|
|
|
|
void AssetBrowser::DoContentContextMenu()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ImGui::BeginPopupContextWindow(0, 1, false))
|
|
|
|
if (ImGui::BeginPopupContextWindow(0, 1, false))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ImGui::Button("New Folder"))
|
|
|
|
if (ImGui::Button("New Folder"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mNewFolder = true;
|
|
|
|
//mNewFolder = true;
|
|
|
|
|
|
|
|
OpenPopup(PopUp::NEW_FOLDER).LogIfFailed(Editor::LogCat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Buttons for creating/importing new assets
|
|
|
|
// TODO: Buttons for creating/importing new assets
|
|
|
|
@ -219,45 +235,8 @@ namespace editor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
void AssetBrowser::DefinePopups()
|
|
|
|
// ASSET DROP HELPER
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::DoNewFolder()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (ImGui::BeginPopupContextItem("New Folder Name"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
char name_buf[64] = "New Folder";
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("Folder Name: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::InputText("##Folder Name", name_buf, 64, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::filesystem::create_directory(mSelectedDir / name_buf);
|
|
|
|
|
|
|
|
mNewFolder = false;
|
|
|
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::ESCAPE, true))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mNewFolder = false;
|
|
|
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ImGui::EndPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::HandlePopupActions()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (mNewFolder)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DoNewFolder();
|
|
|
|
|
|
|
|
ImGui::OpenPopup("New Folder Name");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::HandleAssetDrop(std::filesystem::path dir)
|
|
|
|
void AssetBrowser::HandleAssetDrop(std::filesystem::path dir)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
if (ImGui::BeginDragDropTarget())
|
|
|
|
@ -274,5 +253,36 @@ namespace editor
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
ImGui::EndDragDropTarget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// POPUP PANELS POPUP PANELS
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void AssetBrowser::DefinePopups()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
AddPopup(PopUp::NEW_FOLDER, "New Folder Name", [](Panel *p)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
bool stay_open = true;
|
|
|
|
|
|
|
|
AssetBrowser* ab = (AssetBrowser*)p;
|
|
|
|
|
|
|
|
char name_buf[64] = "New Folder";
|
|
|
|
|
|
|
|
ImGui::TextUnformatted("Folder Name: ");
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
|
|
|
if (ImGui::InputText("##Folder Name", name_buf, 64, ImGuiInputTextFlags_AutoSelectAll | ImGuiInputTextFlags_EnterReturnsTrue))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::filesystem::create_directory(ab->mSelectedDir / name_buf);
|
|
|
|
|
|
|
|
stay_open = false;
|
|
|
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Core::Input().IsKeyDown(KeyCode::ESCAPE, true))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stay_open = false;
|
|
|
|
|
|
|
|
ImGui::CloseCurrentPopup();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return stay_open;
|
|
|
|
|
|
|
|
}).LogIfFailed(Editor::LogCat);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|