载入中...
搜索中...
未找到
AudioEditingCommands.cpp
浏览该文件的文档.
2
4
5#include <string>
6
8namespace {
9
10const editing::Value* field(const editing::Value& value, const char* key) {
11 const auto* object = value.getIf<editing::Value::Object>();
12 if (!object) return nullptr;
13 const auto found = object->find(key);
14 return found == object->end() ? nullptr : &found->second;
15}
16
19 selection.channel = "audio";
22 item.target = editing::TargetId(target.targetId());
23 item.item = editing::StableId(target.targetId().value());
24 item.type = "audio.source";
25 selection.items.push_back(item);
26 selection.primary = item;
27 return selection;
28}
29
30} // namespace
31
34 descriptor.id = editing::CommandId("audio.source.property.set.v1");
35 descriptor.ownerModule = "audio_editing";
36 descriptor.displayName = "Set audio source property";
37 descriptor.category = "Audio";
38 descriptor.automationAllowed = true;
39 return registry.registerPlannedCommand(
41 auto* properties = static_cast<editing::IPropertyProvider*>(
43 const editing::Value* pathValue = field(request.payload, "path");
44 const auto* path = pathValue ? pathValue->getIf<std::string>() : nullptr;
45 const editing::Value* value = field(request.payload, "value");
46 if (!properties || !path || !value)
47 return eve::editing::failed<editing::CommandPlan>(
48 editing::Status::Rejected, editing::RuleId("audio.editing.property-payload"),
49 "Audio property requires a source target, path and value");
50 auto operation = properties->makeSet(selectionFor(target), editing::PropertyPath(*path), *value,
52 if (!operation.ok())
53 return eve::editing::failed<editing::CommandPlan>(operation.code(),
54 editing::RuleId("audio.editing.property-operation"),
55 "Audio source rejected the property value");
57 plan.operations.push_back(std::move(operation.value()));
58 plan.summary = editing::Value::Object{{"path", *path}};
59 return eve::editing::applied<editing::CommandPlan>(std::move(plan));
60 });
61}
62
63} // namespace eve::audio_editing
LogicalId target
ActionParameterOperation operation
double value
std::string descriptor
const GltfImportRequest & request
std::uint32_t key
std::map< std::string, PropertyRule > properties
std::string path
Definition PlayHost.cpp:110
bool found
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
static CapabilityId editingCapabilityId()
Stable capability identity for audio-source property editing.
Definition AudioTarget.h:22
IEditableTarget public API.
Lower-layer registration boundary implemented by an editor or runtime editing host.
virtual Result< void > registerPlannedCommand(EditingCommandDescriptor descriptor, EditingCommandPlanner planner)=0
Register or replace one domain-owned planned command.
UI-independent property access for an immutable selection snapshot.
Dotted property path (layout.size) compared and persisted as text.
Definition EditingIds.h:78
Deterministic owning value tree shared by authoring hosts.
std::map< std::string, Value > Object
const T * getIf() const
Return an immediately borrowed typed value.
editing::Result< void > registerEditingCommands(editing::IEditingCommandRegistry &registry)
Register audio-owned planned commands with a generic editing host.
StrongId< TargetIdTag > TargetId
Definition EditingIds.h:57
StrongId< StableIdTag > StableId
Definition EditingIds.h:64
StrongId< CommandIdTag > CommandId
Definition EditingIds.h:58
CommandPlan public API.
std::vector< DomainOperation > operations
CommandRequest public API.
Domain-owned metadata for one planned editing command.
SelectionItem public API.
SelectionSnapshot public API.
std::vector< SelectionItem > items
std::optional< SelectionItem > primary