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:
authorCampbell Barton <ideasman42@gmail.com>2010-02-03 02:03:56 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-03 02:03:56 +0300
commitfc123a40d3afd699005cd90d46cf205a200a79fb (patch)
tree577e358e52a3f9513eac949f255f1a1e648203e1 /source/blender/makesrna
parent95bfbd470eeb1ccb3f69b5ba63875772860acdbf (diff)
patch [#20889] Support "unit"s for FloatProperty
from Martin Bürbaum (pontiac) (with own minor changes)
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/makesrna/RNA_enum_types.h2
-rw-r--r--source/blender/makesrna/intern/rna_access.c11
-rw-r--r--source/blender/makesrna/intern/rna_rna.c23
4 files changed, 14 insertions, 23 deletions
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index 8559f30bfeb..61197b2296e 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -649,7 +649,6 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft
int RNA_enum_identifier(EnumPropertyItem *item, const int value, const char **identifier);
int RNA_enum_bitflag_identifiers(EnumPropertyItem *item, const int value, const char **identifier);
int RNA_enum_name(EnumPropertyItem *item, const int value, const char **name);
-int RNA_enum_value(EnumPropertyItem *item, const char *name, int *r_value);
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);
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h
index 14b2f0c561e..3e07896d760 100644
--- a/source/blender/makesrna/RNA_enum_types.h
+++ b/source/blender/makesrna/RNA_enum_types.h
@@ -77,6 +77,8 @@ extern EnumPropertyItem keymap_propvalue_items[];
extern EnumPropertyItem wm_report_items[];
+extern EnumPropertyItem property_unit_items[];
+
struct bContext;
struct PointerRNA;
EnumPropertyItem *rna_TransformOrientation_itemf(struct bContext *C, struct PointerRNA *ptr, int *free);
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.");