Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::editor::EditorCommand Struct Reference

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"

Collaboration diagram for donner::editor::EditorCommand:
[legend]

Public Types

enum class  Kind : std::uint8_t {
  SetTransform ,
  ReplaceDocument ,
  SetAttribute ,
  InsertElement ,
  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 InsertElementCommand (svg::SVGElement parent, svg::SVGElement element, std::optional< svg::SVGElement > reference=std::nullopt)
 Builds an InsertElement command.
static EditorCommand DeleteElementCommand (svg::SVGElement element)
 Builds a DeleteElement command.

Public Attributes

Kind kind = Kind::SetTransform
std::optional< svg::SVGElementelement
 Target element for SetTransform and DeleteElement. std::nullopt for ReplaceDocument.
std::optional< svg::SVGElementparentElement
 Parent element for InsertElement.
std::optional< svg::SVGElementreferenceElement
 Optional sibling for InsertElement; inserted before this element when present, otherwise appended to the parent.
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.

Detailed Description

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.

Member Enumeration Documentation

◆ Kind

enum class donner::editor::EditorCommand::Kind : std::uint8_t
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.

InsertElement 

Insert element as a child of parentElement, optionally before referenceElement. Used by authoring tools that create new DOM nodes. Not coalesced.

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.


The documentation for this struct was generated from the following file: