|
|
Donner 0.5.1
Embeddable browser-grade SVG2 engine
|
Discriminated union of every editor-initiated DOM mutation in the M2 scope. Coalescing rules in CommandQueue are keyed off kind plus the command's payload. More...
#include "donner/editor/EditorCommand.h"
Public Types | |
| enum class | Kind : std::uint8_t { SetTransform , ReplaceDocument , SetAttribute , DeleteElement } |
Static Public Member Functions | |
| static EditorCommand | SetTransformCommand (svg::SVGElement element, const Transform2d &transform) |
| Builds a SetTransform command. | |
| static EditorCommand | ReplaceDocumentCommand (std::string bytes, bool preserveUndoOnReparse=false) |
| Builds a ReplaceDocument command from owned bytes. | |
| static EditorCommand | SetAttributeCommand (svg::SVGElement element, std::string name, std::string value) |
| Builds a SetAttribute command. | |
| static EditorCommand | DeleteElementCommand (svg::SVGElement element) |
| Builds a DeleteElement command. | |
Public Attributes | |
| Kind | kind = Kind::SetTransform |
| std::optional< svg::SVGElement > | element |
| Target element for SetTransform and DeleteElement. std::nullopt for ReplaceDocument. | |
| Transform2d | transform |
| SetTransform payload. Default-constructed for ReplaceDocument / DeleteElement. | |
| std::string | bytes |
| ReplaceDocument payload. Empty for SetTransform / DeleteElement. Stored by value because the source buffer (TextEditor or file contents) may go out of scope before the queue flushes. | |
| bool | preserveUndoOnReparse = false |
| ReplaceDocument payload: preserve the undo timeline if this reparse is the only ReplaceDocument in the flushed batch. Used by the editor's self-initiated source writeback path, which reparses to refresh XML source offsets without representing a new user-authored document baseline. | |
| std::string | attributeName |
| SetAttribute payload: the attribute name (e.g. "transform", "fill"). | |
| std::string | attributeValue |
| SetAttribute payload: the new attribute value. | |
Discriminated union of every editor-initiated DOM mutation in the M2 scope. Coalescing rules in CommandQueue are keyed off kind plus the command's payload.
Commands carry svg::SVGElement handles rather than raw ECS entities so the editor never has to touch the registry directly — every payload value comes from a public SVG-level API (EditorApp::hitTest, tree traversal, querySelector) and every applied mutation goes through public SVGElement / SVGGraphicsElement methods.
|
strong |
| Enumerator | |
|---|---|
| SetTransform | Set the element's transform attribute. Used by SelectTool drag and undo/redo replay. Coalesces by element identity at flush time — multiple SetTransform commands targeting the same element collapse into the most-recently-queued one. |
| ReplaceDocument | Replace the entire document by re-parsing the given bytes. Used by file load and by the text-editor pane's typing → full-regen path. Exclusive: drains the queue of every prior command (which would reference now-invalid elements). |
| SetAttribute | Set a single attribute on the element. Used by the structured- editing writeback path (M3) when a tool modifies an attribute value. Coalesces by (element, attributeName) — successive SetAttribute commands for the same element and attribute collapse to the most-recently-queued value. |
| DeleteElement | Detach the element from its parent, making it invisible to the renderer. The ECS entity itself is NOT destroyed — it stays in the registry, just orphaned. This is a "soft delete" so any in-flight references (stale selection, undo snapshots) stay valid. Not coalesced. Undo for DeleteElement is not supported in M2: the design doc defers element create/delete snapshots to when path tools return. Users wanting to undo a delete need to edit the source pane directly. |