|
|
Donner
C++20 SVG rendering library
|
Holds CSS properties for a single element. More...
#include "donner/svg/properties/PropertyRegistry.h"
Public Member Functions | |
| PropertyRegistry () | |
| Constructor. | |
| ~PropertyRegistry () | |
| Destructor. | |
| PropertyRegistry (const PropertyRegistry &) | |
| Copy constructor. | |
| PropertyRegistry (PropertyRegistry &&) noexcept | |
| Move constructor. | |
| PropertyRegistry & | operator= (const PropertyRegistry &) |
| Copy assignment operator. | |
| PropertyRegistry & | operator= (PropertyRegistry &&) noexcept |
| Move assignment operator. | |
| auto | allProperties () const |
| Return a tuple of all properties within the PropertyRegistry. | |
| auto | allPropertiesMutable () |
| Return a mutable tuple of all properties within the PropertyRegistry. | |
| size_t | numPropertiesSet () const |
| Return the number of properties set within the PropertyRegistry. | |
| PropertyRegistry | inheritFrom (const PropertyRegistry &parent, PropertyInheritOptions options=PropertyInheritOptions::All) const |
| Inherit the value of each element in the stylesheet. | |
| std::optional< ParseError > | parseProperty (const css::Declaration &declaration, css::Specificity specificity) |
| Parse a single declaration, adding it to the property registry. | |
| void | parseStyle (std::string_view str) |
| Parse a SVG style attribute, and set the parsed values on this PropertyRegistry. | |
| ParseResult< bool > | parsePresentationAttribute (std::string_view name, std::string_view value, std::optional< ElementType > type=std::nullopt, EntityHandle handle=EntityHandle()) |
| Parse a presentation attribute, which can contain a CSS value. | |
Static Public Member Functions | |
| static constexpr size_t | numProperties () |
| Return the size of the tuple returned by allProperties(). | |
| template<size_t Start, size_t End, class F> | |
| static constexpr void | forEachProperty (const F &f) |
| Calls a compile time functor for each property in the registry. | |
Public Attributes | |
| Property< css::Color, PropertyCascade::Inherit > | color |
| color property, which stores the context color of the element. For painting shapes, use stroke or fill instead. | |
| Property< Display > | display {"display", []() -> std::optional<Display> { return Display::Inline; }} |
| display property, which determines how the element is rendered. Set to Display::None to hide the element. | |
| Property< double > | opacity {"opacity", []() -> std::optional<double> { return 1.0; }} |
| opacity property, which determines the opacity of the element. A value of 0.0 will make the element invisible. | |
| Property< Visibility, PropertyCascade::Inherit > | visibility |
| visibility property, which determines whether the element is visible. Set to Visibility::Hidden to hide the element. Compared to display with Display::None, hiding the element will not remove it from the document, so it will still contribute to bounding boxes. | |
| Property< Overflow > | overflow |
| overflow property, which determines how content that overflows the element's box is handled. Defaults to visible. | |
| Property< TransformOrigin > | transformOrigin |
| transform-origin property, which sets the origin for transformations. | |
| Property< PaintServer, PropertyCascade::PaintInherit > | fill |
| fill property, which determines the color of the element's interior. Defaults to black. | |
| Property< FillRule, PropertyCascade::Inherit > | fillRule |
| fill-rule property, which determines how the interior of the element is filled in the case of overlapping shapes. Defaults to FillRule::NonZero. | |
| Property< double, PropertyCascade::Inherit > | fillOpacity |
| fill-opacity property, which determines the opacity of the element's interior. Defaults to 1.0. A value of 0.0 will make the interior invisible. | |
| Property< PaintServer, PropertyCascade::PaintInherit > | stroke |
| stroke property, which determines the color of the element's outline stroke. Defaults to none. | |
| Property< double, PropertyCascade::Inherit > | strokeOpacity |
| stroke-opacity property, which determines the opacity of the element's outline stroke. Defaults to 1.0. A value of 0.0 will make the outline invisible. | |
| Property< Lengthd, PropertyCascade::Inherit > | strokeWidth |
| stroke-width property, which determines the width of the element's outline stroke. Defaults to 1.0. | |
| Property< StrokeLinecap, PropertyCascade::Inherit > | strokeLinecap |
| stroke-linecap property, which determines the shape of the element's outline stroke at the ends of the path. Defaults to StrokeLinecap::Butt. | |
| Property< StrokeLinejoin, PropertyCascade::Inherit > | strokeLinejoin |
| stroke-linejoin property, which determines the shape of the element's outline stroke in between line segments. Defaults to StrokeLinejoin::Miter. | |
| Property< double, PropertyCascade::Inherit > | strokeMiterlimit |
| stroke-miterlimit property, which determines the limit of the ratio of the miter length to the stroke width. Defaults to 4.0. | |
| Property< StrokeDasharray, PropertyCascade::Inherit > | strokeDasharray |
| stroke-dasharray property, which determines the pattern of dashes and gaps used to stroke paths. | |
| Property< Lengthd, PropertyCascade::Inherit > | strokeDashoffset |
| stroke-dashoffset property, which determines the distance into the dash pattern to start the stroke. | |
| Property< Reference, PropertyCascade::None > | clipPath |
| clip-path property, which determines the shape of the element's clipping region. Defaults to none. | |
| Property< ClipRule, PropertyCascade::Inherit > | clipRule |
| clip-rule property, which determines how the interior of the element is filled in the case of overlapping shapes. Defaults to ClipRule::NonZero. | |
| Property< Reference, PropertyCascade::None > | mask |
| mask property, which determines the shape of the element's clipping region. Defaults to none. | |
| Property< FilterEffect > | filter |
| filter property, which determines the filter effect to apply to the element. Defaults to none. | |
| Property< PointerEvents, PropertyCascade::Inherit > | pointerEvents |
| pointer-events property, which determines how the element responds to pointer events (such as clicks or hover). Defaults to PointerEvents::VisiblePainted. | |
| Property< Reference, PropertyCascade::Inherit > | markerStart |
| marker-start property, which determines the marker to be drawn at the start of the path. | |
| Property< Reference, PropertyCascade::Inherit > | markerMid |
| marker-mid property, which determines the marker to be drawn at the middle of the path. | |
| Property< Reference, PropertyCascade::Inherit > | markerEnd |
| marker-end property, which determines the marker to be drawn at the end of the path. | |
| Property< SmallVector< RcString, 1 >, PropertyCascade::Inherit > | fontFamily |
| font-family property, which determines the font family for text content. Inherited. | |
| Property< Lengthd, PropertyCascade::Inherit > | fontSize |
| font-size property, which determines the font size for text content. Inherited. | |
| std::map< RcString, parser::UnparsedProperty > | unparsedProperties |
| Properties which don't have specific listings above, which are stored as raw css declarations. | |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const PropertyRegistry ®istry) |
| Ostream output operator, for debugging which outputs a human-readable representation of all of the properties. | |
Holds CSS properties for a single element.
This class stores common properties which may be applied to any element, plus unparsedProperties which contains element-specific properties which are applied if the element matches.
For unparsedProperties, presentation attributes specified in CSS such as transform will be stored here until they can be applied to the element.
| Property | Member | Default |
|---|---|---|
| color | color | black |
| display | display | inline |
| opacity | opacity | 1.0 |
| visibility | visibility | visible |
| overflow | overflow | visible |
| fill | fill | black |
| fill-rule | fillRule | nonzero |
| fill-opacity | fillOpacity | 1.0 |
| stroke | stroke | none |
| stroke-opacity | strokeOpacity | 1.0 |
| stroke-width | strokeWidth | 1.0 |
| stroke-linecap | strokeLinecap | butt |
| stroke-linejoin | strokeLinejoin | miter |
| stroke-miterlimit | strokeMiterlimit | 4.0 |
| stroke-dasharray | strokeDasharray | none |
| stroke-dashoffset | strokeDashoffset | 0 |
| clip-path | clipPath | none |
| clip-rule | clipRule | nonzero |
| mask | mask | none |
| filter | filter | none |
| pointer-events | pointerEvents | auto |
| marker-start | markerStart | none |
| marker-mid | markerMid | none |
| marker-end | markerEnd | none |
|
inline |
Return a tuple of all properties within the PropertyRegistry.
To get the size of the tuple, use numProperties().
|
inline |
Return a mutable tuple of all properties within the PropertyRegistry.
|
inlinestaticconstexpr |
Calls a compile time functor for each property in the registry.
Example:
| Start | Index of the current property to call. |
| End | Total number of properties in the registry. |
| F | Type of the functor object, with signature void(std::integral_constant<size_t>). |
| f | Functor instance. |
|
nodiscard |
Inherit the value of each element in the stylesheet.
| parent | PropertyRegistry from this element's direct parent, where properties will be inherited from. |
| options | Options for how to inherit properties, which can be used to skip inheritance for a category of properties. |
| ParseResult< bool > donner::svg::PropertyRegistry::parsePresentationAttribute | ( | std::string_view | name, |
| std::string_view | value, | ||
| std::optional< ElementType > | type = std::nullopt, | ||
| EntityHandle | handle = EntityHandle() ) |
Parse a presentation attribute, which can contain a CSS value.
| name | Name of the attribute. |
| value | Value of the attribute, parsed as a CSS value. |
| type | If set, parses additional presentation attributes for the given element type. |
| handle | Entity handle to use for parsing additional attributes. |
| std::optional< ParseError > donner::svg::PropertyRegistry::parseProperty | ( | const css::Declaration & | declaration, |
| css::Specificity | specificity ) |
Parse a single declaration, adding it to the property registry.
| declaration | Declaration to parse. |
| specificity | Specificity of the declaration. |
| void donner::svg::PropertyRegistry::parseStyle | ( | std::string_view | str | ) |
Parse a SVG style attribute, and set the parsed values on this PropertyRegistry.
Does not clear existing properties, new ones are applied additively.
Parses the string as a CSS "<declaration-list>", ignoring any parse errors or unsupported properties
| str | Input string from a style attribute, e.g. "fill: red; stroke: blue". |
|
friend |
Ostream output operator, for debugging which outputs a human-readable representation of all of the properties.
Example output:
| os | Output stream. |
| registry | PropertyRegistry to output. |
| Property<Reference, PropertyCascade::None> donner::svg::PropertyRegistry::clipPath |
clip-path property, which determines the shape of the element's clipping region. Defaults to none.
| Property<ClipRule, PropertyCascade::Inherit> donner::svg::PropertyRegistry::clipRule |
clip-rule property, which determines how the interior of the element is filled in the case of overlapping shapes. Defaults to ClipRule::NonZero.
| Property<css::Color, PropertyCascade::Inherit> donner::svg::PropertyRegistry::color |
color property, which stores the context color of the element. For painting shapes, use stroke or fill instead.
| Property<PaintServer, PropertyCascade::PaintInherit> donner::svg::PropertyRegistry::fill |
fill property, which determines the color of the element's interior. Defaults to black.
| Property<double, PropertyCascade::Inherit> donner::svg::PropertyRegistry::fillOpacity |
fill-opacity property, which determines the opacity of the element's interior. Defaults to 1.0. A value of 0.0 will make the interior invisible.
| Property<FillRule, PropertyCascade::Inherit> donner::svg::PropertyRegistry::fillRule |
fill-rule property, which determines how the interior of the element is filled in the case of overlapping shapes. Defaults to FillRule::NonZero.
| Property<FilterEffect> donner::svg::PropertyRegistry::filter |
filter property, which determines the filter effect to apply to the element. Defaults to none.
| Property<SmallVector<RcString, 1>, PropertyCascade::Inherit> donner::svg::PropertyRegistry::fontFamily |
font-family property, which determines the font family for text content. Inherited.
| Property<Lengthd, PropertyCascade::Inherit> donner::svg::PropertyRegistry::fontSize |
font-size property, which determines the font size for text content. Inherited.
| Property<Reference, PropertyCascade::Inherit> donner::svg::PropertyRegistry::markerEnd |
marker-end property, which determines the marker to be drawn at the end of the path.
| Property<Reference, PropertyCascade::Inherit> donner::svg::PropertyRegistry::markerMid |
marker-mid property, which determines the marker to be drawn at the middle of the path.
| Property<Reference, PropertyCascade::Inherit> donner::svg::PropertyRegistry::markerStart |
marker-start property, which determines the marker to be drawn at the start of the path.
| Property<Reference, PropertyCascade::None> donner::svg::PropertyRegistry::mask |
mask property, which determines the shape of the element's clipping region. Defaults to none.
overflow property, which determines how content that overflows the element's box is handled. Defaults to visible.
| Property<PointerEvents, PropertyCascade::Inherit> donner::svg::PropertyRegistry::pointerEvents |
pointer-events property, which determines how the element responds to pointer events (such as clicks or hover). Defaults to PointerEvents::VisiblePainted.
| Property<PaintServer, PropertyCascade::PaintInherit> donner::svg::PropertyRegistry::stroke |
stroke property, which determines the color of the element's outline stroke. Defaults to none.
| Property<StrokeDasharray, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeDasharray |
stroke-dasharray property, which determines the pattern of dashes and gaps used to stroke paths.
| Property<Lengthd, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeDashoffset |
stroke-dashoffset property, which determines the distance into the dash pattern to start the stroke.
| Property<StrokeLinecap, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeLinecap |
stroke-linecap property, which determines the shape of the element's outline stroke at the ends of the path. Defaults to StrokeLinecap::Butt.
| Property<StrokeLinejoin, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeLinejoin |
stroke-linejoin property, which determines the shape of the element's outline stroke in between line segments. Defaults to StrokeLinejoin::Miter.
| Property<double, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeMiterlimit |
stroke-miterlimit property, which determines the limit of the ratio of the miter length to the stroke width. Defaults to 4.0.
| Property<double, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeOpacity |
stroke-opacity property, which determines the opacity of the element's outline stroke. Defaults to 1.0. A value of 0.0 will make the outline invisible.
| Property<Lengthd, PropertyCascade::Inherit> donner::svg::PropertyRegistry::strokeWidth |
stroke-width property, which determines the width of the element's outline stroke. Defaults to 1.0.
| Property<TransformOrigin> donner::svg::PropertyRegistry::transformOrigin |
transform-origin property, which sets the origin for transformations.
| Property<Visibility, PropertyCascade::Inherit> donner::svg::PropertyRegistry::visibility |
visibility property, which determines whether the element is visible. Set to Visibility::Hidden to hide the element. Compared to display with Display::None, hiding the element will not remove it from the document, so it will still contribute to bounding boxes.