Donner 0.8.0-pre
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
donner::svg::components::SVGDocumentContext Class Reference

Holds global state of an SVG document, such as the root element, id-to-element mapping, and the document size. More...

#include "donner/svg/components/SVGDocumentContext.h"

Public Member Functions

 SVGDocumentContext (InternalCtorTag ctorTag, SVGDocumentHandle documentState)
 Internal constructor, creates a context on the given SVGDocument.
Entity getEntityById (const RcString &id) const
 Get the entity with the given ID, using the internal id-to-entity mapping.
void bumpMutationRevision () const
 Mark the backing document state as mutated.
bool currentThreadHasWriteAccess () const
 Returns true if the current thread holds write access to the backing document.
DocumentWriteAccess writeAccess () const
 Acquire write access to the backing document.
DetachedNodeStatedetachedNodeState () const
 Get detached-node collection state for the backing document.
bool hasActiveDetachedNodeCollectionDeferral () const
 Returns true when detached-node collection is deferred for a snapshot or observer epoch.
std::uint64_t activeDetachedNodeCollectionEpoch () const
 Current detached-node collection epoch high-water.

Public Attributes

std::optional< Vector2icanvasSize
 Current canvas size, if set. Equivalent to the window size, which controls how the SVG contents are rendered.
Entity rootEntity = entt::null
 Root entity of the document, which contains the "<svg>" element.

Friends

class ::donner::svg::ElementAnchor
class ::donner::svg::SVGDocument
class ::donner::svg::SVGElement

Detailed Description

Holds global state of an SVG document, such as the root element, id-to-element mapping, and the document size.

One instance of this class is created per SVG document.

Access the document context via the Registry::ctx API:

SVGDocumentContext& context = registry.ctx().get<SVGDocumentContext>();
Entity foo = context.getEntityById("foo");
Entity getEntityById(const RcString &id) const
Get the entity with the given ID, using the internal id-to-entity mapping.
Definition SVGDocumentContext.h:89
SVGDocumentContext(InternalCtorTag ctorTag, SVGDocumentHandle documentState)
Internal constructor, creates a context on the given SVGDocument.
entt::entity Entity
Entity type for the Registry, a std::uint32_t alias.
Definition EcsRegistry.h:20

Constructor & Destructor Documentation

◆ SVGDocumentContext()

donner::svg::components::SVGDocumentContext::SVGDocumentContext ( InternalCtorTag ctorTag,
SVGDocumentHandle documentState )
explicit

Internal constructor, creates a context on the given SVGDocument.

To use this class, access it via the Registry::ctx API.

SVGDocumentContext& context = registry.ctx().get<SVGDocumentContext>();
Parameters
ctorTagInternal tag to allow construction.
documentStateShared state for the document.

Member Function Documentation

◆ getEntityById()

Entity donner::svg::components::SVGDocumentContext::getEntityById ( const RcString & id) const
inline

Get the entity with the given ID, using the internal id-to-entity mapping.

If multiple elements have the same id, the first one that was created will be returned.

Parameters
idID to find the entity for.

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