From a80b7d612947e1d26b10165a37bb603dae527afd Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Thu, 8 Mar 2012 14:04:06 +0000 Subject: =?UTF-8?q?Fixing=20several=20issues=20with=20keyingsets:=20*Add?= =?UTF-8?q?=20a=20new=20idname=20to=20keyingsets,=20keeping=20name=20as=20?= =?UTF-8?q?label-only=20(using=20same=20string=20for=20both=20made=20looku?= =?UTF-8?q?p=20fail=20when=20using=20i18n=20other=20than=20english,=20as?= =?UTF-8?q?=20it=20tried=20to=20compare=20an=20untranslated=20static=20str?= =?UTF-8?q?ing=20id=20against=20a=20translated=20RNA=20name).=20Also=20add?= =?UTF-8?q?ing=20a=20description=20string=20(can=20be=20helpful=20with=20c?= =?UTF-8?q?ustom=20keyingsets,=20imho).=20*Fixed=20a=20few=20other=20bugs?= =?UTF-8?q?=20related=20to=20that=20area=20(namely,=20you=20can=E2=80=99t?= =?UTF-8?q?=20deselect=20current=20keyingset=20from=20the=20shift-ctrl-alt?= =?UTF-8?q?-I=20popup=20menu,=20and=20insert/delete=20key=20ops=20were=20u?= =?UTF-8?q?sing=20a=20rather=20strange=20way=20to=20get=20chosen=20custom?= =?UTF-8?q?=20keyingset=E2=80=A6).=20*Fixed=20UI=20code=20so=20that=20it?= =?UTF-8?q?=20always=20uses=20(RNA)=20enum,=20and=20simplified=20menu-crea?= =?UTF-8?q?tion=20code.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- release/scripts/startup/bl_operators/anim.py | 9 +- release/scripts/startup/bl_ui/properties_scene.py | 3 +- release/scripts/startup/keyingsets_builtins.py | 49 +++++++++- source/blender/blenkernel/BKE_animsys.h | 2 +- source/blender/blenkernel/intern/anim_sys.c | 13 ++- source/blender/blenloader/intern/readfile.c | 14 +++ source/blender/editors/animation/keyframing.c | 14 ++- source/blender/editors/animation/keyingsets.c | 108 ++++++++------------- source/blender/editors/include/ED_keyframing.h | 9 +- .../blender/editors/space_outliner/outliner_edit.c | 2 +- source/blender/makesdna/DNA_anim_types.h | 2 + source/blender/makesrna/intern/rna_animation.c | 48 +++++++-- source/blender/makesrna/intern/rna_scene.c | 7 +- 13 files changed, 177 insertions(+), 103 deletions(-) diff --git a/release/scripts/startup/bl_operators/anim.py b/release/scripts/startup/bl_operators/anim.py index d26a7728af1..2689cfda8eb 100644 --- a/release/scripts/startup/bl_operators/anim.py +++ b/release/scripts/startup/bl_operators/anim.py @@ -67,15 +67,16 @@ class ANIM_OT_keying_set_export(Operator): scene = context.scene ks = scene.keying_sets.active - f.write("# Keying Set: %s\n" % ks.name) + f.write("# Keying Set: %s\n" % ks.bl_idname) f.write("import bpy\n\n") - # XXX, why not current scene? - f.write("scene= bpy.data.scenes[0]\n\n") + f.write("scene = bpy.context.scene\n\n") # Add KeyingSet and set general settings f.write("# Keying Set Level declarations\n") - f.write("ks= scene.keying_sets.new(name=\"%s\")\n" % ks.name) + f.write("ks = scene.keying_sets.new(idname=\"%s\", name=\"%s\")\n" + "" % (ks.bl_idname, ks.bl_label)) + f.write("ks.bl_description = \"%s\"\n" % ks.bl_description) if not ks.is_path_absolute: f.write("ks.is_path_absolute = False\n") diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py index 7879f15270a..1c78549c086 100644 --- a/release/scripts/startup/bl_ui/properties_scene.py +++ b/release/scripts/startup/bl_ui/properties_scene.py @@ -115,7 +115,8 @@ class SCENE_PT_keying_sets(SceneButtonsPanel, Panel): row = layout.row() col = row.column() - col.prop(ks, "name") + col.prop(ks, "bl_label") + col.prop(ks, "bl_description") subcol = col.column() subcol.operator_context = 'INVOKE_DEFAULT' diff --git a/release/scripts/startup/keyingsets_builtins.py b/release/scripts/startup/keyingsets_builtins.py index 1caf7c43983..26525bd2ff2 100644 --- a/release/scripts/startup/keyingsets_builtins.py +++ b/release/scripts/startup/keyingsets_builtins.py @@ -38,8 +38,20 @@ from bpy.types import KeyingSetInfo # Built-In KeyingSets +# "Defines" +# Keep these in sync with those in ED_keyframing.h! +ANIM_KS_LOCATION_ID = "Location" +ANIM_KS_ROTATION_ID = "Rotation" +ANIM_KS_SCALING_ID = "Scaling" +ANIM_KS_LOC_ROT_SCALE_ID = "LocRotScale" +ANIM_KS_AVAILABLE_ID = "Available" +ANIM_KS_WHOLE_CHARACTER_ID = "Whole Character" + + # Location class BUILTIN_KSI_Location(KeyingSetInfo): + """Insert a keyframe on each of the three location channels""" + bl_idname = ANIM_KS_LOCATION_ID bl_label = "Location" # poll - use predefined callback for selected bones/objects @@ -54,6 +66,8 @@ class BUILTIN_KSI_Location(KeyingSetInfo): # Rotation class BUILTIN_KSI_Rotation(KeyingSetInfo): + """Insert a keyframe on each of the rotation channels""" + bl_idname = ANIM_KS_ROTATION_ID bl_label = "Rotation" # poll - use predefined callback for selected bones/objects @@ -62,12 +76,14 @@ class BUILTIN_KSI_Rotation(KeyingSetInfo): # iterator - use callback for selected bones/objects iterator = keyingsets_utils.RKS_ITER_selected_item - # generator - use callback for location + # generator - use callback for rotation generate = keyingsets_utils.RKS_GEN_rotation # Scale class BUILTIN_KSI_Scaling(KeyingSetInfo): + """Insert a keyframe on each of the scale channels""" + bl_idname = ANIM_KS_SCALING_ID bl_label = "Scaling" # poll - use predefined callback for selected bones/objects @@ -76,7 +92,7 @@ class BUILTIN_KSI_Scaling(KeyingSetInfo): # iterator - use callback for selected bones/objects iterator = keyingsets_utils.RKS_ITER_selected_item - # generator - use callback for location + # generator - use callback for scaling generate = keyingsets_utils.RKS_GEN_scaling # ------------ @@ -84,6 +100,7 @@ class BUILTIN_KSI_Scaling(KeyingSetInfo): # LocRot class BUILTIN_KSI_LocRot(KeyingSetInfo): + """Insert a keyframe on each of the location and rotation channels""" bl_label = "LocRot" # poll - use predefined callback for selected bones/objects @@ -102,6 +119,7 @@ class BUILTIN_KSI_LocRot(KeyingSetInfo): # LocScale class BUILTIN_KSI_LocScale(KeyingSetInfo): + """Insert a keyframe on each of the location and scale channels""" bl_label = "LocScale" # poll - use predefined callback for selected bones/objects @@ -120,6 +138,10 @@ class BUILTIN_KSI_LocScale(KeyingSetInfo): # LocRotScale class BUILTIN_KSI_LocRotScale(KeyingSetInfo): + """ + Insert a keyframe on each of the location, rotation and scale channels + """ + bl_idname = ANIM_KS_LOC_ROT_SCALE_ID bl_label = "LocRotScale" # poll - use predefined callback for selected bones/objects @@ -140,6 +162,7 @@ class BUILTIN_KSI_LocRotScale(KeyingSetInfo): # RotScale class BUILTIN_KSI_RotScale(KeyingSetInfo): + """Insert a keyframe on each of the rotation and scale channels""" bl_label = "RotScale" # poll - use predefined callback for selected bones/objects @@ -160,6 +183,10 @@ class BUILTIN_KSI_RotScale(KeyingSetInfo): # Location class BUILTIN_KSI_VisualLoc(KeyingSetInfo): + """ + Insert a keyframe on each of the location channels, taking into account + constraints and relationships effects + """ bl_label = "Visual Location" bl_options = {'INSERTKEY_VISUAL'} @@ -176,6 +203,10 @@ class BUILTIN_KSI_VisualLoc(KeyingSetInfo): # Rotation class BUILTIN_KSI_VisualRot(KeyingSetInfo): + """ + Insert a keyframe on each of the rotation channels, taking into account + constraints and relationships effects + """ bl_label = "Visual Rotation" bl_options = {'INSERTKEY_VISUAL'} @@ -192,6 +223,10 @@ class BUILTIN_KSI_VisualRot(KeyingSetInfo): # VisualLocRot class BUILTIN_KSI_VisualLocRot(KeyingSetInfo): + """ + Insert a keyframe on each of the location and rotation channels), + taking into account constraints and relationships effects + """ bl_label = "Visual LocRot" bl_options = {'INSERTKEY_VISUAL'} @@ -214,6 +249,8 @@ class BUILTIN_KSI_VisualLocRot(KeyingSetInfo): # Available class BUILTIN_KSI_Available(KeyingSetInfo): + """Insert a keyframe on each of the already existing F-Curves""" + bl_idname = ANIM_KS_AVAILABLE_ID bl_label = "Available" # poll - selected objects or selected object with animation data @@ -236,6 +273,11 @@ class BUILTIN_KSI_Available(KeyingSetInfo): # All properties that are likely to get animated in a character rig class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): + """ + Insert a keyframe for all properties that are likely to get animated in a + character rig (useful when blocking out a shot) + """ + bl_idname = ANIM_KS_WHOLE_CHARACTER_ID bl_label = "Whole Character" # these prefixes should be avoided, as they are not really bones @@ -379,6 +421,7 @@ class BUILTIN_KSI_WholeCharacter(KeyingSetInfo): # Delta Location class BUILTIN_KSI_DeltaLocation(KeyingSetInfo): + """Insert keyframes for additional location offset""" bl_label = "Delta Location" # poll - selected objects only (and only if active object in object mode) @@ -404,6 +447,7 @@ class BUILTIN_KSI_DeltaLocation(KeyingSetInfo): # Delta Rotation class BUILTIN_KSI_DeltaRotation(KeyingSetInfo): + """Insert keyframes for additional rotation offset""" bl_label = "Delta Rotation" # poll - selected objects only (and only if active object in object mode) @@ -437,6 +481,7 @@ class BUILTIN_KSI_DeltaRotation(KeyingSetInfo): # Delta Scale class BUILTIN_KSI_DeltaScale(KeyingSetInfo): + """Insert keyframes for additional scaling factor""" bl_label = "Delta Scale" # poll - selected objects only (and only if active object in object mode) diff --git a/source/blender/blenkernel/BKE_animsys.h b/source/blender/blenkernel/BKE_animsys.h index fb4a44b2c80..59dc2f2fc70 100644 --- a/source/blender/blenkernel/BKE_animsys.h +++ b/source/blender/blenkernel/BKE_animsys.h @@ -81,7 +81,7 @@ void BKE_relink_animdata(struct AnimData *adt); /* KeyingSets API */ /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */ -struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char name[], short flag, short keyingflag); +struct KeyingSet *BKE_keyingset_add(struct ListBase *list, const char idname[], const char name[], short flag, short keyingflag); /* Add a path to a KeyingSet */ struct KS_Path *BKE_keyingset_add_path(struct KeyingSet *ks, struct ID *id, const char group_name[], const char rna_path[], int array_index, short flag, short groupmode); diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index db8bd8f2066..3a08120f067 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -941,14 +941,16 @@ KS_Path *BKE_keyingset_find_path (KeyingSet *ks, ID *id, const char group_name[] /* Defining Tools --------------------------- */ /* Used to create a new 'custom' KeyingSet for the user, that will be automatically added to the stack */ -KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, short keyingflag) +KeyingSet *BKE_keyingset_add (ListBase *list, const char idname[], const char name[], short flag, short keyingflag) { KeyingSet *ks; /* allocate new KeyingSet */ ks= MEM_callocN(sizeof(KeyingSet), "KeyingSet"); - BLI_strncpy(ks->name, name ? name : "KeyingSet", sizeof(ks->name)); + BLI_strncpy(ks->idname, idname ? idname : name ? name : "KeyingSet", sizeof(ks->idname)); + + BLI_strncpy(ks->name, name ? name : idname ? idname : "Keying Set", sizeof(ks->name)); ks->flag= flag; ks->keyingflag= keyingflag; @@ -956,8 +958,11 @@ KeyingSet *BKE_keyingset_add (ListBase *list, const char name[], short flag, sho /* add KeyingSet to list */ BLI_addtail(list, ks); - /* make sure KeyingSet has a unique name (this helps with identification) */ - BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, name), sizeof(ks->name)); + /* Make sure KeyingSet has a unique idname. */ + BLI_uniquename(list, ks, "KeyingSet", '.', offsetof(KeyingSet, idname), sizeof(ks->idname)); + + /* Make sure KeyingSet has a unique label (this helps with identification). */ + BLI_uniquename(list, ks, "Keying Set", '.', offsetof(KeyingSet, name), sizeof(ks->name)); /* return new KeyingSet for further editing */ return ks; diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 79613f0f8f9..5509fc3dd85 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -13245,6 +13245,20 @@ static void do_versions(FileData *fd, Library *lib, Main *main) do_versions_nodetree_multi_file_output_format_2_62_1(NULL, ntree); } + /* put compatibility code here until next subversion bump */ + { + { + /* Set new idname of keyingsets from their now "label-only" name. */ + Scene *scene; + for (scene = main->scene.first; scene; scene = scene->id.next) { + KeyingSet *ks; + for (ks = scene->keyingsets.first; ks; ks = ks->next) { + if (!ks->idname[0]) + BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname)); + } + } + } + } /* WATCH IT!!!: pointers from libdata have not been converted yet here! */ /* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 559f6ad98d9..e82f234d2b6 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -71,6 +71,7 @@ #include "ED_screen.h" #include "UI_interface.h" +#include "UI_resources.h" #include "WM_api.h" #include "WM_types.h" @@ -1115,7 +1116,7 @@ static int insert_key_exec (bContext *C, wmOperator *op) if (type == 0) type= scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks= BLI_findlink(&scene->keyingsets, type-1); else ks= BLI_findlink(&builtin_keyingsets, -type-1); @@ -1193,8 +1194,15 @@ static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *UNUSED( /* if prompting or no active Keying Set, show the menu */ if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) { + 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_keyframe_insert_menu"); + pup = uiPupMenuBegin(C, op->type->name, ICON_NONE); + layout = uiPupMenuLayout(pup); + uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type"); + uiPupMenuEnd(C, pup); + return OPERATOR_CANCELLED; } else { @@ -1264,7 +1272,7 @@ static int delete_key_exec (bContext *C, wmOperator *op) if (type == 0) type= scene->active_keyingset; if (type > 0) - ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1); + ks= BLI_findlink(&scene->keyingsets, type-1); else ks= BLI_findlink(&builtin_keyingsets, -type-1); 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 */ diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index 63c0511e6b3..a70be6dfb54 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -132,10 +132,12 @@ typedef struct KeyingSetInfo { struct KeyingSetInfo *next, *prev; /* info */ - /* identifier so that user can hook this up to a KeyingSet */ - char name[64]; /* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */ char idname[64]; + /* identifier so that user can hook this up to a KeyingSet (used as label). */ + char name[64]; + /* short help/description. */ + char description[240]; /* RNA_DYN_DESCR_MAX */ /* keying settings */ short keyingflag; @@ -208,9 +210,6 @@ int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks); /* Get Keying Set to use for Auto-Keyframing some transforms */ struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName); -/* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ -void ANIM_keying_sets_menu_setup(struct bContext *C, const char title[], const char op_name[]); - /* Dynamically populate an enum of Keying Sets */ struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 9643958b741..e844688b6c2 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1283,7 +1283,7 @@ static KeyingSet *verify_active_keyingset(Scene *scene, short add) /* add if none found */ // XXX the default settings have yet to evolve if ((add) && (ks==NULL)) { - ks= BKE_keyingset_add(&scene->keyingsets, NULL, KEYINGSET_ABSOLUTE, 0); + ks= BKE_keyingset_add(&scene->keyingsets, NULL, NULL, KEYINGSET_ABSOLUTE, 0); scene->active_keyingset= BLI_countlist(&scene->keyingsets); } diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index f930de8db06..c68592e525c 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -761,7 +761,9 @@ typedef struct KeyingSet { ListBase paths; /* (KS_Path) paths to keyframe to */ + char idname[64]; /* unique name (for search, etc.) */ char name[64]; /* user-viewable name for KeyingSet (for menus, etc.) */ + char description[240]; /* (RNA_DYN_DESCR_MAX) short help text. */ char typeinfo[64]; /* name of the typeinfo data used for the relative paths */ short flag; /* settings for KeyingSet */ diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index 5bf2c080f9f..56c176256bc 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -194,7 +194,8 @@ static StructRNA *rna_KeyingSetInfo_register(Main *bmain, ReportList *reports, v return NULL; if (strlen(identifier) >= sizeof(dummyksi.idname)) { - BKE_reportf(reports, RPT_ERROR, "Registering keying set info class: '%s' is too long, maximum length is %d", identifier, (int)sizeof(dummyksi.idname)); + BKE_reportf(reports, RPT_ERROR, "Registering keying set info class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(dummyksi.idname)); return NULL; } @@ -473,6 +474,13 @@ static void rna_def_common_keying_flags(StructRNA *srna, short reg) /* --- */ +/* To avoid repeating it twice! */ +#define KEYINGSET_IDNAME_DOC "If this is set, the Keying Set gets a custom ID, otherwise it takes " \ + "the name of the class used to define the Keying Set (for example, " \ + "if the class name is \"BUILTIN_KSI_location\", and bl_idname is not " \ + "set by the script, then bl_idname = \"BUILTIN_KSI_location\")" + + static void rna_def_keyingset_info(BlenderRNA *brna) { StructRNA *srna; @@ -489,18 +497,24 @@ static void rna_def_keyingset_info(BlenderRNA *brna) /* Properties --------------------- */ RNA_define_verify_sdna(0); /* not in sdna */ - + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "idname"); RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP); - - /* Name */ - prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_TRANSLATE); + RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC); + + prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "name"); - RNA_def_property_ui_text(prop, "Name", ""); + RNA_def_property_ui_text(prop, "UI Name", ""); RNA_def_struct_name_property(srna, prop); RNA_def_property_flag(prop, PROP_REGISTER); + prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE); + RNA_def_property_string_sdna(prop, NULL, "description"); + RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Description", "A short description of the keying set"); + rna_def_common_keying_flags(srna, 1); /* '1' arg here is to indicate that we need these to be set on registering */ RNA_define_verify_sdna(1); @@ -671,12 +685,25 @@ static void rna_def_keyingset(BlenderRNA *brna) srna = RNA_def_struct(brna, "KeyingSet", NULL); RNA_def_struct_ui_text(srna, "Keying Set", "Settings that should be keyframed together"); - /* Name */ - prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); - RNA_def_property_ui_text(prop, "Name", ""); + /* Id/Label. */ + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "idname"); + RNA_def_property_flag(prop, PROP_REGISTER|PROP_NEVER_CLAMP); + RNA_def_property_ui_text(prop, "ID Name", KEYINGSET_IDNAME_DOC); + RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL); + + prop = RNA_def_property(srna, "bl_label", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "UI Name", ""); RNA_def_struct_ui_icon(srna, ICON_KEYINGSET); RNA_def_struct_name_property(srna, prop); - RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL); +/* RNA_def_property_update(prop, NC_SCENE|ND_KEYINGSET|NA_RENAME, NULL);*/ + + prop = RNA_def_property(srna, "bl_description", PROP_STRING, PROP_TRANSLATE); + RNA_def_property_string_sdna(prop, NULL, "description"); + RNA_def_property_string_maxlength(prop, RNA_DYN_DESCR_MAX); /* else it uses the pointer size! */ + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL); + RNA_def_property_ui_text(prop, "Description", "A short description of the keying set"); /* KeyingSetInfo (Type Info) for Builtin Sets only */ prop = RNA_def_property(srna, "type_info", PROP_POINTER, PROP_NONE); @@ -705,6 +732,7 @@ static void rna_def_keyingset(BlenderRNA *brna) RNA_api_keyingset(srna); } +#undef KEYINGSET_IDNAME_DOC /* --- */ static void rna_api_animdata_nla_tracks(BlenderRNA *brna, PropertyRNA *cprop) diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 7a60a413703..22036024047 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1321,12 +1321,12 @@ static void rna_TimeLine_clear(Scene *scene) WM_main_add_notifier(NC_ANIMATION|ND_MARKERS, NULL); } -static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char name[]) +static KeyingSet *rna_Scene_keying_set_new(Scene *sce, ReportList *reports, const char idname[], const char name[]) { KeyingSet *ks = NULL; /* call the API func, and set the active keyingset index */ - ks = BKE_keyingset_add(&sce->keyingsets, name, KEYINGSET_ABSOLUTE, 0); + ks = BKE_keyingset_add(&sce->keyingsets, idname, name, KEYINGSET_ABSOLUTE, 0); if (ks) { sce->active_keyingset = BLI_countlist(&sce->keyingsets); @@ -3948,7 +3948,8 @@ static void rna_def_scene_keying_sets(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Add a new Keying Set to Scene"); RNA_def_function_flag(func, FUNC_USE_REPORTS); /* name */ - RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set"); + RNA_def_string(func, "idname", "KeyingSet", 64, "IDName", "Internal identifier of Keying Set"); + RNA_def_string(func, "name", "KeyingSet", 64, "Name", "User visible name of Keying Set"); /* returns the new KeyingSet */ parm = RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set"); -- cgit v1.2.3