Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
PropertyRef.h File Reference

Classes

struct  PropertyRef
 A picked "field of a component on an object". More...
struct  PropertyBinding
 A resolved PropertyRef: where the field lives and what it is. More...

Enumerations

enum class  DekiTransformField : uint8_t {
  None = 0 , X , Y , Position ,
  Rotation , ScaleX , ScaleY , Scale ,
  Active
}
 The object's own transform, addressable like a component. More...

Functions

const DekiFieldRefDekiVariableFieldRef (DekiPropertyType type)
 A field descriptor for a standalone value of type, at offset 0.
const DekiFieldRefDekiTransformFields (int &outCount)
 The transform's field table, for pickers and binding.
const char *const * DekiTransformFieldNames (int &outCount)
 Transform field names, index-aligned with DekiTransformFields.
bool BindPropertyRef (DekiObject *object, const PropertyRef &ref, PropertyBinding &out, const char **outError=nullptr)
 Resolve ref against object (already found by name by the caller).
bool ParsePropertyLiteral (const DekiFieldRef &info, const char *text, double &out, double &out2)
 Parse an authored literal per the bound field's type.
bool ParsePropertyLiteral (const DekiFieldRef &info, const char *text, double &out)
 Single-value overload for targets that are not Vector2-typed.
double ReadBoundProperty (const PropertyBinding &binding)
 Read the bound target's live value (first axis for Vector2).
double ReadBoundProperty2 (const PropertyBinding &binding)
 Read the bound target's second axis (Vector2 targets only, else 0).
void WriteBoundNumbers (const PropertyBinding &binding, double v, double v2)
 Write raw numbers to the bound target, bypassing the parsed literal.
void WriteBoundProperty (const PropertyBinding &binding, const std::string &text)
 Write the bound literal (or text for String fields) into the field.
int CompareBoundProperty (const PropertyBinding &binding, const std::string &text)
 Compare the field's live value against the bound literal.

Variables

constexpr const char * kTransformRefComponent = "Transform"
 The component name a reference stores to mean "the object's transform".
constexpr const char * kVariableRefComponent = "Variable"
 The component name a reference stores to mean "a variable of this graph".

Enumeration Type Documentation

◆ DekiTransformField

enum class DekiTransformField : uint8_t
strong

The object's own transform, addressable like a component.

The transform is not a component: it lives on DekiObject with private fields and setters that invalidate the cached world transform of the object and all its descendants. So a Transform-targeted reference is DISPATCHED by id rather than written through an offset, and every write goes through the real setter.

Position and Scale address both axes at once (a Vector2-typed target), which is what makes "move this object to (x, y)" a single generic action instead of two that would run one after the other.

Enumerator
None 
Position 
Rotation 
ScaleX 
ScaleY 
Scale 
Active 

Function Documentation

◆ DekiVariableFieldRef()

const DekiFieldRef * DekiVariableFieldRef ( DekiPropertyType type)

A field descriptor for a standalone value of type, at offset 0.

For runners binding their own storage (graph variables): point PropertyBinding::field at the value and its info at this, and every Read/Write/Compare helper below works on it unchanged. Returns nullptr for a type that has no literal form.

◆ DekiTransformFields()

const DekiFieldRef * DekiTransformFields ( int & outCount)

The transform's field table, for pickers and binding.

NOTE: in THIS table only, DekiFieldRef::offset carries a DekiTransformField id, not a byte offset (the fields are private and dispatched, see above). Nothing outside BindPropertyRef should read it as an offset.

◆ DekiTransformFieldNames()

const char *const * DekiTransformFieldNames ( int & outCount)

Transform field names, index-aligned with DekiTransformFields.

DekiFieldRef stores only a name hash (that is the point: 8 bytes per field), so the names live here for the editor's pickers and for error messages.

◆ BindPropertyRef()

bool BindPropertyRef ( DekiObject * object,
const PropertyRef & ref,
PropertyBinding & out,
const char ** outError = nullptr )

Resolve ref against object (already found by name by the caller).

Fills out.field / out.info. Returns false when the object carries no such component or the component has no such field; outError (optional, may be null) then receives a short human-readable reason for the caller to log. Does not touch out.number.

◆ ParsePropertyLiteral() [1/2]

bool ParsePropertyLiteral ( const DekiFieldRef & info,
const char * text,
double & out,
double & out2 )

Parse an authored literal per the bound field's type.

Numbers, bools ("true"/"1") and enums (stored as their index — the editor resolves value names, the device never needs the name table) land in out. Vector2-typed targets read "x, y" and fill out2 as well. String fields need no parsing and return true with both untouched. Returns false when the text is not a number for a numeric field.

◆ ParsePropertyLiteral() [2/2]

bool ParsePropertyLiteral ( const DekiFieldRef & info,
const char * text,
double & out )

Single-value overload for targets that are not Vector2-typed.

◆ ReadBoundProperty()

double ReadBoundProperty ( const PropertyBinding & binding)

Read the bound target's live value (first axis for Vector2).

◆ ReadBoundProperty2()

double ReadBoundProperty2 ( const PropertyBinding & binding)

Read the bound target's second axis (Vector2 targets only, else 0).

◆ WriteBoundNumbers()

void WriteBoundNumbers ( const PropertyBinding & binding,
double v,
double v2 )

Write raw numbers to the bound target, bypassing the parsed literal.

◆ WriteBoundProperty()

void WriteBoundProperty ( const PropertyBinding & binding,
const std::string & text )

Write the bound literal (or text for String fields) into the field.

◆ CompareBoundProperty()

int CompareBoundProperty ( const PropertyBinding & binding,
const std::string & text )

Compare the field's live value against the bound literal.

Returns
<0, 0 or >0 like strcmp. String fields compare against text.

Variable Documentation

◆ kTransformRefComponent

const char* kTransformRefComponent = "Transform"
inlineconstexpr

The component name a reference stores to mean "the object's transform".

◆ kVariableRefComponent

const char* kVariableRefComponent = "Variable"
inlineconstexpr

The component name a reference stores to mean "a variable of this graph".

Variables are declared by a node carrying DEKI_NODE_VARIABLES and live in storage the graph's RUNNER allocates per instance, so the engine cannot resolve them: BindPropertyRef leaves these alone and the runner binds them itself with DekiVariableFieldRef. Field = the variable's name.