RNA: add fallback update function
Use so we can have a default update function, that doesn't need to be set for every property.
This commit is contained in:
@@ -48,6 +48,7 @@ void RNA_define_free(BlenderRNA *brna);
|
||||
void RNA_free(BlenderRNA *brna);
|
||||
void RNA_define_verify_sdna(bool verify);
|
||||
void RNA_define_animate_sdna(bool animate);
|
||||
void RNA_define_fallback_property_update(int noteflag, const char *updatefunc);
|
||||
|
||||
void RNA_init(void);
|
||||
void RNA_exit(void);
|
||||
|
||||
@@ -709,6 +709,14 @@ void RNA_define_animate_sdna(bool animate)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef RNA_RUNTIME
|
||||
void RNA_define_fallback_property_update(int noteflag, const char *updatefunc)
|
||||
{
|
||||
DefRNA.fallback.property_update.noteflag = noteflag;
|
||||
DefRNA.fallback.property_update.updatefunc = updatefunc;
|
||||
}
|
||||
#endif
|
||||
|
||||
void RNA_struct_free_extension(StructRNA *srna, ExtensionRNA *ext)
|
||||
{
|
||||
#ifdef RNA_RUNTIME
|
||||
@@ -1413,6 +1421,12 @@ PropertyRNA *RNA_def_property(StructOrFunctionRNA *cont_,
|
||||
}
|
||||
/* TODO: do we want that for runtime-defined stuff too? I’d say no, but... maybe yes :/ */
|
||||
|
||||
#ifndef RNA_RUNTIME
|
||||
/* Both are typically cleared. */
|
||||
RNA_def_property_update(
|
||||
prop, DefRNA.fallback.property_update.noteflag, DefRNA.fallback.property_update.updatefunc);
|
||||
#endif
|
||||
|
||||
rna_addtail(&cont->properties, prop);
|
||||
|
||||
return prop;
|
||||
|
||||
@@ -116,6 +116,16 @@ typedef struct BlenderDefRNA {
|
||||
ListBase allocs;
|
||||
struct StructRNA *laststruct;
|
||||
int error, silent, preprocess, verify, animate;
|
||||
/* Keep last. */
|
||||
#ifndef RNA_RUNTIME
|
||||
struct {
|
||||
/** #RNA_def_property_update */
|
||||
struct {
|
||||
int noteflag;
|
||||
const char *updatefunc;
|
||||
} property_update;
|
||||
} fallback;
|
||||
#endif
|
||||
} BlenderDefRNA;
|
||||
|
||||
extern BlenderDefRNA DefRNA;
|
||||
|
||||
Reference in New Issue
Block a user