bind the new file picker

here be lions until further notice.
This commit is contained in:
tildearrow 2025-09-27 23:01:24 -05:00
parent 4ec66a4684
commit d81d8ff6aa
6 changed files with 64 additions and 138 deletions

View file

@ -1,5 +1,4 @@
#include "fileDialog.h"
#include "ImGuiFileDialog.h"
#include "util.h"
#include "../ta-log.h"
@ -192,13 +191,9 @@ bool FurnaceGUIFileDialog::openLoad(String header, std::vector<String> filter, S
}
#endif
convertFilterList(filter);
ImGuiFileDialog::Instance()->singleClickSel=mobileUI;
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
ImGuiFileDialog::Instance()->mobileMode=mobileUI;
ImGuiFileDialog::Instance()->homePath=getHomeDir();
ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,filter.empty()?NULL:noSysFilter,path,hint,allowMultiple?999:1,nullptr,0,clickCallback);
// TODO: hint, clickCallback, "FileDialog" ID
newFilePicker->setHomeDir(getHomeDir());
newFilePicker->open(header+"##FileDialog",path,FP_FLAGS_MODAL|(allowMultiple?FP_FLAGS_MULTI_SELECT:0),filter);
}
opened=true;
return true;
@ -281,13 +276,9 @@ bool FurnaceGUIFileDialog::openSave(String header, std::vector<String> filter, S
} else {
hasError=false;
convertFilterList(filter);
ImGuiFileDialog::Instance()->singleClickSel=false;
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
ImGuiFileDialog::Instance()->mobileMode=mobileUI;
ImGuiFileDialog::Instance()->homePath=getHomeDir();
ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,noSysFilter,path,hint,1,nullptr,ImGuiFileDialogFlags_ConfirmOverwrite);
// TODO: hint, clickCallback, "FileDialog" ID
newFilePicker->setHomeDir(getHomeDir());
newFilePicker->open(header+"##FileDialog",path,FP_FLAGS_MODAL|FP_FLAGS_SAVE,filter);
}
opened=true;
return true;
@ -334,11 +325,9 @@ bool FurnaceGUIFileDialog::openSelectDir(String header, String path, double dpiS
}
#endif
ImGuiFileDialog::Instance()->singleClickSel=mobileUI;
ImGuiFileDialog::Instance()->DpiScale=dpiScale;
ImGuiFileDialog::Instance()->mobileMode=mobileUI;
ImGuiFileDialog::Instance()->homePath=getHomeDir();
ImGuiFileDialog::Instance()->OpenModal("FileDialog",header,NULL,path,hint,1,nullptr,0);
// TODO: hint, "FileDialog" ID
newFilePicker->setHomeDir(getHomeDir());
newFilePicker->open(header+"##FileDialog",path,FP_FLAGS_MODAL|FP_FLAGS_DIR_SELECT,{});
}
opened=true;
return true;
@ -348,7 +337,7 @@ bool FurnaceGUIFileDialog::accepted() {
if (sysDialog) {
return (!fileName.empty());
} else {
return ImGuiFileDialog::Instance()->IsOk();
return (newFilePicker->getStatus()==FP_STATUS_ACCEPTED);
}
}
@ -391,7 +380,7 @@ void FurnaceGUIFileDialog::close() {
dialogOK=false;
#endif
} else {
ImGuiFileDialog::Instance()->Close();
newFilePicker->close();
}
opened=false;
}
@ -468,7 +457,7 @@ bool FurnaceGUIFileDialog::render(const ImVec2& min, const ImVec2& max) {
return false;
#endif
} else {
return ImGuiFileDialog::Instance()->Display("FileDialog",ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove|ImGuiWindowFlags_NoScrollWithMouse,min,max);
return newFilePicker->draw();
}
}
@ -490,7 +479,7 @@ String FurnaceGUIFileDialog::getPath() {
logD("curPath: %s",curPath.c_str());
return curPath;
} else {
return ImGuiFileDialog::Instance()->GetCurrentPath();
return newFilePicker->getPath();
}
}
@ -499,14 +488,7 @@ std::vector<String>& FurnaceGUIFileDialog::getFileName() {
return fileName;
} else {
fileName.clear();
if (dialogType!=0) {
fileName.push_back(ImGuiFileDialog::Instance()->GetFilePathName());
} else {
for (auto& i: ImGuiFileDialog::Instance()->GetSelection()) {
fileName.push_back(i.second);
}
}
//
fileName=newFilePicker->getSelected();
return fileName;
}
}