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 /source/blender/makesrna/intern | |
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.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_constraint.c | 28 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_image.c | 3 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_material.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 18 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 58 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_sculpt_paint.c | 26 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 109 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_texture.c | 4 |
12 files changed, 64 insertions, 201 deletions
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; } |