add javascript binding and file picker for web

This commit is contained in:
2019-10-08 23:16:04 +02:00
parent f2a73a905d
commit a669d1313b
7 changed files with 228 additions and 135 deletions

View File

@@ -15,8 +15,10 @@ void win32_show_cursor(bool visible);
bool win32_clipboard_set_text(const std::string & s);
std::string win32_clipboard_get_text();
#elif __APPLE__
#else
#elif __LINUX__
#include <tinyfiledialogs.h>
#elif __WEB__
void webgl_pick_file(std::function<void(std::string)> callback);
#endif
@@ -149,6 +151,11 @@ void App::pick_image(std::function<void(std::string path)> callback)
std::string path = win32_open_file("Image Files (*.jpg, *.png)\0*.jpg;*.png");
if (!path.empty())
callback(path);
#elif __LINUX__
if (auto p = tinyfd_openFileDialog("Open File", "", 0, nullptr, nullptr, false))
callback(p);
#elif __WEB__
webgl_pick_file(callback);
#endif
}
@@ -196,6 +203,8 @@ void App::pick_file(std::vector<std::string> types, std::function<void (std::str
#elif __LINUX__
if (auto p = tinyfd_openFileDialog("Open File", "", 0, nullptr, nullptr, false))
callback(p);
#elif __WEB__
webgl_pick_file(callback);
#endif
}