Centralize legacy document image exports

This commit is contained in:
2026-06-04 13:57:32 +02:00
parent ab6223c256
commit 78003923ca
9 changed files with 530 additions and 53 deletions

View File

@@ -5,6 +5,7 @@
#include "app_core/document_export.h"
#include "app_core/document_session.h"
#include "legacy_document_canvas_services.h"
#include "legacy_document_export_services.h"
#include "legacy_document_layer_services.h"
#include "legacy_document_session_services.h"
#include "settings.h"
@@ -356,21 +357,9 @@ void App::dialog_export(std::string ext)
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__)
message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
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([=]{
save_prepared_file(target.path, target.suggested_name, [](const std::string&, bool) { });
});
#endif
});
const auto status = pp::panopainter::execute_legacy_document_export_file(*this, target.value());
if (!status.ok())
LOG("Document export file action failed: %s", status.message);
}
void App::dialog_export_layers()
@@ -385,12 +374,12 @@ void App::dialog_export_layers()
return;
}
if (Asset::create_dir(target.value().directory))
{
canvas->m_canvas->export_layers(target.value().stem_path, [this] {
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
});
}
const auto status = pp::panopainter::execute_legacy_document_export_collection(
*this,
pp::app::DocumentExportCollectionKind::layers,
target.value());
if (!status.ok())
LOG("Document layer collection export failed: %s", status.message);
#else
pick_dir([this](std::string path) {
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
@@ -399,9 +388,12 @@ void App::dialog_export_layers()
return;
}
canvas->m_canvas->export_layers(target.value().stem_path, [this, target = target.value()] {
message_box("Export Layers", "Layers exported to: " + target.stem_path);
});
const auto status = pp::panopainter::execute_legacy_document_export_stem(
*this,
pp::app::DocumentExportCollectionKind::layers,
target.value());
if (!status.ok())
LOG("Document layer stem export failed: %s", status.message);
});
#endif
}
@@ -418,12 +410,12 @@ void App::dialog_export_anim_frames()
return;
}
if (Asset::create_dir(target.value().directory))
{
canvas->m_canvas->export_anim_frames(target.value().stem_path, [this] {
message_box("Export Layers", "Image layers exported to Files/PanoPainter");
});
}
const auto status = pp::panopainter::execute_legacy_document_export_collection(
*this,
pp::app::DocumentExportCollectionKind::animation_frames,
target.value());
if (!status.ok())
LOG("Document animation frame collection export failed: %s", status.message);
#else
pick_dir([this](std::string path) {
const auto target = pp::app::make_document_export_stem_target(path, doc_name);
@@ -432,9 +424,12 @@ void App::dialog_export_anim_frames()
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);
});
const auto status = pp::panopainter::execute_legacy_document_export_stem(
*this,
pp::app::DocumentExportCollectionKind::animation_frames,
target.value());
if (!status.ok())
LOG("Document animation frame stem export failed: %s", status.message);
});
#endif
}
@@ -444,16 +439,9 @@ void App::dialog_export_depth()
if (!can_start_document_export(*this, true))
return;
// TODO: use picker
canvas->m_canvas->export_depth(doc_name, [this] {
#if defined(__IOS__)
message_box("Export 3D View + Depth", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
message_box("Export 3D View + Depth", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
message_box("Export 3D View + Depth", "Image and depth exported to " + work_path);
#endif
});
const auto status = pp::panopainter::execute_legacy_document_export_depth(*this, doc_name);
if (!status.ok())
LOG("Document depth export failed: %s", status.message);
}
void App::dialog_resize()
@@ -487,15 +475,9 @@ void App::dialog_export_cube_faces()
if (!can_start_document_export(*this, false))
return;
canvas->m_canvas->export_cube_faces(doc_name, [this] {
#if defined(__IOS__)
message_box("Export Cube Faces", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
message_box("Export Cube Faces", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
message_box("Export Cube Faces", "Image and depth exported to " + work_path);
#endif
});
const auto status = pp::panopainter::execute_legacy_document_export_cube_faces(*this, doc_name);
if (!status.ok())
LOG("Document cube-face export failed: %s", status.message);
}
void App::dialog_layer_rename()