From 7b30cfb1b75ad4569b86134fc4a0235e52f7c019 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Fri, 16 Jun 2023 15:43:41 -0500 Subject: [PATCH] IGFD: some changes --- extern/igfd/ImGuiFileDialog.cpp | 13 +++++++------ extern/igfd/ImGuiFileDialog.h | 2 ++ src/gui/fileDialog.cpp | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/extern/igfd/ImGuiFileDialog.cpp b/extern/igfd/ImGuiFileDialog.cpp index 4af6ca44..4ad01ba1 100644 --- a/extern/igfd/ImGuiFileDialog.cpp +++ b/extern/igfd/ImGuiFileDialog.cpp @@ -133,6 +133,9 @@ namespace IGFD #ifndef resetButtonString #define resetButtonString ICON_FA_REPEAT #endif // resetButtonString +#ifndef homeButtonString +#define homeButtonString ICON_FA_HOME +#endif // bomeButtonString #ifndef drivesButtonString #define drivesButtonString ICON_FA_HDD_O #endif // drivesButtonString @@ -170,7 +173,7 @@ namespace IGFD #define buttonEditPathString "Edit path\nYou can also right click on path buttons" #endif // buttonEditPathString #ifndef buttonResetPathString -#define buttonResetPathString "Reset to current directory" +#define buttonResetPathString "Go to home directory" #endif // buttonResetPathString #ifndef buttonParentDirString #define buttonParentDirString "Go to parent directory" @@ -700,10 +703,8 @@ namespace IGFD if (ImGui::IsItemHovered()) ImGui::SetTooltip(buttonResetSearchString); ImGui::SameLine(); - ImGui::Text(searchString); - ImGui::SameLine(); ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x); - bool edited = ImGui::InputText("##InputImGuiFileDialogSearchField", puSearchBuffer, MAX_FILE_DIALOG_NAME_BUFFER); + bool edited = ImGui::InputTextWithHint("##InputImGuiFileDialogSearchField", searchString, puSearchBuffer, MAX_FILE_DIALOG_NAME_BUFFER); if (ImGui::GetItemID() == ImGui::GetActiveID()) puSearchInputIsActive = true; ImGui::PopItemWidth(); @@ -2245,9 +2246,9 @@ namespace IGFD void IGFD::FileManager::DrawPathComposer(const FileDialogInternal& vFileDialogInternal) { - if (IMGUI_BUTTON(resetButtonString)) + if (IMGUI_BUTTON(homeButtonString)) { - SetCurrentPath("."); + SetCurrentPath(FileDialog::Instance()->homePath); OpenCurrentPath(vFileDialogInternal); } if (ImGui::IsItemHovered()) diff --git a/extern/igfd/ImGuiFileDialog.h b/extern/igfd/ImGuiFileDialog.h index 827a987e..2ad9cbc8 100644 --- a/extern/igfd/ImGuiFileDialog.h +++ b/extern/igfd/ImGuiFileDialog.h @@ -878,6 +878,7 @@ namespace IGFD bool fileListActuallyEmpty = false; std::string puDLGpath; // base path set by user when OpenDialog/OpenModal was called + std::string puError; // last error std::string puDLGDefaultFileName; // base default file path name set by user when OpenDialog/OpenModal was called size_t puDLGcountSelectionMax = 1U; // 0 for infinite // base max selection count set by user when OpenDialog/OpenModal was called bool puDLGDirectoryMode = false; // is directory mode (defiend like : puDLGDirectoryMode = (filters.empty())) @@ -1145,6 +1146,7 @@ namespace IGFD double DpiScale; bool singleClickSel; bool mobileMode; + std::string homePath; public: static FileDialog* Instance() // Singleton for easier accces form anywhere but only one dialog at a time diff --git a/src/gui/fileDialog.cpp b/src/gui/fileDialog.cpp index 94ffa94e..a0a45e1e 100644 --- a/src/gui/fileDialog.cpp +++ b/src/gui/fileDialog.cpp @@ -1,5 +1,6 @@ #include "fileDialog.h" #include "ImGuiFileDialog.h" +#include "util.h" #include "../ta-log.h" #ifdef USE_NFD @@ -152,6 +153,7 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector filter, c ImGuiFileDialog::Instance()->singleClickSel=mobileUI; ImGuiFileDialog::Instance()->DpiScale=dpiScale; ImGuiFileDialog::Instance()->mobileMode=mobileUI; + ImGuiFileDialog::Instance()->homePath=getHomeDir(); ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,noSysFilter,path,allowMultiple?999:1,nullptr,0,clickCallback); } opened=true; @@ -235,6 +237,7 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector filter, c ImGuiFileDialog::Instance()->singleClickSel=false; ImGuiFileDialog::Instance()->DpiScale=dpiScale; ImGuiFileDialog::Instance()->mobileMode=mobileUI; + ImGuiFileDialog::Instance()->homePath=getHomeDir(); ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,noSysFilter,path,1,nullptr,ImGuiFileDialogFlags_ConfirmOverwrite); } opened=true;