[Bf-taskforce25] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21540] branches/blender2.5/blender/source /blender: 2.5: Couple of small fun features
Dalai Felinto
dfelinto at gmail.com
Sun Jul 12 06:26:34 CEST 2009
Hi Brecht,
> * 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.
That's definitively super cool (I'll use it a lot). However it
completely messed up with the line numbers display.
Cheers,
Dalai
2009/7/11 Brecht Van Lommel <brecht at blender.org>:
> Revision: 21540
> http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21540
> Author: blendix
> Date: 2009-07-12 04:06:15 +0200 (Sun, 12 Jul 2009)
>
> Log Message:
> -----------
> 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.
>
> Modified Paths:
> --------------
> branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
> branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
> branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
> branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h
> branches/blender2.5/blender/source/blender/editors/animation/drivers.c
> branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
> branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
> branches/blender2.5/blender/source/blender/editors/interface/interface.c
> branches/blender2.5/blender/source/blender/editors/interface/interface_anim.c
> branches/blender2.5/blender/source/blender/editors/interface/interface_handlers.c
> branches/blender2.5/blender/source/blender/editors/interface/interface_intern.h
> branches/blender2.5/blender/source/blender/editors/interface/interface_regions.c
> branches/blender2.5/blender/source/blender/editors/interface/interface_widgets.c
> branches/blender2.5/blender/source/blender/editors/space_buttons/space_buttons.c
> branches/blender2.5/blender/source/blender/editors/space_outliner/outliner.c
> branches/blender2.5/blender/source/blender/editors/space_text/text_draw.c
> branches/blender2.5/blender/source/blender/editors/space_text/text_intern.h
> branches/blender2.5/blender/source/blender/editors/space_text/text_ops.c
> branches/blender2.5/blender/source/blender/editors/space_text/text_python.c
> branches/blender2.5/blender/source/blender/editors/transform/transform.h
> branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
> branches/blender2.5/blender/source/blender/makesdna/DNA_space_types.h
> branches/blender2.5/blender/source/blender/makesdna/DNA_userdef_types.h
> branches/blender2.5/blender/source/blender/makesrna/intern/rna_space.c
> branches/blender2.5/blender/source/blender/makesrna/intern/rna_userdef.c
>
> Modified: branches/blender2.5/blender/source/blender/blenfont/BLF_api.h
> ===================================================================
> --- branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/blenfont/BLF_api.h 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -70,7 +70,14 @@
> float BLF_width(char *str);
> float BLF_height(char *str);
>
> +
> /*
> + * For fixed width fonts only, returns the width of a
> + * character.
> + */
> +float BLF_fixed_width(void);
> +
> +/*
> * and this two function return the width and height
> * of the string, using the default font and both value
> * are multiplied by the aspect of the font.
>
> Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/blenfont/intern/blf.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/blenfont/intern/blf.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -398,6 +398,16 @@
> return(0.0f);
> }
>
> +float BLF_fixed_width(void)
> +{
> + FontBLF *font;
> +
> + font= global_font[global_font_cur];
> + if (font)
> + return(blf_font_fixed_width(font));
> + return(0.0f);
> +}
> +
> float BLF_width_default(char *str)
> {
> FontBLF *font;
>
> Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_font.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -274,6 +274,27 @@
> return((box.ymax - box.ymin) * font->aspect);
> }
>
> +float blf_font_fixed_width(FontBLF *font)
> +{
> + GlyphBLF *g;
> + FT_UInt glyph_index;
> + unsigned int c = ' ';
> +
> + if (!font->glyph_cache)
> + return 0.0f;
> +
> + glyph_index= FT_Get_Char_Index(font->face, c);
> + g= blf_glyph_search(font->glyph_cache, c);
> + if (!g)
> + g= blf_glyph_add(font, glyph_index, c);
> +
> + /* if we don't find the glyph. */
> + if (!g)
> + return 0.0f;
> +
> + return g->advance;
> +}
> +
> void blf_font_free(FontBLF *font)
> {
> GlyphCacheBLF *gc;
>
> Modified: branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h
> ===================================================================
> --- branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/blenfont/intern/blf_internal.h 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -48,6 +48,7 @@
> void blf_font_boundbox(FontBLF *font, char *str, rctf *box);
> float blf_font_width(FontBLF *font, char *str);
> float blf_font_height(FontBLF *font, char *str);
> +float blf_font_fixed_width(FontBLF *font);
> void blf_font_free(FontBLF *font);
>
> GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi);
>
> Modified: branches/blender2.5/blender/source/blender/editors/animation/drivers.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/animation/drivers.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/editors/animation/drivers.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -135,7 +135,7 @@
> /* 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 @@
>
> /* 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 @@
> 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);
> }
>
> Modified: branches/blender2.5/blender/source/blender/editors/animation/keyframing.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/editors/animation/keyframing.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -1426,6 +1426,22 @@
> }
>
> /* ******************************************* */
> +/* AUTO KEYFRAME */
> +
> +int autokeyframe_cfra_can_key(Scene *scene, ID *id)
> +{
> + float cfra= (float)CFRA; // XXX for now, this will do
> +
> + /* only filter if auto-key mode requires this */
> + if (IS_AUTOKEY_ON(scene) == 0)
> + return 0;
> + else if (IS_AUTOKEY_MODE(scene, NORMAL))
> + return 1;
> + else
> + return id_frame_has_keyframe(id, cfra, ANIMFILTER_KEYS_LOCAL);
> +}
> +
> +/* ******************************************* */
> /* KEYFRAME DETECTION */
>
> /* --------------- API/Per-Datablock Handling ------------------- */
>
> Modified: branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/editors/include/ED_keyframing.h 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -30,6 +30,7 @@
>
> struct ListBase;
> struct ID;
> +struct Scene;
>
> struct KeyingSet;
>
> @@ -168,7 +169,7 @@
> /* Main Driver Management API calls:
> * Add a new driver for the specified property on the given ID block
> */
> -short ANIM_add_driver (struct ID *id, const char rna_path[], int array_index, short flag);
> +short ANIM_add_driver (struct ID *id, const char rna_path[], int array_index, short flag, int type);
>
> /* Main Driver Management API calls:
> * Remove the driver for the specified property on the given ID block (if available)
> @@ -197,6 +198,9 @@
> /* check if a flag is set for auto-keyframing (as userprefs only!) */
> #define IS_AUTOKEY_FLAG(flag) (U.autokey_flag & AUTOKEY_FLAG_##flag)
>
> +/* auto-keyframing feature - checks for whether anything should be done for the current frame */
> +int autokeyframe_cfra_can_key(struct Scene *scene, struct ID *id);
> +
> /* ************ Keyframe Checking ******************** */
>
> /* Lesser Keyframe Checking API call:
>
> Modified: branches/blender2.5/blender/source/blender/editors/interface/interface.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/editors/interface/interface.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -1312,8 +1312,10 @@
> BLI_strncpy(str, but->poin, maxlen);
> return;
> }
> + else if(ui_but_anim_expression_get(but, str, maxlen))
> + ; /* driver expression */
> else {
> - /* number */
> + /* number editing */
> double value;
>
> value= ui_get_but_val(but);
> @@ -1384,7 +1386,12 @@
> BLI_strncpy(but->poin, str, but->hardmax);
> return 1;
> }
> + else if(ui_but_anim_expression_set(but, str)) {
> + /* driver expression */
> + return 1;
> + }
> else {
> + /* number editing */
> double value;
>
> /* XXX 2.50 missing python api */
>
> Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_anim.c
> ===================================================================
> --- branches/blender2.5/blender/source/blender/editors/interface/interface_anim.c 2009-07-12 02:01:13 UTC (rev 21539)
> +++ branches/blender2.5/blender/source/blender/editors/interface/interface_anim.c 2009-07-12 02:06:15 UTC (rev 21540)
> @@ -10,6 +10,7 @@
> #include "DNA_screen_types.h"
>
> #include "BLI_listbase.h"
> +#include "BLI_string.h"
>
> #include "BKE_animsys.h"
> #include "BKE_context.h"
> @@ -27,51 +28,137 @@
>
> #include "interface_intern.h"
>
> -void ui_but_anim_flag(uiBut *but, float cfra)
> +static FCurve *ui_but_get_fcurve(uiBut *but, bAction **action, int *driven)
> {
> - but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN);
> -
> + FCurve *fcu= NULL;
> +
> + *driven= 0;
> +
> /* there must be some RNA-pointer + property combo for this button */
> - if (but->rnaprop && but->rnapoin.id.data &&
> + if(but->rnaprop && but->rnapoin.id.data &&
> RNA_property_animateable(&but->rnapoin, but->rnaprop))
> {
> AnimData *adt= BKE_animdata_from_id(but->rnapoin.id.data);
> - FCurve *fcu;
> char *path;
>
> - if (adt) {
> - if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
> + if(adt) {
> + if((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
> /* XXX this function call can become a performance bottleneck */
> path= RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
> -
> - if (path) {
> +
> + if(path) {
> /* animation takes priority over drivers */
> - if (adt->action && adt->action->curves.first) {
> + if(adt->action && adt->action->curves.first)
> fcu= list_find_fcurve(&adt->action->curves, path, but->rnaindex);
> -
> - if (fcu) {
> - but->flag |= UI_BUT_ANIMATED;
> -
> - if (fcurve_frame_has_keyframe(fcu, cfra, 0))
> - but->flag |= UI_BUT_ANIMATED_KEY;
> - }
> - }
>
> /* if not animated, check if driven */
> - if ((but->flag & UI_BUT_ANIMATED)==0 && (adt->drivers.first)) {
> + if(!fcu && (adt->drivers.first)) {
> fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
>
>
> @@ Diff output truncated at 10240 characters. @@
>
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
More information about the Bf-taskforce25
mailing list