Changeset View
Changeset View
Standalone View
Standalone View
source/blender/makesrna/intern/rna_main_api.c
| Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | switch (GS(data->name)) { | ||||
| type = OB_SPEAKER; | type = OB_SPEAKER; | ||||
| break; | break; | ||||
| case ID_CA: | case ID_CA: | ||||
| type = OB_CAMERA; | type = OB_CAMERA; | ||||
| break; | break; | ||||
| case ID_LT: | case ID_LT: | ||||
| type = OB_LATTICE; | type = OB_LATTICE; | ||||
| break; | break; | ||||
| case ID_GD: | |||||
| type = OB_GPENCIL; | |||||
| break; | |||||
| case ID_AR: | case ID_AR: | ||||
| type = OB_ARMATURE; | type = OB_ARMATURE; | ||||
| break; | break; | ||||
| default: | default: | ||||
| { | { | ||||
| const char *idname; | const char *idname; | ||||
| if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) | if (RNA_enum_id_from_value(rna_enum_id_type_items, GS(data->name), &idname) == 0) | ||||
| idname = "UNKNOWN"; | idname = "UNKNOWN"; | ||||
| Show All 19 Lines | static Material *rna_Main_materials_new(Main *bmain, const char *name) | ||||
| char safe_name[MAX_ID_NAME - 2]; | char safe_name[MAX_ID_NAME - 2]; | ||||
| rna_idname_validate(name, safe_name); | rna_idname_validate(name, safe_name); | ||||
| ID *id = (ID *)BKE_material_add(bmain, safe_name); | ID *id = (ID *)BKE_material_add(bmain, safe_name); | ||||
| id_us_min(id); | id_us_min(id); | ||||
| return (Material *)id; | return (Material *)id; | ||||
| } | } | ||||
| static void rna_Main_materials_gpencil_data(Main *UNUSED(bmain), struct PointerRNA *ma) | |||||
| { | |||||
| BKE_material_init_gpencil_settings((Material *)ma); | |||||
| } | |||||
| static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) | static const EnumPropertyItem *rna_Main_nodetree_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) | ||||
| { | { | ||||
| return rna_node_tree_type_itemf(NULL, NULL, r_free); | return rna_node_tree_type_itemf(NULL, NULL, r_free); | ||||
| } | } | ||||
| static struct bNodeTree *rna_Main_nodetree_new(Main *bmain, const char *name, int type) | static struct bNodeTree *rna_Main_nodetree_new(Main *bmain, const char *name, int type) | ||||
| { | { | ||||
| char safe_name[MAX_ID_NAME - 2]; | char safe_name[MAX_ID_NAME - 2]; | ||||
| rna_idname_validate(name, safe_name); | rna_idname_validate(name, safe_name); | ||||
| ▲ Show 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | void RNA_def_main_materials(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| func = RNA_def_function(srna, "new", "rna_Main_materials_new"); | func = RNA_def_function(srna, "new", "rna_Main_materials_new"); | ||||
| RNA_def_function_ui_description(func, "Add a new material to the main database"); | RNA_def_function_ui_description(func, "Add a new material to the main database"); | ||||
| parm = RNA_def_string(func, "name", "Material", 0, "", "New name for the data-block"); | parm = RNA_def_string(func, "name", "Material", 0, "", "New name for the data-block"); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| /* return type */ | /* return type */ | ||||
| parm = RNA_def_pointer(func, "material", "Material", "", "New material data-block"); | parm = RNA_def_pointer(func, "material", "Material", "", "New material data-block"); | ||||
| RNA_def_function_return(func, parm); | RNA_def_function_return(func, parm); | ||||
| func = RNA_def_function(srna, "create_gpencil_data", "rna_Main_materials_gpencil_data"); | |||||
| RNA_def_function_ui_description(func, "Add grease pencil material settings"); | |||||
| parm = RNA_def_pointer(func, "material", "Material", "", "Material"); | |||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | |||||
| func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); | func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); | ||||
| RNA_def_function_flag(func, FUNC_USE_REPORTS); | RNA_def_function_flag(func, FUNC_USE_REPORTS); | ||||
| RNA_def_function_ui_description(func, "Remove a material from the current blendfile"); | RNA_def_function_ui_description(func, "Remove a material from the current blendfile"); | ||||
| parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove"); | parm = RNA_def_pointer(func, "material", "Material", "", "Material to remove"); | ||||
| RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); | ||||
| RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); | ||||
| RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this material before deleting it"); | RNA_def_boolean(func, "do_unlink", true, "", "Unlink all usages of this material before deleting it"); | ||||
| RNA_def_boolean(func, "do_id_user", true, "", | RNA_def_boolean(func, "do_id_user", true, "", | ||||
| "Decrement user counter of all datablocks used by this material"); | "Decrement user counter of all datablocks used by this material"); | ||||
| RNA_def_boolean(func, "do_ui_user", true, "", | RNA_def_boolean(func, "do_ui_user", true, "", | ||||
| "Make sure interface does not reference this material"); | "Make sure interface does not reference this material"); | ||||
| func = RNA_def_function(srna, "tag", "rna_Main_materials_tag"); | func = RNA_def_function(srna, "tag", "rna_Main_materials_tag"); | ||||
| parm = RNA_def_boolean(func, "value", 0, "Value", ""); | parm = RNA_def_boolean(func, "value", 0, "Value", ""); | ||||
| RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); | ||||
| } | } | ||||
| void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) | void RNA_def_main_node_groups(BlenderRNA *brna, PropertyRNA *cprop) | ||||
| { | { | ||||
| StructRNA *srna; | StructRNA *srna; | ||||
| FunctionRNA *func; | FunctionRNA *func; | ||||
campbellbarton: Dont do this, better remove the function and make it possible to use any material - since we… | |||||
| PropertyRNA *parm; | PropertyRNA *parm; | ||||
| static const EnumPropertyItem dummy_items[] = { | static const EnumPropertyItem dummy_items[] = { | ||||
| {0, "DUMMY", 0, "", ""}, | {0, "DUMMY", 0, "", ""}, | ||||
| {0, NULL, 0, NULL, NULL} | {0, NULL, 0, NULL, NULL} | ||||
| }; | }; | ||||
| RNA_def_property_srna(cprop, "BlendDataNodeTrees"); | RNA_def_property_srna(cprop, "BlendDataNodeTrees"); | ||||
| ▲ Show 20 Lines • Show All 1,022 Lines • Show Last 20 Lines | |||||
Dont do this, better remove the function and make it possible to use any material - since we will likely want this anyway.
We can have BKE_material_init_gpencil_settings be accessed as:
material.create_gpencil_data() RNA method.