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.
Loading...
Searching...
No Matches
SelectionAabb.h File Reference
#include <cstdint>
#include <limits>
#include <optional>
#include <span>
#include <vector>
#include "donner/base/Box.h"
#include "donner/svg/SVGElement.h"
#include "donner/svg/SVGGeometryElement.h"
#include "donner/svg/SVGTextElement.h"
Include dependency graph for SelectionAabb.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  donner::editor::SelectionBoundsCache
 Pending/displayed selection AABBs tracked across document-version changes. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

std::vector< svg::SVGGeometryElementdonner::editor::CollectRenderableGeometry (const svg::SVGElement &root)
 Collect every renderable svg::SVGGeometryElement in root's subtree (including root itself if it is geometry). Skips container subtrees that are not part of the visual tree - defs, clipPath, mask, filter, pattern, gradients, symbol, marker, style.
std::vector< svg::SVGTextElementdonner::editor::CollectRenderableTextRoots (const svg::SVGElement &root)
 Collect every renderable <text> root in root's subtree (including root itself if it is one). Skips the same non-rendered containers as CollectRenderableGeometry and does not descend into text content - tspans contribute chrome through their text root.
std::optional< Box2ddonner::editor::TextWorldInkBounds (const svg::SVGTextElement &text)
 Document-space AABB of text's laid-out glyph ink, or nullopt when the text has no ink (empty content or unlaid-out text). The text-local ink box is mapped corner-by-corner through the element's transform, so a rotated text still produces a covering axis-aligned box.
std::optional< Box2ddonner::editor::AuthoredTextBoxLocal (const svg::SVGTextElement &text)
 Text-local frame rect authored by the text tool: the data-donner-text-box-width/-height region anchored one font-size above the x/y origin (inverting the tool's "first baseline sits one font-size below the box top" rule). Nullopt for point text.
std::optional< Box2ddonner::editor::TextWorldFrameBounds (const svg::SVGTextElement &text)
 Document-space frame of text: the authored text box when present (the region the user dragged out), otherwise the laid-out ink bounds (the computed extent of a point-text span). This is the rect that selection chrome and transform handles anchor to.
std::vector< Box2ddonner::editor::SnapshotSelectionWorldBounds (std::span< const svg::SVGElement > selection)
 Snapshot world-space bounds for every selected element that has renderable content. Elements that are themselves geometry contribute their own bounds; <text> roots contribute their laid-out ink bounds; group-like elements contribute the union of their renderable descendants. Elements with no renderable content produce no entry.
std::vector< Box2ddonner::editor::SnapshotSelectionOccludingWorldBounds (std::span< const svg::SVGElement > selection)
 Snapshot world-space bounds for renderable content (geometry and text) painted after a single selected element. This is a conservative occlusion hint for the async-safe re-drag path: if the click falls inside one of these bounds, the editor should wait for the normal hit-test path instead of assuming the selected element owns the click.
void donner::editor::PromoteSelectionBoundsIfReady (SelectionBoundsCache &cache, std::uint64_t displayedDocVersion)
 Promote pending bounds when the corresponding document bitmap is visible.
void donner::editor::RefreshSelectionBoundsCache (SelectionBoundsCache &cache, std::span< const svg::SVGElement > selection, std::uint64_t currentDocVersion, std::uint64_t displayedDocVersion)
 Refresh the cache from the current selection and document version.

Function Documentation

◆ CollectRenderableGeometry()

std::vector< svg::SVGGeometryElement > donner::editor::CollectRenderableGeometry ( const svg::SVGElement & root)
nodiscard

Collect every renderable svg::SVGGeometryElement in root's subtree (including root itself if it is geometry). Skips container subtrees that are not part of the visual tree - defs, clipPath, mask, filter, pattern, gradients, symbol, marker, style.

Used by the editor to expand a group selection ("I picked this `<g filter>`") into the set of leaves whose outlines + world bounds should drive selection chrome.

◆ SnapshotSelectionOccludingWorldBounds()

std::vector< Box2d > donner::editor::SnapshotSelectionOccludingWorldBounds ( std::span< const svg::SVGElement > selection)
nodiscard

Snapshot world-space bounds for renderable content (geometry and text) painted after a single selected element. This is a conservative occlusion hint for the async-safe re-drag path: if the click falls inside one of these bounds, the editor should wait for the normal hit-test path instead of assuming the selected element owns the click.

Multi-selection produces no occlusion hints because the fast re-drag path is single-selection only.

Parameters
selectionCurrent selection handles.
Returns
Document-space AABBs for later-painted renderable geometry.

◆ SnapshotSelectionWorldBounds()

std::vector< Box2d > donner::editor::SnapshotSelectionWorldBounds ( std::span< const svg::SVGElement > selection)
nodiscard

Snapshot world-space bounds for every selected element that has renderable content. Elements that are themselves geometry contribute their own bounds; <text> roots contribute their laid-out ink bounds; group-like elements contribute the union of their renderable descendants. Elements with no renderable content produce no entry.

Parameters
selectionCurrent selection handles.
Returns
Document-space AABBs in selection order (one per selected element that has geometry).