diff options
Diffstat (limited to 'source/blender/editors/animation/keyingsets.c')
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 108 |
1 files changed, 39 insertions, 69 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index abd57e35586..bc066b074ea 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -127,7 +127,7 @@ static int add_default_keyingset_exec (bContext *C, wmOperator *UNUSED(op)) keyingflag = ANIM_get_keyframing_flags(scene, 0); /* call the API func, and set the active keyingset index */ - BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag); + BKE_keyingset_add(&scene->keyingsets, NULL, NULL, flag, keyingflag); scene->active_keyingset= BLI_countlist(&scene->keyingsets); @@ -317,7 +317,7 @@ static int add_keyingset_button_exec (bContext *C, wmOperator *op) keyingflag |= INSERTKEY_XYZ2RGB; /* call the API func, and set the active keyingset index */ - ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", flag, keyingflag); + ks= BKE_keyingset_add(&scene->keyingsets, "ButtonKeyingSet", "Button Keying Set", flag, keyingflag); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } @@ -468,22 +468,26 @@ void ANIM_OT_keyingset_button_remove (wmOperatorType *ot) static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED(event)) { + uiPopupMenu *pup; + uiLayout *layout; + /* call the menu, which will call this operator again, hence the canceled */ - ANIM_keying_sets_menu_setup(C, op->type->name, "ANIM_OT_keying_set_active_set"); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); + uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type"); + uiPupMenuEnd(C, pup); + return OPERATOR_CANCELLED; } static int keyingset_active_menu_exec (bContext *C, wmOperator *op) { - Scene *scene= CTX_data_scene(C); - int type= RNA_int_get(op->ptr, "type"); + Scene *scene = CTX_data_scene(C); + int type = RNA_enum_get(op->ptr, "type"); + + /* If type == 0, it will deselect any active keying set. */ + scene->active_keyingset = type; - /* simply set the scene's active keying set index, unless the type == 0 - * (i.e. which happens if we want the current active to be maintained) - */ - if (type) - scene->active_keyingset= type; - /* send notifiers */ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL); @@ -492,6 +496,8 @@ static int keyingset_active_menu_exec (bContext *C, wmOperator *op) void ANIM_OT_keying_set_active_set (wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name= "Set Active Keying Set"; ot->idname= "ANIM_OT_keying_set_active_set"; @@ -504,10 +510,10 @@ void ANIM_OT_keying_set_active_set (wmOperatorType *ot) /* flags */ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - /* keyingset to use - * - here the type is int not enum, since many of the indices here are determined dynamically - */ - RNA_def_int(ot->srna, "type", 0, INT_MIN, INT_MAX, "Keying Set Number", "Index (determined internally) of the Keying Set to use", 0, 1); + /* keyingset to use (dynamic enum) */ + prop= RNA_def_enum(ot->srna, "type", DummyRNA_DEFAULT_items, 0, "Keying Set", "The Keying Set to use"); + RNA_def_enum_funcs(prop, ANIM_keying_sets_enum_itemf); +/* RNA_def_property_flag(prop, PROP_HIDDEN);*/ } /* ******************************************* */ @@ -546,10 +552,10 @@ KeyingSet *ANIM_builtin_keyingset_get_named (KeyingSet *prevKS, const char name[ first= prevKS->next; else first= builtin_keyingsets.first; - + /* loop over KeyingSets checking names */ for (ks= first; ks; ks= ks->next) { - if (strcmp(name, ks->name) == 0) + if (strcmp(name, ks->idname) == 0) return ks; } @@ -572,11 +578,14 @@ void ANIM_keyingset_info_register (KeyingSetInfo *ksi) /* create a new KeyingSet * - inherit name and keyframing settings from the typeinfo */ - ks = BKE_keyingset_add(&builtin_keyingsets, ksi->name, 1, ksi->keyingflag); + ks = BKE_keyingset_add(&builtin_keyingsets, ksi->idname, ksi->name, 1, ksi->keyingflag); /* link this KeyingSet with its typeinfo */ memcpy(&ks->typeinfo, ksi->idname, sizeof(ks->typeinfo)); + /* Copy description... */ + BLI_strncpy(ks->description, ksi->description, sizeof(ks->description)); + /* add type-info to the list */ BLI_addtail(&keyingset_type_infos, ksi); } @@ -717,23 +726,26 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p */ if (scene->active_keyingset) { /* active Keying Set */ - item_tmp.identifier= item_tmp.name= "Active Keying Set"; - item_tmp.value= i++; + item_tmp.identifier= "__ACTIVE__"; + item_tmp.name= "Active Keying Set"; + item_tmp.value= i; RNA_enum_item_add(&item, &totitem, &item_tmp); /* separator */ RNA_enum_item_add_separator(&item, &totitem); } - else - i++; - + + i++; + /* user-defined Keying Sets * - these are listed in the order in which they were defined for the active scene */ if (scene->keyingsets.first) { for (ks= scene->keyingsets.first; ks; ks= ks->next, i++) { if (ANIM_keyingset_context_ok_poll(C, ks)) { - item_tmp.identifier= item_tmp.name= ks->name; + item_tmp.identifier = ks->idname; + item_tmp.name = ks->name; + item_tmp.description = ks->description; item_tmp.value= i; RNA_enum_item_add(&item, &totitem, &item_tmp); } @@ -748,7 +760,9 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p for (ks= builtin_keyingsets.first; ks; ks= ks->next, i--) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) { - item_tmp.identifier= item_tmp.name= ks->name; + item_tmp.identifier = ks->idname; + item_tmp.name = ks->name; + item_tmp.description = ks->description; item_tmp.value= i; RNA_enum_item_add(&item, &totitem, &item_tmp); } @@ -760,50 +774,6 @@ EnumPropertyItem *ANIM_keying_sets_enum_itemf (bContext *C, PointerRNA *UNUSED(p return item; } -/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ -void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op_name[]) -{ - Scene *scene= CTX_data_scene(C); - KeyingSet *ks; - uiPopupMenu *pup; - uiLayout *layout; - int i = 0; - - pup= uiPupMenuBegin(C, title, ICON_NONE); - layout= uiPupMenuLayout(pup); - - /* active Keying Set - * - only include entry if it exists - */ - if (scene->active_keyingset) { - uiItemEnumO(layout, op_name, "Active Keying Set", ICON_NONE, "type", i++); - uiItemS(layout); - } - else - i++; - - /* user-defined Keying Sets - * - these are listed in the order in which they were defined for the active scene - */ - if (scene->keyingsets.first) { - for (ks= scene->keyingsets.first; ks; ks=ks->next, i++) { - if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i); - } - uiItemS(layout); - } - - /* builtin Keying Sets */ - i= -1; - for (ks= builtin_keyingsets.first; ks; ks=ks->next, i--) { - /* only show KeyingSet if context is suitable */ - if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemEnumO(layout, op_name, ks->name, ICON_NONE, "type", i); - } - - uiPupMenuEnd(C, pup); -} - /* ******************************************* */ /* KEYFRAME MODIFICATION */ |