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>
Additional Inherited Members | |
Public Types inherited from kanzi::AbstractBinding | |
using | BindingProcessorConstIterator |
Binding processor iterator type. | |
using | BindingProcessorContainer |
Binding processor container type. | |
Public Member Functions inherited from kanzi::AbstractBinding | |
void | addProcessor (BindingProcessorSharedPtr processor) |
Add a binding processor. | |
void | addReverseProcessor (BindingProcessorSharedPtr processor) |
Add a binding processor (reverse direction). | |
BindingProcessorConstIterator | beginProcessors () const |
Gets an iterator to the beginning of binding processors. | |
BindingProcessorConstIterator | beginReverseProcessors () const |
Gets an iterator to the beginning of reverse direction binding processors. | |
AbstractBindingRuntimeSharedPtr | createRuntime (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr targetRuntime) |
Creates a binding runtime for this binding. | |
BindingProcessorConstIterator | endProcessors () const |
Gets an iterator to the end of binding processors. | |
BindingProcessorConstIterator | endReverseProcessors () const |
Gets an iterator to the end of reverse direction binding processors. | |
BindingSource * | getSource () |
Gets the binding source for this binding. | |
bool | isCreatedFromKZB () const |
Indicates whether the binding is sourced from a KZB? Used to check whether or not to remove the binding during patching. | |
void | removeProcessor (BindingProcessor &processor) |
Remove a binding processor. | |
void | removeReverseProcessor (BindingProcessor &processor) |
Remove a binding processor (reverse direction). | |
void | setCreatedFromKZB (bool flag) |
Sets the created from KZB flag. | |
virtual | ~AbstractBinding ()=default |
Destructor. | |
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. | |
BindingProcessorContainer | m_processors |
Binding processor (forward direction). | |
BindingSourcePtr | m_source |
Binding source. | |
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.