Plan cube export face targets in app core
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "app_core/app_dialog.h"
|
||||
#include "document/document.h"
|
||||
#include "foundation/result.h"
|
||||
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
@@ -23,6 +26,16 @@ struct DocumentExportStemTarget {
|
||||
std::string stem_path;
|
||||
};
|
||||
|
||||
struct DocumentCubeFaceExportFileTarget {
|
||||
std::string face_name;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct DocumentCubeFaceExportTarget {
|
||||
std::array<DocumentCubeFaceExportFileTarget, pp::document::cube_face_count> faces;
|
||||
std::size_t face_count = 0;
|
||||
};
|
||||
|
||||
struct DocumentExportSuggestedName {
|
||||
std::string name;
|
||||
};
|
||||
@@ -535,6 +548,51 @@ public:
|
||||
return pp::foundation::Result<DocumentExportStemTarget>::success(std::move(target));
|
||||
}
|
||||
|
||||
[[nodiscard]] constexpr std::array<std::string_view, pp::document::cube_face_count>
|
||||
document_cube_face_export_names() noexcept
|
||||
{
|
||||
return {
|
||||
"front",
|
||||
"right",
|
||||
"back",
|
||||
"left",
|
||||
"top",
|
||||
"bottom",
|
||||
};
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Result<DocumentCubeFaceExportTarget> make_document_cube_face_export_target(
|
||||
std::string_view work_directory,
|
||||
std::string_view document_name)
|
||||
{
|
||||
if (work_directory.empty()) {
|
||||
return pp::foundation::Result<DocumentCubeFaceExportTarget>::failure(
|
||||
pp::foundation::Status::invalid_argument("work directory must not be empty"));
|
||||
}
|
||||
|
||||
if (document_name.empty()) {
|
||||
return pp::foundation::Result<DocumentCubeFaceExportTarget>::failure(
|
||||
pp::foundation::Status::invalid_argument("document name must not be empty"));
|
||||
}
|
||||
|
||||
DocumentCubeFaceExportTarget target;
|
||||
const auto face_names = document_cube_face_export_names();
|
||||
target.face_count = face_names.size();
|
||||
for (std::size_t face_index = 0; face_index < face_names.size(); ++face_index) {
|
||||
auto& face = target.faces[face_index];
|
||||
face.face_name = face_names[face_index];
|
||||
face.path.reserve(work_directory.size() + document_name.size() + face_names[face_index].size() + 6);
|
||||
face.path += work_directory;
|
||||
face.path += "/";
|
||||
face.path += document_name;
|
||||
face.path += "-";
|
||||
face.path += face_names[face_index];
|
||||
face.path += ".png";
|
||||
}
|
||||
|
||||
return pp::foundation::Result<DocumentCubeFaceExportTarget>::success(std::move(target));
|
||||
}
|
||||
|
||||
[[nodiscard]] inline pp::foundation::Result<DocumentExportSuggestedName> make_document_export_suggested_name(
|
||||
std::string_view document_name,
|
||||
std::string_view suffix)
|
||||
|
||||
Reference in New Issue
Block a user