diff options
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface.c | 16 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_anim.c | 77 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 9 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 30 | ||||
-rw-r--r-- | source/blender/editors/interface/resources.c | 36 |
6 files changed, 148 insertions, 21 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index a5ceb8bdb19..0dee7a3813a 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1721,6 +1721,10 @@ int ui_set_but_string(bContext *C, uiBut *but, const char *str) /* driver expression */ return 1; } + else if(str[0]=='#') { + /* shortcut to create new driver expression (versus immediate Py-execution) */ + return ui_but_anim_expression_create(but, str+1); + } else { /* number editing */ double value; @@ -3242,11 +3246,17 @@ void uiButSetUnitType(uiBut *but, const int unit_type) int uiButGetUnitType(uiBut *but) { - if(but->rnaprop) { - return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); + int ownUnit = (int)but->unit_type; + + /* own unit define always takes precidence over RNA provided, allowing for overriding + * default value provided in RNA in a few special cases (i.e. Active Keyframe in Graph Edit) + */ + // XXX: this doesn't allow clearing unit completely, though the same could be said for icons + if ((ownUnit != 0) || (but->rnaprop == NULL)) { + return ownUnit << 16; } else { - return ((int)but->unit_type)<<16; + return RNA_SUBTYPE_UNIT(RNA_property_subtype(but->rnaprop)); } } diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index d9691819b29..1113f90a652 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -30,6 +30,7 @@ #include <stdlib.h> #include <string.h> +#include "MEM_guardedalloc.h" #include "DNA_anim_types.h" #include "DNA_scene_types.h" @@ -37,15 +38,19 @@ #include "BLI_listbase.h" #include "BLI_string.h" +#include "BLI_utildefines.h" #include "BKE_context.h" +#include "BKE_animsys.h" #include "BKE_fcurve.h" - +#include "BKE_global.h" #include "ED_keyframing.h" #include "UI_interface.h" +#include "RNA_access.h" + #include "WM_api.h" #include "WM_types.h" @@ -108,7 +113,7 @@ int ui_but_anim_expression_set(uiBut *but, const char *str) if(fcu && driven) { driver= fcu->driver; - + if(driver && driver->type == DRIVER_TYPE_PYTHON) { BLI_strncpy(driver->expression, str, sizeof(driver->expression)); driver->flag |= DRIVER_FLAG_RECOMPILE; @@ -120,6 +125,74 @@ int ui_but_anim_expression_set(uiBut *but, const char *str) return 0; } +/* create new expression for button (i.e. a "scripted driver"), if it can be created... */ +int ui_but_anim_expression_create(uiBut *but, const char *str) +{ + bContext *C = but->block->evil_C; + ID *id; + FCurve *fcu; + char *path; + short ok=0; + + /* button must have RNA-pointer to a numeric-capable property */ + if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) { + if (G.f & G_DEBUG) + printf("ERROR: create expression failed - button has no RNA info attached\n"); + return 0; + } + + /* make sure we have animdata for this */ + // FIXME: until materials can be handled by depsgraph, don't allow drivers to be created for them + id = (ID *)but->rnapoin.id.data; + if ((id == NULL) || (GS(id->name)==ID_MA) || (GS(id->name)==ID_TE)) { + if (G.f & G_DEBUG) + printf("ERROR: create expression failed - invalid id-datablock for adding drivers (%p)\n", id); + return 0; + } + + /* get path */ + path = RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop); + + /* create driver */ + fcu = verify_driver_fcurve(id, path, but->rnaindex, 1); + if (fcu) { + ChannelDriver *driver= fcu->driver; + + if (driver) { + /* set type of driver */ + driver->type = DRIVER_TYPE_PYTHON; + + /* set the expression */ + // TODO: need some way of identifying variables used + BLI_strncpy(driver->expression, str, sizeof(driver->expression)); + + /* FIXME: for now, assume that + * - for expressions, users are likely to be using "frame" -> current frame" as a variable + * - driver_add_new_variable() adds a single-prop variable by default + */ + { + DriverVar *dvar; + DriverTarget *dtar; + + dvar = driver_add_new_variable(driver); + BLI_strncpy(dvar->name, "frame", sizeof(dvar->name)); + + dtar = &dvar->targets[0]; + dtar->id = (ID *)CTX_data_scene(C); // XXX: should we check that C is valid first? + dtar->rna_path = BLI_sprintfN("frame_current"); + } + + /* updates */ + driver->flag |= DRIVER_FLAG_RECOMPILE; + WM_event_add_notifier(C, NC_ANIMATION|ND_KEYFRAME, NULL); + } + } + + MEM_freeN(path); + + return ok; +} + void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) { ID *id; diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d7eba8c0ac7..7661fa5994b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1235,7 +1235,7 @@ static short test_special_char(char ch) case ':': case ';': case '\'': - case '\"': + case '\"': // " - an extra closing one for Aligorith's text editor case '<': case '>': case ',': @@ -4234,6 +4234,7 @@ static int ui_but_menu(bContext *C, uiBut *but) /* Keyframes */ if(but->flag & UI_BUT_ANIMATED_KEY) { + /* replace/delete keyfraemes */ if(length) { uiItemBooleanO(layout, "Replace Keyframes", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 1); uiItemBooleanO(layout, "Replace Single Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); @@ -4244,6 +4245,11 @@ static int ui_but_menu(bContext *C, uiBut *but) uiItemBooleanO(layout, "Replace Keyframe", ICON_NONE, "ANIM_OT_keyframe_insert_button", "all", 0); uiItemBooleanO(layout, "Delete Keyframe", ICON_NONE, "ANIM_OT_keyframe_delete_button", "all", 0); } + + /* keyframe settings */ + uiItemS(layout); + + } else if(but->flag & UI_BUT_DRIVEN); else if(is_anim) { @@ -4286,6 +4292,7 @@ static int ui_but_menu(bContext *C, uiBut *but) } /* Keying Sets */ + // TODO: check on modifyability of Keying Set when doing this if(is_anim) { uiItemS(layout); diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 40b98bebcd0..ebc8725ad5d 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -523,6 +523,7 @@ void ui_but_anim_add_keyingset(struct bContext *C); void ui_but_anim_remove_keyingset(struct bContext *C); int ui_but_anim_expression_get(uiBut *but, char *str, int maxlen); int ui_but_anim_expression_set(uiBut *but, const char *str); +int ui_but_anim_expression_create(uiBut *but, const char *str); void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra); #endif diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 67123476f06..d2cee11c755 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -33,6 +33,7 @@ #include "MEM_guardedalloc.h" +#include "DNA_anim_types.h" #include "DNA_key_types.h" #include "DNA_scene_types.h" #include "DNA_userdef_types.h" @@ -58,6 +59,7 @@ #include "ED_render.h" #include "RNA_access.h" +#include "RNA_enum_types.h" #include "WM_api.h" #include "WM_types.h" @@ -237,7 +239,7 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) { TemplateID *template= (TemplateID*)arg_litem; PointerRNA idptr= RNA_property_pointer_get(&template->ptr, template->prop); - ID *id= idptr.data, *newid; + ID *id= idptr.data; int event= GET_INT_FROM_POINTER(arg_event); switch(event) { @@ -287,17 +289,8 @@ static void template_id_cb(bContext *C, void *arg_litem, void *arg_event) WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene); } else { - if(id_copy(id, &newid, 0) && newid) { - /* copy animation actions too */ - BKE_copy_animdata_id_action(id); - /* us is 1 by convention, but RNA_property_pointer_set - will also incremement it, so set it to zero */ - newid->us= 0; - - /* assign copy */ - RNA_id_pointer_create(newid, &idptr); - RNA_property_pointer_set(&template->ptr, template->prop, idptr); - RNA_property_update(C, &template->ptr, template->prop); + if(id) { + id_single_user(C, id, &template->ptr, template->prop); } } } @@ -321,11 +314,13 @@ static const char *template_id_browse_tip(StructRNA *type) case ID_MA: return "Browse Material to be linked"; case ID_TE: return "Browse Texture to be linked"; case ID_IM: return "Browse Image to be linked"; - case ID_LA: return "Browse Lattice Data to be linked"; + case ID_LT: return "Browse Lattice Data to be linked"; + case ID_LA: return "Browse Lamp Data to be linked"; case ID_CA: return "Browse Camera Data to be linked"; case ID_WO: return "Browse World Settings to be linked"; case ID_SCR: return "Choose Screen lay-out"; case ID_TXT: return "Browse Text to be linked"; + case ID_SPK: return "Browse Speaker Data to be linked"; case ID_SO: return "Browse Sound to be linked"; case ID_AR: return "Browse Armature data to be linked"; case ID_AC: return "Browse Action to be linked"; @@ -2127,6 +2122,15 @@ static void list_item_row(bContext *C, uiLayout *layout, PointerRNA *ptr, Pointe //uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF); uiBlockSetEmboss(block, UI_EMBOSS); } + else if(itemptr->type == &RNA_KeyingSetPath) { + KS_Path *ksp = (KS_Path*)itemptr->data; + + /* icon needs to be the type of ID which is currently active */ + RNA_enum_icon_from_value(id_type_items, ksp->idtype, &icon); + + /* nothing else special to do... */ + uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */ + } else uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */ diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index e71f709f89b..692c8940a21 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -250,6 +250,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->wire; break; case TH_LAMP: cp= ts->lamp; break; + case TH_SPEAKER: + cp= ts->speaker; break; case TH_SELECT: cp= ts->select; break; case TH_ACTIVE: @@ -326,6 +328,8 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->handle_free; break; case TH_HANDLE_AUTO: cp= ts->handle_auto; break; + case TH_HANDLE_AUTOCLAMP: + cp= ts->handle_auto_clamped; break; case TH_HANDLE_VECT: cp= ts->handle_vect; break; case TH_HANDLE_ALIGN: @@ -334,11 +338,13 @@ const unsigned char *UI_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colo cp= ts->handle_sel_free; break; case TH_HANDLE_SEL_AUTO: cp= ts->handle_sel_auto; break; + case TH_HANDLE_SEL_AUTOCLAMP: + cp= ts->handle_sel_auto_clamped; break; case TH_HANDLE_SEL_VECT: cp= ts->handle_sel_vect; break; case TH_HANDLE_SEL_ALIGN: cp= ts->handle_sel_align; break; - + case TH_SYNTAX_B: cp= ts->syntaxb; break; case TH_SYNTAX_V: @@ -587,6 +593,7 @@ void ui_theme_init_default(void) SETCOLF(btheme->tv3d.grid, 0.251, 0.251, 0.251, 1.0); SETCOL(btheme->tv3d.wire, 0x0, 0x0, 0x0, 255); SETCOL(btheme->tv3d.lamp, 0, 0, 0, 40); + SETCOL(btheme->tv3d.speaker, 0, 0, 0, 255); SETCOL(btheme->tv3d.select, 241, 88, 0, 255); SETCOL(btheme->tv3d.active, 255, 170, 64, 255); SETCOL(btheme->tv3d.group, 8, 48, 8, 255); @@ -666,7 +673,9 @@ void ui_theme_init_default(void) SETCOL(btheme->tipo.handle_vertex, 0, 0, 0, 255); SETCOL(btheme->tipo.handle_vertex_select, 255, 133, 0, 255); - btheme->tipo.handle_vertex_size= 3; + SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); + SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); + btheme->tipo.handle_vertex_size= 4; SETCOL(btheme->tipo.ds_channel, 82, 96, 110, 255); SETCOL(btheme->tipo.ds_subchannel, 124, 137, 150, 255); @@ -1564,6 +1573,29 @@ void init_userdef_do_versions(void) } } + if (bmain->versionfile < 258 || (bmain->versionfile == 258 && bmain->subversionfile < 1)) { + bTheme *btheme; + + /* if new keyframes handle default is stuff "auto", make it "auto-clamped" instead */ + if (U.keyhandles_new == HD_AUTO) + U.keyhandles_new = HD_AUTO_ANIM; + + /* theme color additions */ + for (btheme= U.themes.first; btheme; btheme= btheme->next) { + /* auto-clamped handles -> based on auto */ + SETCOL(btheme->tipo.handle_auto_clamped, 0x99, 0x40, 0x30, 255); + SETCOL(btheme->tipo.handle_sel_auto_clamped, 0xf0, 0xaf, 0x90, 255); + } + } + + if (bmain->versionfile < 259 || (bmain->versionfile == 259 && bmain->subversionfile < 1)) { + bTheme *btheme; + + for(btheme= U.themes.first; btheme; btheme= btheme->next) { + btheme->tv3d.speaker[3] = 255; + } + } + /* GL Texture Garbage Collection (variable abused above!) */ if (U.textimeout == 0) { U.texcollectrate = 60; |