Added cross platform support for file and folder select widgets

This commit is contained in:
Ryzerth
2021-04-29 20:43:17 +02:00
parent 1738706c59
commit ab4cde9bb8
9 changed files with 1747 additions and 127 deletions

View File

@@ -3,16 +3,11 @@
#include <imgui_internal.h>
#include <stdint.h>
#include <string>
#ifdef _WIN32
#include <Windows.h>
#include <thread>
#include <ShlObj.h>
#endif
class FileSelect {
public:
FileSelect(std::string defaultPath);
FileSelect(std::string defaultPath, std::vector<std::string> filter = {"All Files", "*"});
bool render(std::string id);
void setPath(std::string path);
bool pathIsValid();
@@ -20,20 +15,13 @@ public:
std::string expandString(std::string input);
std::string path = "";
#ifdef _WIN32
void setWindowsFilter(COMDLG_FILTERSPEC* filt, int n);
#endif
private:
#ifdef _WIN32
void windowsWorker();
void worker();
std::thread workerThread;
COMDLG_FILTERSPEC* filter = NULL;
int filterCount = 0;
#endif
std::vector<std::string> _filter;
char _filter[2048];
bool pathValid = false;
bool dialogOpen = false;
char strPath[2048];