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:
authorBastien Montagne <montagne29@wanadoo.fr>2012-03-08 18:04:06 +0400
committerBastien Montagne <montagne29@wanadoo.fr>2012-03-08 18:04:06 +0400
commita80b7d612947e1d26b10165a37bb603dae527afd (patch)
tree7a575b2f99b093e43d50d9322f8d1c50477b0fa6 /source/blender/editors/animation/keyingsets.c
parenta5f2db9992327764126ee7f275294d1f0699a26a (diff)
Fixing several issues with keyingsets:
*Add a new idname to keyingsets, keeping name as label-only (using same string for both made lookup fail when using i18n other than english, as it tried to compare an untranslated static string id against a translated RNA name). Also adding a description string (can be helpful with custom keyingsets, imho). *Fixed a few other bugs related to that area (namely, you can’t deselect current keyingset from the shift-ctrl-alt-I popup menu, and insert/delete key ops were using a rather strange way to get chosen custom keyingset…). *Fixed UI code so that it always uses (RNA) enum, and simplified menu-creation code.
Diffstat (limited to 'source/blender/editors/animation/keyingsets.c')
-rw-r--r--source/blender/editors/animation/keyingsets.c108
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 */