2022-03-13 19:32:35 -04:00
|
|
|
#include "../ta-utils.h"
|
|
|
|
#include "imgui.h"
|
2022-04-25 20:20:41 -04:00
|
|
|
#include <functional>
|
2022-03-13 22:06:08 -04:00
|
|
|
#include <vector>
|
2022-03-13 19:32:35 -04:00
|
|
|
|
2022-12-28 16:07:01 -05:00
|
|
|
#if defined(_WIN64) || defined(__APPLE__)
|
2022-06-17 02:28:22 -04:00
|
|
|
#define USE_NFD
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_NFD
|
|
|
|
#include <atomic>
|
|
|
|
#include <thread>
|
2022-06-19 19:51:51 -04:00
|
|
|
|
2023-01-18 14:57:01 -05:00
|
|
|
#ifdef __APPLE__
|
2022-06-19 19:51:51 -04:00
|
|
|
#define NFD_NON_THREADED
|
2023-01-18 14:57:01 -05:00
|
|
|
#endif
|
2022-06-19 19:51:51 -04:00
|
|
|
|
2022-11-05 20:24:14 -04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
#include <jni.h>
|
2022-06-17 02:28:22 -04:00
|
|
|
#else
|
2022-03-13 19:32:35 -04:00
|
|
|
namespace pfd {
|
|
|
|
class open_file;
|
|
|
|
class save_file;
|
|
|
|
}
|
2022-06-17 02:28:22 -04:00
|
|
|
#endif
|
2022-03-13 19:32:35 -04:00
|
|
|
|
2022-04-25 19:58:17 -04:00
|
|
|
typedef std::function<void(const char*)> FileDialogSelectCallback;
|
|
|
|
|
2022-03-13 19:32:35 -04:00
|
|
|
class FurnaceGUIFileDialog {
|
|
|
|
bool sysDialog;
|
|
|
|
bool opened;
|
|
|
|
bool saving;
|
2022-07-14 02:59:55 -04:00
|
|
|
bool hasError;
|
2022-03-13 19:32:35 -04:00
|
|
|
String curPath;
|
2022-07-15 03:23:16 -04:00
|
|
|
std::vector<String> fileName;
|
2022-06-17 02:28:22 -04:00
|
|
|
#ifdef USE_NFD
|
|
|
|
std::thread* dialogO;
|
|
|
|
std::thread* dialogS;
|
|
|
|
std::atomic<bool> dialogOK;
|
2022-07-16 02:52:15 -04:00
|
|
|
std::vector<String> nfdResult;
|
2022-11-05 20:24:14 -04:00
|
|
|
#elif defined(ANDROID)
|
|
|
|
JNIEnv* jniEnv;
|
|
|
|
void* dialogO;
|
|
|
|
void* dialogS;
|
2022-06-17 02:28:22 -04:00
|
|
|
#else
|
2022-03-13 19:32:35 -04:00
|
|
|
pfd::open_file* dialogO;
|
|
|
|
pfd::save_file* dialogS;
|
2022-06-17 02:28:22 -04:00
|
|
|
#endif
|
2022-03-13 19:32:35 -04:00
|
|
|
public:
|
2022-12-03 00:51:57 -05:00
|
|
|
bool mobileUI;
|
2022-07-15 03:23:16 -04:00
|
|
|
bool openLoad(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale, FileDialogSelectCallback clickCallback=NULL, bool allowMultiple=false);
|
2022-03-14 00:10:43 -04:00
|
|
|
bool openSave(String header, std::vector<String> filter, const char* noSysFilter, String path, double dpiScale);
|
2022-03-13 19:32:35 -04:00
|
|
|
bool accepted();
|
|
|
|
void close();
|
|
|
|
bool render(const ImVec2& min, const ImVec2& max);
|
2022-04-30 03:02:55 -04:00
|
|
|
bool isOpen();
|
2022-07-14 02:59:55 -04:00
|
|
|
bool isError();
|
2022-03-13 19:32:35 -04:00
|
|
|
String getPath();
|
2022-07-15 03:23:16 -04:00
|
|
|
std::vector<String>& getFileName();
|
2022-04-14 19:25:59 -04:00
|
|
|
explicit FurnaceGUIFileDialog(bool system):
|
2022-03-13 19:32:35 -04:00
|
|
|
sysDialog(system),
|
|
|
|
opened(false),
|
|
|
|
saving(false),
|
2022-07-14 02:59:55 -04:00
|
|
|
hasError(false),
|
2022-11-05 20:24:14 -04:00
|
|
|
#ifdef ANDROID
|
|
|
|
jniEnv(NULL),
|
|
|
|
#endif
|
2022-03-13 19:32:35 -04:00
|
|
|
dialogO(NULL),
|
2022-12-02 16:52:47 -05:00
|
|
|
dialogS(NULL),
|
2022-12-03 00:51:57 -05:00
|
|
|
mobileUI(false) {}
|
2022-03-13 22:06:08 -04:00
|
|
|
};
|