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-12 06:06:15 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2009-07-12 06:06:15 +0400
commit3116062a828e24ed2e91c219ab338a38030f2f42 (patch)
treefe77a0722deaee3afd521b4a596bbe5c1c827b2e /source/blender/editors/animation/drivers.c
parent8b9bb47a3faf753cb0ca2ec0e9c6a741c7af31c2 (diff)
2.5: Couple of small fun features
* Text window font size now supports full range 8-32, instead of just 12 and 15. I added BLF_fixed_width to get the character width of a fixed size font. * Buttons do undo push on change again. * Animated/Keyframe/Driver colors are now themable, with blend value to blend with original color. Set this to 0.5 now to give colors less constrast. * Fix tooltip popping up with RMB menu open, and missing redraw. * Autokeyframe now works for buttons. * Driver expressions can be edited in place in a button now. (still some refresh issues). * Also made python driver default for the Add Driver function in the RMB button. This way you don't have to open a Graph editor if you just want to type an expression. Also, the default expression then is the current value. * Tooltips now show some extra info, not sure what is good to have, but currently I added: * Shortcut key for operator buttons. * Python struct & property name for RNA buttons. * Expression for driven values. * Value for text/search/pointer buttons.
Diffstat (limited to 'source/blender/editors/animation/drivers.c')
-rw-r--r--source/blender/editors/animation/drivers.c37
1 files changed, 35 insertions, 2 deletions
diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index fdce0965ce3..849e2d2eede 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -135,7 +135,7 @@ FCurve *verify_driver_fcurve (ID *id, const char rna_path[], const int array_ind
/* Main Driver Management API calls:
* Add a new driver for the specified property on the given ID block
*/
-short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short flag)
+short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short flag, int type)
{
PointerRNA id_ptr, ptr;
PropertyRNA *prop;
@@ -150,6 +150,39 @@ short ANIM_add_driver (ID *id, const char rna_path[], int array_index, short fla
/* create F-Curve with Driver */
fcu= verify_driver_fcurve(id, rna_path, array_index, 1);
+
+ if(fcu && fcu->driver) {
+ fcu->driver->type= type;
+
+ /* fill in current value for python */
+ if(type == DRIVER_TYPE_PYTHON) {
+ PropertyType proptype= RNA_property_type(prop);
+ int array= RNA_property_array_length(prop);
+ char *expression= fcu->driver->expression;
+ int val, maxlen= sizeof(fcu->driver->expression);
+ float fval;
+
+ if(proptype == PROP_BOOLEAN) {
+ if(!array) val= RNA_property_boolean_get(&ptr, prop);
+ else val= RNA_property_boolean_get_index(&ptr, prop, array_index);
+
+ BLI_strncpy(expression, (val)? "True": "False", maxlen);
+ }
+ else if(proptype == PROP_INT) {
+ if(!array) val= RNA_property_int_get(&ptr, prop);
+ else val= RNA_property_int_get_index(&ptr, prop, array_index);
+
+ BLI_snprintf(expression, maxlen, "%d", val);
+ }
+ else if(proptype == PROP_FLOAT) {
+ if(!array) fval= RNA_property_float_get(&ptr, prop);
+ else fval= RNA_property_float_get_index(&ptr, prop, array_index);
+
+ BLI_snprintf(expression, maxlen, "%.3f", fval);
+ }
+
+ }
+ }
/* done */
return (fcu != NULL);
@@ -217,7 +250,7 @@ static int add_driver_button_exec (bContext *C, wmOperator *op)
length= 1;
for (a=0; a<length; a++)
- success+= ANIM_add_driver(ptr.id.data, path, index+a, 0);
+ success+= ANIM_add_driver(ptr.id.data, path, index+a, 0, DRIVER_TYPE_PYTHON);
MEM_freeN(path);
}