add js save dialog

This commit is contained in:
2019-10-10 01:33:59 +02:00
parent a669d1313b
commit fd3eba69b8
5 changed files with 105 additions and 19 deletions

View File

@@ -167,7 +167,7 @@ public:
bool clipboard_set_text(const std::string& s);
void pick_image(std::function<void(std::string path)> callback);
void pick_file(std::vector<std::string> types, std::function<void(std::string path)> callback);
#if __IOS__
#if __IOS__ || __WEB__
void pick_file_save(const std::string& type, std::function<void(std::string path)> writer,
std::function<void(bool saved)> callback);
#else

View File

@@ -8,11 +8,15 @@
#include "node_about.h"
#include "node_changelog.h"
#include "node_usermanual.h"
#include "node_dialog_export_ppbr.h"
#ifdef __QUEST__
#include "oculus_vr.h"
#elif __WEB__
void webgl_pick_file(std::function<void(std::string)> callback);
void webgl_pick_file_save(const std::string& path,
const std::string& name, std::function<void(bool)> callback);
#endif
#include "node_dialog_export_ppbr.h"
std::shared_ptr<NodeProgressBar> App::show_progress(const std::string& title, int total /*= 0*/)
{
@@ -435,7 +439,8 @@ void App::dialog_export(std::string ext)
{
// TODO: use picker
auto path = work_path + "/" + doc_name + ext;
canvas->m_canvas->export_equirectangular(path, [this, path]{
auto name = doc_name + ext;
canvas->m_canvas->export_equirectangular(path, [this, path, name]{
#if defined(__IOS__)
message_box("Export Equirectangular", "Image exported to Photos");
#elif defined(__OSX__)
@@ -444,6 +449,10 @@ void App::dialog_export(std::string ext)
message_box("Export Equirectangular", "Image exported to " + work_path);
#elif defined(__QUEST__)
//auto result = ovr_Media_ShareToFacebook("Sharing from PanoPainter on Oculus Quest", path.c_str(), ovrMediaContentType_Photo);
#elif __WEB__
ui_task([=]{
webgl_pick_file_save(path, name, [](bool success){ });
});
#endif
});
}
@@ -609,7 +618,7 @@ void App::dialog_ppbr_export()
info.dest_path = dialog->m_dest_path;
if (dialog->export_check)
info.export_data = dialog->export_check->checked;
#if __IOS__
#if __IOS__ || __WEB__
App::I->pick_file_save("ppbr",
[this, dialog, info] (std::string path) {
presets->export_ppbr(path, info);

View File

@@ -19,6 +19,8 @@ std::string win32_clipboard_get_text();
#include <tinyfiledialogs.h>
#elif __WEB__
void webgl_pick_file(std::function<void(std::string)> callback);
void webgl_pick_file_save(const std::string& path,
const std::string& name, std::function<void(bool)> callback);
#endif
@@ -235,8 +237,18 @@ void App::pick_file_save(const std::string& type, std::function<void(std::string
mb->destroy();
};
}
#elif __WEB__
void App::pick_file_save(const std::string& type, std::function<void(std::string)> writer,
std::function<void(bool saved)> callback)
{
redraw = true;
auto path = data_path + "/file-save." + type;
LOG("App::pick_file_save %s", path.c_str());
writer(path);
webgl_pick_file_save(path, "file." + type, callback);
}
#else
void App::pick_file_save(std::vector<std::string> types, std::function<void (std::string)> callback)
void App::pick_file_save(std::vector<std::string> types, std::function<void(std::string)> callback)
{
redraw = true;
#if __OSX__