Plan document export success messages

This commit is contained in:
2026-06-05 09:31:11 +02:00
parent f46839bf5c
commit 808a084ee3
8 changed files with 575 additions and 34 deletions

View File

@@ -1,5 +1,6 @@
#pragma once
#include "app_core/app_dialog.h"
#include "foundation/result.h"
#include <string>
@@ -71,6 +72,26 @@ enum class DocumentVideoExportKind {
timelapse,
};
enum class DocumentExportSuccessKind {
equirectangular,
layers,
animation_frames,
depth,
cube_faces,
animation_mp4,
timelapse,
};
enum class DocumentExportSuccessDestination {
suppressed,
photos,
pictures_panopainter,
files_panopainter,
work_directory,
path,
generic_success,
};
struct DocumentExportMenuPlan {
DocumentExportMenuKind kind = DocumentExportMenuKind::jpeg;
DocumentExportMenuAction action = DocumentExportMenuAction::show_jpeg_dialog;
@@ -83,6 +104,13 @@ struct DocumentExportCollectionTargetPlan {
std::string_view suffix;
};
struct DocumentExportSuccessDialogPlan {
DocumentExportSuccessKind kind = DocumentExportSuccessKind::equirectangular;
DocumentExportSuccessDestination destination = DocumentExportSuccessDestination::suppressed;
AppMessageDialogPlan dialog;
bool show_dialog = false;
};
class DocumentExportMenuServices {
public:
virtual ~DocumentExportMenuServices() = default;
@@ -180,6 +208,32 @@ public:
return DocumentExportMenuAction::show_jpeg_dialog;
}
[[nodiscard]] constexpr DocumentExportSuccessDestination document_export_equirectangular_platform_destination() noexcept
{
#if defined(__IOS__)
return DocumentExportSuccessDestination::photos;
#elif defined(__OSX__)
return DocumentExportSuccessDestination::pictures_panopainter;
#elif defined(_WIN32)
return DocumentExportSuccessDestination::work_directory;
#else
return DocumentExportSuccessDestination::suppressed;
#endif
}
[[nodiscard]] constexpr DocumentExportSuccessDestination document_export_media_platform_destination() noexcept
{
#if defined(__IOS__)
return DocumentExportSuccessDestination::files_panopainter;
#elif defined(__OSX__)
return DocumentExportSuccessDestination::pictures_panopainter;
#elif defined(_WIN32)
return DocumentExportSuccessDestination::work_directory;
#else
return DocumentExportSuccessDestination::suppressed;
#endif
}
[[nodiscard]] constexpr DocumentExportMenuPlan plan_document_export_menu_action(
DocumentExportMenuKind kind,
bool has_canvas,
@@ -230,6 +284,99 @@ public:
};
}
[[nodiscard]] inline DocumentExportSuccessDialogPlan plan_document_export_success_dialog(
DocumentExportSuccessKind kind,
DocumentExportSuccessDestination destination,
std::string_view detail = {})
{
DocumentExportSuccessDialogPlan plan;
plan.kind = kind;
plan.destination = destination;
if (destination == DocumentExportSuccessDestination::suppressed) {
return plan;
}
std::string message;
switch (kind) {
case DocumentExportSuccessKind::equirectangular:
plan.dialog.title = "Export Equirectangular";
switch (destination) {
case DocumentExportSuccessDestination::photos:
message = "Image exported to Photos";
break;
case DocumentExportSuccessDestination::pictures_panopainter:
message = "Image exported to Pictures/PanoPainter folder";
break;
case DocumentExportSuccessDestination::work_directory:
message = "Image exported to ";
message += detail;
break;
case DocumentExportSuccessDestination::suppressed:
case DocumentExportSuccessDestination::files_panopainter:
case DocumentExportSuccessDestination::path:
case DocumentExportSuccessDestination::generic_success:
break;
}
break;
case DocumentExportSuccessKind::layers:
case DocumentExportSuccessKind::animation_frames:
plan.dialog.title = "Export Layers";
if (destination == DocumentExportSuccessDestination::files_panopainter) {
message = "Image layers exported to Files/PanoPainter";
} else if (destination == DocumentExportSuccessDestination::path) {
message = "Layers exported to: ";
message += detail;
}
break;
case DocumentExportSuccessKind::depth:
plan.dialog.title = "Export 3D View + Depth";
if (destination == DocumentExportSuccessDestination::files_panopainter) {
message = "Image and depth exported to Files/PanoPainter";
} else if (destination == DocumentExportSuccessDestination::pictures_panopainter) {
message = "Image and depth exported to Pictures/PanoPainter folder";
} else if (destination == DocumentExportSuccessDestination::work_directory) {
message = "Image and depth exported to ";
message += detail;
}
break;
case DocumentExportSuccessKind::cube_faces:
plan.dialog.title = "Export Cube Faces";
if (destination == DocumentExportSuccessDestination::files_panopainter) {
message = "Image and depth exported to Files/PanoPainter";
} else if (destination == DocumentExportSuccessDestination::pictures_panopainter) {
message = "Image and depth exported to Pictures/PanoPainter folder";
} else if (destination == DocumentExportSuccessDestination::work_directory) {
message = "Image and depth exported to ";
message += detail;
}
break;
case DocumentExportSuccessKind::animation_mp4:
plan.dialog.title = "Export Animation";
if (destination == DocumentExportSuccessDestination::path) {
message = "Animation exported to: ";
message += detail;
} else if (destination == DocumentExportSuccessDestination::generic_success) {
message = "Animation exported successfully.";
}
break;
case DocumentExportSuccessKind::timelapse:
plan.dialog.title = "Export Timelapse";
if (destination == DocumentExportSuccessDestination::path) {
message = "Timelapse exported to: ";
message += detail;
} else if (destination == DocumentExportSuccessDestination::generic_success) {
message = "Timelapse exported successfully.";
}
break;
}
if (!plan.dialog.title.empty() && !message.empty()) {
plan.dialog.message = std::move(message);
plan.show_dialog = true;
}
return plan;
}
[[nodiscard]] inline pp::foundation::Result<DocumentExportFileTarget> make_document_export_file_target(
std::string_view work_directory,
std::string_view document_name,

View File

@@ -10,6 +10,15 @@
namespace pp::panopainter {
namespace {
void show_export_success_dialog(
App& app,
const pp::app::DocumentExportSuccessDialogPlan& plan)
{
if (plan.show_dialog) {
app.message_box(plan.dialog.title, plan.dialog.message, plan.dialog.show_cancel);
}
}
class LegacyDocumentExportServices final : public pp::app::DocumentExportServices {
public:
explicit LegacyDocumentExportServices(App& app) noexcept
@@ -26,20 +35,18 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_equirectangular(target.path, [app, target] {
#if defined(__IOS__)
app->message_box("Export Equirectangular", "Image exported to Photos");
#elif defined(__OSX__)
app->message_box("Export Equirectangular", "Image exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export Equirectangular", "Image exported to " + app->work_path);
#elif defined(__QUEST__)
(void)target;
#elif __WEB__
#if __WEB__
app->ui_task([app, target] {
app->save_prepared_file(target.path, target.suggested_name, [](const std::string&, bool) { });
});
#else
(void)target;
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::equirectangular,
pp::app::document_export_equirectangular_platform_destination(),
app->work_path));
#endif
});
}
@@ -48,7 +55,12 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_layers(target.stem_path, [app, target] {
app->message_box("Export Layers", "Layers exported to: " + target.stem_path);
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::layers,
pp::app::DocumentExportSuccessDestination::path,
target.stem_path));
});
}
@@ -56,7 +68,11 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_layers(target.stem_path, [app] {
app->message_box("Export Layers", "Image layers exported to Files/PanoPainter");
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::layers,
pp::app::DocumentExportSuccessDestination::files_panopainter));
});
}
@@ -64,7 +80,12 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app, target] {
app->message_box("Export Layers", "Layers exported to: " + target.stem_path);
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::animation_frames,
pp::app::DocumentExportSuccessDestination::path,
target.stem_path));
});
}
@@ -72,7 +93,11 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_anim_frames(target.stem_path, [app] {
app->message_box("Export Layers", "Image layers exported to Files/PanoPainter");
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::animation_frames,
pp::app::DocumentExportSuccessDestination::files_panopainter));
});
}
@@ -80,13 +105,12 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_depth(std::string(document_name), [app] {
#if defined(__IOS__)
app->message_box("Export 3D View + Depth", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
app->message_box("Export 3D View + Depth", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export 3D View + Depth", "Image and depth exported to " + app->work_path);
#endif
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::depth,
pp::app::document_export_media_platform_destination(),
app->work_path));
});
}
@@ -94,13 +118,12 @@ public:
{
auto* app = &app_;
app_.canvas->m_canvas->export_cube_faces(std::string(document_name), [app] {
#if defined(__IOS__)
app->message_box("Export Cube Faces", "Image and depth exported to Files/PanoPainter");
#elif defined(__OSX__)
app->message_box("Export Cube Faces", "Image and depth exported to Pictures/PanoPainter folder");
#elif defined(_WIN32)
app->message_box("Export Cube Faces", "Image and depth exported to " + app->work_path);
#endif
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::cube_faces,
pp::app::document_export_media_platform_destination(),
app->work_path));
});
}
@@ -122,13 +145,22 @@ public:
auto path_string = std::string(path);
if (asynchronous_) {
Canvas::I->export_anim_mp4(path_string, [app, path_string] {
app->message_box("Export Animation", "Animation exported to: " + path_string);
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::animation_mp4,
pp::app::DocumentExportSuccessDestination::path,
path_string));
});
return;
}
Canvas::I->export_anim_mp4(path_string, [app] {
app->message_box("Export Animation", "Animation exported successfully.");
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::animation_mp4,
pp::app::DocumentExportSuccessDestination::generic_success));
});
}
@@ -140,7 +172,12 @@ public:
std::thread([app, path_string] {
BT_SetTerminate();
app->rec_export(path_string);
app->message_box("Export Timelapse", "Timelapse exported to: " + path_string);
show_export_success_dialog(
*app,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::timelapse,
pp::app::DocumentExportSuccessDestination::path,
path_string));
}).detach();
return;
}
@@ -158,7 +195,12 @@ public:
if (asynchronous_) {
(void)path;
} else {
app_.message_box("Export Timelapse", "Timelapse exported successfully.");
(void)path;
show_export_success_dialog(
app_,
pp::app::plan_document_export_success_dialog(
pp::app::DocumentExportSuccessKind::timelapse,
pp::app::DocumentExportSuccessDestination::generic_success));
}
}