furnace/src/gui/fileDialog.h

90 lines
2.2 KiB
C
Raw Normal View History

#include "../ta-utils.h"
#include "newFilePicker.h"
2022-04-26 09:20:41 +09:00
#include <functional>
2023-09-20 00:24:55 -05:00
#include "../pch.h"
#if defined(_WIN32) || defined(_WIN64) || defined(__APPLE__)
#ifndef SUPPORT_XP
#define USE_NFD
#endif
#endif
#ifdef USE_NFD
#include <atomic>
#include <thread>
2023-01-18 14:57:01 -05:00
#ifdef __APPLE__
#define NFD_NON_THREADED
2023-01-18 14:57:01 -05:00
#endif
#elif defined(ANDROID)
#include <jni.h>
2025-06-03 19:54:02 -05:00
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
namespace pfd {
class open_file;
class save_file;
class select_folder;
}
2025-06-03 19:54:02 -05:00
#else
// nothing
#endif
typedef std::function<void(const char*)> FileDialogSelectCallback;
class FurnaceGUIFileDialog {
bool sysDialog;
bool opened;
unsigned char dialogType;
2022-07-14 01:59:55 -05:00
bool hasError;
char noSysFilter[4096];
String curPath;
FurnaceFilePicker* newFilePicker;
std::vector<String> fileName;
#ifdef USE_NFD
std::thread* dialogO;
std::thread* dialogS;
std::thread* dialogF;
std::atomic<bool> dialogOK;
std::vector<String> nfdResult;
#elif defined(ANDROID)
JNIEnv* jniEnv;
void* dialogO;
void* dialogS;
void* dialogF;
2025-06-03 19:54:02 -05:00
#elif (!defined(SUPPORT_XP) || !defined(_WIN32))
pfd::open_file* dialogO;
pfd::save_file* dialogS;
pfd::select_folder* dialogF;
2025-06-03 19:54:02 -05:00
#else
unsigned char* dialogO;
unsigned char* dialogS;
unsigned char* dialogF;
#endif
void convertFilterList(std::vector<String>& filter);
public:
2022-12-03 00:51:57 -05:00
bool mobileUI;
2024-05-24 03:51:35 -05:00
bool openLoad(String header, std::vector<String> filter, String path, double dpiScale, FileDialogSelectCallback clickCallback=NULL, bool allowMultiple=false, String hint="");
bool openSave(String header, std::vector<String> filter, String path, double dpiScale, String hint="");
bool openSelectDir(String header, String path, double dpiScale, String hint="");
bool accepted();
void close();
bool render(const ImVec2& min, const ImVec2& max);
bool isOpen();
2022-07-14 01:59:55 -05:00
bool isError();
String getPath();
std::vector<String>& getFileName();
explicit FurnaceGUIFileDialog(bool system, FurnaceFilePicker* builtInPicker):
sysDialog(system),
opened(false),
dialogType(0),
2022-07-14 01:59:55 -05:00
hasError(false),
newFilePicker(builtInPicker),
#ifdef ANDROID
jniEnv(NULL),
#endif
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 21:06:08 -05:00
};