diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-14 23:19:43 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-10-14 23:19:43 +0400 |
commit | 991e67ddc756cdbf6e85b9a0520792d1f48026e4 (patch) | |
tree | ca930274523e3355cfda68939b45525c1bed93d0 | |
parent | 96d2dc7d090975687e5b99495fcc1e5725e75120 (diff) |
RNA:
* Enums with an _itemf callback now never get context NULL passed in,
rather a fixed list of enum items are defined which should contain
all items (if possible), from which the _itemf callback can then use
a subset.
19 files changed, 132 insertions, 311 deletions
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c index d6f93757505..f67c94eebc3 100644 --- a/source/blender/editors/armature/poselib.c +++ b/source/blender/editors/armature/poselib.c @@ -432,9 +432,6 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *ptr, int totitem= 0; int i= 0; - if (C == NULL) - return NULL; - memset(&item_tmp, 0, sizeof(item_tmp)); /* check that the action exists */ @@ -448,12 +445,10 @@ static EnumPropertyItem *poselib_stored_pose_itemf(bContext *C, PointerRNA *ptr, } } - if (i > 0) { - *free= 1; - return item; - } - else - return NULL; + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; } static int poselib_remove_exec (bContext *C, wmOperator *op) diff --git a/source/blender/editors/mesh/editmesh_mods.c b/source/blender/editors/mesh/editmesh_mods.c index 288af7f7874..74870778d02 100644 --- a/source/blender/editors/mesh/editmesh_mods.c +++ b/source/blender/editors/mesh/editmesh_mods.c @@ -658,7 +658,25 @@ static int unified_findnearest(ViewContext *vc, EditVert **eve, EditEdge **eed, /* selects new faces/edges/verts based on the existing selection */ -/* FACES GROUP */ +/* VERT GROUP */ + +#define SIMVERT_NORMAL 0 +#define SIMVERT_FACE 1 +#define SIMVERT_VGROUP 2 +#define SIMVERT_TOT 3 + +/* EDGE GROUP */ + +#define SIMEDGE_LENGTH 101 +#define SIMEDGE_DIR 102 +#define SIMEDGE_FACE 103 +#define SIMEDGE_FACE_ANGLE 104 +#define SIMEDGE_CREASE 105 +#define SIMEDGE_SEAM 106 +#define SIMEDGE_SHARP 107 +#define SIMEDGE_TOT 108 + +/* FACE GROUP */ #define SIMFACE_MATERIAL 201 #define SIMFACE_IMAGE 202 @@ -666,8 +684,19 @@ static int unified_findnearest(ViewContext *vc, EditVert **eve, EditEdge **eed, #define SIMFACE_PERIMETER 204 #define SIMFACE_NORMAL 205 #define SIMFACE_COPLANAR 206 +#define SIMFACE_TOT 207 -static EnumPropertyItem prop_simface_types[] = { +static EnumPropertyItem prop_similar_types[] = { + {SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""}, + {SIMVERT_FACE, "FACE", 0, "Amount of Vertices in Face", ""}, + {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, + {SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""}, + {SIMEDGE_DIR, "DIR", 0, "Direction", ""}, + {SIMEDGE_FACE, "FACE", 0, "Amount of Vertices in Face", ""}, + {SIMEDGE_FACE_ANGLE, "FACE_ANGLE", 0, "Face Angles", ""}, + {SIMEDGE_CREASE, "CREASE", 0, "Crease", ""}, + {SIMEDGE_SEAM, "SEAM", 0, "Seam", ""}, + {SIMEDGE_SHARP, "SHARP", 0, "Sharpness", ""}, {SIMFACE_MATERIAL, "MATERIAL", 0, "Material", ""}, {SIMFACE_IMAGE, "IMAGE", 0, "Image", ""}, {SIMFACE_AREA, "AREA", 0, "Area", ""}, @@ -831,27 +860,6 @@ static int similar_face_select_exec(bContext *C, wmOperator *op) /* ***************************************************** */ -/* EDGE GROUP */ - -#define SIMEDGE_LENGTH 101 -#define SIMEDGE_DIR 102 -#define SIMEDGE_FACE 103 -#define SIMEDGE_FACE_ANGLE 104 -#define SIMEDGE_CREASE 105 -#define SIMEDGE_SEAM 106 -#define SIMEDGE_SHARP 107 - -static EnumPropertyItem prop_simedge_types[] = { - {SIMEDGE_LENGTH, "LENGTH", 0, "Length", ""}, - {SIMEDGE_DIR, "DIR", 0, "Direction", ""}, - {SIMEDGE_FACE, "FACE", 0, "Amount of Vertices in Face", ""}, - {SIMEDGE_FACE_ANGLE, "FACE_ANGLE", 0, "Face Angles", ""}, - {SIMEDGE_CREASE, "CREASE", 0, "Crease", ""}, - {SIMEDGE_SEAM, "SEAM", 0, "Seam", ""}, - {SIMEDGE_SHARP, "SHARP", 0, "Sharpness", ""}, - {0, NULL, 0, NULL, NULL} -}; - static int similar_edge_select__internal(ToolSettings *ts, EditMesh *em, int mode) { EditEdge *eed, *base_eed=NULL; @@ -1073,25 +1081,6 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op) /* ********************************* */ -/* -VERT GROUP - mode 1: same normal - mode 2: same number of face users - mode 3: same vertex groups -*/ - -#define SIMVERT_NORMAL 0 -#define SIMVERT_FACE 1 -#define SIMVERT_VGROUP 2 - -static EnumPropertyItem prop_simvertex_types[] = { - {SIMVERT_NORMAL, "NORMAL", 0, "Normal", ""}, - {SIMVERT_FACE, "FACE", 0, "Amount of Vertices in Face", ""}, - {SIMVERT_VGROUP, "VGROUP", 0, "Vertex Groups", ""}, - {0, NULL, 0, NULL, NULL} -}; - - static int similar_vert_select_exec(bContext *C, wmOperator *op) { ToolSettings *ts= CTX_data_tool_settings(C); @@ -1243,37 +1232,30 @@ static int select_similar_exec(bContext *C, wmOperator *op) static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *ptr, int *free) { - Object *obedit; + Object *obedit= CTX_data_edit_object(C); EnumPropertyItem *item= NULL; - int totitem= 0; - - if(C) { - obedit= CTX_data_edit_object(C); + int a, totitem= 0; - if(obedit && obedit->type == OB_MESH) { - EditMesh *em= BKE_mesh_get_editmesh(obedit->data); - - if(em->selectmode & SCE_SELECT_VERTEX) - RNA_enum_items_add(&item, &totitem, prop_simvertex_types); - else if(em->selectmode & SCE_SELECT_EDGE) - RNA_enum_items_add(&item, &totitem, prop_simedge_types); - else if(em->selectmode & SCE_SELECT_FACE) - RNA_enum_items_add(&item, &totitem, prop_simface_types); - RNA_enum_item_end(&item, &totitem); + if(obedit && obedit->type == OB_MESH) { + EditMesh *em= BKE_mesh_get_editmesh(obedit->data); - *free= 1; - - return item; + if(em->selectmode & SCE_SELECT_VERTEX) { + for(a=SIMVERT_NORMAL; a<=SIMVERT_TOT; a++) + RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); + } + else if(em->selectmode & SCE_SELECT_EDGE) { + for(a=SIMEDGE_LENGTH; a<=SIMEDGE_TOT; a++) + RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); + } + else if(em->selectmode & SCE_SELECT_FACE) { + for(a=SIMFACE_MATERIAL; a<=SIMFACE_TOT; a++) + RNA_enum_items_add_value(&item, &totitem, prop_similar_types, a); } } - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, prop_simvertex_types); - RNA_enum_items_add(&item, &totitem, prop_simedge_types); - RNA_enum_items_add(&item, &totitem, prop_simface_types); RNA_enum_item_end(&item, &totitem); *free= 1; - + return item; } @@ -1295,7 +1277,7 @@ void MESH_OT_select_similar(wmOperatorType *ot) ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; /* properties */ - prop= RNA_def_enum(ot->srna, "type", prop_simvertex_types, SIMVERT_NORMAL, "Type", ""); + prop= RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", ""); RNA_def_enum_funcs(prop, select_similar_type_itemf); } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 80ea5c51e1f..d447040e8ea 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -5856,14 +5856,10 @@ static EnumPropertyItem merge_type_items[]= { static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *free) { - Object *obedit; + Object *obedit= CTX_data_edit_object(C); EnumPropertyItem *item= NULL; int totitem= 0; - - if(!C) /* needed for docs */ - return merge_type_items; - - obedit= CTX_data_edit_object(C); + if(obedit && obedit->type == OB_MESH) { EditMesh *em= BKE_mesh_get_editmesh(obedit->data); @@ -5882,14 +5878,12 @@ static EnumPropertyItem *merge_type_itemf(bContext *C, PointerRNA *ptr, int *fre RNA_enum_items_add_value(&item, &totitem, merge_type_items, 3); RNA_enum_items_add_value(&item, &totitem, merge_type_items, 4); RNA_enum_items_add_value(&item, &totitem, merge_type_items, 5); - RNA_enum_item_end(&item, &totitem); + } - *free= 1; + RNA_enum_item_end(&item, &totitem); + *free= 1; - return item; - } - - return NULL; + return item; } void MESH_OT_merge(wmOperatorType *ot) diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 5f088f23939..25ecb41a523 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -608,9 +608,6 @@ static EnumPropertyItem *add_dupligroup_itemf(bContext *C, PointerRNA *ptr, int int i= 0; Group *group; - if(C==NULL) - return NULL; - memset(&item_tmp, 0, sizeof(item_tmp)); for(group= CTX_data_main(C)->group.first; group; group= group->id.next) { @@ -619,13 +616,10 @@ static EnumPropertyItem *add_dupligroup_itemf(bContext *C, PointerRNA *ptr, int RNA_enum_item_add(&item, &totitem, &item_tmp); } - if(i>0) { - *free= 1; - return item; - } - else { - return NULL; - } + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; } static int group_instance_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index c83f3022c7c..198838d6f05 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -275,18 +275,14 @@ static EnumPropertyItem group_items[]= { static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) { + Main *bmain= CTX_data_main(C); + Group *group; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item= NULL; - Main *bmain; - Group *group; int a, totitem= 0; - if(!C) /* needed for docs */ - return group_items; - RNA_enum_items_add_value(&item, &totitem, group_items, -1); - bmain= CTX_data_main(C); if(bmain->group.first) RNA_enum_item_add_separator(&item, &totitem); @@ -298,7 +294,6 @@ static EnumPropertyItem *group_itemf(bContext *C, PointerRNA *ptr, int *free) } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 252fdb5522a..f58e8cfeb9d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -440,12 +440,12 @@ static int modifier_add_exec(bContext *C, wmOperator *op) static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *free) { + Object *ob= CTX_data_active_object(C); EnumPropertyItem *item= NULL, *md_item; ModifierTypeInfo *mti; - Object *ob; int totitem= 0, a; - if(!C || !(ob= CTX_data_active_object(C))) /* needed for docs */ + if(!ob) return modifier_type_items; for(a=0; modifier_type_items[a].identifier; a++) { @@ -466,7 +466,6 @@ static EnumPropertyItem *modifier_add_itemf(bContext *C, PointerRNA *ptr, int *f } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 902a32bb7f3..dd3e5969a75 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1233,13 +1233,13 @@ static int set_active_group_exec(bContext *C, wmOperator *op) static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free) { - Object *ob; + Object *ob= CTX_data_pointer_get_type(C, "object", &RNA_Object).data; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item= NULL; bDeformGroup *def; int a, totitem= 0; - if(!C || !(ob = CTX_data_pointer_get_type(C, "object", &RNA_Object).data)) /* needed for docs */ + if(!ob) return vgroup_items; for(a=0, def=ob->defbase.first; def; def=def->next, a++) { @@ -1250,7 +1250,6 @@ static EnumPropertyItem *vgroup_itemf(bContext *C, PointerRNA *ptr, int *free) } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index bec2025907a..6cf2fd0c60f 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -727,7 +727,7 @@ void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, En *free= 0; - if(eprop->itemf) { + if(eprop->itemf && C) { int tot= 0; *item= eprop->itemf(C, ptr, free); diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 395633f5240..53c8db6ff0f 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -232,20 +232,6 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRN Object *ob= (Object*)ptr->id.data; bConstraint *con= (bConstraint*)ptr->data; - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, space_object_items); - RNA_enum_items_add(&item, &totitem, space_pchan_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - if(BLI_findindex(&ob->constraints, con) == -1) return space_pchan_items; else /* object */ @@ -259,20 +245,6 @@ static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerR ListBase targets = {NULL, NULL}; bConstraintTarget *ct; - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, space_object_items); - RNA_enum_items_add(&item, &totitem, space_pchan_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - if(cti && cti->get_constraint_targets) { cti->get_constraint_targets(con, &targets); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index f3fb1244565..48de7ace222 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -2135,6 +2135,11 @@ PropertyRNA *RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, co { ContainerRNA *cont= cont_; PropertyRNA *prop; + + if(!items) { + printf("RNA_def_enum: items not allowed to be NULL.\n"); + return NULL; + } prop= RNA_def_property(cont, identifier, PROP_ENUM, PROP_NONE); if(items) RNA_def_property_enum_items(prop, items); diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c index 521756b8539..44c55e821a9 100644 --- a/source/blender/makesrna/intern/rna_image.c +++ b/source/blender/makesrna/intern/rna_image.c @@ -128,9 +128,6 @@ static EnumPropertyItem *rna_Image_source_itemf(bContext *C, PointerRNA *ptr, in EnumPropertyItem *item= NULL; int totitem= 0; - if(C==NULL) /* needed for doc generation */ - return image_source_items; - if(ima->source == IMA_SRC_VIEWER) { RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_VIEWER); } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index e03e221f822..74cb8675ad5 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -260,10 +260,6 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, Poi EnumPropertyItem *item= NULL; int totitem= 0; - if(C==NULL) { - return prop_texture_coordinates_items; - } - RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_GLOB); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_OBJECT); RNA_enum_items_add_value(&item, &totitem, prop_texture_coordinates_items, TEXCO_ORCO); @@ -283,7 +279,6 @@ static EnumPropertyItem *rna_Material_texture_coordinates_itemf(bContext *C, Poi } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 092f18ef0e2..09e0ac3feac 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -229,10 +229,6 @@ static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *p EnumPropertyItem *item= NULL; int totitem= 0; - if(C==NULL) { - return parent_type_items; - } - RNA_enum_items_add_value(&item, &totitem, parent_type_items, PAROBJECT); if(ob->parent) { @@ -253,7 +249,6 @@ static EnumPropertyItem *rna_Object_parent_type_itemf(bContext *C, PointerRNA *p } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 404223ab590..2247e5499fb 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -546,24 +546,6 @@ static EnumPropertyItem *rna_Effector_shape_itemf(bContext *C, PointerRNA *ptr, { Object *ob= NULL; - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, effector_shape_items); - RNA_enum_items_add(&item, &totitem, curve_shape_items); - RNA_enum_items_add(&item, &totitem, empty_shape_items); - RNA_enum_items_add(&item, &totitem, vortex_shape_items); - RNA_enum_items_add(&item, &totitem, curve_vortex_shape_items); - RNA_enum_items_add(&item, &totitem, empty_vortex_shape_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - if(particle_field_check(ptr)) return empty_shape_items; diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 2c81bda121f..28d0d2deb34 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -499,39 +499,9 @@ static void rna_ParticleDupliWeight_name_get(PointerRNA *ptr, char *str) else strcpy(str, "No object"); } -EnumPropertyItem from_items[] = { - {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, - {PART_FROM_FACE, "FACE", 0, "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, - {0, NULL, 0, NULL, NULL} -}; - -EnumPropertyItem reactor_from_items[] = { - {PART_FROM_VERT, "VERT", 0, "Vertexes", ""}, - {PART_FROM_FACE, "FACE", 0, "Faces", ""}, - {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""}, - {PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""}, - {0, NULL, 0, NULL, NULL} -}; static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, int *free) { - /* ParticleSettings *part = ptr->id.data; */ - - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, part_reactor_from_items); - RNA_enum_items_add(&item, &totitem, part_from_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - //if(part->type==PART_REACTOR) // return part_reactor_from_items; //else @@ -542,20 +512,6 @@ static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr { ParticleSettings *part = ptr->id.data; - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, part_hair_draw_as_items); - RNA_enum_items_add(&item, &totitem, part_draw_as_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - if(part->type==PART_HAIR) return part_hair_draw_as_items; else @@ -566,20 +522,6 @@ static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, { ParticleSettings *part = ptr->id.data; - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, part_hair_ren_as_items); - RNA_enum_items_add(&item, &totitem, part_ren_as_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - if(part->type==PART_HAIR) return part_hair_ren_as_items; else diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index fbb24f9ada9..31aecbb8a76 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -624,7 +624,7 @@ static EnumPropertyItem *rna_EnumProperty_default_itemf(bContext *C, PointerRNA rna_idproperty_check(&prop, ptr); eprop= (EnumPropertyRNA*)prop; - if(eprop->itemf==NULL || eprop->itemf==rna_EnumProperty_default_itemf) + if(eprop->itemf==NULL || eprop->itemf==rna_EnumProperty_default_itemf || !C) return eprop->item; return eprop->itemf(C, ptr, free); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 413f7c3dc7c..7f8ded7d3ee 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -119,27 +119,13 @@ static void rna_ParticleEdit_update(bContext *C, PointerRNA *ptr) static EnumPropertyItem *rna_ParticleEdit_tool_itemf(bContext *C, PointerRNA *ptr, int *free) { - if(C==NULL) { - EnumPropertyItem *item= NULL; - int totitem= 0; - - /* needed for doc generation */ - RNA_enum_items_add(&item, &totitem, particle_edit_hair_brush_items); - RNA_enum_item_end(&item, &totitem); - - *free= 1; - - return item; - } - else { - Scene *scene= CTX_data_scene(C); - PTCacheEdit *edit = PE_get_current(scene, CTX_data_active_object(C)); - - if(edit && edit->psys) - return particle_edit_hair_brush_items; + Scene *scene= CTX_data_scene(C); + PTCacheEdit *edit = PE_get_current(scene, CTX_data_active_object(C)); + + if(edit && edit->psys) + return particle_edit_hair_brush_items; - return particle_edit_cache_brush_items; - } + return particle_edit_cache_brush_items; } static int rna_ParticleEdit_editable_get(PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 5665d9d7adc..015df0e73de 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -64,19 +64,23 @@ EnumPropertyItem space_type_items[] = { {SPACE_USERPREF, "USER_PREFERENCES", 0, "User Preferences", ""}, {0, NULL, 0, NULL, NULL}}; -#define DC_RGB {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."} -#define DC_RGBA {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", "Draw image with RGB colors and alpha transparency."} -#define DC_ALPHA {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel."} -#define DC_Z {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."} +static EnumPropertyItem draw_channels_items[] = { + {0, "COLOR", ICON_IMAGE_RGB, "Color", "Draw image with RGB colors."}, + {SI_USE_ALPHA, "COLOR_ALPHA", ICON_IMAGE_RGB_ALPHA, "Color and Alpha", "Draw image with RGB colors and alpha transparency."}, + {SI_SHOW_ALPHA, "ALPHA", ICON_IMAGE_ALPHA, "Alpha", "Draw alpha transparency channel."}, + {SI_SHOW_ZBUF, "Z_BUFFER", ICON_IMAGE_ZDEPTH, "Z-Buffer", "Draw Z-buffer associated with image (mapped from camera clip start to end)."}, #ifdef WITH_LCMS -#define DC_LCMS {SI_COLOR_CORRECTION, "COLOR_CORRECTED", ICON_IMAGE_ALPHA, "Color Corrected", "Display color corrected image."} -#else -#define DC_LCMS {0, NULL, 0, NULL, NULL} + {SI_COLOR_CORRECTION, "COLOR_CORRECTED", ICON_IMAGE_ALPHA, "Color Corrected", "Display color corrected image."}, #endif -#define DC_ZERO {0, NULL, 0, NULL, NULL} - -static EnumPropertyItem dc_all_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_Z, DC_LCMS, DC_ZERO}; + {0, NULL, 0, NULL, NULL}}; +static EnumPropertyItem transform_orientation_items[] = { + {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", "Align the transformation axes to world space"}, + {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, + {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", "Align the transformation axes to average normal of selected elements (bone Y axis for pose mode)"}, + {V3D_MANIP_VIEW, "VIEW", 0, "View", "Align the transformation axes to the window"}, + {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", "Use a custom transform orientation"}, + {0, NULL, 0, NULL, NULL}}; #ifdef RNA_RUNTIME @@ -155,37 +159,26 @@ EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, i Scene *scene; ListBase *transform_spaces; TransformOrientation *ts= NULL; - - EnumPropertyItem global = {V3D_MANIP_GLOBAL, "Global", 0, "Global", ""}; - EnumPropertyItem normal = {V3D_MANIP_NORMAL, "Normal", 0, "Normal", ""}; - EnumPropertyItem local = {V3D_MANIP_LOCAL, "Local", 0, "Local", ""}; - EnumPropertyItem view = {V3D_MANIP_VIEW, "View", 0, "View", ""}; EnumPropertyItem tmp = {0, "", 0, "", ""}; EnumPropertyItem *item= NULL; int i = V3D_MANIP_CUSTOM, totitem= 0; - RNA_enum_item_add(&item, &totitem, &global); - RNA_enum_item_add(&item, &totitem, &normal); - RNA_enum_item_add(&item, &totitem, &local); - RNA_enum_item_add(&item, &totitem, &view); - - if(C) { - scene= CTX_data_scene(C); - - if(scene) { - transform_spaces = &scene->transform_spaces; - ts = transform_spaces->first; - } - else - { - printf("no scene\n"); - } + RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_GLOBAL); + RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_NORMAL); + RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_LOCAL); + RNA_enum_items_add_value(&item, &totitem, transform_orientation_items, V3D_MANIP_VIEW); + + scene= CTX_data_scene(C); + + if(scene) { + transform_spaces = &scene->transform_spaces; + ts = transform_spaces->first; } else { - printf("no context\n"); + printf("no scene\n"); } - + if(ts) RNA_enum_item_add_separator(&item, &totitem); @@ -197,7 +190,6 @@ EnumPropertyItem *rna_TransformOrientation_itemf(bContext *C, PointerRNA *ptr, i } RNA_enum_item_end(&item, &totitem); - *free= 1; return item; @@ -245,22 +237,14 @@ static void rna_SpaceImageEditor_image_set(PointerRNA *ptr, PointerRNA value) ED_space_image_set(NULL, sima, sc->scene, sc->scene->obedit, (Image*)value.data); } -static EnumPropertyItem dc_rgb_items[] = {DC_RGB, DC_LCMS, DC_ZERO}; -static EnumPropertyItem dc_alpha_items[] = {DC_RGB, DC_RGBA, DC_ALPHA, DC_LCMS, DC_ZERO}; -static EnumPropertyItem dc_z_items[] = {DC_RGB, DC_Z, DC_LCMS, DC_ZERO}; - static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free) { SpaceImage *sima= (SpaceImage*)ptr->data; + EnumPropertyItem *item= NULL; ImBuf *ibuf; void *lock; - int zbuf, alpha; + int zbuf, alpha, totitem= 0; - if(C==NULL) { - /* needed for doc generation */ - return dc_all_items; - } - ibuf= ED_space_image_acquire_buffer(sima, &lock); alpha= ibuf && (ibuf->channels == 4); @@ -269,13 +253,26 @@ static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, P ED_space_image_release_buffer(sima, lock); if(alpha && zbuf) - return dc_all_items; - else if(alpha) - return dc_alpha_items; - else if(zbuf) - return dc_z_items; - else - return dc_rgb_items; + return draw_channels_items; + + RNA_enum_items_add_value(&item, &totitem, draw_channels_items, 0); + + if(alpha) { + RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ALPHA); + RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_USE_ALPHA); + } + else if(zbuf) { + RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_SHOW_ZBUF); + } + +#ifdef WITH_LCMS + RNA_enum_items_add_value(&item, &totitem, draw_channels_items, SI_COLOR_CORRECTION); +#endif + + RNA_enum_item_end(&item, &totitem); + *free= 1; + + return item; } static void rna_SpaceImageEditor_curves_update(bContext *C, PointerRNA *ptr) @@ -641,14 +638,6 @@ static void rna_def_space_3dview(BlenderRNA *brna) {V3D_ACTIVE, "ACTIVE_ELEMENT", 0, "Active Element", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem transform_orientation_items[] = { - {V3D_MANIP_GLOBAL, "ORIENT_GLOBAL", 0, "Global", "Align the transformation axes to world space"}, - {V3D_MANIP_LOCAL, "ORIENT_LOCAL", 0, "Local", "Align the transformation axes to the selected objects' local space"}, - {V3D_MANIP_NORMAL, "ORIENT_NORMAL", 0, "Normal", "Align the transformation axes to average normal of selected elements (bone Y axis for pose mode)"}, - {V3D_MANIP_VIEW, "ORIENT_VIEW", 0, "View", "Align the transformation axes to the window"}, - {V3D_MANIP_CUSTOM, "ORIENT_CUSTOM", 0, "Custom", "Use a custom transform orientation"}, - {0, NULL, 0, NULL, NULL}}; - srna= RNA_def_struct(brna, "Space3DView", "Space"); RNA_def_struct_sdna(srna, "View3D"); RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data"); @@ -911,7 +900,7 @@ static void rna_def_space_image(BlenderRNA *brna) prop= RNA_def_property(srna, "draw_channels", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); - RNA_def_property_enum_items(prop, dc_all_items); + RNA_def_property_enum_items(prop, draw_channels_items); RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_SpaceImageEditor_draw_channels_itemf"); RNA_def_property_ui_text(prop, "Draw Channels", "Channels of the image to draw."); RNA_def_property_update(prop, NC_SPACE|ND_SPACE_IMAGE, NULL); diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index c4fb9ea3d0d..6f7bc9a4feb 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -206,7 +206,7 @@ static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerR EnumPropertyItem *item= NULL; int totitem= 0; - if(tex && C) { /* Note, tex/mtex/ntree can be invalid of C is NULL, TODO - can this give valid results when C is NULL? */ + if(tex) { bNodeTree *ntree= tex->nodetree; if(ntree) { EnumPropertyItem tmp= {0, "", 0, "", ""}; @@ -229,8 +229,8 @@ static EnumPropertyItem *rna_TextureSlot_output_node_itemf(bContext *C, PointerR } RNA_enum_item_end(&item, &totitem); - *free = 1; + return item; } |