Dispatch layer rename through app core

This commit is contained in:
2026-06-03 20:06:11 +02:00
parent 921fc8f00b
commit 10c995f1da
6 changed files with 185 additions and 51 deletions

View File

@@ -88,6 +88,14 @@ public:
virtual void show_merge_animated_not_supported() = 0;
};
class DocumentLayerRenameServices {
public:
virtual ~DocumentLayerRenameServices() = default;
virtual void rename_layer(std::string_view old_name, std::string_view new_name) = 0;
virtual void finish_layer_rename() = 0;
};
class DocumentLayerOperationServices {
public:
virtual ~DocumentLayerOperationServices() = default;
@@ -439,6 +447,29 @@ public:
return pp::foundation::Result<DocumentLayerMenuPlan>::success(std::move(plan));
}
[[nodiscard]] inline pp::foundation::Status execute_document_layer_rename_plan(
const DocumentLayerRenamePlan& plan,
DocumentLayerRenameServices& services)
{
switch (plan.action) {
case DocumentLayerRenameAction::no_op_same_name:
services.finish_layer_rename();
return pp::foundation::Status::success();
case DocumentLayerRenameAction::rename_and_record_undo:
if (plan.new_name.empty()) {
return pp::foundation::Status::invalid_argument("layer rename plan must include a new name");
}
if (plan.old_name == plan.new_name) {
return pp::foundation::Status::invalid_argument("layer rename plan must change the name");
}
services.rename_layer(plan.old_name, plan.new_name);
services.finish_layer_rename();
return pp::foundation::Status::success();
}
return pp::foundation::Status::invalid_argument("unknown document layer rename action");
}
inline void execute_document_layer_operation_side_effects(
const DocumentLayerOperationPlan& plan,
DocumentLayerOperationServices& services)