Route prepared export policy through platform services
This commit is contained in:
@@ -184,6 +184,7 @@ public:
|
||||
void pick_file_save(const std::string& type, const std::string& default_name,
|
||||
std::function<void(std::string path)> writer, std::function<void(const std::string& path, bool saved)> callback);
|
||||
void pick_file_save(std::vector<std::string> types, std::function<void(std::string path)> callback);
|
||||
[[nodiscard]] bool uses_prepared_file_writes() const;
|
||||
void pick_dir(std::function<void(std::string path)> callback);
|
||||
void display_file(std::string path);
|
||||
void share_file(std::string path);
|
||||
|
||||
@@ -515,25 +515,29 @@ void App::dialog_ppbr_export()
|
||||
auto dialog = root->add_child_ref<NodeDialogExportPPBR>();
|
||||
dialog->btn_ok->on_click = [this, dialog] (Node*) {
|
||||
const auto request = pp::panopainter::make_legacy_brush_package_export_request(*dialog);
|
||||
#if __IOS__ || __WEB__
|
||||
App::I->pick_file_save("ppbr", "exported-brushes",
|
||||
[this, dialog, request] (std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_brush_package_export(
|
||||
*this,
|
||||
*dialog,
|
||||
request,
|
||||
path,
|
||||
pp::panopainter::LegacyBrushPackageExportMode::inline_export_only);
|
||||
if (!status.ok())
|
||||
LOG("PPBR export failed: %s", status.message);
|
||||
},
|
||||
[dialog] (const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
pp::panopainter::complete_legacy_brush_package_export(*dialog, saved);
|
||||
}
|
||||
);
|
||||
#else
|
||||
App::I->pick_file_save({ "ppbr" }, [this, dialog, request] (std::string path) {
|
||||
|
||||
if (uses_prepared_file_writes())
|
||||
{
|
||||
pick_file_save("ppbr", "exported-brushes",
|
||||
[this, dialog, request] (std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_brush_package_export(
|
||||
*this,
|
||||
*dialog,
|
||||
request,
|
||||
path,
|
||||
pp::panopainter::LegacyBrushPackageExportMode::inline_export_only);
|
||||
if (!status.ok())
|
||||
LOG("PPBR export failed: %s", status.message);
|
||||
},
|
||||
[dialog] (const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
pp::panopainter::complete_legacy_brush_package_export(*dialog, saved);
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
pick_file_save({ "ppbr" }, [this, dialog, request] (std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_brush_package_export(
|
||||
*this,
|
||||
*dialog,
|
||||
@@ -543,7 +547,6 @@ void App::dialog_ppbr_export()
|
||||
if (!status.ok())
|
||||
LOG("PPBR export failed: %s", status.message);
|
||||
});
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
||||
@@ -552,29 +555,32 @@ void App::dialog_timelapse_export()
|
||||
if (!can_start_document_export(*this, false))
|
||||
return;
|
||||
|
||||
#if __IOS__ || __WEB__
|
||||
const auto target = pp::app::make_document_export_suggested_name(doc_name, "-timelapse");
|
||||
if (!target) {
|
||||
message_box("Export Timelapse", target.status().message);
|
||||
if (uses_prepared_file_writes())
|
||||
{
|
||||
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) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
pp::app::DocumentVideoExportKind::timelapse,
|
||||
path,
|
||||
false);
|
||||
if (!status.ok())
|
||||
LOG("Document timelapse export failed: %s", status.message);
|
||||
},
|
||||
[](const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
(void)saved;
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
pick_file_save("mp4", target.value().name,
|
||||
[this](std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
pp::app::DocumentVideoExportKind::timelapse,
|
||||
path,
|
||||
false);
|
||||
if (!status.ok())
|
||||
LOG("Document timelapse export failed: %s", status.message);
|
||||
},
|
||||
[](const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
(void)saved;
|
||||
}
|
||||
);
|
||||
#else
|
||||
pick_file_save({ "mp4" }, [this](std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
@@ -584,7 +590,6 @@ void App::dialog_timelapse_export()
|
||||
if (!status.ok())
|
||||
LOG("Document timelapse export failed: %s", status.message);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::dialog_export_mp4()
|
||||
@@ -592,29 +597,32 @@ void App::dialog_export_mp4()
|
||||
if (!can_start_document_export(*this, false))
|
||||
return;
|
||||
|
||||
#if __IOS__ || __WEB__
|
||||
const auto target = pp::app::make_document_export_suggested_name(doc_name, "-animation");
|
||||
if (!target) {
|
||||
message_box("Export Animation", target.status().message);
|
||||
if (uses_prepared_file_writes())
|
||||
{
|
||||
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) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
pp::app::DocumentVideoExportKind::animation_mp4,
|
||||
path,
|
||||
false);
|
||||
if (!status.ok())
|
||||
LOG("Document animation export failed: %s", status.message);
|
||||
},
|
||||
[](const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
(void)saved;
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
pick_file_save("mp4", target.value().name,
|
||||
[this](std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
pp::app::DocumentVideoExportKind::animation_mp4,
|
||||
path,
|
||||
false);
|
||||
if (!status.ok())
|
||||
LOG("Document animation export failed: %s", status.message);
|
||||
},
|
||||
[](const std::string& path, bool saved) {
|
||||
(void)path;
|
||||
(void)saved;
|
||||
}
|
||||
);
|
||||
#else
|
||||
pick_file_save({ "mp4" }, [this](std::string path) {
|
||||
const auto status = pp::panopainter::execute_legacy_document_video_export(
|
||||
*this,
|
||||
@@ -624,7 +632,6 @@ void App::dialog_export_mp4()
|
||||
if (!status.ok())
|
||||
LOG("Document animation export failed: %s", status.message);
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::dialog_whatsnew(bool force_show)
|
||||
|
||||
@@ -181,6 +181,11 @@ void App::pick_file_save(std::vector<std::string> types, std::function<void(std:
|
||||
active_platform_services().pick_save_file(std::move(types), std::move(callback));
|
||||
}
|
||||
|
||||
bool App::uses_prepared_file_writes() const
|
||||
{
|
||||
return active_platform_services().uses_prepared_file_writes();
|
||||
}
|
||||
|
||||
void App::pick_dir(std::function<void(std::string path)> callback)
|
||||
{
|
||||
redraw = true;
|
||||
|
||||
@@ -63,6 +63,7 @@ public:
|
||||
virtual void pick_file(std::vector<std::string> file_types, PickedPathCallback callback) = 0;
|
||||
virtual void pick_save_file(std::vector<std::string> file_types, PickedPathCallback callback) = 0;
|
||||
virtual void pick_directory(PickedPathCallback callback) = 0;
|
||||
[[nodiscard]] virtual bool uses_prepared_file_writes() = 0;
|
||||
[[nodiscard]] virtual PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
@@ -431,6 +431,15 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]] bool uses_prepared_file_writes() override
|
||||
{
|
||||
#if __IOS__ || __WEB__
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::platform::PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
@@ -448,6 +448,11 @@ public:
|
||||
invoke_selected_path(path, callback);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool uses_prepared_file_writes() override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
[[nodiscard]] pp::platform::PreparedFileTarget prepare_writable_file(
|
||||
std::string_view type,
|
||||
std::string_view default_name,
|
||||
|
||||
Reference in New Issue
Block a user