ExpressionBinding enables you to bind from multiple sources to one target, and to modify the values before writing them to target values. More...
#include <kanzi/core.ui/binding/expression_binding.hpp>
Protected Member Functions | |
AbstractBindingRuntimeSharedPtr | createRuntimeOverride (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr bindingTarget) override |
AbstractBinding::createRuntime() implementation. More... | |
ExpressionBinding (BindingSourcePtr source) | |
Constructor. More... | |
Protected Member Functions inherited from kanzi::AbstractBinding | |
AbstractBinding (BindingSourcePtr source) | |
Constructor. More... | |
virtual void | addReverseProcessorOverride (BindingProcessorSharedPtr processor) |
Implementation-dependent binding processor add (reverse direction). More... | |
virtual BindingProcessorConstIterator | beginReverseProcessorsOverride () const |
Implementation-dependent access to reverse direction binding processors. More... | |
virtual BindingProcessorConstIterator | endReverseProcessorsOverride () const |
Implementation-dependent access to reverse direction binding processors. More... | |
virtual void | removeReverseProcessorOverride (BindingProcessor &processor) |
Implementation-dependent binding processor remove (reverse direction). More... | |
Additional Inherited Members | |
Public Types inherited from kanzi::AbstractBinding | |
using | BindingProcessorConstIterator = BindingProcessorContainer::const_iterator |
Binding processor iterator type. More... | |
using | BindingProcessorContainer = vector< BindingProcessorSharedPtr > |
Binding processor container type. More... | |
Public Member Functions inherited from kanzi::AbstractBinding | |
void | addProcessor (BindingProcessorSharedPtr processor) |
Add a binding processor. More... | |
void | addReverseProcessor (BindingProcessorSharedPtr processor) |
Add a binding processor (reverse direction). More... | |
BindingProcessorConstIterator | beginProcessors () const |
Gets an iterator to the beginning of binding processors. More... | |
BindingProcessorConstIterator | beginReverseProcessors () const |
Gets an iterator to the beginning of reverse direction binding processors. More... | |
AbstractBindingRuntimeSharedPtr | createRuntime (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr targetRuntime) |
Creates a binding runtime for this binding. More... | |
BindingProcessorConstIterator | endProcessors () const |
Gets an iterator to the end of binding processors. More... | |
BindingProcessorConstIterator | endReverseProcessors () const |
Gets an iterator to the end of reverse direction binding processors. More... | |
BindingSource * | getSource () |
Gets the binding source for this binding. More... | |
bool | isCreatedFromKZB () const |
Indicates whether the binding is sourced from a KZB? Used to check whether or not to remove the binding during patching. More... | |
void | removeProcessor (BindingProcessor &processor) |
Remove a binding processor. More... | |
void | removeReverseProcessor (BindingProcessor &processor) |
Remove a binding processor (reverse direction). More... | |
void | setCreatedFromKZB (bool flag) |
Sets the created from KZB flag. More... | |
virtual | ~AbstractBinding ()=default |
Destructor. More... | |
Protected Attributes inherited from kanzi::AbstractBinding | |
bool | m_createdFromKZB |
Is the binding sourced from a KZB? This field is used to determine if the binding should be removed during patching. More... | |
BindingProcessorContainer | m_processors |
Binding processor (forward direction). More... | |
BindingSourcePtr | m_source |
Binding source. More... | |
ExpressionBinding enables you to bind from multiple sources to one target, and to modify the values before writing them to target values.
Regular bindings declare a relation from source value to a target value. For example, you bind a property value in a Node or RenderPass to a data source value. You can use expression bindings to:
ExpressionBinding provides a way to read data from multiple sources and execute mathematical operations on these values before writing the target value. You can define simple mathematical operations in Kanzi Studio, without writing any program code. The operations and code that is executed do not compose a proper programming language with conditions or flow control.
You do not usually need to create expression bindings manually, because expression bindings are usually read from kzb data.
To create a simple one-to-one binding using an expression binding:
To use an expression binding to its full extent and use operations:
Kanzi executes the expression operation codes in order. The result is written to the first temporary register, which is why the count of temporary registers must be at least 1. Array of constant registers can be empty.
Binding operations do not do automatic conversions between data types, but if necessary, the result value is converted before writing. To explicitly convert within the binding code, use operations such as KZU_EXPRESSION_VALIDATOR_OPERATION_TO_STRING.
For details about the expressions, see everything contained in expression_binding_processor.hpp and especially the operation enumeration types BindingExpressionArgumentType and KzuExpressionValidatorOperation.
In more complex cases, if you cannot conveniently do the transformation using mathematical expressions, you can use an animation curve to transform the values. It is recommended to use Kanzi Studio or a third-party tool to create the animation, but you can define animations also in the Kanzi Engine code.
To create an animation binding:
Before executing animations, Kanzi converts to milliseconds the input values used to drive the animation. For example, Kanzi converts the floating-point value 1.0f to 1000 milliseconds and the integer 5 to 5000 milliseconds.
|
inlineexplicitprotected |
Constructor.
source | Binding source to be used. |
|
static |
Creates an expression binding.
You can use this binding only with explicitly created target runtime, because this function does not set the target.
source | Binding source. |
|
static |
Creates an expression binding.
Creates one WRITE instruction from source to target.
objectPath | Path to source object. |
sourcePropertyType | Source property type from which to bind. |
sourceField | Field of the source property type from which to bind. Use PropertyFieldWhole for the whole property. |
|
static |
Creates an expression binding.
operations | Binding operations. |
operationProcessors | Operation processors. |
valueSources | Binding expression value sources for the expression binding source. |
dataSources | Binding expression data sources for the expression binding source. |
constantRegisters | Constant registers. |
temporaryCount | Number of temporary registers. |
|
inlinestatic |
Creates an expression binding.
No animation binding processors are specified.
operations | Binding operations. |
valueSources | Binding expression value sources for the expression binding source. |
dataSources | Binding expression data sources for the expression binding source. |
constantRegisters | Constant registers. |
temporaryCount | Number of temporary registers. |
|
inlinestatic |
Creates an expression binding.
No animation binding processors or data sources are specified.
operations | Binding operations. |
valueSources | Binding expression value sources for the expression binding source. |
constantRegisters | Constant registers. |
temporaryCount | Number of temporary registers. |
|
overrideprotectedvirtual |
AbstractBinding::createRuntime() implementation.
Implements kanzi::AbstractBinding.