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:
authorJoshua Leung <aligorith@gmail.com>2009-10-03 08:21:38 +0400
committerJoshua Leung <aligorith@gmail.com>2009-10-03 08:21:38 +0400
commitf4c697cf7fc1b3bd3e040b90921fafbee8bafa4a (patch)
treea8d0ae5eb0fd5ee75bc094c0fc176b471c73d7e6 /source/blender
parent97d8839ad565bff1a02da59a1a2f97264ba79e68 (diff)
Keying Sets UI:
Added a way to view and edit Keying Sets via the Scene Buttons. These are still some tweaks needed to make this really workable, but should still work well enough for simply viewing and tweaking existing Keying Sets created using other means. Additional bugfixes: * Adjusted the size of labels on properties that had a 'label' for their name. Now it uses 1/3 of the total width instead, which looks much better for most cases. * Added missing entries for adding Force Fields from the Info-header 'Add' menu. At some point we should unify this menu with the popup operator's one, since this is exactly the kind of situation we had hoped in avoid with new UI architectures. * Moved all the operator defines for keyframing stuff to the 'intern' anim header instead
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/anim_sys.c2
-rw-r--r--source/blender/editors/animation/anim_intern.h40
-rw-r--r--source/blender/editors/animation/anim_ops.c14
-rw-r--r--source/blender/editors/animation/keyingsets.c209
-rw-r--r--source/blender/editors/include/ED_keyframing.h32
-rw-r--r--source/blender/editors/interface/interface_layout.c2
-rw-r--r--source/blender/makesdna/DNA_anim_types.h6
-rw-r--r--source/blender/makesrna/intern/rna_animation.c56
8 files changed, 322 insertions, 39 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c
index ab902bbbae5..47f5dd116d7 100644
--- a/source/blender/blenkernel/intern/anim_sys.c
+++ b/source/blender/blenkernel/intern/anim_sys.c
@@ -211,7 +211,7 @@ static void make_local_strips(ListBase *strips)
for (strip=strips->first; strip; strip=strip->next) {
if (strip->act) make_local_action(strip->act);
- //if (strip->remap && strip->remap->target) make_local_action(strip->remap->target);
+ if (strip->remap && strip->remap->target) make_local_action(strip->remap->target);
make_local_strips(&strip->strips);
}
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index 462ef76ea8d..853aeb6c8f3 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -39,4 +39,44 @@ short keyingset_context_ok_poll(bContext *C, KeyingSet *ks);
/* Main KeyingSet operations API call */
short modifykey_get_context_data (bContext *C, ListBase *dsources, KeyingSet *ks);
+/* Operator Define Prototypes ------------------- */
+
+/* Main Keyframe Management operators:
+ * These handle keyframes management from various spaces. They only make use of
+ * Keying Sets.
+ */
+void ANIM_OT_insert_keyframe(struct wmOperatorType *ot);
+void ANIM_OT_delete_keyframe(struct wmOperatorType *ot);
+
+/* Main Keyframe Management operators:
+ * These handle keyframes management from various spaces. They will handle the menus
+ * required for each space.
+ */
+void ANIM_OT_insert_keyframe_menu(struct wmOperatorType *ot);
+void ANIM_OT_delete_keyframe_v3d(struct wmOperatorType *ot);
+
+/* Keyframe managment operators for UI buttons (RMB menu). */
+void ANIM_OT_insert_keyframe_button(struct wmOperatorType *ot);
+void ANIM_OT_delete_keyframe_button(struct wmOperatorType *ot);
+
+/* .......... */
+
+/* KeyingSet managment operators for UI buttons (RMB menu) */
+void ANIM_OT_add_keyingset_button(struct wmOperatorType *ot);
+void ANIM_OT_remove_keyingset_button(struct wmOperatorType *ot);
+
+/* KeyingSet management operators for RNA collections/UI buttons */
+void ANIM_OT_keying_set_add(struct wmOperatorType *ot);
+void ANIM_OT_keying_set_remove(struct wmOperatorType *ot);
+void ANIM_OT_keying_set_path_add(struct wmOperatorType *ot);
+void ANIM_OT_keying_set_path_remove(struct wmOperatorType *ot);
+
+/* .......... */
+
+/* Driver management operators for UI buttons (RMB menu) */
+void ANIM_OT_add_driver_button(struct wmOperatorType *ot);
+void ANIM_OT_remove_driver_button(struct wmOperatorType *ot);
+void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
+void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
+
#endif // ANIM_INTERN_H
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index a4038028062..4317204f347 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -31,6 +31,7 @@
#include "MEM_guardedalloc.h"
+#include "DNA_anim_types.h"
#include "DNA_action_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
@@ -41,6 +42,7 @@
#include "BKE_context.h"
#include "BKE_utildefines.h"
+#include "BKE_sound.h"
#include "UI_interface.h"
#include "UI_view2d.h"
@@ -52,11 +54,11 @@
#include "WM_types.h"
#include "ED_anim_api.h"
-#include "ED_keyframing.h" // XXX remove?
+#include "ED_keyframing.h"
#include "ED_markers.h"
#include "ED_screen.h"
-#include "BKE_sound.h"
+#include "anim_intern.h"
/* ********************** frame change operator ***************************/
@@ -395,15 +397,21 @@ void ED_operatortypes_anim(void)
WM_operatortype_append(ANIM_OT_delete_keyframe_v3d);
WM_operatortype_append(ANIM_OT_insert_keyframe_button);
WM_operatortype_append(ANIM_OT_delete_keyframe_button);
-
+
WM_operatortype_append(ANIM_OT_add_driver_button);
WM_operatortype_append(ANIM_OT_remove_driver_button);
WM_operatortype_append(ANIM_OT_copy_driver_button);
WM_operatortype_append(ANIM_OT_paste_driver_button);
+
WM_operatortype_append(ANIM_OT_add_keyingset_button);
WM_operatortype_append(ANIM_OT_remove_keyingset_button);
+
+ WM_operatortype_append(ANIM_OT_keying_set_add);
+ WM_operatortype_append(ANIM_OT_keying_set_remove);
+ WM_operatortype_append(ANIM_OT_keying_set_path_add);
+ WM_operatortype_append(ANIM_OT_keying_set_path_remove);
}
void ED_keymap_anim(wmWindowManager *wm)
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 81259ae7ced..99cdf0a86f4 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -78,6 +78,215 @@
#include "anim_intern.h"
/* ************************************************** */
+/* KEYING SETS - OPERATORS (for use in UI panels) */
+/* These operators are really duplication of existing functionality, but just for completeness,
+ * they're here too, and will give the basic data needed...
+ */
+
+/* poll callback for adding default KeyingSet */
+static int keyingset_poll_default_add (bContext *C)
+{
+ /* as long as there's an active Scene, it's fine */
+ return (CTX_data_scene(C) != NULL);
+}
+
+/* poll callback for editing active KeyingSet */
+static int keyingset_poll_active_edit (bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+
+ if (scene == NULL)
+ return 0;
+
+ /* there must be an active KeyingSet (and KeyingSets) */
+ return ((scene->active_keyingset > 0) && (scene->keyingsets.first));
+}
+
+/* poll callback for editing active KeyingSet Path */
+static int keyingset_poll_activePath_edit (bContext *C)
+{
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks;
+
+ if (scene == NULL)
+ return 0;
+ if (scene->active_keyingset <= 0)
+ return 0;
+ else
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+
+ /* there must be an active KeyingSet and an active path */
+ return ((ks) && (ks->paths.first) && (ks->active_path > 0));
+}
+
+
+/* Add a Default (Empty) Keying Set ------------------------- */
+
+static int add_default_keyingset_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ short flag=0, keyingflag=0;
+
+ /* validate flags
+ * - absolute KeyingSets should be created by default
+ */
+ flag |= KEYINGSET_ABSOLUTE;
+
+ if (IS_AUTOKEY_FLAG(AUTOMATKEY))
+ keyingflag |= INSERTKEY_MATRIX;
+ if (IS_AUTOKEY_FLAG(INSERTNEEDED))
+ keyingflag |= INSERTKEY_NEEDED;
+
+ /* call the API func, and set the active keyingset index */
+ BKE_keyingset_add(&scene->keyingsets, NULL, flag, keyingflag);
+
+ scene->active_keyingset= BLI_countlist(&scene->keyingsets);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keying_set_add (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Empty Keying Set";
+ ot->idname= "ANIM_OT_keying_set_add";
+ ot->description= "Add a new (empty) Keying Set to the active Scene.";
+
+ /* callbacks */
+ ot->exec= add_default_keyingset_exec;
+ ot->poll= keyingset_poll_default_add;
+}
+
+/* Remove 'Active' Keying Set ------------------------- */
+
+static int remove_active_keyingset_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks;
+
+ /* verify the Keying Set to use:
+ * - use the active one
+ * - return error if it doesn't exist
+ */
+ if (scene->active_keyingset == 0) {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove");
+ return OPERATOR_CANCELLED;
+ }
+ else
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+
+ /* free KeyingSet's data, then remove it from the scene */
+ BKE_keyingset_free(ks);
+
+ BLI_freelinkN(&scene->keyingsets, ks);
+ scene->active_keyingset= 0;
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keying_set_remove (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Removed Active Keying Set";
+ ot->idname= "ANIM_OT_keying_set_remove";
+ ot->description= "Remove the active Keying Set.";
+
+ /* callbacks */
+ ot->exec= remove_active_keyingset_exec;
+ ot->poll= keyingset_poll_active_edit;
+}
+
+/* Add Empty Keying Set Path ------------------------- */
+
+static int add_empty_ks_path_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks;
+ KS_Path *ksp;
+
+ /* verify the Keying Set to use:
+ * - use the active one
+ * - return error if it doesn't exist
+ */
+ if (scene->active_keyingset == 0) {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set to add empty path to");
+ return OPERATOR_CANCELLED;
+ }
+ else
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+
+ /* don't use the API method for this, since that checks on values... */
+ ksp= MEM_callocN(sizeof(KS_Path), "KeyingSetPath Empty");
+ BLI_addtail(&ks->paths, ksp);
+ ks->active_path= BLI_countlist(&ks->paths) + 1;
+
+ ksp->groupmode= KSP_GROUP_KSNAME; // XXX?
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keying_set_path_add (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Add Empty Keying Set Path";
+ ot->idname= "ANIM_OT_keying_set_path_add";
+ ot->description= "Add empty path to active Keying Set";
+
+ /* callbacks */
+ ot->exec= add_empty_ks_path_exec;
+ ot->poll= keyingset_poll_active_edit;
+}
+
+/* Remove Active Keying Set Path ------------------------- */
+
+static int remove_active_ks_path_exec (bContext *C, wmOperator *op)
+{
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+
+ /* if there is a KeyingSet, find the nominated path to remove */
+ if (ks) {
+ KS_Path *ksp= BLI_findlink(&ks->paths, ks->active_path-1);
+
+ if (ksp) {
+ /* NOTE: sync this code with BKE_keyingset_free() */
+ {
+ /* free RNA-path info */
+ MEM_freeN(ksp->rna_path);
+
+ /* free path itself */
+ BLI_freelinkN(&ks->paths, ksp);
+ }
+
+ /* fix active path index */
+ ks->active_path= 0;
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set Path to remove");
+ return OPERATOR_CANCELLED;
+ }
+ }
+ else {
+ BKE_report(op->reports, RPT_ERROR, "No active Keying Set to remove a path from");
+ return OPERATOR_CANCELLED;
+ }
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keying_set_path_remove (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Remove Active Keying Set Path";
+ ot->idname= "ANIM_OT_keying_set_path_remove";
+ ot->description= "Remove active Path from active Keying Set.";
+
+ /* callbacks */
+ ot->exec= remove_active_ks_path_exec;
+ ot->poll= keyingset_poll_activePath_edit;
+}
+
+/* ************************************************** */
/* KEYING SETS - OPERATORS (for use in UI menus) */
/* Add to KeyingSet Button Operator ------------------------ */
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index d30fccfe4de..92dda4162cc 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -97,26 +97,6 @@ short insert_keyframe(struct ID *id, struct bAction *act, const char group[], co
*/
short delete_keyframe(struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag);
-/* -------- */
-
-/* Main Keyframe Management operators:
- * These handle keyframes management from various spaces. They only make use of
- * Keying Sets.
- */
-void ANIM_OT_insert_keyframe(struct wmOperatorType *ot);
-void ANIM_OT_delete_keyframe(struct wmOperatorType *ot);
-
-/* Main Keyframe Management operators:
- * These handle keyframes management from various spaces. They will handle the menus
- * required for each space.
- */
-void ANIM_OT_insert_keyframe_menu(struct wmOperatorType *ot);
-void ANIM_OT_delete_keyframe_v3d(struct wmOperatorType *ot);
-
-/* Keyframe managment operators for UI buttons. */
-void ANIM_OT_insert_keyframe_button(struct wmOperatorType *ot);
-void ANIM_OT_delete_keyframe_button(struct wmOperatorType *ot);
-
/* ************ Keying Sets ********************** */
/* temporary struct to gather data combos to keyframe
@@ -155,12 +135,6 @@ struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, cha
/* Initialise builtin KeyingSets on startup */
void init_builtin_keyingsets(void);
-/* -------- */
-
-/* KeyingSet managment operators for UI buttons. */
-void ANIM_OT_add_keyingset_button(struct wmOperatorType *ot);
-void ANIM_OT_remove_keyingset_button(struct wmOperatorType *ot);
-
/* ************ Drivers ********************** */
/* Returns whether there is a driver in the copy/paste buffer to paste */
@@ -187,12 +161,6 @@ short ANIM_copy_driver(struct ID *id, const char rna_path[], int array_index, sh
*/
short ANIM_paste_driver(struct ID *id, const char rna_path[], int array_index, short flag);
-/* Driver management operators for UI buttons */
-void ANIM_OT_add_driver_button(struct wmOperatorType *ot);
-void ANIM_OT_remove_driver_button(struct wmOperatorType *ot);
-void ANIM_OT_copy_driver_button(struct wmOperatorType *ot);
-void ANIM_OT_paste_driver_button(struct wmOperatorType *ot);
-
/* ************ Auto-Keyframing ********************** */
/* Notes:
* - All the defines for this (User-Pref settings and Per-Scene settings)
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index e9160e0e416..11dfc44906a 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -492,7 +492,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, uiBlock *block, char *name, i
/* XXX UI_GetStringWidth is not accurate
labelw= UI_GetStringWidth(name);
CLAMP(labelw, w/4, 3*w/4);*/
- labelw= w/2;
+ labelw= w/3;
uiDefBut(block, LABEL, 0, name, x, y, labelw, h, NULL, 0.0, 0.0, 0, 0, "");
w= w-labelw;
}
diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h
index 9921878e926..fedde34ae18 100644
--- a/source/blender/makesdna/DNA_anim_types.h
+++ b/source/blender/makesdna/DNA_anim_types.h
@@ -654,8 +654,10 @@ typedef struct KeyingSet {
char name[64]; /* user-viewable name for KeyingSet (for menus, etc.) */
- int flag; /* settings for KeyingSet */
- int keyingflag; /* settings to supply insertkey() with */
+ short flag; /* settings for KeyingSet */
+ short keyingflag; /* settings to supply insertkey() with */
+
+ int active_path; /* index of the active path */
} KeyingSet;
/* KeyingSet settings */
diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c
index 4b2c11c2e0d..a62eef66cf0 100644
--- a/source/blender/makesrna/intern/rna_animation.c
+++ b/source/blender/makesrna/intern/rna_animation.c
@@ -96,6 +96,49 @@ static void rna_ksPath_RnaPath_set(PointerRNA *ptr, const char *value)
ksp->rna_path= NULL;
}
+
+static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+
+ /* only editable if there are some paths to change to */
+ return (ks->paths.first != NULL);
+}
+
+static PointerRNA rna_KeyingSet_active_ksPath_get(PointerRNA *ptr)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+ return rna_pointer_inherit_refine(ptr, &RNA_KeyingSetPath, BLI_findlink(&ks->paths, ks->active_path-1));
+}
+
+static void rna_KeyingSet_active_ksPath_set(PointerRNA *ptr, PointerRNA value)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+ KS_Path *ksp= (KS_Path*)value.data;
+ ks->active_path= BLI_findindex(&ks->paths, ksp) + 1;
+}
+
+static int rna_KeyingSet_active_ksPath_index_get(PointerRNA *ptr)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+ return MAX2(ks->active_path-1, 0);
+}
+
+static void rna_KeyingSet_active_ksPath_index_set(PointerRNA *ptr, int value)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+ ks->active_path= value+1;
+}
+
+static void rna_KeyingSet_active_ksPath_index_range(PointerRNA *ptr, int *min, int *max)
+{
+ KeyingSet *ks= (KeyingSet *)ptr->data;
+
+ *min= 0;
+ *max= BLI_countlist(&ks->paths)-1;
+ *max= MAX2(0, *max);
+}
+
#else
@@ -127,6 +170,7 @@ static void rna_def_keyingset_path(BlenderRNA *brna)
//RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now editable
RNA_def_property_string_funcs(prop, "rna_ksPath_RnaPath_get", "rna_ksPath_RnaPath_length", "rna_ksPath_RnaPath_set");
RNA_def_property_ui_text(prop, "RNA Path", "RNA Path to property setting.");
+ RNA_def_struct_name_property(srna, prop); // XXX this is the best indicator for now...
prop= RNA_def_property(srna, "array_index", PROP_INT, PROP_NONE);
//RNA_def_property_clear_flag(prop, PROP_EDITABLE); // XXX for now editable
@@ -157,6 +201,18 @@ static void rna_def_keyingset(BlenderRNA *brna)
RNA_def_property_struct_type(prop, "KeyingSetPath");
RNA_def_property_ui_text(prop, "Paths", "Keying Set Paths to define settings that get keyframed together.");
+ prop= RNA_def_property(srna, "active_path", PROP_POINTER, PROP_NONE);
+ RNA_def_property_struct_type(prop, "KeyingSetPath");
+ RNA_def_property_flag(prop, PROP_EDITABLE);
+ RNA_def_property_editable_func(prop, "rna_KeyingSet_active_ksPath_editable");
+ RNA_def_property_pointer_funcs(prop, "rna_KeyingSet_active_ksPath_get", "rna_KeyingSet_active_ksPath_set", NULL);
+ RNA_def_property_ui_text(prop, "Active Keying Set", "Active Keying Set used to insert/delete keyframes.");
+
+ prop= RNA_def_property(srna, "active_path_index", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "active_path");
+ RNA_def_property_int_funcs(prop, "rna_KeyingSet_active_ksPath_index_get", "rna_KeyingSet_active_ksPath_index_set", "rna_KeyingSet_active_ksPath_index_range");
+ RNA_def_property_ui_text(prop, "Active Path Index", "Current Keying Set index.");
+
/* Flags */
prop= RNA_def_property(srna, "builtin", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);