diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-03 02:03:56 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-03 02:03:56 +0300 |
commit | fc123a40d3afd699005cd90d46cf205a200a79fb (patch) | |
tree | 577e358e52a3f9513eac949f255f1a1e648203e1 /source/blender/makesrna/intern | |
parent | 95bfbd470eeb1ccb3f69b5ba63875772860acdbf (diff) |
patch [#20889] Support "unit"s for FloatProperty
from Martin Bürbaum (pontiac)
(with own minor changes)
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 23 |
2 files changed, 12 insertions, 22 deletions
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 84baec784df..9dd03ed7477 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -1034,17 +1034,6 @@ int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name) return 0; } -int RNA_enum_value(EnumPropertyItem *item, const char *name, int *r_value) -{ - for (; item->identifier; item++) { - if(item->identifier[0] && strcmp(item->identifier, name)==0) { - *r_value= item->value; - return 1; - } - } - return 0; -} - int RNA_property_enum_identifier(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **identifier) { EnumPropertyItem *item= NULL; diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 7de418108ed..b185d8f8961 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -32,6 +32,17 @@ #include "rna_internal.h" +EnumPropertyItem property_unit_items[] = { + {PROP_UNIT_NONE, "NONE", 0, "None", ""}, + {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""}, + {PROP_UNIT_AREA, "AREA", 0, "Area", ""}, + {PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""}, + {PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""}, + {PROP_UNIT_TIME, "TIME", 0, "Time", ""}, + {PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""}, + {PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME #include "BLI_ghash.h" @@ -926,16 +937,6 @@ static void rna_def_property(BlenderRNA *brna) {PROP_LAYER, "LAYER", 0, "Layer", ""}, {PROP_LAYER_MEMBER, "LAYER_MEMBERSHIP", 0, "Layer Membership", ""}, {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem unit_items[] = { - {PROP_UNIT_NONE, "NONE", 0, "None", ""}, - {PROP_UNIT_LENGTH, "LENGTH", 0, "Length", ""}, - {PROP_UNIT_AREA, "AREA", 0, "Area", ""}, - {PROP_UNIT_VOLUME, "VOLUME", 0, "Volume", ""}, - {PROP_UNIT_ROTATION, "ROTATION", 0, "Rotation", ""}, - {PROP_UNIT_TIME, "TIME", 0, "Time", ""}, - {PROP_UNIT_VELOCITY, "VELOCITY", 0, "Velocity", ""}, - {PROP_UNIT_ACCELERATION, "ACCELERATION", 0, "Acceleration", ""}, - {0, NULL, 0, NULL, NULL}}; srna= RNA_def_struct(brna, "Property", NULL); RNA_def_struct_ui_text(srna, "Property Definition", "RNA property definition."); @@ -978,7 +979,7 @@ static void rna_def_property(BlenderRNA *brna) prop= RNA_def_property(srna, "unit", PROP_ENUM, PROP_NONE); RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_enum_items(prop, unit_items); + RNA_def_property_enum_items(prop, property_unit_items); RNA_def_property_enum_funcs(prop, "rna_Property_unit_get", NULL, NULL); RNA_def_property_ui_text(prop, "Unit", "Type of units for this property."); |