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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-10 23:56:13 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-10 23:56:13 +0400
commit2e3e044d27e90dc87bdce6af9cef77d9543e4d89 (patch)
tree4d87ed9c283fd99baf9d23d4b8ace0868972f156 /source/blender/makesrna
parenta95c68a3eaa692f742e7f2e626b65daa71727c17 (diff)
RNA
* Enums can now be dynamically created in the _itemf callback, using RNA_enum_item(s)_add, RNA_enum_item_end. All places asking for enum items now need to potentially free the items. * This callback now also gets context, this was added specifically for operators. This doesn't fit design well at all, needed to do some ugly hacks, but can't find a good solution at the moment. * All enums must have a default list of items too, even with an _itemf callback, for docs and fallback in case there is no context. * Used by MESH_OT_merge, MESH_OT_select_similar, TFM_OT_select_orientation. * Also changes some operator properties that were enums to booleas (unselected, deselect), to make them consistent with other ops.
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_access.h16
-rw-r--r--source/blender/makesrna/RNA_define.h7
-rw-r--r--source/blender/makesrna/RNA_types.h2
-rw-r--r--source/blender/makesrna/intern/makesrna.c1
-rw-r--r--source/blender/makesrna/intern/rna_access.c57
-rw-r--r--source/blender/makesrna/intern/rna_constraint.c29
-rw-r--r--source/blender/makesrna/intern/rna_define.c36
-rw-r--r--source/blender/makesrna/intern/rna_internal_types.h4
-rw-r--r--source/blender/makesrna/intern/rna_particle.c123
-rw-r--r--source/blender/makesrna/intern/rna_space.c2
10 files changed, 168 insertions, 109 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 3b2520c41b2..93fbc8b5f17 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -548,12 +548,12 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin,
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax);
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision);
-int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier);
-int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name);
+int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
+int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
-void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem);
-int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
-int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
+void RNA_property_enum_items(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free);
+int RNA_property_enum_value(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value);
+int RNA_property_enum_identifier(struct bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier);
StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop);
@@ -677,11 +677,11 @@ void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
int RNA_enum_get(PointerRNA *ptr, const char *name);
void RNA_enum_set(PointerRNA *ptr, const char *name, int value);
-int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname);
+int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname);
/* lower level functions that donr use a PointerRNA */
-int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value);
-int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier);
+int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value);
+int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier);
void RNA_string_get(PointerRNA *ptr, const char *name, char *value);
char *RNA_string_get_alloc(PointerRNA *ptr, const char *name, char *fixedbuf, int fixedlen);
diff --git a/source/blender/makesrna/RNA_define.h b/source/blender/makesrna/RNA_define.h
index 69f5b5adc37..a3fa97bf4b1 100644
--- a/source/blender/makesrna/RNA_define.h
+++ b/source/blender/makesrna/RNA_define.h
@@ -160,6 +160,13 @@ void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret);
void RNA_def_function_flag(FunctionRNA *func, int flag);
void RNA_def_function_ui_description(FunctionRNA *func, const char *description);
+/* Dynamic Enums
+ * strings are not freed, assumed pointing to static location. */
+
+void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
+void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item);
+void RNA_enum_item_end(EnumPropertyItem **items, int *totitem);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h
index 98646acd727..dc2a2a1a1de 100644
--- a/source/blender/makesrna/RNA_types.h
+++ b/source/blender/makesrna/RNA_types.h
@@ -157,7 +157,7 @@ typedef struct EnumPropertyItem {
const char *description;
} EnumPropertyItem;
-typedef EnumPropertyItem *(*EnumPropertyItemFunc)(PointerRNA *ptr);
+typedef EnumPropertyItem *(*EnumPropertyItemFunc)(struct bContext *C, PointerRNA *ptr, int *free);
typedef struct PropertyRNA PropertyRNA;
diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c
index ec509dbf863..5230c260dbd 100644
--- a/source/blender/makesrna/intern/makesrna.c
+++ b/source/blender/makesrna/intern/makesrna.c
@@ -1597,7 +1597,6 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr
DefRNA.error= 1;
}
}
- else if(eprop->itemf);
else {
fprintf(stderr, "rna_generate_structs: %s%s.%s, enum must have items defined.\n", srna->identifier, errnest, prop->identifier);
DefRNA.error= 1;
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index 42f6250728f..f20df81d6ad 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -640,17 +640,19 @@ StructRNA *RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
return &RNA_UnknownType;
}
-void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **item, int *totitem)
+void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, EnumPropertyItem **item, int *totitem, int *free)
{
EnumPropertyRNA *eprop= (EnumPropertyRNA*)rna_ensure_property(prop);
int tot;
- if(eprop->itemf) {
- *item= eprop->itemf(ptr);
- if(totitem) {
+ *free= 0;
+
+ if(C && eprop->itemf) {
+ *item= eprop->itemf(C, ptr, free);
+
+ if(totitem)
for(tot=0; (*item)[tot].identifier; tot++);
- *totitem= tot;
- }
+ *totitem= tot;
}
else {
*item= eprop->item;
@@ -659,11 +661,12 @@ void RNA_property_enum_items(PointerRNA *ptr, PropertyRNA *prop, const EnumPrope
}
}
-int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
+int RNA_property_enum_value(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const char *identifier, int *value)
{
- const EnumPropertyItem *item;
+ EnumPropertyItem *item;
+ int free;
- RNA_property_enum_items(ptr, prop, &item, NULL);
+ RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
for(; item->identifier; item++) {
if(item->identifier[0] && strcmp(item->identifier, identifier)==0) {
@@ -672,10 +675,13 @@ int RNA_property_enum_value(PointerRNA *ptr, PropertyRNA *prop, const char *iden
}
}
+ if(free)
+ MEM_freeN(item);
+
return 0;
}
-int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const char **identifier)
+int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier)
{
for (; item->identifier; item++) {
if(item->identifier[0] && item->value==value) {
@@ -686,7 +692,7 @@ int RNA_enum_identifier(const EnumPropertyItem *item, const int value, const cha
return 0;
}
-int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **name)
+int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name)
{
for (; item->identifier; item++) {
if(item->identifier[0] && item->value==value) {
@@ -697,12 +703,17 @@ int RNA_enum_name(const EnumPropertyItem *item, const int value, const char **na
return 0;
}
-int RNA_property_enum_identifier(PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
+int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier)
{
- const EnumPropertyItem *item= NULL;
+ EnumPropertyItem *item= NULL;
+ int result, free;
- RNA_property_enum_items(ptr, prop, &item, NULL);
- return RNA_enum_identifier(item, value, identifier);
+ RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
+ result= RNA_enum_identifier(item, value, identifier);
+ if(free)
+ MEM_freeN(item);
+
+ return result;
}
const char *RNA_property_ui_name(PropertyRNA *prop)
@@ -2384,18 +2395,22 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name);
}
-int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
+int RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const char *enumname)
{
PropertyRNA *prop= RNA_struct_find_property(ptr, name);
- const EnumPropertyItem *item;
+ EnumPropertyItem *item;
+ int free;
if(prop) {
- RNA_property_enum_items(ptr, prop, &item, NULL);
+ RNA_property_enum_items(C, ptr, prop, &item, NULL, &free);
for(; item->identifier; item++)
if(strcmp(item->identifier, enumname) == 0)
return (item->value == RNA_property_enum_get(ptr, prop));
+ if(free)
+ MEM_freeN(item);
+
printf("RNA_enum_is_equal: %s.%s item %s not found.\n", ptr->type->identifier, name, enumname);
return 0;
}
@@ -2405,7 +2420,7 @@ int RNA_enum_is_equal(PointerRNA *ptr, const char *name, const char *enumname)
}
}
-int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier, int *value)
+int RNA_enum_value_from_id(EnumPropertyItem *item, const char *identifier, int *value)
{
for( ; item->identifier; item++) {
if(strcmp(item->identifier, identifier)==0) {
@@ -2417,7 +2432,7 @@ int RNA_enum_value_from_id(const EnumPropertyItem *item, const char *identifier,
return 0;
}
-int RNA_enum_id_from_value(const EnumPropertyItem *item, int value, const char **identifier)
+int RNA_enum_id_from_value(EnumPropertyItem *item, int value, const char **identifier)
{
for( ; item->identifier; item++) {
if(item->value==value) {
@@ -2659,7 +2674,7 @@ char *RNA_property_as_string(PointerRNA *ptr, PropertyRNA *prop)
const char *identifier;
int val = RNA_property_enum_get(ptr, prop);
- if(RNA_property_enum_identifier(ptr, prop, val, &identifier)) {
+ if(RNA_property_enum_identifier(NULL, ptr, prop, val, &identifier)) {
BLI_dynstr_appendf(dynstr, "'%s'", identifier);
}
else {
diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c
index cda1716f664..cd3642f65a2 100644
--- a/source/blender/makesrna/intern/rna_constraint.c
+++ b/source/blender/makesrna/intern/rna_constraint.c
@@ -68,6 +68,17 @@ EnumPropertyItem constraint_type_items[] ={
{CONSTRAINT_TYPE_NULL, "NULL", 0, "Null", ""},
{0, NULL, 0, NULL, NULL}};
+EnumPropertyItem space_pchan_items[] = {
+ {0, "WORLD", 0, "World Space", ""},
+ {2, "POSE", 0, "Pose Space", ""},
+ {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""},
+ {1, "LOCAL", 0, "Local Space", ""},
+ {0, NULL, 0, NULL, NULL}};
+
+EnumPropertyItem space_object_items[] = {
+ {0, "WORLD", 0, "World Space", ""},
+ {1, "LOCAL", 0, "Local (Without Parent) Space", ""},
+ {0, NULL, 0, NULL, NULL}};
#ifdef RNA_RUNTIME
@@ -166,19 +177,7 @@ static void rna_Constraint_influence_update(bContext *C, PointerRNA *ptr)
rna_Constraint_update(C, ptr);
}
-static EnumPropertyItem space_pchan_items[] = {
- {0, "WORLD", 0, "World Space", ""},
- {2, "POSE", 0, "Pose Space", ""},
- {3, "LOCAL_WITH_PARENT", 0, "Local With Parent", ""},
- {1, "LOCAL", 0, "Local Space", ""},
- {0, NULL, 0, NULL, NULL}};
-
-static EnumPropertyItem space_object_items[] = {
- {0, "WORLD", 0, "World Space", ""},
- {1, "LOCAL", 0, "Local (Without Parent) Space", ""},
- {0, NULL, 0, NULL, NULL}};
-
-static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr)
+static EnumPropertyItem *rna_Constraint_owner_space_itemf(bContext *C, PointerRNA *ptr, int *free)
{
Object *ob= (Object*)ptr->id.data;
bConstraint *con= (bConstraint*)ptr->data;
@@ -189,7 +188,7 @@ static EnumPropertyItem *rna_Constraint_owner_space_itemf(PointerRNA *ptr)
return space_object_items;
}
-static EnumPropertyItem *rna_Constraint_target_space_itemf(PointerRNA *ptr)
+static EnumPropertyItem *rna_Constraint_target_space_itemf(bContext *C, PointerRNA *ptr, int *free)
{
bConstraint *con= (bConstraint*)ptr->data;
bConstraintTypeInfo *cti= constraint_get_typeinfo(con);
@@ -1505,11 +1504,13 @@ void RNA_def_constraint(BlenderRNA *brna)
prop= RNA_def_property(srna, "owner_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ownspace");
+ RNA_def_property_enum_items(prop, space_pchan_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_owner_space_itemf");
RNA_def_property_ui_text(prop, "Owner Space", "Space that owner is evaluated in.");
prop= RNA_def_property(srna, "target_space", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "tarspace");
+ RNA_def_property_enum_items(prop, space_pchan_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Constraint_target_space_itemf");
RNA_def_property_ui_text(prop, "Target Space", "Space that target is evaluated in.");
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c
index 2b414adf05b..07515d3ad56 100644
--- a/source/blender/makesrna/intern/rna_define.c
+++ b/source/blender/makesrna/intern/rna_define.c
@@ -1112,7 +1112,7 @@ void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item
switch(prop->type) {
case PROP_ENUM: {
EnumPropertyRNA *eprop= (EnumPropertyRNA*)prop;
- eprop->item= item;
+ eprop->item= (EnumPropertyItem*)item;
eprop->totitem= 0;
for(i=0; item[i].identifier; i++) {
eprop->totitem++;
@@ -2262,3 +2262,37 @@ int rna_parameter_size(PropertyRNA *parm)
return sizeof(void *);
}
+/* Dynamic Enums */
+
+void RNA_enum_item_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
+{
+ EnumPropertyItem *newitems;
+ int tot= *totitem;
+
+ if(tot == 0) {
+ *items= MEM_callocN(sizeof(EnumPropertyItem)*8, "RNA_enum_items_add");
+ }
+ else if(tot >= 8 && (tot&(tot-1)) == 0){
+ /* power of two > 8 */
+ newitems= MEM_callocN(sizeof(EnumPropertyItem)*tot*2, "RNA_enum_items_add");
+ memcpy(newitems, *items, sizeof(EnumPropertyItem)*tot);
+ MEM_freeN(*items);
+ *items= newitems;
+ }
+
+ (*items)[tot]= *item;
+ *totitem= tot+1;
+}
+
+void RNA_enum_items_add(EnumPropertyItem **items, int *totitem, EnumPropertyItem *item)
+{
+ for(; item->identifier; item++)
+ RNA_enum_item_add(items, totitem, item);
+}
+
+void RNA_enum_item_end(EnumPropertyItem **items, int *totitem)
+{
+ static EnumPropertyItem empty = {0, NULL, 0, NULL, NULL};
+ RNA_enum_item_add(items, totitem, &empty);
+}
+
diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h
index 401b430ebc9..b63e347e165 100644
--- a/source/blender/makesrna/intern/rna_internal_types.h
+++ b/source/blender/makesrna/intern/rna_internal_types.h
@@ -68,7 +68,7 @@ typedef int (*PropStringLengthFunc)(struct PointerRNA *ptr);
typedef void (*PropStringSetFunc)(struct PointerRNA *ptr, const char *value);
typedef int (*PropEnumGetFunc)(struct PointerRNA *ptr);
typedef void (*PropEnumSetFunc)(struct PointerRNA *ptr, int value);
-typedef EnumPropertyItem *(*PropEnumItemFunc)(struct PointerRNA *ptr);
+typedef EnumPropertyItem *(*PropEnumItemFunc)(struct bContext *C, struct PointerRNA *ptr, int *free);
typedef PointerRNA (*PropPointerGetFunc)(struct PointerRNA *ptr);
typedef StructRNA* (*PropPointerTypeFunc)(struct PointerRNA *ptr);
typedef void (*PropPointerSetFunc)(struct PointerRNA *ptr, const PointerRNA value);
@@ -225,7 +225,7 @@ typedef struct EnumPropertyRNA {
PropEnumSetFunc set;
PropEnumItemFunc itemf;
- const EnumPropertyItem *item;
+ EnumPropertyItem *item;
int totitem;
int defaultvalue;
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c
index bb19b66b34d..c4f2c29409f 100644
--- a/source/blender/makesrna/intern/rna_particle.c
+++ b/source/blender/makesrna/intern/rna_particle.c
@@ -40,6 +40,57 @@
#include "WM_types.h"
#include "WM_api.h"
+EnumPropertyItem part_from_items[] = {
+ {PART_FROM_VERT, "VERT", 0, "Verts", ""},
+ {PART_FROM_FACE, "FACE", 0, "Faces", ""},
+ {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem part_reactor_from_items[] = {
+ {PART_FROM_VERT, "VERT", 0, "Verts", ""},
+ {PART_FROM_FACE, "FACE", 0, "Faces", ""},
+ {PART_FROM_VOLUME, "VOLUME", 0, "Volume", ""},
+ {PART_FROM_PARTICLE, "PARTICLE", 0, "Particle", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem part_draw_as_items[] = {
+ {PART_DRAW_NOT, "NONE", 0, "None", ""},
+ {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
+ {PART_DRAW_DOT, "DOT", 0, "Point", ""},
+ {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
+ {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
+ {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem part_hair_draw_as_items[] = {
+ {PART_DRAW_NOT, "NONE", 0, "None", ""},
+ {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
+ {PART_DRAW_PATH, "PATH", 0, "Path", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem part_ren_as_items[] = {
+ {PART_DRAW_NOT, "NONE", 0, "None", ""},
+ {PART_DRAW_HALO, "HALO", 0, "Halo", ""},
+ {PART_DRAW_LINE, "LINE", 0, "Line", ""},
+ {PART_DRAW_PATH, "PATH", 0, "Path", ""},
+ {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
+ {PART_DRAW_GR, "GROUP", 0, "Group", ""},
+ {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
+EnumPropertyItem part_hair_ren_as_items[] = {
+ {PART_DRAW_NOT, "NONE", 0, "None", ""},
+ {PART_DRAW_PATH, "PATH", 0, "Path", ""},
+ {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
+ {PART_DRAW_GR, "GROUP", 0, "Group", ""},
+ {0, NULL, 0, NULL, NULL}
+};
+
#ifdef RNA_RUNTIME
#include "BKE_context.h"
@@ -248,85 +299,34 @@ static void rna_ParticleSystem_name_get(PointerRNA *ptr, char *str)
strcpy(str, "");
}
-static 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}
-};
-
-static 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(PointerRNA *ptr)
+static EnumPropertyItem *rna_Particle_from_itemf(bContext *C, PointerRNA *ptr, int *free)
{
ParticleSettings *part = ptr->id.data;
if(part->type==PART_REACTOR)
- return reactor_from_items;
+ return part_reactor_from_items;
else
- return from_items;
+ return part_from_items;
}
-static EnumPropertyItem draw_as_items[] = {
- {PART_DRAW_NOT, "NONE", 0, "None", ""},
- {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
- {PART_DRAW_DOT, "DOT", 0, "Point", ""},
- {PART_DRAW_CIRC, "CIRC", 0, "Circle", ""},
- {PART_DRAW_CROSS, "CROSS", 0, "Cross", ""},
- {PART_DRAW_AXIS, "AXIS", 0, "Axis", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-static EnumPropertyItem hair_draw_as_items[] = {
- {PART_DRAW_NOT, "NONE", 0, "None", ""},
- {PART_DRAW_REND, "RENDER", 0, "Rendered", ""},
- {PART_DRAW_PATH, "PATH", 0, "Path", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-static EnumPropertyItem ren_as_items[] = {
- {PART_DRAW_NOT, "NONE", 0, "None", ""},
- {PART_DRAW_HALO, "HALO", 0, "Halo", ""},
- {PART_DRAW_LINE, "LINE", 0, "Line", ""},
- {PART_DRAW_PATH, "PATH", 0, "Path", ""},
- {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
- {PART_DRAW_GR, "GROUP", 0, "Group", ""},
- {PART_DRAW_BB, "BILLBOARD", 0, "Billboard", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-static EnumPropertyItem hair_ren_as_items[] = {
- {PART_DRAW_NOT, "NONE", 0, "None", ""},
- {PART_DRAW_PATH, "PATH", 0, "Path", ""},
- {PART_DRAW_OB, "OBJECT", 0, "Object", ""},
- {PART_DRAW_GR, "GROUP", 0, "Group", ""},
- {0, NULL, 0, NULL, NULL}
-};
-
-static EnumPropertyItem *rna_Particle_draw_as_itemf(PointerRNA *ptr)
+static EnumPropertyItem *rna_Particle_draw_as_itemf(bContext *C, PointerRNA *ptr, int *free)
{
ParticleSettings *part = ptr->id.data;
if(part->type==PART_HAIR)
- return hair_draw_as_items;
+ return part_hair_draw_as_items;
else
- return draw_as_items;
+ return part_draw_as_items;
}
-static EnumPropertyItem *rna_Particle_ren_as_itemf(PointerRNA *ptr)
+static EnumPropertyItem *rna_Particle_ren_as_itemf(bContext *C, PointerRNA *ptr, int *free)
{
ParticleSettings *part = ptr->id.data;
if(part->type==PART_HAIR)
- return hair_ren_as_items;
+ return part_hair_ren_as_items;
else
- return ren_as_items;
+ return part_ren_as_items;
}
@@ -801,6 +801,7 @@ static void rna_def_particle_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "emit_from", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "from");
+ RNA_def_property_enum_items(prop, part_reactor_from_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_from_itemf");
RNA_def_property_ui_text(prop, "Emit From", "Where to emit particles from");
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset");
@@ -914,12 +915,14 @@ static void rna_def_particle_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "draw_as", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "draw_as");
+ RNA_def_property_enum_items(prop, part_draw_as_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_draw_as_itemf");
RNA_def_property_ui_text(prop, "Particle Drawing", "How particles are drawn in viewport");
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
prop= RNA_def_property(srna, "ren_as", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "ren_as");
+ RNA_def_property_enum_items(prop, part_ren_as_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Particle_ren_as_itemf");
RNA_def_property_ui_text(prop, "Particle Rendering", "How particles are rendered");
RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 996e54384e2..b4422541718 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -173,7 +173,7 @@ 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(PointerRNA *ptr)
+static EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(bContext *C, PointerRNA *ptr, int *free)
{
SpaceImage *sima= (SpaceImage*)ptr->data;
ImBuf *ibuf= ED_space_image_buffer(sima);