Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::NodeEffect2D Class Referenceabstract

Use node effects to apply post-processing effects to 2D nodes. More...

#include <kanzi/core.ui/node/node_effect2d.hpp>

Inheritance diagram for kanzi::NodeEffect2D:
[legend]

Public Member Functions

void attach (Node *node)
 Attaches the node effect. More...
 
BindingLookupContextPtr createLookupContext (NodeEffect2DSharedPtr templateRoot)
 Creates a lookup context for a given effect. More...
 
NodeEffectRenderer2DUniquePtr createRenderer ()
 Creates a renderer instance. More...
 
void detach ()
 Detaches the node effect. More...
 
unsigned int getEffectPaddingChangeCounter () const
 Gets the effect quad padding change counter. More...
 
Vector4 getEffectQuadPadding () const
 Gets the effect quad padding. More...
 
Vector2 getEffectQuadPaddingOffset () const
 Gets the effect quad offset relative relative to the top-left corner of the node. More...
 
Vector2 getEffectQuadPaddingSize () const
 Gets the effect quad padding size. More...
 
bool getEnabled () const
 Gets the value of EnabledProperty. More...
 
NodegetHostNode () const
 Gets the node that hosts the effect. More...
 
NodeEffect2DgetParent () const
 Gets the parent of a node effect. More...
 
NodeEffectRenderer2DgetRendererInstance () const
 Gets a pointer to NodeEffectRenderer2D instance or null pointer if none exists. More...
 
NodeEffect2DSharedPtr getTemplateRoot () const
 Gets the template root of this node effect. More...
 
bool isAlphaRequired () const
 Indicates whether the effect requires alpha channel for the result. More...
 
bool isAttached () const
 Returns whether a node effect is attached to a node. More...
 
bool isAttaching () const
 Returns whether a node effect is attaching to a node. More...
 
bool isDetached () const
 Returns whether a node effect is detached from a node. More...
 
bool isDetaching () const
 Returns whether a node effect is detaching from a node. More...
 
bool isRenderingRequired ()
 Indicates whether the effect requires rendering. More...
 
ObjectSharedPtr lookupObject (string_view relativePath)
 Lookup for an object from the effect. More...
 
template<typename T >
shared_ptr< TlookupObject (string_view relativePath)
 Lookup a relative object of a given type. More...
 
void setEffectPaddingChangeCounter (unsigned int value)
 Sets the effect quad padding change counter. More...
 
void setEnabled (bool value)
 Sets the value of EnabledProperty. More...
 
void setParent (NodeEffect2D *parent)
 Sets the parent of a node effect. More...
 
void setTemplateRoot (NodeEffect2DSharedPtr templateRoot)
 Sets the template root for this node effect. More...
 
void unregisterEffectRenderer (NodeEffectRenderer2D *effectRenderer)
 Unregister effect renderer. More...
 
 ~NodeEffect2D ()
 
- Public Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsage () const
 Function for getting the memory usage of a resource. More...
 
const string & getName () const
 Gets the resource name. More...
 
const string & getUrl () const
 Gets the resource URL. More...
 
bool isKeepAlive () const
 Tells if the resource has keep alive flag set. More...
 
void reload ()
 
void reloadFromFile (string_view filePath)
 
void reloadFromKzb (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
void setKeepAlive (bool keepAlive)
 Sets the keep alive flag. More...
 
void setUrl (string_view url)
 Sets the resource URL. More...
 
 ~Resource () override
 Destructor. More...
 
- Public Member Functions inherited from kanzi::Object
AppliedStyleEntrySharedPtr applyObjectStyle (kanzi::StyleSharedPtr style)
 Applies a style to an object. More...
 
void applyObjectStyles ()
 Apply all styles for an object node. More...
 
DomaingetDomain () const
 Returns the domain the object belongs to. More...
 
const MetaclassgetDynamicMetaclass () const override
 Returns the metaclass of the dynamic type of the object. More...
 
MainLoopSchedulergetMainLoopScheduler () const
 Returns the MainLoopScheduler instance of the associated Domain. More...
 
detail::MessageDispatcher * getMessageDispatcher () const
 Returns the message dispatcher of the object. More...
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object. More...
 
ScriptingContextSharedPtr getScriptingContext () const
 Gets the scripting context of the object. More...
 
 Object (Domain *domain)
 
void setScriptingContext (ScriptingContextSharedPtr context)
 Sets the scripting context of the object. More...
 
void unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry)
 
void unapplyObjectStyles ()
 Unapplies and removes all applied styles. More...
 
 ~Object () override
 
- Public Member Functions inherited from kanzi::MetaObject
bool isTypeOf (const Metaclass *objectType) const
 Determines if the type of this object is the given type or derived from it. More...
 
virtual ~MetaObject ()
 
- Public Member Functions inherited from kanzi::PropertyObject
template<typename DataType >
void addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void addPropertyModifierWithoutNotifyingHandlers (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 Adds a property modifier without notifying handlers. More...
 
template<typename DataType >
void addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 
template<typename DataType >
void addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 
PropertyStorageContainer::iterator beginPropertyStorage ()
 Returns the begin iterator to the internal property storage container. More...
 
PropertyStorageContainer::const_iterator beginPropertyStorage () const
 Returns the begin iterator to the internal property storage container. More...
 
void clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
void copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType)
 Copies local value of single property from another object. More...
 
void copyLocalValues (const PropertyObject &other)
 Copies all local values from another object. More...
 
PropertyStorageContainer::iterator endPropertyStorage ()
 Returns the end iterator to the internal property storage container. More...
 
PropertyStorageContainer::const_iterator endPropertyStorage () const
 Returns the end iterator to the internal property storage container. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalProperty (const PropertyType< DataType > &propertyType) const
 Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
optional< typename PropertyType< DataType >::Traits::ReturnType > getOptionalPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getProperty (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property type. More...
 
template<typename DataType >
PropertyType< DataType >::Traits::ReturnType getPropertyBase (const PropertyType< DataType > &propertyType) const
 Returns the current value of a property disregarding modifiers. More...
 
template<typename DataType >
size_t getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) const
 Gets number of current notification handlers for given property type. More...
 
bool hasBaseValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value, disregarding modifiers. More...
 
bool hasLocalValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a local value set for the property. More...
 
bool hasNonClassValue (AbstractPropertyType propertyType) const
 Evaluates whether there is a value of any precedence higher than class default value set for the property. More...
 
bool hasValue (AbstractPropertyType propertyType) const
 Evaluates whether there are any inputs into the property value. More...
 
bool isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const
 
 PropertyObject ()
 
void removeKzbProperties (flat_set< AbstractPropertyType > *keepProperties)
 Remove all KZB properties that are not included in a given set. More...
 
void removeKzbProperties ()
 Remove all KZB properties. More...
 
template<typename DataType >
void removeLocalPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
void removeLocalValue (AbstractPropertyType propertyType)
 Removes the local value associated with the property. More...
 
template<typename DataType >
void removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner)
 
template<typename DataType >
void removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner)
 
template<typename DataType >
void removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *ownerPointer)
 
template<typename DataType >
void setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 
template<typename DataType >
void setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value)
 Sets the local value of a property type. More...
 
void setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag)
 
KZ_DEPRECATED void validatePropertyModifiers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers. More...
 
void validatePropertyModifiersAndNotifyHandlers (AbstractPropertyType propertyType)
 Validates property modifiers and notifies handlers. More...
 
virtual ~PropertyObject ()
 
- Public Member Functions inherited from kanzi::BindingHostConceptImpl< NodeEffect2D >
void addBindingRuntime (AbstractBindingRuntimeSharedPtr entry, shared_ptr< void > owner)
 Adds an already-created binding runtime to this binding host. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyValuePrecedence precedence)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a binding. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot)
 Sets a binding with no target. More...
 
BindingRuntimeHandle setBinding (AbstractBindingSharedPtr binding)
 Wrapper for setting a binding with no target. More...
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Sets a binding to a certain property. More...
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field, PropertyValuePrecedence precedence)
 Wrapper for setting a binding with owner. More...
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a binding with owner. More...
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot)
 Sets a binding with no target. More...
 
BindingRuntimeHandle setBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner)
 Wrapper for setting a binding with no target. More...
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding. More...
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding. More...
 
BindingRuntimeHandle setModifierBinding (AbstractBindingSharedPtr binding, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding. More...
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, shared_ptr< NodeEffect2D > templateRoot, AbstractPropertyType propertyType, PropertyField field)
 Sets a modifier binding. More...
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType, PropertyField field)
 Wrapper for setting a modifier binding. More...
 
BindingRuntimeHandle setModifierBindingWithOwner (AbstractBindingSharedPtr binding, shared_ptr< void > owner, AbstractPropertyType propertyType)
 Wrapper for setting a modifier binding. More...
 
- Public Member Functions inherited from kanzi::BindingHostConcept
BindingRuntimeConstIterator beginBindingRuntimes () const
 Returns an iterator to the beginning of binding runtimes. More...
 
BindingRuntimeConstIterator endBindingRuntimes () const
 Returns an iterator to the end of binding runtimes. More...
 
AbstractBindingRuntimeSharedPtr getBindingRuntime (size_t idx)
 Gets binding by index. More...
 
size_t getBindingRuntimeCount () const
 Gets the number of binding runtimes added to this node. More...
 
void removeAllBindings ()
 Removes all binding runtimes. More...
 
void removeBinding (BindingRuntimeHandle &bindingRuntime)
 Removes a binding runtime added earlier. More...
 
void removeBindingsWithOwner (shared_ptr< void > owner)
 Removes all binding runtimes with the specified owner. More...
 

Static Public Attributes

static PropertyType< bool > EnabledProperty
 Sets whether the effect is enabled. More...
 

Protected Member Functions

virtual NodeEffectRenderer2DUniquePtr createRendererOverride ()=0
 Creates a renderer instance. More...
 
virtual void initializeRendererOverride ()=0
 Initializes a previously created renderer instance. More...
 
virtual bool isRenderingRequiredOverride ()
 Implementation-dependent check on whether effect rendering is required. More...
 
virtual ObjectSharedPtr lookupObjectOverride (string_view initialPart, string_view remainingPart)
 Lookup for an object from the effect. More...
 
 NodeEffect2D (Domain *domain, string_view name)
 Constructor. More...
 
virtual void onAttached ()
 Called by Kanzi when effect is attached. More...
 
virtual void onDetached ()
 Called by Kanzi when effect is detached. More...
 
void onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) override
 PropertyObject::onPropertyChanged implementation. More...
 
void setAlphaRequired (bool required)
 Sets the framebuffer alpha channel requirements of the effect. More...
 
void setEffectQuadPadding (float left, float right, float top, float bottom)
 Sets the padding required by the effect around the node bounds during the rendering of the effect. More...
 
- Protected Member Functions inherited from kanzi::Resource
virtual unsigned int getCPUMemoryUsageOverride () const
 
virtual void reloadFromFileOverride (string_view filePath)
 
virtual void reloadFromKzbOverride (KzbFile &kzbFile, ReadOnlyMemoryFile &file, KzbMemoryParser &parser)
 
virtual void reloadOverride ()
 
 Resource (Domain *domain, string_view name)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Member Functions inherited from kanzi::MetaObject
void initialize ()
 
 MetaObject ()
 
- Protected Member Functions inherited from kanzi::PropertyObject
AbstractPropertyTypeDescriptor::ValueSourceEntryacquireLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Acquires a local value source entry that is free for the assignment of a value. More...
 
AbstractPropertyTypeDescriptor::ModifierStorageacquireModifierStorage (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
AbstractPropertyTypeDescriptor::NotificationStorageacquireNotificationStorage (AbstractPropertyTypeDescriptor &descriptor)
 
PropertyStoragePtr acquirePropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
template<typename DataType >
void addPropertyModifierBase (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner, bool notify)
 Adds a property modifier entry to the property modifier stack and validates them. More...
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, void *ownerPointer)
 Internally adds a property value source. More...
 
void addPropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, PropertyValuePrecedence precedence, AbstractPropertyTypeDescriptor::ValueSourceOwner *owner)
 Internally adds a property value source. More...
 
AbstractPropertyTypeDescriptor::ValueSourceEntryconstructLocalValueSourceEntry (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::PropertyStorage &propertyStorage)
 
PropertyStoragePtr constructPropertyStorage (AbstractPropertyTypeDescriptor &descriptor)
 
void copyLocalValue (const AbstractPropertyTypeDescriptor::PropertyStorage &otherPropertyStorage)
 Copy local value from property storage. More...
 
AbstractPropertyTypeDescriptor::ModifierStoragefindModifierStorage (AbstractPropertyTypeDescriptor &descriptor)
 
AbstractPropertyTypeDescriptor::NotificationStoragefindNotificationStorage (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::PropertyStoragefindPropertyStorage (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the property storage for given property type descriptor. More...
 
PropertyStoragePtr findPropertyStoragePtr (AbstractPropertyTypeDescriptor &descriptor) const
 Gets property storage intrusive pointer which you can use to hold a reference until the end of the operation. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByNameAndDataType (string_view name, PropertyDataType dataType) const
 Finds a property type descriptor by name and data type. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByQualifiedNameAndDataType (string_view qualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with qualified names. More...
 
AbstractPropertyTypeDescriptorfindPropertyTypeDescriptorByUnqualifiedNameAndDataType (string_view unqualifiedName, PropertyDataType dataType) const
 Like findPropertyTypeDescriptorByNameAndDataType, but only searches by matching with unqualified names. More...
 
AbstractPropertyTypeDescriptor::ValueSourcegetClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetFinalValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetNonClassValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 
AbstractPropertyTypeDescriptor::ValueSourcegetTopValueSource (AbstractPropertyTypeDescriptor &descriptor) const
 Gets the top-level value source for a given property descriptor. More...
 
virtual void notifyPropertyHandlers (PropertyStoragePtr &storagePtr, PropertyNotificationReason reason)
 Notifies all property handlers on a property storage. More...
 
void onCopy (const PropertyObject &other)
 
void removeLocalValue (AbstractPropertyTypeDescriptor &descriptor, PropertyStoragePtr &propertyStorage)
 Removes a local value from the given property storage. More...
 
void removePropertyValueSource (AbstractPropertyTypeDescriptor &descriptor, AbstractPropertyTypeDescriptor::ValueSource *valueSource, void *owner)
 Removes a property value source. More...
 
void validatePropertyModifiers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers without notifying handlers. More...
 
void validatePropertyModifiersAndNotifyHandlers (PropertyStoragePtr &propertyStorage)
 Validates property modifiers and notifies handlers. More...
 
- Protected Member Functions inherited from kanzi::BindingHostConceptImpl< NodeEffect2D >
NodeEffect2DgetThisObject ()
 Internal accessor for the Curiously Recurring Template Pattern. More...
 
const NodeEffect2DgetThisObject () const
 Internal accessor for the Curiously Recurring Template Pattern. More...
 
- Protected Member Functions inherited from kanzi::BindingHostConcept
void attachBindings ()
 Attach all bindings stored in this object. More...
 
void detachBindings ()
 Detach bindings. More...
 

Additional Inherited Members

- Public Types inherited from kanzi::PropertyObject
typedef PropertyStorageContainer::const_iterator PropertyStorageConstIterator
 
typedef vector< PropertyStoragePtrPropertyStorageContainer
 
typedef PropertyStorageContainer::iterator PropertyStorageIterator
 
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStoragePropertyStoragePtr
 
typedef PropertyStorageContainer::reverse_iterator PropertyStorageReverseIterator
 
- Public Types inherited from kanzi::BindingHostConcept
using BindingHostConceptSharedPtr = shared_ptr< BindingHostConcept >
 Binding host concept shared pointer type. More...
 
using BindingRuntimeConstIterator = BindingRuntimeContainer::const_iterator
 Const iterator for binding runtimes. More...
 
using BindingRuntimeContainer = vector< AbstractBindingRuntimeSharedPtr >
 Container for binding runtimes. More...
 
using BindingRuntimeIterator = BindingRuntimeContainer::iterator
 Iterator for binding runtimes. More...
 
- Static Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 
- Static Public Member Functions inherited from kanzi::MetaObject
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static PropertyTypeEditorInfoSharedPtr makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 
- Protected Types inherited from kanzi::Object
typedef vector< AppliedStyleEntrySharedPtrAppliedStyleContainer
 Applied style container. More...
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object. More...
 
- Protected Attributes inherited from kanzi::BindingHostConcept
BindingRuntimeContainer m_bindingRuntimes
 Bindings in this object. More...
 

Detailed Description

Use node effects to apply post-processing effects to 2D nodes.

Examples

To create an effect:

// An effect that is assigned to a 2D node is an effect prefab.
// Before you can construct an effect prefab, you must create an effect template.
// This example creates an effect template for the ShadowEffect2D effect prefab.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
// Create a node effect prefab from the effect template.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);

To assign an effect to a 2D node:

// To assign an effect prefab to a 2D node, set the Node2D::EffectPrefabProperty.
node2d->setProperty(Node2D::EffectPrefabProperty, shadowEffectPrefab);
// To assign an effect prefab to a 2D node, call the Node2D::setEffectPrefab method.
node2d->setEffectPrefab(shadowEffectPrefab);

To set the effect properties:

// Create an effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
// Set the value of the AngleProperty in the template. This value serves as the default value
// of the property in instances of the effect prefab.
shadowEffectTemplate->addPropertyValue(ShadowEffect2D::AngleProperty, Variant(35.f));
// Create an effect prefab.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);
// Assign the effect to a 2D node.
node2d->setEffectPrefab(shadowEffectPrefab);
// Get the node-specific effect instance created from the assigned prefab.
ShadowEffect2DSharedPtr shadowEffect = dynamic_pointer_cast<ShadowEffect2D>(node2d->getEffect());
// Set the shadow distance to 15 pixels for this node only. This overrides
// the property default value defined by the ShadowEffect2D metaclass.
shadowEffect->setDistance(15.f);
// Set the direction of the shadow to 55 degrees relative to the positive x axis.
// This overrides the default value of 35 degrees set in the shadow effect template.
shadowEffect->setAngle(55.f);

To set multiple nodes to use the same effect:

// Create an effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
// Create an effect prefab from the effect template.
NodeEffectPrefab2DSharedPtr shadowEffectPrefab =
NodeEffectPrefab2D::create(getDomain(), "DropShadow prefab", shadowEffectTemplate);
// Set two nodes to use the same effect prefab. The nodes create separate instances
// of NodeEffect2D but share the same NodeEffectPrefab2D instance.
node1->setEffectPrefab(shadowEffectPrefab);
node2->setEffectPrefab(shadowEffectPrefab);

To enable and disable an effect:

// Enable an effect on a 2D node by assigning an effect prefab.
node2d->setEffectPrefab(shadowEffectPrefab);
// Disable an effect by assigning a nullptr or an empty shared pointer.
node2d->setEffectPrefab(nullptr);

To create an effect type:

// To create an effect resource type, inherit a new class from NodeEffect2D
// and define a new associated metaclass. Each effect resource class must
// have an associated renderer class inherited from NodeEffectRenderer2D.
class EmptyEffectRenderer2D;
using EmptyEffectRenderer2DUniquePtr = unique_ptr<EmptyEffectRenderer2D>;
class EmptyEffect2D;
using EmptyEffect2DSharedPtr = shared_ptr<EmptyEffect2D>;
// EmptyEffect2D defines a new effect that defines no properties
// nor padding.
class EmptyEffect2D : public NodeEffect2D
{
public:
KZ_METACLASS_BEGIN(EmptyEffect2D, NodeEffect2D, "Kanzi.EmptyEffect2D")
// Create an instance of EmptyEffect2D.
static EmptyEffect2DSharedPtr create(Domain* domain, string_view name)
{
return make_polymorphic_shared_ptr<Resource>(new EmptyEffect2D(domain, name));
}
protected:
// Constructor.
explicit EmptyEffect2D(Domain* domain, string_view name) :
NodeEffect2D(domain, name)
{
}
// NodeEffect2D::createRendererOverride implementation.
// NodeEffect2D::initializeRendererOverride implementation.
{
}
};
// EmptyEffectRenderer2D implements the rendering of the effect.
// Because this example effect does not render anything, Kanzi renders
// the original node as is.
class EmptyEffectRenderer2D : public NodeEffectRenderer2D
{
public:
// Creates an instance of MinimalEffectRenderer2D. Never call this
// function directly. Instead, use NodeEffect2D::createRenderer().
static EmptyEffectRenderer2DUniquePtr create(EmptyEffect2DSharedPtr effect)
{
return unique_ptr<EmptyEffectRenderer2D>(new EmptyEffectRenderer2D(effect));
}
private:
// Constructor.
explicit EmptyEffectRenderer2D(EmptyEffect2DSharedPtr effect) :
NodeEffectRenderer2D(effect)
{
}
// Implementation of NodeEffectRenderer2D::beginEffectOverride.
void beginEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/,
const Matrix3x3& /*worldTransform*/, const CompositionContentRequirements& /*requirements*/) override
{
}
// Implementation of NodeEffectRenderer2D::endEffectOverride.
void endEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/) override
{
}
// Implementation of NodeEffectRenderer2D::blitEffectOverride.
void blitEffectOverride(Renderer3D& /*renderer*/, CompositionStack& /*compositionStack*/, CompositionManager* /*compositionManager*/,
const QuadDescription& /*effectQuad*/, const Matrix3x3& /*transform*/, const Matrix4x4* /*perspectiveMatrix*/,
const Matrix4x4* /*projectionMatrix*/, int /*blendMode*/, bool /*needsClear*/) override
{
}
// Implementation of NodeEffectRenderer2D::restoreResourcesOverride.
virtual void restoreResourcesOverride() override
{
}
};
NodeEffectRenderer2DUniquePtr EmptyEffect2D::createRendererOverride()
{
return EmptyEffectRenderer2D::create(static_pointer_cast<EmptyEffect2D>(shared_from_this()));
}

To use bindings with effects:

// Create an outline effect template.
NodeEffectTemplate2DSharedPtr outlineEffectTemplate =
// Create a shadow effect template.
NodeEffectTemplate2DSharedPtr shadowEffectTemplate =
// Add to the shadow effect a binding that binds the shadow distance to a value in the root
// of the effect template.
shadowEffectTemplate->addBinding(BindingLoadInfo(Binding::create("##Template", ShadowEffect2D::DistanceProperty), ShadowEffect2D::DistanceProperty));
// Add to the host node a binding that binds the shadow distance value in the effect template root
// to the value in the node.
node->setBinding(
// Create an effect stack template
// Add the outline effect template to the effect stack template.
effectStackTemplate->addChild(outlineEffectTemplate);
// Add the shadow effect template to the effect stack template.
effectStackTemplate->addChild(shadowEffectTemplate);
// Create a prefab from the effect stack template.
NodeEffectPrefab2DSharedPtr effectStackPrefab =
NodeEffectPrefab2D::create(getDomain(), "Effect Stack prefab", effectStackTemplate);
// Assign the effect stack to a 2D node.
node->setEffectPrefab(effectStackPrefab);
// In the host node, set the shadow distance.
node->setProperty(ShadowEffect2D::DistanceProperty, 20.f);
See also
NodeEffectPrefab2D, NodeEffectTemplate2D
Since
Kanzi 3.9.0

Constructor & Destructor Documentation

kanzi::NodeEffect2D::~NodeEffect2D ( )
kanzi::NodeEffect2D::NodeEffect2D ( Domain domain,
string_view  name 
)
explicitprotected

Constructor.

Parameters
domainDomain to use.
nameResource name.

Member Function Documentation

bool kanzi::NodeEffect2D::getEnabled ( ) const
inline

Gets the value of EnabledProperty.

See also
setEnabled()
Since
Kanzi 3.9.8
void kanzi::NodeEffect2D::setEnabled ( bool  value)
inline

Sets the value of EnabledProperty.

See also
getEnabled()
Since
Kanzi 3.9.8
NodeEffectRenderer2DUniquePtr kanzi::NodeEffect2D::createRenderer ( )

Creates a renderer instance.

Only single renderer instance may exist.

See also
NodeEffect2D::createRendererOverride.
Returns
NodeEffectRenderer2D instance.
Vector4 kanzi::NodeEffect2D::getEffectQuadPadding ( ) const
inline

Gets the effect quad padding.

Returns
Effect quad padding as Vector4 where padding parameters are assigned as Vector4(left, right, top, bottom).
Vector2 kanzi::NodeEffect2D::getEffectQuadPaddingOffset ( ) const
inline

Gets the effect quad offset relative relative to the top-left corner of the node.

Returns
Effect quad offset as Vector2.
Vector2 kanzi::NodeEffect2D::getEffectQuadPaddingSize ( ) const
inline

Gets the effect quad padding size.

Effect quad padding size defines how much the node quad size increases because of the effect padding.

Returns
Effect quad padding size as Vector2.
unsigned int kanzi::NodeEffect2D::getEffectPaddingChangeCounter ( ) const
inline

Gets the effect quad padding change counter.

Kanzi updates the effect quad change count when the effect padding changes.

Returns
Effect padding change counter.
void kanzi::NodeEffect2D::setEffectPaddingChangeCounter ( unsigned int  value)
inline

Sets the effect quad padding change counter.

Parameters
valueEffect padding change counter value.
Since
Kanzi 3.9.8
bool kanzi::NodeEffect2D::isAlphaRequired ( ) const
inline

Indicates whether the effect requires alpha channel for the result.

Returns
If alpha channel is required true, otherwise false.
void kanzi::NodeEffect2D::unregisterEffectRenderer ( NodeEffectRenderer2D effectRenderer)
inline

Unregister effect renderer.

Effect renderer is automatically registered by NodeEffect2D::createRenderer() and unregistered by the NodeEffectRenderer2D destructor.

Parameters
effectRendererEffect renderer pointer to unregister.
bool kanzi::NodeEffect2D::isRenderingRequired ( )
inline

Indicates whether the effect requires rendering.

Some effect property values can eliminate the need to render the effect. Typically this reflects a situation where the effect has no visible impact.

Returns
If effect rendering is required true, otherwise false.
Since
Kanzi 3.9.5
NodeEffectRenderer2D* kanzi::NodeEffect2D::getRendererInstance ( ) const
inline

Gets a pointer to NodeEffectRenderer2D instance or null pointer if none exists.

Returns
If the NodeEffectRenderer2D instance exists, a pointer to it, otherwise null pointer.
BindingLookupContextPtr kanzi::NodeEffect2D::createLookupContext ( NodeEffect2DSharedPtr  templateRoot)

Creates a lookup context for a given effect.

Parameters
templateRootTemplate root for given effect.
Returns
The effect lookup context.
Since
Kanzi 3.9.8
NodeEffect2DSharedPtr kanzi::NodeEffect2D::getTemplateRoot ( ) const
inline

Gets the template root of this node effect.

Kanzi uses the template root internally in template root bindings.

Since
Kanzi 3.9.8
void kanzi::NodeEffect2D::setTemplateRoot ( NodeEffect2DSharedPtr  templateRoot)
inline

Sets the template root for this node effect.

Kanzi uses the template root internally in template root bindings.

Since
Kanzi 3.9.8
bool kanzi::NodeEffect2D::isAttached ( ) const

Returns whether a node effect is attached to a node.

Returns
If the node effect is attached, true, otherwise false.
Since
Kanzi 3.9.8
bool kanzi::NodeEffect2D::isAttaching ( ) const

Returns whether a node effect is attaching to a node.

Returns
If the node effect is attaching, true, otherwise false.
Since
Kanzi 3.9.8
bool kanzi::NodeEffect2D::isDetached ( ) const

Returns whether a node effect is detached from a node.

Returns
If the node effect is detached, true, otherwise false.
Since
Kanzi 3.9.8
bool kanzi::NodeEffect2D::isDetaching ( ) const

Returns whether a node effect is detaching from a node.

Returns
If the node effect is detaching, true, otherwise false.
Since
Kanzi 3.9.8
NodeEffect2D* kanzi::NodeEffect2D::getParent ( ) const
inline

Gets the parent of a node effect.

Returns
Pointer to parent node effect or, if the node effect does not have a parent, a nullptr.
Since
Kanzi 3.9.8
void kanzi::NodeEffect2D::setParent ( NodeEffect2D parent)
inline

Sets the parent of a node effect.

Parameters
parentThe parent node effect.
Since
Kanzi 3.9.8
ObjectSharedPtr kanzi::NodeEffect2D::lookupObject ( string_view  relativePath)

Lookup for an object from the effect.

The object can be another effect, a node, or a resource within a node.

Parameters
relativePathRelative path to use for lookup.
Returns
Shared pointer that references the object or, if no object is found, null pointer.
Since
Kanzi 3.9.8
template<typename T >
shared_ptr<T> kanzi::NodeEffect2D::lookupObject ( string_view  relativePath)
inline

Lookup a relative object of a given type.

If the object is found but it is not of the given type, the search fails.

Returns
Shared pointer that references the object. If no object is found or the object is not of the correct type, returns a null pointer.
Since
Kanzi 3.9.8
void kanzi::NodeEffect2D::attach ( Node node)

Attaches the node effect.

Parameters
nodeOptional pointer to the node that hosts the effect.
Since
Kanzi 3.9.8
void kanzi::NodeEffect2D::detach ( )

Detaches the node effect.

Since
Kanzi 3.9.8
Node* kanzi::NodeEffect2D::getHostNode ( ) const

Gets the node that hosts the effect.

Returns
The node that hosts the effect.
Since
Kanzi 3.9.8
virtual NodeEffectRenderer2DUniquePtr kanzi::NodeEffect2D::createRendererOverride ( )
protectedpure virtual

Creates a renderer instance.

Only single renderer instance may exist.

Returns
NodeEffectRenderer2D instance.

Implemented in kanzi::OutlineEffect2D, kanzi::MaskEffect2D, kanzi::ShadowEffect2D, kanzi::EffectStack2D, and kanzi::BlurEffect2D.

virtual void kanzi::NodeEffect2D::initializeRendererOverride ( )
protectedpure virtual

Initializes a previously created renderer instance.

Implemented in kanzi::OutlineEffect2D, kanzi::MaskEffect2D, kanzi::ShadowEffect2D, kanzi::EffectStack2D, and kanzi::BlurEffect2D.

virtual bool kanzi::NodeEffect2D::isRenderingRequiredOverride ( )
protectedvirtual

Implementation-dependent check on whether effect rendering is required.

The default implementation always returns true. Individual effects must override this function to turn themselves off.

Returns
If effect rendering is required true, otherwise false.
Since
Kanzi 3.9.5

Reimplemented in kanzi::OutlineEffect2D, kanzi::ShadowEffect2D, kanzi::EffectStack2D, and kanzi::BlurEffect2D.

void kanzi::NodeEffect2D::setEffectQuadPadding ( float  left,
float  right,
float  top,
float  bottom 
)
inlineprotected

Sets the padding required by the effect around the node bounds during the rendering of the effect.

Kanzi accounts for the effect quad padding when determining the visibility of the node.

void kanzi::NodeEffect2D::setAlphaRequired ( bool  required)
inlineprotected

Sets the framebuffer alpha channel requirements of the effect.

Parameters
requiredIf the effect rendering requires alpha channel and blending, true, otherwise false.
virtual void kanzi::NodeEffect2D::onAttached ( )
protectedvirtual

Called by Kanzi when effect is attached.

Since
Kanzi 3.9.8

Reimplemented in kanzi::EffectStack2D.

virtual void kanzi::NodeEffect2D::onDetached ( )
protectedvirtual

Called by Kanzi when effect is detached.

Since
Kanzi 3.9.8

Reimplemented in kanzi::EffectStack2D.

virtual ObjectSharedPtr kanzi::NodeEffect2D::lookupObjectOverride ( string_view  initialPart,
string_view  remainingPart 
)
protectedvirtual

Lookup for an object from the effect.

The object can be another effect, a node, or a resource within a node.

Parameters
initialPartThe leading part of the relative path before the first slash.
remainingPartThe trailing part of the relative part after the first slash.
Returns
Shared pointer that references the object or, if no object is found, null pointer.

Reimplemented in kanzi::EffectStack2D.

void kanzi::NodeEffect2D::onPropertyChanged ( AbstractPropertyType  propertyType,
PropertyNotificationReason  reason 
)
overrideprotectedvirtual

PropertyObject::onPropertyChanged implementation.

Reimplemented from kanzi::PropertyObject.

Member Data Documentation

PropertyType<bool> kanzi::NodeEffect2D::EnabledProperty
static

Sets whether the effect is enabled.

The default value is true.

See also
setEnabled(), getEnabled()
Since
Kanzi 3.9.8

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