give IDPropertyGroups's an identifier so they can display text in the listview, hardcoded to "name"
This commit is contained in:
@@ -225,6 +225,40 @@ ID *rna_ID_copy(ID *id)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int rna_IDPropertyGroup_name_length(PointerRNA *ptr)
|
||||
{
|
||||
IDProperty *group=(IDProperty*)ptr->id.data;
|
||||
IDProperty *idprop;
|
||||
idprop= IDP_GetPropertyFromGroup(group, "name");
|
||||
|
||||
if(idprop && idprop->type == IDP_STRING)
|
||||
return strlen(idprop->data.pointer);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rna_IDPropertyGroup_name_get(PointerRNA *ptr, char *str)
|
||||
{
|
||||
IDProperty *group=(IDProperty*)ptr->id.data;
|
||||
IDProperty *idprop;
|
||||
idprop= IDP_GetPropertyFromGroup(group, "name");
|
||||
|
||||
if(idprop && idprop->type == IDP_STRING)
|
||||
strcpy(str, idprop->data.pointer);
|
||||
else
|
||||
strcpy(str, "");
|
||||
}
|
||||
|
||||
void rna_IDPropertyGroup_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
IDProperty *group=(IDProperty*)ptr->id.data;
|
||||
IDProperty *idprop;
|
||||
IDPropertyTemplate val = {0};
|
||||
val.str= (char *)value;
|
||||
idprop = IDP_New(IDP_STRING, val, "name");
|
||||
IDP_ReplaceInGroup(group, idprop);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void rna_def_ID_properties(BlenderRNA *brna)
|
||||
@@ -275,6 +309,15 @@ static void rna_def_ID_properties(BlenderRNA *brna)
|
||||
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
|
||||
RNA_def_property_struct_type(prop, "IDPropertyGroup");
|
||||
|
||||
// never tested, maybe its useful to have this?
|
||||
#if 0
|
||||
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
|
||||
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting.");
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
#endif
|
||||
|
||||
/* IDP_ID -- not implemented yet in id properties */
|
||||
|
||||
/* ID property groups > level 0, since level 0 group is merged
|
||||
@@ -285,6 +328,16 @@ static void rna_def_ID_properties(BlenderRNA *brna)
|
||||
RNA_def_struct_idproperties_func(srna, "rna_IDPropertyGroup_idproperties");
|
||||
RNA_def_struct_register_funcs(srna, "rna_IDPropertyGroup_register", "rna_IDPropertyGroup_unregister");
|
||||
RNA_def_struct_refine_func(srna, "rna_IDPropertyGroup_refine");
|
||||
|
||||
/* important so python types can have their name used in list views
|
||||
* however this isnt prefect because it overrides how python would set the name
|
||||
* when we only really want this so RNA_def_struct_name_property() is set to something useful */
|
||||
prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_flag(prop, PROP_EXPORT|PROP_IDPROPERTY);
|
||||
//RNA_def_property_clear_flag(prop, PROP_EDITABLE);
|
||||
RNA_def_property_ui_text(prop, "Name", "Unique name used in the code and scripting.");
|
||||
RNA_def_property_string_funcs(prop, "rna_IDPropertyGroup_name_get", "rna_IDPropertyGroup_name_length", "rna_IDPropertyGroup_name_set");
|
||||
RNA_def_struct_name_property(srna, prop);
|
||||
}
|
||||
|
||||
static void rna_def_ID(BlenderRNA *brna)
|
||||
|
||||
Reference in New Issue
Block a user