RNA:
* Test with constructing RNA paths from pointer + property, based on a callback per struct. For animato we'll need to be able to do this, for keyframing from buttons, unless we can somehow derive the paths from the interface code, which seems like an unnecessary burden. However constructing such paths is not always quick, and we need a fast way to find out if a property is animated for drawing buttons, so this may not be the best solution. See rna_mesh.c for some callbacks created as a test. * Added BLI_sprintfN to mallocN a new string using printf style formatting.
This commit is contained in:
@@ -318,7 +318,7 @@ PropertyRNA *RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
|
||||
prop= NULL;
|
||||
|
||||
for(; iter.valid; RNA_property_collection_next(&iter), i++) {
|
||||
if(strcmp(identifier, RNA_property_identifier(&iter.ptr, iter.ptr.data)) == 0) {
|
||||
if(strcmp(identifier, RNA_property_identifier(ptr, iter.ptr.data)) == 0) {
|
||||
prop= iter.ptr.data;
|
||||
break;
|
||||
}
|
||||
@@ -1462,7 +1462,7 @@ int RNA_path_resolve(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, Prope
|
||||
prop= NULL;
|
||||
|
||||
for(; iter.valid; RNA_property_collection_next(&iter)) {
|
||||
if(strcmp(token, RNA_property_identifier(&iter.ptr, iter.ptr.data)) == 0) {
|
||||
if(strcmp(token, RNA_property_identifier(&curptr, iter.ptr.data)) == 0) {
|
||||
prop= iter.ptr.data;
|
||||
break;
|
||||
}
|
||||
@@ -1622,6 +1622,33 @@ char *RNA_path_back(const char *path)
|
||||
return result;
|
||||
}
|
||||
|
||||
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop)
|
||||
{
|
||||
char *ptrpath=NULL, *path;
|
||||
const char *propname;
|
||||
|
||||
if(!ptr->id.data || !ptr->data || !prop)
|
||||
return NULL;
|
||||
|
||||
if(!RNA_struct_is_ID(ptr)) {
|
||||
if(ptr->type->path)
|
||||
ptrpath= ptr->type->path(ptr);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
propname= RNA_property_identifier(ptr, prop);
|
||||
|
||||
if(ptrpath) {
|
||||
path= BLI_sprintfN("%s.%s", ptrpath, propname);
|
||||
MEM_freeN(ptrpath);
|
||||
}
|
||||
else
|
||||
path= BLI_strdup(propname);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
/* Quick name based property access */
|
||||
|
||||
int RNA_boolean_get(PointerRNA *ptr, const char *name)
|
||||
|
||||
Reference in New Issue
Block a user