Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_rna.c
| Show First 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| ListBaseIterator *internal = &iter->internal.listbase; | ListBaseIterator *internal = &iter->internal.listbase; | ||||
| /* we return either PropertyRNA* or IDProperty*, the rna_access.c | /* we return either PropertyRNA* or IDProperty*, the rna_access.c | ||||
| * functions can handle both as PropertyRNA* with some tricks */ | * functions can handle both as PropertyRNA* with some tricks */ | ||||
| return rna_pointer_inherit_refine(&iter->parent, &RNA_Function, internal->link); | return rna_pointer_inherit_refine(&iter->parent, &RNA_Function, internal->link); | ||||
| } | } | ||||
| static void rna_Struct_property_tags_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | |||||
| { | |||||
| /* here ptr->data should always be the same as iter->parent.type */ | |||||
| StructRNA *srna = (StructRNA *)ptr->data; | |||||
| const EnumPropertyItem *tag_defines = RNA_struct_property_tag_defines(srna); | |||||
| unsigned int tag_count = RNA_enum_items_count(tag_defines); | |||||
| rna_iterator_array_begin(iter, (void *)tag_defines, sizeof(EnumPropertyItem), tag_count, 0, NULL); | |||||
| } | |||||
| /* Builtin properties iterator re-uses the Struct properties iterator, only | /* Builtin properties iterator re-uses the Struct properties iterator, only | ||||
| * difference is that we need to set the ptr data to the type of the struct | * difference is that we need to set the ptr data to the type of the struct | ||||
| * whose properties we want to iterate over. */ | * whose properties we want to iterate over. */ | ||||
| void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | void rna_builtin_properties_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) | ||||
| { | { | ||||
| PointerRNA newptr; | PointerRNA newptr; | ||||
| ▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| static int rna_Property_is_library_editable_flag_get(PointerRNA *ptr) | static int rna_Property_is_library_editable_flag_get(PointerRNA *ptr) | ||||
| { | { | ||||
| PropertyRNA *prop = (PropertyRNA *)ptr->data; | PropertyRNA *prop = (PropertyRNA *)ptr->data; | ||||
| return (prop->flag & PROP_LIB_EXCEPTION) != 0; | return (prop->flag & PROP_LIB_EXCEPTION) != 0; | ||||
| } | } | ||||
| static int rna_Property_tags_get(PointerRNA *ptr) | |||||
| { | |||||
| return RNA_property_tags(ptr->data); | |||||
| } | |||||
| static const EnumPropertyItem *rna_Property_tags_itemf( | |||||
| bContext *UNUSED(C), PointerRNA *ptr, | |||||
| PropertyRNA *UNUSED(prop), bool *r_free) | |||||
| { | |||||
| PropertyRNA *this_prop = (PropertyRNA *)ptr->data; | |||||
| const StructRNA *srna = RNA_property_pointer_type(ptr, this_prop); | |||||
| EnumPropertyItem *prop_tags; | |||||
| EnumPropertyItem tmp = {0, "", 0, "", ""}; | |||||
| int totitem = 0; | |||||
| for (const EnumPropertyItem *struct_tags = RNA_struct_property_tag_defines(srna); | |||||
| struct_tags->identifier; | |||||
| struct_tags++) | |||||
| { | |||||
| memcpy(&tmp, struct_tags, sizeof(tmp)); | |||||
| RNA_enum_item_add(&prop_tags, &totitem, &tmp); | |||||
| } | |||||
| RNA_enum_item_end(&prop_tags, &totitem); | |||||
| *r_free = true; | |||||
| return prop_tags; | |||||
| } | |||||
| static int rna_Property_array_length_get(PointerRNA *ptr) | static int rna_Property_array_length_get(PointerRNA *ptr) | ||||
| { | { | ||||
| PropertyRNA *prop = (PropertyRNA *)ptr->data; | PropertyRNA *prop = (PropertyRNA *)ptr->data; | ||||
| rna_idproperty_check(&prop, ptr); | rna_idproperty_check(&prop, ptr); | ||||
| return prop->totarraylength; | return prop->totarraylength; | ||||
| } | } | ||||
| static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RNA_MAX_ARRAY_DIMENSION]) | static void rna_Property_array_dimensions_get(PointerRNA *ptr, int dimensions[RNA_MAX_ARRAY_DIMENSION]) | ||||
| ▲ Show 20 Lines • Show All 452 Lines • ▼ Show 20 Lines | static void rna_def_struct(BlenderRNA *brna) | ||||
| RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL); | RNA_def_property_string_funcs(prop, "rna_Struct_identifier_get", "rna_Struct_identifier_length", NULL); | ||||
| RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting"); | RNA_def_property_ui_text(prop, "Identifier", "Unique name used in the code and scripting"); | ||||
| RNA_def_struct_name_property(srna, prop); | RNA_def_struct_name_property(srna, prop); | ||||
| prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL); | RNA_def_property_string_funcs(prop, "rna_Struct_description_get", "rna_Struct_description_length", NULL); | ||||
| RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose"); | RNA_def_property_ui_text(prop, "Description", "Description of the Struct's purpose"); | ||||
| prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "translation_context", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_string_funcs(prop, "rna_Struct_translation_context_get", | RNA_def_property_string_funcs(prop, "rna_Struct_translation_context_get", | ||||
| "rna_Struct_translation_context_length", NULL); | "rna_Struct_translation_context_length", NULL); | ||||
| RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the struct's name"); | RNA_def_property_ui_text(prop, "Translation Context", "Translation context of the struct's name"); | ||||
| prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE); | prop = RNA_def_property(srna, "base", PROP_POINTER, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| Show All 24 Lines | static void rna_def_struct(BlenderRNA *brna) | ||||
| prop = RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE); | prop = RNA_def_property(srna, "functions", PROP_COLLECTION, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_struct_type(prop, "Function"); | RNA_def_property_struct_type(prop, "Function"); | ||||
| RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", | RNA_def_property_collection_funcs(prop, "rna_Struct_functions_begin", "rna_Struct_functions_next", | ||||
| "rna_iterator_listbase_end", "rna_Struct_functions_get", | "rna_iterator_listbase_end", "rna_Struct_functions_get", | ||||
| NULL, NULL, NULL, NULL); | NULL, NULL, NULL, NULL); | ||||
| RNA_def_property_ui_text(prop, "Functions", ""); | RNA_def_property_ui_text(prop, "Functions", ""); | ||||
| prop = RNA_def_property(srna, "property_tags", PROP_COLLECTION, PROP_NONE); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_struct_type(prop, "EnumPropertyItem"); | |||||
| RNA_def_property_collection_funcs(prop, "rna_Struct_property_tags_begin", "rna_iterator_array_next", | |||||
| "rna_iterator_array_end", "rna_iterator_array_get", | |||||
| NULL, NULL, NULL, NULL); | |||||
| RNA_def_property_ui_text(prop, "Property Tags", "Tags that properties can use to influence behavior"); | |||||
| } | } | ||||
| static void rna_def_property(BlenderRNA *brna) | static void rna_def_property(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| static const EnumPropertyItem subtype_items[] = { | static const EnumPropertyItem subtype_items[] = { | ||||
| {PROP_NONE, "NONE", 0, "None", ""}, | {PROP_NONE, "NONE", 0, "None", ""}, | ||||
| Show All 14 Lines | static const EnumPropertyItem subtype_items[] = { | ||||
| {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, | {PROP_QUATERNION, "QUATERNION", 0, "Quaternion", ""}, | ||||
| {PROP_XYZ, "XYZ", 0, "XYZ", ""}, | {PROP_XYZ, "XYZ", 0, "XYZ", ""}, | ||||
| {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Gamma Corrected Color", ""}, | {PROP_COLOR_GAMMA, "COLOR_GAMMA", 0, "Gamma Corrected Color", ""}, | ||||
| {PROP_COORDS, "COORDINATES", 0, "Vector Coordinates", ""}, | {PROP_COORDS, "COORDINATES", 0, "Vector Coordinates", ""}, | ||||
| {PROP_LAYER, "LAYER", 0, "Layer", ""}, | {PROP_LAYER, "LAYER", 0, "Layer", ""}, | ||||
| {PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""}, | {PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| EnumPropertyItem dummy_prop_tags[] = { | |||||
| {0, NULL, 0, NULL, NULL} | |||||
| }; | |||||
| srna = RNA_def_struct(brna, "Property", NULL); | srna = RNA_def_struct(brna, "Property", NULL); | ||||
| RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition"); | RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition"); | ||||
| RNA_def_struct_refine_func(srna, "rna_Property_refine"); | RNA_def_struct_refine_func(srna, "rna_Property_refine"); | ||||
| RNA_def_struct_ui_icon(srna, ICON_RNA); | RNA_def_struct_ui_icon(srna, ICON_RNA); | ||||
| prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | static void rna_def_property(BlenderRNA *brna) | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_boolean_funcs(prop, "rna_Property_is_enum_flag_get", NULL); | RNA_def_property_boolean_funcs(prop, "rna_Property_is_enum_flag_get", NULL); | ||||
| RNA_def_property_ui_text(prop, "Enum Flag", "True when multiple enums "); | RNA_def_property_ui_text(prop, "Enum Flag", "True when multiple enums "); | ||||
| prop = RNA_def_property(srna, "is_library_editable", PROP_BOOLEAN, PROP_NONE); | prop = RNA_def_property(srna, "is_library_editable", PROP_BOOLEAN, PROP_NONE); | ||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | RNA_def_property_clear_flag(prop, PROP_EDITABLE); | ||||
| RNA_def_property_boolean_funcs(prop, "rna_Property_is_library_editable_flag_get", NULL); | RNA_def_property_boolean_funcs(prop, "rna_Property_is_library_editable_flag_get", NULL); | ||||
| RNA_def_property_ui_text(prop, "Library Editable", "Property is editable from linked instances (changes not saved)"); | RNA_def_property_ui_text(prop, "Library Editable", "Property is editable from linked instances (changes not saved)"); | ||||
| prop = RNA_def_property(srna, "tags", PROP_ENUM, PROP_NONE); | |||||
| RNA_def_property_clear_flag(prop, PROP_EDITABLE); | |||||
| RNA_def_property_enum_items(prop, dummy_prop_tags); | |||||
| RNA_def_property_enum_funcs(prop, "rna_Property_tags_get", NULL, "rna_Property_tags_itemf"); | |||||
| RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); | |||||
| RNA_def_property_ui_text(prop, "Tags", "Subset of tags (defined in parent struct) that are set for this property"); | |||||
| } | } | ||||
| static void rna_def_function(BlenderRNA *brna) | static void rna_def_function(BlenderRNA *brna) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| srna = RNA_def_struct(brna, "Function", NULL); | srna = RNA_def_struct(brna, "Function", NULL); | ||||
| ▲ Show 20 Lines • Show All 323 Lines • Show Last 20 Lines | |||||