Plan app export targets in app core
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
#include "action.h"
|
||||
#include "app_core/document_export.h"
|
||||
#include "settings.h"
|
||||
#include "node_dialog_open.h"
|
||||
#include "node_dialog_browse.h"
|
||||
@@ -421,9 +422,13 @@ void App::dialog_export(std::string ext)
|
||||
if (canvas)
|
||||
{
|
||||
// TODO: use picker
|
||||
auto path = work_path + "/" + doc_name + ext;
|
||||
auto name = doc_name + ext;
|
||||
canvas->m_canvas->export_equirectangular(path, [this, path, name]{
|
||||
const auto target = pp::app::make_document_export_file_target(work_path, doc_name, ext);
|
||||
if (!target) {
|
||||
message_box("Export Equirectangular", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_equirectangular(target.value().path, [this, target = target.value()]{
|
||||
#if defined(__IOS__)
|
||||
message_box("Export Equirectangular", "Image exported to Photos");
|
||||
#elif defined(__OSX__)
|
||||
@@ -434,7 +439,7 @@ void App::dialog_export(std::string ext)
|
||||
//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){ });
|
||||
webgl_pick_file_save(target.path, target.suggested_name, [](bool success){ });
|
||||
});
|
||||
#endif
|
||||
});
|
||||
@@ -452,19 +457,28 @@ void App::dialog_export_layers()
|
||||
if (canvas)
|
||||
{
|
||||
#if defined(__IOS__)
|
||||
auto dir = work_path + "/" + doc_name + "_layers";
|
||||
if (Asset::create_dir(dir))
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_layers");
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
auto p = dir + "/" + doc_name;
|
||||
canvas->m_canvas->export_layers(p, [this, p] {
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
auto p = path + "/" + doc_name;
|
||||
canvas->m_canvas->export_layers(p, [this, p] {
|
||||
message_box("Export Layers", "Layers exported to: " + p);
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_layers(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
});
|
||||
#endif
|
||||
@@ -482,19 +496,28 @@ void App::dialog_export_anim_frames()
|
||||
if (canvas)
|
||||
{
|
||||
#if defined(__IOS__)
|
||||
auto dir = work_path + "/" + doc_name + "_frames";
|
||||
if (Asset::create_dir(dir))
|
||||
const auto target = pp::app::make_document_export_collection_target(work_path, doc_name, "_frames");
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Asset::create_dir(target.value().directory))
|
||||
{
|
||||
auto p = dir + "/" + doc_name;
|
||||
canvas->m_canvas->export_anim_frames(p, [this, p] {
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this] {
|
||||
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
|
||||
});
|
||||
}
|
||||
#else
|
||||
pick_dir([this](std::string path) {
|
||||
auto p = path + "/" + doc_name;
|
||||
canvas->m_canvas->export_anim_frames(p, [this, p] {
|
||||
message_box("Export Layers", "Layers exported to: " + p);
|
||||
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
|
||||
if (!target) {
|
||||
message_box("Export Layers", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this, target = target.value()] {
|
||||
message_box("Export Layers", "Layers exported to: " + target.stem_path);
|
||||
});
|
||||
});
|
||||
#endif
|
||||
@@ -657,7 +680,13 @@ void App::dialog_ppbr_export()
|
||||
void App::dialog_timelapse_export()
|
||||
{
|
||||
#if __IOS__ || __WEB__
|
||||
pick_file_save("mp4", doc_name + "-timelapse",
|
||||
const auto target = pp::app::make_document_export_suggested_name(doc_name, "-timelapse");
|
||||
if (!target) {
|
||||
message_box("Export Timelapse", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
pick_file_save("mp4", target.value().name,
|
||||
[this](std::string path) {
|
||||
rec_export(path);
|
||||
},
|
||||
@@ -679,7 +708,13 @@ void App::dialog_timelapse_export()
|
||||
void App::dialog_export_mp4()
|
||||
{
|
||||
#if __IOS__ || __WEB__
|
||||
pick_file_save("mp4", doc_name + "-animation",
|
||||
const auto target = pp::app::make_document_export_suggested_name(doc_name, "-animation");
|
||||
if (!target) {
|
||||
message_box("Export Animation", target.status().message);
|
||||
return;
|
||||
}
|
||||
|
||||
pick_file_save("mp4", target.value().name,
|
||||
[this](std::string path) {
|
||||
export_anim_mp4(path);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user