|
|
Donner SVG Editor & Engine
SVG-native editor and embeddable SVG2 + CSS3 engine in C++20, with GPU (WebGPU) and compact CPU renderers, built for correctness, security, and performance.
|
Pure shape-clipboard command helpers, decoupled from ImGui and from the editor shell so they can be unit-tested headlessly (see donner/editor/tests/ShapeClipboard_tests.cc). More...
#include <cstdint>#include <optional>#include <string>#include <string_view>#include <vector>#include "donner/editor/ShapeClipboardPayload.h"#include "donner/svg/SVGDocument.h"#include "donner/svg/SVGElement.h"Classes | |
| struct | donner::editor::PreparePasteResult |
| Result of preparing a paste. More... | |
Namespaces | |
| namespace | donner |
| Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. | |
Enumerations | |
| enum class | donner::editor::PastePlacement : std::uint8_t { EndOfRootOffset , InFrontNoOffset } |
| Where a paste should insert its fragment. More... | |
Functions | |
| std::optional< ShapeClipboardPayload > | donner::editor::copySelectionToPayload (const svg::SVGDocument &document, const std::vector< svg::SVGElement > &selection) |
| Build a clipboard payload from the given selection (in paint order). | |
| PreparePasteResult | donner::editor::preparePaste (const svg::SVGDocument &document, const ShapeClipboardPayload &payload, PastePlacement placement, const std::optional< svg::SVGElement > &selectedGroup=std::nullopt) |
Prepare a paste of payload into document. | |
Pure shape-clipboard command helpers, decoupled from ImGui and from the editor shell so they can be unit-tested headlessly (see donner/editor/tests/ShapeClipboard_tests.cc).
These functions implement the structural core of Cut/Copy/Paste/Paste-in-Front:
The editor wires the merged source through EditorCommand::Kind::PasteShapes / Kind::CutShapes so the resulting reparse is a single undo step that keeps the source pane coherent.
|
strong |
Where a paste should insert its fragment.
| Enumerator | |
|---|---|
| EndOfRootOffset | Default paste: append inside the root <svg> (or selected group) and offset the fragment by translate(20,20) so the new shapes are visible. |
| InFrontNoOffset | Paste-in-Front: no offset; insert above the source elements in paint order when they still exist, otherwise at the end of the root. |
|
nodiscard |
Build a clipboard payload from the given selection (in paint order).
Serializes each selected element subtree from the document source store. For in-editor elements with no source mapping, the element is skipped (a future temporary-doc round-trip can fill this gap); if no element can be serialized, returns std::nullopt.
| document | Source document (provides source() and bounds). |
| selection | Selected elements, in the order they should be serialized. |
|
nodiscard |
Prepare a paste of payload into document.
Does not mutate document; it computes the merged source string the editor should reparse. See file comment for id/reference repair semantics.
| document | Destination document. |
| payload | Parsed clipboard payload. |
| placement | Default-offset vs. in-front placement. |
| selectedGroup | Optional single selected group/svg container to paste into instead of the root (default paste only). |