Browse Source

Data bindings: Allow binding customized DataVariables, see #145.

Michael Ragazzon 5 years ago
parent
commit
5add300271
2 changed files with 17 additions and 0 deletions
  1. 6 0
      Include/RmlUi/Core/DataModelHandle.h
  2. 11 0
      Include/RmlUi/Core/DataVariable.h

+ 6 - 0
Include/RmlUi/Core/DataModelHandle.h

@@ -87,6 +87,12 @@ public:
 		});
 	}
 
+	// Bind a user-declared DataVariable.
+	// For advanced use cases, for example for binding variables to a custom 'VariableDefinition'.
+	bool BindCustomDataVariable(const String& name, DataVariable data_variable) {
+		return BindVariable(name, data_variable);
+	}
+
 	// Register a struct type.
 	// @note The type applies to every data model associated with the current Context.
 	// @return A handle which can be used to register struct members.

+ 11 - 0
Include/RmlUi/Core/DataVariable.h

@@ -41,6 +41,12 @@ namespace Rml {
 enum class DataVariableType { Scalar, Array, Struct, Function, MemberFunction };
 
 
+/*
+*   A 'DataVariable' wraps a user handle (pointer) and a VariableDefinition.
+*
+*   Together they can be used to get and set variables between the user side and data model side.
+*/
+
 class RMLUICORE_API DataVariable {
 public:
 	DataVariable() {}
@@ -60,6 +66,11 @@ private:
 };
 
 
+/*
+*   A 'VariableDefinition' specifies how a user handle (pointer) is translated to and from a value in the data model.
+* 
+*   Generally, Scalar types can set and get values, while Array and Struct types can retrieve children based on data addresses.
+*/
 
 class RMLUICORE_API VariableDefinition {
 public: