Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-12-10 01:37:02 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-12-10 01:37:02 +0300
commit30fd13387dc5b9733a0402f1a58dbbddd162d918 (patch)
tree7366cc457a6dcdbd7362ca2a4d8f3510b5fcdbd4
parent80bd73639f57203b0383d9b313b4bd640f24f2ca (diff)
give IDPropertyGroups's an identifier so they can display text in the listview, hardcoded to "name"
-rw-r--r--source/blender/makesrna/intern/rna_ID.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c
index 3bcdf373c43..ed73ddef3f5 100644
--- a/source/blender/makesrna/intern/rna_ID.c
+++ b/source/blender/makesrna/intern/rna_ID.c
@@ -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)