Donner
C++20 SVG rendering library
Loading...
Searching...
No Matches
donner::svg::components::StyleComponent Struct Reference

Contains properties the style="" attribute for an element, local to the element. More...

#include "donner/svg/components/style/StyleComponent.h"

Collaboration diagram for donner::svg::components::StyleComponent:
[legend]

Public Member Functions

void setStyle (std::string_view style)
 Sets the properties from the value of the element's style="" attribute.
 
parser::ParseResult< bool > trySetPresentationAttribute (EntityHandle handle, std::string_view name, std::string_view value)
 Tries to set a presentation attribute on the given entity.
 

Public Attributes

PropertyRegistry properties
 The properties of the element, which are parsed from the style="" attribute.
 

Detailed Description

Contains properties the style="" attribute for an element, local to the element.

This is used during the CSS cascade, which stores the final element style in ComputedStyleComponent.

Member Function Documentation

◆ setStyle()

void donner::svg::components::StyleComponent::setStyle ( std::string_view style)
inline

Sets the properties from the value of the element's style="" attribute.

Note that this applies the style additively, and does not invalidate the existing style.

Todo
Add an option to clear the existing style first. For now, this can be done by setting properties to an empty PropertyRegistry.
Parameters
styleThe value of the style attribute.

◆ trySetPresentationAttribute()

parser::ParseResult< bool > donner::svg::components::StyleComponent::trySetPresentationAttribute ( EntityHandle handle,
std::string_view name,
std::string_view value )
inline

Tries to set a presentation attribute on the given entity.

This is used during the CSS cascade to apply the computed style to the element.

Parameters
handleThe entity to set the attribute on.
nameThe name of the attribute.
valueThe value of the attribute.
Returns
true if the attribute was set, false if the attribute was not recognized.

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