载入中...
搜索中...
未找到
WorkspacePresentationBindings.h
浏览该文件的文档.
1#pragma once
2
6
7namespace eve::editor {
13template <class ScriptEditor, class Source>
15 cls.addFunc("presentationState", [vm](ScriptEditor* self) -> ssq::Table {
16 Source source(self->editor());
17 const auto state = source.state();
18 const auto preview = self->editor().previewState();
21 Value::Object{{"revision", static_cast<std::int64_t>(state.revision)},
22 {"context", state.context},
23 {"playing", state.playing},
24 {"preview", previewPhaseName(preview.phase)},
25 {"previewRequest", static_cast<std::int64_t>(preview.request)},
26 {"providerGeneration", static_cast<std::int64_t>(preview.providerGeneration)}});
27 });
28 cls.addFunc("presentationSnapshot", [vm](ScriptEditor* self) -> ssq::Table {
29 Source source(self->editor());
30 return script::projectStatusResult(vm, Status::success(), self->presentation().snapshot(source));
31 });
32 cls.addFunc(
33 "presentationEdit",
34 [vm](ScriptEditor* self, const std::string& path, ssq::Object input, bool staged) -> ssq::Table {
36 if (!value.ok()) return script::projectStatusResult(vm, value.status());
37 Source source(self->editor());
38 auto& controller = self->presentation();
40 vm, staged ? controller.stage(source, PropertyPath(path), toEditorValue(std::move(value).takeValue()))
41 : controller.edit(source, PropertyPath(path), toEditorValue(std::move(value).takeValue())));
42 });
43 cls.addFunc("presentationCommit", [vm](ScriptEditor* self) -> ssq::Table {
44 Source source(self->editor());
45 return script::projectResult(vm, self->presentation().commit(source));
46 });
47 cls.addFunc("presentationClose", [](ScriptEditor* self) -> void {
48 self->presentation().cancel();
49 self->editor().closePreview();
50 });
51 cls.addFunc("presentationCancel", [](ScriptEditor* self) -> void { self->presentation().cancel(); });
52 cls.addFunc("presentationAction", [vm](ScriptEditor* self, const std::string& id) -> ssq::Table {
53 Source source(self->editor());
54 return script::projectResult(vm, self->presentation().action(source, id));
55 });
56}
57} // namespace eve::editor
struct SQVM * HSQUIRRELVM
HSQUIRRELVM vm
Definition ECS.cpp:38
HSQOBJECT cls
Definition ECS.cpp:39
EvpackChunkInput input
Definition Evpack.cpp:170
std::string path
Definition PlayHost.cpp:111
Object::Ptr value
std::string_view source
The single Squirrel projection for common Result, Status and Value.
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
std::map< std::string, Value > Object
Definition Value.h:34
Dotted property path (layout.size) compared and persisted as text.
Definition EditingIds.h:78
void exposeWorkspacePresentation(ssq::Class &cls, HSQUIRRELVM vm)
Install the same presentation projection on each domain's owned script editor. @ownership Script edit...
EditorValue toEditorValue(const eve::Value &value)
Compatibility spelling for conversion into the authoring value tree.
eve::editing::PropertyPath PropertyPath
Definition EditorIds.h:37
const char * previewPhaseName(PreviewPhase phase) noexcept
Stable UI label for lifecycle observations (not a persisted format). @ownership Borrowed static strin...
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Result< Value > valueFromSquirrel(HSQUIRRELVM vm, SQInteger index, const SquirrelValueOptions &options)
Convert one Squirrel value into the canonical owning Value tree.