Toast Engine
Loading...
Searching...
No Matches
workspace_events.hpp
Go to the documentation of this file.
1
6
7#pragma once
8#include <cstdint>
9#include <glm/glm.hpp>
10#include <string>
11#include <toast/events/event.hpp>
12#include <toast/uid.hpp>
13#include <toast/world/node.hpp>
14#include <utility>
15#include <vector>
16
17namespace event {
18
19struct UpdateHierarchyData : Event<UpdateHierarchyData> {
20 struct HierarchyElement {
21 toast::UID uid;
22 std::string name;
23 std::string type;
24 bool enabled;
25 bool is_prefab;
26 toast::UID prefab_uid;
27 std::vector<HierarchyElement> children;
28
29 HierarchyElement(const toast::Box<toast::Node>& node);
30
31 HierarchyElement() = default;
32 };
33
35 bool is_empty = false;
36 uint64_t workspace_handle = 0;
37
38 UpdateHierarchyData(const toast::Box<toast::Node>& node, uint64_t handle);
39
40 UpdateHierarchyData(HierarchyElement h, bool is_empty, uint64_t handle)
41 : root(std::move(h)),
42 is_empty(is_empty),
43 workspace_handle(handle) { }
44};
45
46struct RequestHierarchyUpdate : Event<RequestHierarchyUpdate> { };
47
48struct HierarchyNodesEnabled : Event<HierarchyNodesEnabled> {
49 struct Entry {
50 std::vector<toast::UID> path;
51 bool enabled = false;
52 };
53
54 std::vector<Entry> nodes;
55 uint64_t workspace_handle = 0;
56
57 HierarchyNodesEnabled() = default;
58
59 HierarchyNodesEnabled(std::vector<Entry> nodes, uint64_t handle) : nodes(std::move(nodes)), workspace_handle(handle) { }
60};
61
62struct WorkspaceCreate : Event<WorkspaceCreate> {
63 toast::UID parent;
64 std::string type;
65
66 WorkspaceCreate(toast::UID parent, std::string_view type) : parent(parent), type(type) { }
67};
68
69struct WorkspaceSpawn : Event<WorkspaceSpawn> {
70 toast::UID parent;
71 bool is_uri;
72 toast::UID uid;
73 std::string uri;
74
75 WorkspaceSpawn() = default;
76
77 WorkspaceSpawn(toast::UID parent, toast::UID uid) : parent(parent), is_uri(false), uid(uid) { }
78
79 WorkspaceSpawn(toast::UID parent, std::string_view uri) : parent(parent), is_uri(true), uri(uri) { }
80};
81
82struct [[deprecated]] WorkspaceRemove : Event<WorkspaceRemove> {
83 toast::UID target;
84
85 WorkspaceRemove(toast::UID target) : target(target) { }
86};
87
88struct WorkspaceDestroy : Event<WorkspaceDestroy> {
89 uint64_t handle;
90
91 WorkspaceDestroy(uint64_t handle) : handle(handle) { }
92};
93
94struct SetActiveWorkspace : Event<SetActiveWorkspace> {
95 uint64_t handle;
96
97 SetActiveWorkspace(uint64_t handle) : handle(handle) { }
98};
99
100struct WorkspaceSave : Event<WorkspaceSave> {
101 toast::UID target;
102 std::string uri;
103 uint64_t workspace_handle = 0;
104 uint64_t request = 0;
105
106 WorkspaceSave(toast::UID target, std::string uri, uint64_t workspace_handle = 0, uint64_t request = 0)
107 : target(target),
108 uri(std::move(uri)),
109 workspace_handle(workspace_handle),
110 request(request) { }
111};
112
113struct WorkspaceSaveCompleted : Event<WorkspaceSaveCompleted> {
114 uint64_t workspace_handle = 0;
115 uint64_t request = 0;
116 bool success = false;
117 std::vector<uint8_t> snapshot;
118 std::string error;
119};
120
121struct WorkspaceAutosave : Event<WorkspaceAutosave> {
122 uint64_t handle;
123 std::string uri;
124
125 WorkspaceAutosave(uint64_t handle, std::string uri) : handle(handle), uri(std::move(uri)) { }
126};
127
128struct WorkspaceCreateNode : Event<WorkspaceCreateNode> {
129 toast::UID parent;
130 std::string type;
131
132 WorkspaceCreateNode(toast::UID parent, std::string_view type) : parent(parent), type(type) { }
133};
134
135struct WorkspaceRemoveNode : Event<WorkspaceRemoveNode> {
136 toast::UID target;
137
138 WorkspaceRemoveNode(toast::UID target) : target(target) { }
139};
140
141struct WorkspaceMoveNodeTo : Event<WorkspaceMoveNodeTo> {
142 toast::UID target;
143 toast::UID new_parent;
144 toast::UID predecessor;
145
146 WorkspaceMoveNodeTo(toast::UID target, toast::UID new_parent, toast::UID predecessor)
147 : target(target),
148 new_parent(new_parent),
149 predecessor(predecessor) { }
150};
151
152struct WorkspaceDuplicateNode : Event<WorkspaceDuplicateNode> {
153 toast::UID source;
154 toast::UID parent;
155};
156
157struct WorkspaceCopyNode : Event<WorkspaceCopyNode> {
158 toast::UID source;
159};
160
161struct WorkspacePasteNode : Event<WorkspacePasteNode> {
162 toast::UID parent;
163};
164
165struct NodeChangeType : Event<NodeChangeType> {
166 toast::UID node;
167 std::string type;
168};
169
170struct WorkspacePromoteNode : Event<WorkspacePromoteNode> {
171 toast::UID target;
172 std::string path;
173};
174
175struct WorkspaceConvertToProceduralVoxel : Event<WorkspaceConvertToProceduralVoxel> {
176 toast::UID target;
177 std::string path;
178};
179
180struct ProceduralVoxelPromoted : Event<ProceduralVoxelPromoted> {
181 uint64_t workspace_handle = 0;
182 toast::UID prefab_uid;
183 bool success = false;
184 std::string error;
185};
186
188 toast::UID uid;
189 std::string name;
190 uint32_t kind = 0;
191 glm::ivec3 min {0};
192 glm::ivec3 max {0};
193 glm::vec3 color {0.0f};
194 std::vector<glm::vec4> planes;
195 bool resizable = false;
196 uint32_t color_id = 0;
197};
198
200 int32_t min_h = 0;
201 int32_t min_v = 0;
202 uint32_t width = 0;
203 uint32_t height = 0;
204 std::vector<uint8_t> colors;
205 std::vector<int16_t> depths;
206 std::vector<uint8_t> edges_h;
207 std::vector<uint8_t> edges_v;
208};
209
210struct ProceduralVoxelLayout : Event<ProceduralVoxelLayout> {
211 toast::UID root_uid;
212 std::vector<VoxelPieceLayoutData> pieces;
213 toast::UID palette_uid;
214 std::vector<VoxelProjectionData> projections;
215};
216
217struct VoxelSetPieceBounds : Event<VoxelSetPieceBounds> {
218 toast::UID target;
219 glm::ivec3 min {0};
220 glm::ivec3 max {0};
221};
222
223struct VoxelCreatePiece : Event<VoxelCreatePiece> {
224 toast::UID parent;
225 std::string type;
226 toast::UID source;
227 glm::ivec3 min {0};
228 glm::ivec3 max {0};
229 toast::UID script;
230 uint32_t mode = 0;
231};
232
233struct VoxelExtrude : Event<VoxelExtrude> {
234 toast::UID source;
235 glm::ivec3 min {0};
236 glm::ivec3 max {0};
237 bool inward = false;
238};
239
240struct VoxelSplitPieces : Event<VoxelSplitPieces> {
241 std::vector<toast::UID> targets;
242 glm::vec4 plane {0.0f};
243 uint32_t keep = 0;
244};
245
246struct VoxelRotatePieces : Event<VoxelRotatePieces> {
247 std::vector<toast::UID> targets;
248 uint32_t axis = 2;
249 int32_t turns = 1;
250};
251
252struct VoxelBucketFill : Event<VoxelBucketFill> {
253 toast::UID target;
254 glm::ivec3 voxel {0};
255 uint32_t id = 0;
256 bool search = false;
257 uint32_t search_axis = 0;
258 int32_t search_step = 1;
259};
260
261struct VoxelCollapsePieces : Event<VoxelCollapsePieces> {
262 std::vector<toast::UID> targets;
263 std::string path;
264};
265
266struct VoxelBake : Event<VoxelBake> {
267 toast::UID target;
268 std::string path;
269 bool replace = false;
270};
271
272struct VoxelBakeCompleted : Event<VoxelBakeCompleted> {
273 std::string path;
274};
275
276struct SetVoxelEditorOverlays : Event<SetVoxelEditorOverlays> {
277 bool unit_grid = true;
278 bool voxel_grid = false;
279 bool edges = true;
280 bool voxel_edges = false;
281 bool projections = false;
282};
283
284struct SetVoxelCutPreview : Event<SetVoxelCutPreview> {
285 toast::UID root;
286 bool active = false;
287 glm::vec4 plane {0.0f};
288};
289
290struct NodePicked : Event<NodePicked> {
291 uint64_t workspace_handle = 0;
292 toast::UID node;
293};
294
295struct SetVoxelTool : Event<SetVoxelTool> {
296 uint32_t tool = 0;
297 uint32_t paint_id = 1;
298 toast::UID default_script;
299 uint32_t default_mode = 0;
300};
301
302struct SetShowOthers : Event<SetShowOthers> {
303 bool show = false;
304 uint64_t workspace = 0;
305 uint64_t source_workspace = 0;
306 toast::UID source_instance;
307};
308
309struct SetFocusedNode : Event<SetFocusedNode> {
310 toast::UID node;
311
312 SetFocusedNode(toast::UID n) : node(n) { }
313};
314
315struct NodeChangeParam : Event<NodeChangeParam> {
316 toast::UID node;
317 std::string parameter;
318 std::string value;
319
320 NodeChangeParam(toast::UID node, std::string_view parameter, std::string_view value)
321 : node(node),
322 parameter(parameter),
323 value(value) { }
324};
325
326struct NodeChangeName : Event<NodeChangeName> {
327 toast::UID node;
328 std::string name;
329
330 NodeChangeName(toast::UID n, std::string_view name) : node(n), name(name) { }
331};
332
333struct NodeCallFunction : Event<NodeCallFunction> {
334 toast::UID node;
335 std::string function;
336
337 NodeCallFunction(toast::UID node, std::string_view f) : node(node), function(f) { }
338};
339
340struct NodeEnabled : Event<NodeEnabled> {
341 toast::UID node;
342 bool enabled;
343
344 NodeEnabled(toast::UID n, bool enabled) : node(n), enabled(enabled) { }
345};
346
347struct WorkspacePause : Event<WorkspacePause> {
348 uint64_t handle;
349 bool paused;
350
351 WorkspacePause(uint64_t handle, bool paused) : handle(handle), paused(paused) { }
352};
353
354struct SetGizmoTool : Event<SetGizmoTool> {
355 uint32_t tool;
356
357 SetGizmoTool(uint32_t tool) : tool(tool) { }
358};
359
362struct SetRenderMode : Event<SetRenderMode> {
363 uint32_t mode;
364
365 SetRenderMode(uint32_t mode) : mode(mode) { }
366};
367
368struct SetCoordinateSpace : Event<SetCoordinateSpace> {
369 bool world;
370
371 SetCoordinateSpace(bool world) : world(world) { }
372};
373
374struct SetSnapping : Event<SetSnapping> {
375 uint32_t kind;
376 bool enabled;
377 float value;
378
379 SetSnapping(uint32_t kind, bool enabled, float value) : kind(kind), enabled(enabled), value(value) { }
380};
381
382struct SetCameraMode : Event<SetCameraMode> {
383 bool game;
384
385 SetCameraMode(bool game) : game(game) { }
386};
387
389struct EditorCameraFlyMode : Event<EditorCameraFlyMode> {
390 bool active;
391
392 EditorCameraFlyMode(bool active) : active(active) { }
393};
394
397struct CaptureFrame : Event<CaptureFrame> { };
398
400struct EditorCameraMoveState : Event<EditorCameraMoveState> {
401 bool forward, back, left, right, up, down, boost;
402
403 EditorCameraMoveState(bool forward, bool back, bool left, bool right, bool up, bool down, bool boost)
404 : forward(forward),
405 back(back),
406 left(left),
407 right(right),
408 up(up),
409 down(down),
410 boost(boost) { }
411};
412
414struct EditorCameraLook : Event<EditorCameraLook> {
415 float dx, dy;
416
417 EditorCameraLook(float dx, float dy) : dx(dx), dy(dy) { }
418};
419
420enum class EditorCameraMode : uint8_t {
421 free = 0,
422 orbit = 1
423};
424
425struct SetEditorCameraSettings : Event<SetEditorCameraSettings> {
426 EditorCameraMode mode;
427 float speed;
428
429 uint64_t workspace_handle;
430
431 SetEditorCameraSettings(EditorCameraMode mode, float speed, uint64_t workspace_handle = 0)
432 : mode(mode),
433 speed(speed),
434 workspace_handle(workspace_handle) { }
435
436 SetEditorCameraSettings(uint32_t mode, float speed, uint64_t workspace_handle = 0)
437 : mode(static_cast<EditorCameraMode>(mode)),
438 speed(speed),
439 workspace_handle(workspace_handle) { }
440};
441
442struct EditorCameraGesture : Event<EditorCameraGesture> {
443 float dx, dy, zoom;
444
445 EditorCameraGesture(float dx, float dy, float zoom) : dx(dx), dy(dy), zoom(zoom) { }
446};
447
448struct InspectorContent : Event<InspectorContent> {
449 struct InspectorField {
450 std::string name;
451 std::string value;
452
453 InspectorField(std::string_view name, std::string_view value) : name(name), value(value) { }
454 };
455
456 std::string uid;
457 std::string name;
458 bool enabled;
459 std::vector<InspectorField> parameters;
460 std::vector<toast::NodeMessage> messages;
461
462 InspectorContent(
463 std::string_view uid, std::string_view name, bool enabled, std::vector<InspectorField> fields,
464 std::vector<toast::NodeMessage> messages
465 )
466 : uid(uid),
467 name(name),
468 enabled(enabled),
469 parameters(std::move(fields)),
470 messages(std::move(messages)) { }
471};
472
473struct InspectorLuaContent : Event<InspectorLuaContent> {
474 struct LuaField {
475 std::string path;
476 std::string name;
477 uint32_t kind = 0;
478 bool is_array = false;
479 std::string ref_type;
480 std::string value;
481 std::string default_value;
482 std::string display_name;
483 bool read_only = false;
484 bool hidden = false;
485 double min = 0.0;
486 double max = 0.0;
487 std::string unit;
488 };
489
490 struct LuaSubgroup {
491 std::string name;
492 std::vector<LuaField> fields;
493 };
494
495 struct LuaGroup {
496 std::string name;
497 std::vector<LuaField> fields;
498 std::vector<LuaSubgroup> subgroups;
499 };
500
502 std::string script;
503 std::vector<LuaField> fields;
504 std::vector<LuaGroup> groups;
505 };
506
507 std::string uid;
508 uint32_t schema_version = 0;
509 std::vector<LuaScriptCard> scripts;
510
511 InspectorLuaContent() = default;
512
513 InspectorLuaContent(std::string_view uid, uint32_t schema_version, std::vector<LuaScriptCard> scripts)
514 : uid(uid),
515 schema_version(schema_version),
516 scripts(std::move(scripts)) { }
517};
518
519struct NodeChangeLuaParam : Event<NodeChangeLuaParam> {
520 toast::UID node;
521 std::string path;
522 std::string value;
523
524 NodeChangeLuaParam(toast::UID node, std::string_view path, std::string_view value) : node(node), path(path), value(value) { }
525};
526
527enum class HistoryOperation : uint8_t {
528 initial,
529 create,
530 remove,
531 rename,
532 enable,
533 change_value,
534 move,
535 reparent,
536 retype,
537 duplicate,
538 spawn_prefab,
539 paste,
540 promote,
541 call_function,
542 cherry_pick,
543 merge
544};
545
547 uint64_t id = 0;
548 uint64_t sequence = 0;
549 std::vector<uint64_t> parents;
550 toast::UID node_uid;
551 std::string node_name;
552 HistoryOperation operation = HistoryOperation::initial;
553 std::string subject;
554 std::string previous_value;
555 std::string current_value;
556};
557
558struct WorkspaceHistoryInitialSnapshot : Event<WorkspaceHistoryInitialSnapshot> {
559 uint64_t workspace_handle = 0;
560 std::vector<uint8_t> snapshot;
561 bool available = true;
562 bool initially_saved = false;
563 std::string unavailable_reason;
564};
565
566struct WorkspaceHistoryCommitted : Event<WorkspaceHistoryCommitted> {
567 uint64_t workspace_handle = 0;
568 std::vector<uint8_t> before_snapshot;
569 std::vector<uint8_t> after_snapshot;
570 toast::UID node_uid;
571 std::string node_name;
572 HistoryOperation operation = HistoryOperation::change_value;
573 std::string subject;
574 std::string previous_value;
575 std::string current_value;
576};
577
578struct WorkspaceApplyHistorySnapshot : Event<WorkspaceApplyHistorySnapshot> {
579 uint64_t workspace_handle = 0;
580 uint64_t request = 0;
581 std::vector<uint8_t> snapshot;
582};
583
584struct WorkspaceHistorySnapshotApplied : Event<WorkspaceHistorySnapshotApplied> {
585 uint64_t workspace_handle = 0;
586 uint64_t request = 0;
587 bool success = false;
588 std::string error;
589};
590
591struct WorkspacePrepareHistoryMerge : Event<WorkspacePrepareHistoryMerge> {
592 uint64_t workspace_handle = 0;
593 uint64_t request = 0;
594 bool is_merge = false;
595 std::vector<uint8_t> base_snapshot;
596 std::vector<uint8_t> current_snapshot;
597 std::vector<uint8_t> incoming_snapshot;
598};
599
600struct WorkspaceHistoryMergePrepared : Event<WorkspaceHistoryMergePrepared> {
601 uint64_t workspace_handle = 0;
602 uint64_t request = 0;
603 bool success = false;
604 std::vector<uint8_t> snapshot;
605 std::string error;
606};
607
608struct UpdateWorkspaceHistory : Event<UpdateWorkspaceHistory> {
609 uint64_t workspace_handle = 0;
610 bool available = true;
611 std::string unavailable_reason;
612 uint64_t current_revision = 0;
613 bool is_dirty = false;
614 bool transaction_open = false;
615 std::vector<HistoryRevision> revisions;
616};
617
618struct RequestWorkspaceHistory : Event<RequestWorkspaceHistory> {
619 uint64_t workspace_handle = 0;
620};
621
622struct WorkspaceUndo : Event<WorkspaceUndo> {
623 uint64_t workspace_handle = 0;
624};
625
626struct WorkspaceRedo : Event<WorkspaceRedo> {
627 uint64_t workspace_handle = 0;
628};
629
630struct WorkspaceCheckoutHistory : Event<WorkspaceCheckoutHistory> {
631 uint64_t workspace_handle = 0;
632 uint64_t revision = 0;
633};
634
635struct WorkspaceCherryPickHistory : Event<WorkspaceCherryPickHistory> {
636 uint64_t workspace_handle = 0;
637 uint64_t revision = 0;
638};
639
640struct WorkspaceMergeHistory : Event<WorkspaceMergeHistory> {
641 uint64_t workspace_handle = 0;
642 uint64_t revision = 0;
643};
644
645struct WorkspaceHistoryTransaction : Event<WorkspaceHistoryTransaction> {
646 enum class Phase : uint8_t {
647 begin,
648 commit,
649 cancel
650 };
651 uint64_t workspace_handle = 0;
652 uint64_t transaction = 0;
653 Phase phase = Phase::begin;
654 HistoryOperation operation = HistoryOperation::change_value;
655 toast::UID node;
656 std::string subject;
657};
658
659enum class HistoryConflictKind : uint8_t {
660 value,
661 name,
662 type,
663 enabled,
664 parent,
665 order,
666 existence,
667 lua_value
668};
669
671 uint64_t id = 0;
672 toast::UID node_uid;
673 std::string node_name;
674 HistoryConflictKind kind = HistoryConflictKind::value;
675 std::string field;
676 uint32_t value_type = 0;
677 bool is_array = false;
678 std::string ref_type;
679 std::string base_value;
680 std::string current_value;
681 std::string incoming_value;
682};
683
684struct WorkspaceHistoryConflicts : Event<WorkspaceHistoryConflicts> {
685 uint64_t workspace_handle = 0;
686 uint64_t request = 0;
687 bool is_merge = false;
688 uint64_t source_revision = 0;
689 std::vector<HistoryConflict> conflicts;
690};
691
693 enum class Choice : uint8_t {
694 base,
695 current,
696 incoming,
697 custom_value
698 };
699 uint64_t conflict = 0;
700 Choice choice = Choice::current;
701 std::string custom_value;
702};
703
704struct WorkspaceResolveHistoryConflicts : Event<WorkspaceResolveHistoryConflicts> {
705 uint64_t workspace_handle = 0;
706 uint64_t request = 0;
707 bool cancel = false;
708 std::vector<HistoryConflictResolution> resolutions;
709};
710
711}
Intrusive reference-counted handle to a Node.
Definition box.hpp:35
Base object type for the scene graph.
Requests a single RenderDoc frame capture around the next rendered frame, sent on F12 in the viewport...
Definition workspace_events.hpp:397
Definition workspace_events.hpp:49
Definition workspace_events.hpp:692
Definition workspace_events.hpp:670
Definition workspace_events.hpp:546
Definition workspace_events.hpp:474
Definition workspace_events.hpp:495
Definition workspace_events.hpp:501
Definition workspace_events.hpp:490
Definition workspace_events.hpp:165
Definition workspace_events.hpp:290
Definition workspace_events.hpp:210
std::vector< VoxelProjectionData > projections
front, side, top
Definition workspace_events.hpp:214
Definition workspace_events.hpp:180
Definition workspace_events.hpp:46
Definition workspace_events.hpp:618
Definition workspace_events.hpp:302
Definition workspace_events.hpp:284
Definition workspace_events.hpp:276
Definition workspace_events.hpp:295
Definition workspace_events.hpp:20
Definition workspace_events.hpp:608
Definition workspace_events.hpp:272
Definition workspace_events.hpp:266
Definition workspace_events.hpp:252
Definition workspace_events.hpp:261
Definition workspace_events.hpp:223
Definition workspace_events.hpp:233
Definition workspace_events.hpp:187
Definition workspace_events.hpp:199
std::vector< uint8_t > colors
rgba, alpha 0 is empty
Definition workspace_events.hpp:204
std::vector< uint8_t > edges_v
rgba, width x (height + 1)
Definition workspace_events.hpp:207
std::vector< uint8_t > edges_h
rgba, (width + 1) x height, alpha 0 is no line
Definition workspace_events.hpp:206
Definition workspace_events.hpp:246
Definition workspace_events.hpp:217
Definition workspace_events.hpp:240
Definition workspace_events.hpp:578
Definition workspace_events.hpp:630
Definition workspace_events.hpp:635
Definition workspace_events.hpp:175
Definition workspace_events.hpp:157
Definition workspace_events.hpp:152
Definition workspace_events.hpp:566
Definition workspace_events.hpp:684
Definition workspace_events.hpp:558
Definition workspace_events.hpp:600
Definition workspace_events.hpp:584
Definition workspace_events.hpp:645
Definition workspace_events.hpp:640
Definition workspace_events.hpp:161
Definition workspace_events.hpp:591
Definition workspace_events.hpp:170
Definition workspace_events.hpp:626
Definition workspace_events.hpp:704
Definition workspace_events.hpp:113
Definition workspace_events.hpp:622
Definition uid.hpp:20
Unique identifier for everything that exists in our engine.