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

DOM object for a "<marker>" element, which is used to define graphical objects that can be used repeatedly along a path, such as arrowheads or other markers on paths. More...

#include "donner/svg/SVGMarkerElement.h"

Inheritance diagram for donner::svg::SVGMarkerElement:
[legend]
Collaboration diagram for donner::svg::SVGMarkerElement:
[legend]

Public Member Functions

void setViewBox (OptionalRef< Box2d > viewBox)
 Set the viewBox attribute, which defines a rectangle in userspace that should be mapped to the SVG viewport bounds established by the pattern.
std::optional< Box2dviewBox () const
 Get the parsed value of the viewBox attribute, if specified, which defines a rectangle in userspace that should be mapped to the SVG viewport bounds established by the pattern.
void setPreserveAspectRatio (PreserveAspectRatio preserveAspectRatio)
 Set the preserveAspectRatio attribute, which defines how to scale the viewport to fit the content.
PreserveAspectRatio preserveAspectRatio () const
 The value of the preserveAspectRatio attribute, which defines how to scale the viewport to fit the content.
void setMarkerWidth (Lengthd value)
 Set the marker width.
Lengthd markerWidth () const
 Get the marker width.
void setMarkerHeight (Lengthd value)
 Set the marker height.
Lengthd markerHeight () const
 Get the marker height.
void setRefX (Lengthd value)
 Set the reference point X coordinate.
Lengthd refX () const
 Get the reference point X coordinate.
void setRefY (Lengthd value)
 Set the reference point Y coordinate.
Lengthd refY () const
 Get the reference point Y coordinate.
MarkerUnits markerUnits () const
 Get the markerUnits attribute which defines the coordinate system for attributes markerWidth, markerHeight, and the contents of the marker.
void setMarkerUnits (MarkerUnits value)
 Set the markerUnits attribute which defines the coordinate system for attributes markerWidth, markerHeight, and the contents of the marker.
void setOrient (MarkerOrient value)
 Set the orientation of the marker, the orient attribute.
MarkerOrient orient () const
 Get the orientation of the marker, the orient attribute.
Public Member Functions inherited from donner::svg::SVGElement
 SVGElement (const SVGElement &other)
 Create another reference to the same SVGElement.
 SVGElement (SVGElement &&other) noexcept
 Move constructor.
 ~SVGElement () noexcept
 Destructor.
SVGElementoperator= (const SVGElement &other)
 Create another reference to the same SVGElement.
SVGElementoperator= (SVGElement &&other) noexcept
 Move assignment operator.
ElementType type () const
 Get the ElementType for known XML element types.
std::optional< ElementTypetryType () const
 Get the ElementType if this handle still has SVG element identity.
xml::XMLQualifiedNameRef tagName () const
 Get the XML tag name string for this element.
std::optional< xml::XMLQualifiedNameReftryTagName () const
 Get the XML tag name if this handle still has XML tree identity.
bool isKnownType () const
 Returns true if this is a known element type, returns false if this is an donner::svg::SVGUnknownElement.
EntityHandle unsafeEntityHandle () const
 Get the underlying donner::EntityHandle.
EntityHandle entityHandle () const
 Get the underlying donner::EntityHandle, for advanced use-cases that require direct access to the ECS.
template<typename Callback>
decltype(auto) withReadAccess (Callback &&callback) const
 Run a callback with scoped read access to this element's document and resolved entity handle.
template<typename Callback>
decltype(auto) withWriteAccess (Callback &&callback) const
 Run a callback with scoped write access to this element's document and resolved entity handle.
RcString id () const
 Get the element id, the value of the "id" attribute.
void setId (std::string_view id)
 Set the element id, the value of the "id" attribute.
RcString className () const
 Get the element class name, the value of the "class" attribute.
void setClassName (std::string_view name)
 Set the element class name, the value of the "class" attribute.
void setStyle (std::string_view style)
 Set the element style, the value of the "style" attribute.
void updateStyle (std::string_view style)
 Update the element style, adding new attributes or overridding existing ones (without removing them).
ParseResult< bool > trySetPresentationAttribute (std::string_view name, std::string_view value)
 Set the value of a presentation attribute, such as "fill" or "stroke".
bool hasAttribute (const xml::XMLQualifiedNameRef &name) const
 Returns true if the element has an attribute with the given name.
std::optional< RcStringgetAttribute (const xml::XMLQualifiedNameRef &name) const
 Get the value of an attribute, if it exists.
SmallVector< xml::XMLQualifiedNameRef, 1 > findMatchingAttributes (const xml::XMLQualifiedNameRef &matcher) const
 Find attributes matching the given name matcher.
SmallVector< xml::XMLQualifiedNameRef, 10 > attributes () const
 Get the list of attributes for this element.
void setAttribute (const xml::XMLQualifiedNameRef &name, std::string_view value)
 Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute.
void removeAttribute (const xml::XMLQualifiedNameRef &name)
 Remove an attribute, which may be either a presentation attribute or custom user-provided attribute.
SVGDocument ownerDocument ()
 Get an owning reference to the SVGDocument containing this element.
std::optional< SVGElementparentElement () const
 Get this element's parent, if it exists.
std::optional< SVGElementfirstChild () const
 Get the first child of this element, if it exists.
std::optional< SVGElementlastChild () const
 Get the last child of this element, if it exists.
std::optional< SVGElementpreviousSibling () const
 Get the previous sibling of this element, if it exists.
std::optional< SVGElementnextSibling () const
 Get the next sibling of this element, if it exists.
void insertBefore (const SVGElement &newNode, std::optional< SVGElement > referenceNode)
 Insert newNode as a child, before referenceNode.
void appendChild (const SVGElement &child)
 Append child as a child of the current node.
void replaceChild (const SVGElement &newChild, const SVGElement &oldChild)
 Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place.
void removeChild (const SVGElement &child)
 Remove child from this node.
void remove ()
 Remove this node from its parent, if it has one.
bool operator== (const SVGElement &other) const
 Returns true if the two SVGElement handles reference the same underlying document.
bool operator!= (const SVGElement &other) const
 Returns true if the two SVGElement handles reference the same underlying document.
template<typename Derived>
bool isa () const
 Return true if this element "is a" instance of type, if it be cast to a specific type with cast.
template<typename Derived>
Derived cast ()
 Cast this element to its derived type.
template<typename Derived>
Derived cast () const
 Cast this element to its derived type (const version).
template<typename Derived>
std::optional< Derived > tryCast ()
 Cast this element to its derived type, if possible.
template<typename Derived>
std::optional< const Derived > tryCast () const
 Cast this element to its derived type, if possible.
std::optional< SVGElementquerySelector (std::string_view selector)
 Find the first element in the tree that matches the given CSS selector.
const PropertyRegistrygetComputedStyle () const
 Get the computed CSS style of this element, after the CSS cascade has been applied.

Static Public Member Functions

static SVGMarkerElement Create (SVGDocument &document)
 Create a new "<marker>" element.

Static Public Attributes

static constexpr ElementType Type = ElementType::Marker
 Element type.
static constexpr std::string_view Tag {"marker"}
 XML tag name, "<marker>".

Friends

class parser::SVGParserImpl

Additional Inherited Members

Protected Member Functions inherited from donner::svg::SVGElement
 SVGElement (EntityHandle handle)
 Internal constructor to create an SVGElement from an donner::EntityHandle.
template<typename InvalidateCallback>
ScopedMutation< std::decay_t< InvalidateCallback > > mutationScope (InvalidateCallback &&invalidateOnScopeExit) const
 Create a scoped mutation that runs invalidateOnScopeExit before the revision commit.
std::optional< ParseDiagnosticsetAttributeFromXMLMutation (const xml::XMLQualifiedNameRef &name, std::string_view value)
 Set an attribute from an XML mutation and return any SVG semantic parse diagnostic.
void removeAttributeFromXMLMutation (const xml::XMLQualifiedNameRef &name)
 Remove an attribute from an XML mutation without writing back to XML source.
RegistryunsafeRegistry () const
 Get the underlying ECS Registry, which holds all data for the document, for advanced use.
Registryregistry () const
 Get the underlying ECS Registry, which holds all data for the document, for advanced use.
EntityHandle toHandle (Entity entity) const
 Convert an Entity to an EntityHandle, for advanced use.
Static Protected Member Functions inherited from donner::svg::SVGElement
static DocumentWriteAccess CreateElementWriteAccess (SVGDocument &document)
 Acquire write access for creating an element in a document.
static DocumentMutationBatch CreateElementMutationBatch (SVGDocument &document)
 Acquire a mutation scope for creating an element in a document.
static EntityHandle CreateEmptyEntity (SVGDocument &document)
 Create a new Entity within the document ECS, and return a handle to it.
static EntityHandle CreateEmptyEntity (DocumentWriteAccess &access)
 Create a new Entity within a guarded document ECS, and return a handle to it.
static void CreateEntityOn (EntityHandle handle, const xml::XMLQualifiedNameRef &tagName, ElementType Type)
 Create a new SVG element instance on a given donner::Entity.
Protected Attributes inherited from donner::svg::SVGElement
ElementAnchor handle_
 The lifetime-aware ECS entity anchor for this element.

Detailed Description

DOM object for a "<marker>" element, which is used to define graphical objects that can be used repeatedly along a path, such as arrowheads or other markers on paths.

Member Function Documentation

◆ Create()

SVGMarkerElement donner::svg::SVGMarkerElement::Create ( SVGDocument & document)
inlinestatic

Create a new "<marker>" element.

Parameters
documentContaining document.

◆ markerHeight()

Lengthd donner::svg::SVGMarkerElement::markerHeight ( ) const

Get the marker height.

Returns
Height of the marker viewport.

◆ markerUnits()

MarkerUnits donner::svg::SVGMarkerElement::markerUnits ( ) const

Get the markerUnits attribute which defines the coordinate system for attributes markerWidth, markerHeight, and the contents of the marker.

Defaults to MarkerUnits::StrokeWidth.

Returns
Coordinate system for marker attributes and contents.

◆ markerWidth()

Lengthd donner::svg::SVGMarkerElement::markerWidth ( ) const

Get the marker width.

Returns
Width of the marker viewport.

◆ orient()

MarkerOrient donner::svg::SVGMarkerElement::orient ( ) const

Get the orientation of the marker, the orient attribute.

Returns
Orientation of the marker relative to the path.

◆ preserveAspectRatio()

PreserveAspectRatio donner::svg::SVGMarkerElement::preserveAspectRatio ( ) const

The value of the preserveAspectRatio attribute, which defines how to scale the viewport to fit the content.

Only applies is viewBox is specified.

◆ refX()

Lengthd donner::svg::SVGMarkerElement::refX ( ) const

Get the reference point X coordinate.

Returns
X coordinate for the reference point of the marker.

◆ refY()

Lengthd donner::svg::SVGMarkerElement::refY ( ) const

Get the reference point Y coordinate.

Returns
Y coordinate for the reference point of the marker.

◆ setMarkerHeight()

void donner::svg::SVGMarkerElement::setMarkerHeight ( Lengthd value)

Set the marker height.

Percentage units resolve against the viewport height at render time.

Parameters
valueHeight of the marker viewport.

◆ setMarkerUnits()

void donner::svg::SVGMarkerElement::setMarkerUnits ( MarkerUnits value)

Set the markerUnits attribute which defines the coordinate system for attributes markerWidth, markerHeight, and the contents of the marker.

Parameters
valueCoordinate system for marker attributes and contents.

◆ setMarkerWidth()

void donner::svg::SVGMarkerElement::setMarkerWidth ( Lengthd value)

Set the marker width.

Percentage units resolve against the viewport width at render time.

Parameters
valueWidth of the marker viewport.

◆ setOrient()

void donner::svg::SVGMarkerElement::setOrient ( MarkerOrient value)

Set the orientation of the marker, the orient attribute.

Parameters
valueOrientation of the marker relative to the path.

◆ setPreserveAspectRatio()

void donner::svg::SVGMarkerElement::setPreserveAspectRatio ( PreserveAspectRatio preserveAspectRatio)

Set the preserveAspectRatio attribute, which defines how to scale the viewport to fit the content.

Only applies if viewBox is specified.

Parameters
preserveAspectRatioThe preserveAspectRatio value to set.

◆ setRefX()

void donner::svg::SVGMarkerElement::setRefX ( Lengthd value)

Set the reference point X coordinate.

Percentage units resolve against the viewport width at render time.

Parameters
valueX coordinate for the reference point of the marker.

◆ setRefY()

void donner::svg::SVGMarkerElement::setRefY ( Lengthd value)

Set the reference point Y coordinate.

Percentage units resolve against the viewport height at render time.

Parameters
valueY coordinate for the reference point of the marker.

◆ setViewBox()

void donner::svg::SVGMarkerElement::setViewBox ( OptionalRef< Box2d > viewBox)

Set the viewBox attribute, which defines a rectangle in userspace that should be mapped to the SVG viewport bounds established by the pattern.

Parameters
viewBoxThe viewBox value to set.

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