diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_idprop.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idprop.c | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/sequencer_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/imbuf/intern/jp2.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 107 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal_types.h | 4 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 8 |
9 files changed, 124 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 1980ba78c86..9c7460851cb 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -117,7 +117,7 @@ int IDP_InsertToGroup(struct IDProperty *group, struct IDProperty *previous, */ void IDP_RemFromGroup(struct IDProperty *group, struct IDProperty *prop); -IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, char *name); +IDProperty *IDP_GetPropertyFromGroup(struct IDProperty *prop, const char *name); /*Get an iterator to iterate over the members of an id property group. Note that this will automatically free the iterator once iteration is complete; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index 3cff82f522a..7e081982f24 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -442,7 +442,7 @@ void IDP_RemFromGroup(IDProperty *group, IDProperty *prop) BLI_remlink(&group->data.group, prop); } -IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, char *name) +IDProperty *IDP_GetPropertyFromGroup(IDProperty *prop, const char *name) { IDProperty *loop; for (loop=prop->data.group.first; loop; loop=loop->next) { diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 51c38ee859f..b9f80946345 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1355,15 +1355,15 @@ static void ui_get_but_string_unit(uiBut *but, char *str, int len_max, double va Scene *scene= CTX_data_scene((bContext *)but->block->evil_C); int do_split= scene->unit.flag & USER_UNIT_OPT_SPLIT; int unit_type= RNA_SUBTYPE_UNIT_VALUE(RNA_property_subtype(but->rnaprop)); - int precission= but->a2; + int precision= but->a2; if(scene->unit.scale_length<0.0001) scene->unit.scale_length= 1.0; // XXX do_versions /* Sanity checks */ - if(precission>4) precission= 4; - else if(precission==0) precission= 2; + if(precision>4) precision= 4; + else if(precision==0) precision= 2; - bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precission, scene->unit.system, unit_type, do_split, pad); + bUnit_AsString(str, len_max, ui_get_but_scale_unit(but, value), precision, scene->unit.system, unit_type, do_split, pad); } static float ui_get_but_step_unit(uiBut *but, double value, float step_default) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 80c1ed2fe95..56c9165c6a1 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -525,7 +525,7 @@ static void draw_shadedstrip(Sequence *seq, char *col, float x1, float y1, float /* Draw a sequence strip, bounds check alredy made ARegion is currently only used to get the windows width in pixels -so wave file sample drawing precission is zoom adjusted +so wave file sample drawing precision is zoom adjusted */ static void draw_seq_strip(Scene *scene, ARegion *ar, SpaceSeq *sseq, Sequence *seq, int outline_tint, float pixelx) { diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 339dc830016..23cd6f0c7d9 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2234,7 +2234,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E if(G.f & (G_RENDER_OGL|G_RENDER_SHADOW)) return; - /* make the precission of the pronted value proportionate to the gridsize */ + /* make the precision of the pronted value proportionate to the gridsize */ if (grid < 0.01f) strcpy(conv_float, "%.6f"); diff --git a/source/blender/imbuf/intern/jp2.c b/source/blender/imbuf/intern/jp2.c index 2583a155d6a..a6591adfff1 100644 --- a/source/blender/imbuf/intern/jp2.c +++ b/source/blender/imbuf/intern/jp2.c @@ -91,7 +91,7 @@ void info_callback(const char *msg, void *client_data) { struct ImBuf *imb_jp2_decode(unsigned char *mem, int size, int flags) { struct ImBuf *ibuf = 0; - int use_float = 0; /* for precissions higher then 8 use float */ + int use_float = 0; /* for precision higher then 8 use float */ unsigned char *rect= NULL; float *rect_float= NULL; diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 422c4d9befe..155f2ff594d 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -190,6 +190,29 @@ PointerRNA rna_pointer_inherit_refine(PointerRNA *ptr, StructRNA *type, void *da /* ID Properties */ +/* return a UI local ID prop definition for this prop */ +IDProperty *rna_idproperty_ui(PropertyRNA *prop) +{ + IDProperty *idprop; + + for(idprop= ((IDProperty *)prop)->prev; idprop; idprop= idprop->prev) { + if (strcmp(RNA_IDP_UI, idprop->name)==0) + break; + } + + if(idprop==NULL) { + for(idprop= ((IDProperty *)prop)->next; idprop; idprop= idprop->next) { + if (strcmp(RNA_IDP_UI, idprop->name)==0) + break; + } + } + + if (idprop) + return IDP_GetPropertyFromGroup(idprop, ((IDProperty *)prop)->name); + + return NULL; +} + IDProperty *RNA_struct_idproperties(PointerRNA *ptr, int create) { StructRNA *type= ptr->type; @@ -396,8 +419,17 @@ static const char *rna_ensure_property_description(PropertyRNA *prop) { if(prop->magic == RNA_MAGIC) return prop->description; - else + else { + /* attempt to get the local ID values */ + IDProperty *idp_ui= rna_idproperty_ui(prop); + + if(idp_ui) { /* TODO, type checking on ID props */ + IDProperty *item= IDP_GetPropertyFromGroup(idp_ui, "description"); + return item ? ((IDProperty*)prop)->name : item->data.pointer; + } + return ((IDProperty*)prop)->name; /* XXX - not correct */ + } } static const char *rna_ensure_property_name(PropertyRNA *prop) @@ -668,6 +700,22 @@ void RNA_property_int_range(PointerRNA *ptr, PropertyRNA *prop, int *hardmin, in { IntPropertyRNA *iprop= (IntPropertyRNA*)rna_ensure_property(prop); + if(prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + IDProperty *idp_ui= rna_idproperty_ui(prop); + IDProperty *item; + + if(idp_ui) { /* TODO, type checking on ID props */ + item= IDP_GetPropertyFromGroup(idp_ui, "min"); + *hardmin= item ? item->data.val : INT_MIN; + + item= IDP_GetPropertyFromGroup(idp_ui, "max"); + *hardmax= item ? item->data.val : INT_MAX; + + return; + } + } + if(iprop->range) { iprop->range(ptr, hardmin, hardmax); } @@ -682,6 +730,25 @@ void RNA_property_int_ui_range(PointerRNA *ptr, PropertyRNA *prop, int *softmin, IntPropertyRNA *iprop= (IntPropertyRNA*)rna_ensure_property(prop); int hardmin, hardmax; + if(prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + IDProperty *idp_ui= rna_idproperty_ui(prop); + IDProperty *item; + + if(idp_ui) { /* TODO, type checking on ID props */ + item= IDP_GetPropertyFromGroup(idp_ui, "soft_min"); + *softmin= item ? item->data.val : INT_MIN; + + item= IDP_GetPropertyFromGroup(idp_ui, "soft_max"); + *softmax= item ? item->data.val : INT_MAX; + + item= IDP_GetPropertyFromGroup(idp_ui, "step"); + *step= item ? item->data.val : 1; + + return; + } + } + if(iprop->range) { iprop->range(ptr, &hardmin, &hardmax); *softmin= MAX2(iprop->softmin, hardmin); @@ -699,6 +766,22 @@ void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin { FloatPropertyRNA *fprop= (FloatPropertyRNA*)rna_ensure_property(prop); + if(prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + IDProperty *idp_ui= rna_idproperty_ui(prop); + IDProperty *item; + + if(idp_ui) { /* TODO, type checking on ID props */ + item= IDP_GetPropertyFromGroup(idp_ui, "min"); + *hardmin= item ? *(double*)&item->data.val : FLT_MIN; + + item= IDP_GetPropertyFromGroup(idp_ui, "max"); + *hardmax= item ? *(double*)&item->data.val : FLT_MAX; + + return; + } + } + if(fprop->range) { fprop->range(ptr, hardmin, hardmax); } @@ -713,6 +796,28 @@ void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *soft FloatPropertyRNA *fprop= (FloatPropertyRNA*)rna_ensure_property(prop); float hardmin, hardmax; + if(prop->magic != RNA_MAGIC) { + /* attempt to get the local ID values */ + IDProperty *idp_ui= rna_idproperty_ui(prop); + IDProperty *item; + + if(idp_ui) { /* TODO, type checking on ID props */ + item= IDP_GetPropertyFromGroup(idp_ui, "soft_min"); + *softmin= item ? *(double*)&item->data.val : FLT_MIN; + + item= IDP_GetPropertyFromGroup(idp_ui, "soft_max"); + *softmax= item ? *(double*)&item->data.val : FLT_MAX; + + item= IDP_GetPropertyFromGroup(idp_ui, "step"); + *step= item ? *(double*)&item->data.val : 1.0f; + + item= IDP_GetPropertyFromGroup(idp_ui, "precision"); + *precision= item ? *(double*)&item->data.val : 3.0f; + + return; + } + } + if(fprop->range) { fprop->range(ptr, &hardmin, &hardmax); *softmin= MAX2(fprop->softmin, hardmin); diff --git a/source/blender/makesrna/intern/rna_internal_types.h b/source/blender/makesrna/intern/rna_internal_types.h index db2063b899c..46ed1fa055f 100644 --- a/source/blender/makesrna/intern/rna_internal_types.h +++ b/source/blender/makesrna/intern/rna_internal_types.h @@ -47,6 +47,10 @@ struct GHash; #define RNA_MAX_ARRAY_DIMENSION 3 + +/* store local properties here */ +#define RNA_IDP_UI "_RNA_UI" + /* Function Callbacks */ typedef void (*UpdateFunc)(struct bContext *C, struct PointerRNA *ptr); diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index ba268201b81..d12de5f2e46 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -3252,9 +3252,10 @@ PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) { - static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "default", NULL}; + static char *kwlist[] = {"attr", "name", "description", "min", "max", "soft_min", "soft_max", "step", "precision", "default", NULL}; char *id=NULL, *name="", *description=""; - float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, def=0.0f; + float min=-FLT_MAX, max=FLT_MAX, soft_min=-FLT_MAX, soft_max=FLT_MAX, step=3, def=0.0f; + int precision= 1; PropertyRNA *prop; StructRNA *srna; @@ -3269,10 +3270,11 @@ PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) } else if(srna) { - if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffff:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &def)) + if (!PyArg_ParseTupleAndKeywords(args, kw, "s|ssfffffif:FloatProperty", kwlist, &id, &name, &description, &min, &max, &soft_min, &soft_max, &step, &precision, &def)) return NULL; prop= RNA_def_float(srna, id, def, min, max, name, description, soft_min, soft_max); + RNA_def_property_ui_range(prop, min, max, step, precision); RNA_def_property_duplicate_pointers(prop); Py_RETURN_NONE; } |