Storage for factories that are used to create lazy attributes. More...
Classes | |
| class | Registrant |
Typedefs | |
|
typedef std::function < Valuable::Attribute *(Valuable::Node *, const QByteArray &)> | Func |
Functions | |
| STYLISH_API Valuable::Attribute * | create (Valuable::Node *node, const QByteArray &name) |
Storage for factories that are used to create lazy attributes.
Lazy attributes are dynamically (on-demand) created Valuable::Attribute objects. These attributes are created by factory functions that are registered by using LAZY_ATTRIBUTE-macro. If there is a CSS rule that matches a Styleable object but fails to find the target attribute, LazyAttributeManager is invoked in order to create the missing attribute.
For example, see this CSS rule:
This rule will match all ImageWidgets, but there is no such attribute in ImageWidget as 'max-scale', so this will trigger a warning.
However, we can add this attribute without modifying ImageWidget using LAZY_ATTRIBUTE-macro and custom factory:
So when ever any ImageWidget is given any value for max-scale attribute in CSS, a new LimitScaleOperator is created and added to the widget. Any changes to the attribute change LimitScaleOperator::maximum-value attribute directly.