|
|
|
|
@ -21,16 +21,12 @@
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
FileBrowser::FileBrowser()
|
|
|
|
|
: mIsOpen(false), mSelectionMode(SelectionMode::FILES_ONLY), mWarnOnExisting(false), mpFolderIcon(nullptr), mResult(Result::CANCEL),
|
|
|
|
|
mpNewFolderIcon(nullptr), mpUpFolderIcon(nullptr)
|
|
|
|
|
: mIsOpen(false), mSelectionMode(SelectionMode::FILES_ONLY), mWarnOnExisting(false), mResult(Result::CANCEL)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
mPrompt = "Select an item";
|
|
|
|
|
memset(mDirNameBuffer, 0, mBufferSize);
|
|
|
|
|
memset(mInputBuffer, 0, mBufferSize);
|
|
|
|
|
|
|
|
|
|
mpFolderIcon = DataManager::mFolderIcon;
|
|
|
|
|
mpNewFolderIcon = DataManager::mNewFolderIcon;
|
|
|
|
|
mpUpFolderIcon = DataManager::mUpArrowIcon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// If the given path does not exist this will default to the
|
|
|
|
|
@ -71,8 +67,8 @@ namespace lunarium
|
|
|
|
|
ImGui::TextUnformatted(mPrompt.c_str());
|
|
|
|
|
ImGui::Separator();
|
|
|
|
|
|
|
|
|
|
ImVec2 iconSize(mpNewFolderIcon->GetWidth(), mpNewFolderIcon->GetHeight());
|
|
|
|
|
if (ImGui::ImageButton((ImTextureID) mpNewFolderIcon->GetGLTextureID64(), iconSize))
|
|
|
|
|
ImVec2 iconSize(DataManager::mNewFolderIcon->GetWidth(), DataManager::mNewFolderIcon->GetHeight());
|
|
|
|
|
if (ImGui::ImageButton((ImTextureID) DataManager::mNewFolderIcon->GetGLTextureID64(), iconSize))
|
|
|
|
|
{
|
|
|
|
|
ImGui::OpenPopup("New Folder Name");
|
|
|
|
|
memset(mDirNameBuffer, 0, mBufferSize);
|
|
|
|
|
@ -90,8 +86,8 @@ namespace lunarium
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
iconSize = ImVec2(mpUpFolderIcon->GetWidth(), mpUpFolderIcon->GetHeight());
|
|
|
|
|
if (ImGui::ImageButton((ImTextureID) mpUpFolderIcon->GetGLTextureID64(), iconSize))
|
|
|
|
|
iconSize = ImVec2(DataManager::mUpArrowIcon->GetWidth(), DataManager::mUpArrowIcon->GetHeight());
|
|
|
|
|
if (ImGui::ImageButton((ImTextureID) DataManager::mUpArrowIcon->GetGLTextureID64(), iconSize))
|
|
|
|
|
{
|
|
|
|
|
mCurrentDirectory = mCurrentDirectory.parent_path();
|
|
|
|
|
ReloadItems();
|
|
|
|
|
@ -197,8 +193,8 @@ namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
if (std::filesystem::is_directory(mItemsInDir[i]))
|
|
|
|
|
{
|
|
|
|
|
ImVec2 size(mpFolderIcon->GetWidth(), mpFolderIcon->GetHeight());
|
|
|
|
|
ImTextureID id = (ImTextureID) mpFolderIcon->GetGLTextureID64();
|
|
|
|
|
ImVec2 size(DataManager::mFolderIcon->GetWidth(), DataManager::mFolderIcon->GetHeight());
|
|
|
|
|
ImTextureID id = (ImTextureID) DataManager::mFolderIcon->GetGLTextureID64();
|
|
|
|
|
ImGui::Image(id, size);
|
|
|
|
|
ImGui::SameLine();
|
|
|
|
|
}
|
|
|
|
|
@ -219,6 +215,8 @@ namespace lunarium
|
|
|
|
|
if (mSelectionMode == SelectionMode::FILES_ONLY || mSelectionMode == SelectionMode::ANY)
|
|
|
|
|
{
|
|
|
|
|
mpSelectedItem = &mItemsInDir[i];
|
|
|
|
|
memset(mInputBuffer, 0, mBufferSize);
|
|
|
|
|
memcpy(mInputBuffer, mpSelectedItem->string().c_str(), mpSelectedItem->string().size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -231,7 +229,7 @@ namespace lunarium
|
|
|
|
|
bool FileBrowser::DoButtons()
|
|
|
|
|
{
|
|
|
|
|
ImGui::SetCursorPosX(ImGui::GetWindowSize().x - 100.0f);
|
|
|
|
|
if (ImGui::Button("OK"))
|
|
|
|
|
if (mpSelectedItem && ImGui::Button("OK"))
|
|
|
|
|
{
|
|
|
|
|
if (std::filesystem::exists(*mpSelectedItem) && mWarnOnExisting)
|
|
|
|
|
{
|
|
|
|
|
|