|
|
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.
|
Layer-lock state shared between the Layers panel (which draws the lock affordance and toggles it) and EditorApp's edit-gating path (which drops geometry-changing and destructive mutations targeting a locked element). More...
Namespaces | |
| namespace | donner |
| Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css. | |
Functions | |
| bool | donner::editor::IsLocked (const svg::SVGElement &element) |
Whether element is locked: true when the element OR ANY ANCESTOR carries data-donner-locked="true". Locking a group therefore locks every descendant. Shared by the Layers panel (to draw the lock affordance) and by the edit-gating path in EditorApp (to reject transform/delete mutations on locked elements). | |
| std::optional< svg::SVGElement > | donner::editor::LockedAncestor (const svg::SVGElement &element) |
The nearest ancestor-or-self of element that directly carries the data-donner-locked="true" marker - i.e. the element that actually owns the lock - or std::nullopt if neither element nor any ancestor is locked. | |
Variables | |
| constexpr std::string_view | donner::editor::kLockedAttributeName = "data-donner-locked" |
| Marker attribute name used to lock a layer against geometry-changing edits and deletion. | |
| constexpr std::string_view | donner::editor::kLockedAttributeValue = "true" |
| Attribute value that marks a layer locked. Any other value (including the attribute being absent or set to "false") reads as unlocked. | |
Layer-lock state shared between the Layers panel (which draws the lock affordance and toggles it) and EditorApp's edit-gating path (which drops geometry-changing and destructive mutations targeting a locked element).
A layer is "locked" when it - or any ancestor - carries the non-standard data-donner-locked="true" marker attribute. Using a data-* attribute keeps the marker round-tripping through SVG serialization without colliding with any presentation attribute or affecting rendering.
This lives in its own translation unit (rather than in LayerTreeModel or EditorApp) because both of those targets need IsLocked but layer_tree_model already depends on editor_app; a shared low-level target avoids a dependency cycle.
|
nodiscard |
The nearest ancestor-or-self of element that directly carries the data-donner-locked="true" marker - i.e. the element that actually owns the lock - or std::nullopt if neither element nor any ancestor is locked.
This walks the same ancestor chain as IsLocked, but returns the locked layer rather than a boolean: clicking a <rect> inside a locked <g> resolves to the <g>, so locked-rejection feedback (the red outline flash and the Layers-panel row highlight) targets the whole locked layer rather than just the clicked leaf. When element itself carries the marker, it is returned unchanged.