diff options
author | Campbell Barton <ideasman42@gmail.com> | 2009-08-11 15:50:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2009-08-11 15:50:40 +0400 |
commit | 911078aaaddfab72eeea564f671f7e1a1c392300 (patch) | |
tree | 20dbde50059816b202dd663ec94060aeb58cc34a | |
parent | e49ad2e148391aa92cf71d23df6ddeec136c510e (diff) |
fix for using subtype units that are not defined as a part of types. eg.
prop= RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ|PROP_UNIT_LENGTH);
-rw-r--r-- | source/blender/makesrna/RNA_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 26 |
2 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 0a641ecebe9..4833640a04b 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -66,6 +66,7 @@ typedef enum PropertyType { PROP_COLLECTION = 6 } PropertyType; +/* also update rna_property_subtype_unit when you change this */ typedef enum PropertyUnit { PROP_UNIT_NONE = (0<<16), PROP_UNIT_LENGTH = (1<<16), /* m */ diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 8b9ce879b8a..05eac06de7f 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -1388,6 +1388,30 @@ static const char *rna_property_subtypename(PropertyType type) case PROP_XYZ: return "PROP_XYZ"; case PROP_RGB: return "PROP_RGB"; case PROP_NEVER_NULL: return "PROP_NEVER_NULL"; + default: { + /* incase we dont have a type preset that includes the subtype */ + if(RNA_SUBTYPE_UNIT(type)) { + return rna_property_subtypename(type & ~RNA_SUBTYPE_UNIT(type)); + } + else { + return "PROP_SUBTYPE_UNKNOWN"; + } + } + } +} + +static const char *rna_property_subtype_unit(PropertyType type) +{ + switch(RNA_SUBTYPE_UNIT(type)) { + case PROP_UNIT_NONE: return "PROP_UNIT_NONE"; + case PROP_UNIT_LENGTH: return "PROP_UNIT_LENGTH"; + case PROP_UNIT_AREA: return "PROP_UNIT_AREA"; + case PROP_UNIT_VOLUME: return "PROP_UNIT_VOLUME"; + case PROP_UNIT_MASS: return "PROP_UNIT_MASS"; + case PROP_UNIT_ROTATION: return "PROP_UNIT_ROTATION"; + case PROP_UNIT_TIME: return "PROP_UNIT_TIME"; + case PROP_UNIT_VELOCITY: return "PROP_UNIT_VELOCITY"; + case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION"; default: return "PROP_UNKNOWN"; } } @@ -1693,7 +1717,7 @@ static void rna_generate_property(FILE *f, StructRNA *srna, const char *nest, Pr rna_print_c_string(f, prop->name); fprintf(f, ",\n\t"); rna_print_c_string(f, prop->description); fprintf(f, ",\n\t"); fprintf(f, "%d,\n", prop->icon); - fprintf(f, "\t%s, %s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), prop->arraylength); + fprintf(f, "\t%s, %s|%s, %d,\n", rna_property_typename(prop->type), rna_property_subtypename(prop->subtype), rna_property_subtype_unit(prop->subtype), prop->arraylength); fprintf(f, "\t%s, %d, %s,\n", rna_function_string(prop->update), prop->noteflag, rna_function_string(prop->editable)); if(prop->flag & PROP_RAW_ACCESS) rna_set_raw_offset(f, srna, prop); |