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>2010-03-25 14:34:18 +0300
committerJoshua Leung <aligorith@gmail.com>2010-03-25 14:34:18 +0300
commitb88278b62b676765c03a94dd739ace73b582cea7 (patch)
tree1c5b0bc210aa0e38f91e49946bd35089f0192036 /source/blender/editors
parent57b2ea62ab6f2f8e6dbd8cd51be0ef93b65ef34a (diff)
More assorted Keying Sets changes for Cessen (mainly api stuff):
* Added operator (Ctrl Shift Alt I) to show menu for changing the active Keying Set in the 3D view (todo item from last commit) * KeyingSetInfo (i.e. the Builtin Keying Set classes) can now be accessed from Keying Set instances with ks.type_info * Added ks.remove_all_paths() function to remove all the paths for a Keying Set. --- These two changes mean that builtin Keying Sets could be refreshed in response to context changes by doing: <code> ks = bpy.context.scene.active_keying_set if ks.absolute==False and ks.type_info: ksi = ks.type_info # remove existing paths to fill with new ks.remove_all_paths() # check if Keying Set can be used in current context if ksi.poll(bpy.context): # call iterator() which calls generate() and re-populates paths list ksi.iterator(bpy.context, ks) </code> And then, once this has been done, the paths that the Keying Set will operate on can be accessed as <code> paths = bpy.context.scene.active_keying_set.paths </code>
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/animation/anim_intern.h3
-rw-r--r--source/blender/editors/animation/anim_ops.c2
-rw-r--r--source/blender/editors/animation/keyframing.c47
-rw-r--r--source/blender/editors/animation/keyingsets.c107
-rw-r--r--source/blender/editors/armature/armature_ops.c1
-rw-r--r--source/blender/editors/include/ED_keyframing.h3
-rw-r--r--source/blender/editors/object/object_ops.c1
7 files changed, 116 insertions, 48 deletions
diff --git a/source/blender/editors/animation/anim_intern.h b/source/blender/editors/animation/anim_intern.h
index 379b8c27de5..274d33e4833 100644
--- a/source/blender/editors/animation/anim_intern.h
+++ b/source/blender/editors/animation/anim_intern.h
@@ -65,6 +65,9 @@ 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);
+/* KeyingSet general operators */
+void ANIM_OT_keying_set_active_set(struct wmOperatorType *ot);
+
/* .......... */
/* Driver management operators for UI buttons (RMB menu) */
diff --git a/source/blender/editors/animation/anim_ops.c b/source/blender/editors/animation/anim_ops.c
index 348520b60bf..88d6051b23b 100644
--- a/source/blender/editors/animation/anim_ops.c
+++ b/source/blender/editors/animation/anim_ops.c
@@ -361,6 +361,8 @@ void ED_operatortypes_anim(void)
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);
+
+ WM_operatortype_append(ANIM_OT_keying_set_active_set);
}
void ED_keymap_anim(wmKeyConfig *keyconf)
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index 5b8f9418a04..8a238566563 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1144,52 +1144,9 @@ void ANIM_OT_keyframe_insert (wmOperatorType *ot)
/* Insert Key Operator (With Menu) ------------------------ */
/* This operator checks if a menu should be shown for choosing the KeyingSet to use,
- * then calls the
+ * then calls the menu if necessary before
*/
-static void insert_key_menu_prompt (bContext *C)
-{
- Scene *scene= CTX_data_scene(C);
- KeyingSet *ks;
- uiPopupMenu *pup;
- uiLayout *layout;
- int i = 0;
-
- pup= uiPupMenuBegin(C, "Insert Keyframe", 0);
- layout= uiPupMenuLayout(pup);
-
- /* active Keying Set
- * - only include entry if it exists
- */
- if (scene->active_keyingset) {
- uiItemIntO(layout, "Active Keying Set", 0, "ANIM_OT_keyframe_insert_menu", "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) {
- if (ANIM_keyingset_context_ok_poll(C, ks))
- uiItemIntO(layout, ks->name, 0, "ANIM_OT_keyframe_insert_menu", "type", i++);
- }
- uiItemS(layout);
- }
-
- /* builtin Keying Sets */
- i= -1;
- for (ks= builtin_keyingsets.first; ks; ks= ks->next) {
- /* only show KeyingSet if context is suitable */
- if (ANIM_keyingset_context_ok_poll(C, ks))
- uiItemIntO(layout, ks->name, 0, "ANIM_OT_keyframe_insert_menu", "type", i--);
- }
-
- uiPupMenuEnd(C, pup);
-}
-
static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
{
Scene *scene= CTX_data_scene(C);
@@ -1197,7 +1154,7 @@ static int insert_key_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
/* if prompting or no active Keying Set, show the menu */
if ((scene->active_keyingset == 0) || RNA_boolean_get(op->ptr, "always_prompt")) {
/* call the menu, which will call this operator again, hence the cancelled */
- insert_key_menu_prompt(C);
+ ANIM_keying_sets_menu_setup(C, op->type->name, "ANIM_OT_keyframe_insert_menu");
return OPERATOR_CANCELLED;
}
else {
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 5e2bf4a7061..f0f35b852bb 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -45,6 +45,7 @@
#include "BKE_animsys.h"
#include "BKE_action.h"
+#include "BKE_context.h"
#include "BKE_constraint.h"
#include "BKE_depsgraph.h"
#include "BKE_fcurve.h"
@@ -55,6 +56,7 @@
#include "BKE_material.h"
#include "ED_keyframing.h"
+#include "ED_screen.h"
#include "UI_interface.h"
@@ -450,6 +452,55 @@ void ANIM_OT_keyingset_button_remove (wmOperatorType *ot)
}
/* ******************************************* */
+
+/* Change Active KeyingSet Operator ------------------------ */
+/* This operator checks if a menu should be shown for choosing the KeyingSet to make the active one */
+
+static int keyingset_active_menu_invoke (bContext *C, wmOperator *op, wmEvent *event)
+{
+ /* call the menu, which will call this operator again, hence the cancelled */
+ ANIM_keying_sets_menu_setup(C, op->type->name, "ANIM_OT_keying_set_active_set");
+ 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");
+
+ /* 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);
+
+ return OPERATOR_FINISHED;
+}
+
+void ANIM_OT_keying_set_active_set (wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name= "Set Active Keying Set";
+ ot->idname= "ANIM_OT_keying_set_active_set";
+
+ /* callbacks */
+ ot->invoke= keyingset_active_menu_invoke;
+ ot->exec= keyingset_active_menu_exec;
+ ot->poll= ED_operator_areaactive;
+
+ /* flags */
+ ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* keyingset to use
+ * - here the type is int not enum, since many of the indicies 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);
+}
+
+/* ******************************************* */
/* REGISTERED KEYING SETS */
/* Keying Set Type Info declarations */
@@ -569,6 +620,8 @@ void ANIM_keyingset_infos_exit ()
/* ******************************************* */
/* KEYING SETS API (for UI) */
+/* Getters for Active/Indices ----------------------------- */
+
/* Get the active Keying Set for the Scene provided */
KeyingSet *ANIM_scene_get_active_keyingset (Scene *scene)
{
@@ -617,6 +670,57 @@ int ANIM_scene_get_keyingset_index (Scene *scene, KeyingSet *ks)
return 0;
}
+/* Menu of All Keying Sets ----------------------------- */
+
+/* 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, char title[], char op_name[])
+{
+ Scene *scene= CTX_data_scene(C);
+ KeyingSet *ks;
+ uiPopupMenu *pup;
+ uiLayout *layout;
+ int i = 0;
+
+ pup= uiPupMenuBegin(C, title, 0);
+ layout= uiPupMenuLayout(pup);
+
+ /* active Keying Set
+ * - only include entry if it exists
+ */
+ if (scene->active_keyingset) {
+ uiItemIntO(layout, "Active Keying Set", 0, op_name, "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) {
+ if (ANIM_keyingset_context_ok_poll(C, ks))
+ uiItemIntO(layout, ks->name, 0, op_name, "type", i++);
+ }
+ uiItemS(layout);
+ }
+
+ /* builtin Keying Sets */
+ i= -1;
+ for (ks= builtin_keyingsets.first; ks; ks= ks->next) {
+ /* only show KeyingSet if context is suitable */
+ if (ANIM_keyingset_context_ok_poll(C, ks))
+ uiItemIntO(layout, ks->name, 0, op_name, "type", i--);
+ }
+
+ uiPupMenuEnd(C, pup);
+}
+
+/* ******************************************* */
+/* KEYFRAME MODIFICATION */
+
+/* Polling API ----------------------------------------------- */
+
/* Check if KeyingSet can be used in the current context */
short ANIM_keyingset_context_ok_poll (bContext *C, KeyingSet *ks)
{
@@ -635,9 +739,6 @@ short ANIM_keyingset_context_ok_poll (bContext *C, KeyingSet *ks)
return 1;
}
-/* ******************************************* */
-/* KEYFRAME MODIFICATION */
-
/* Special 'Overrides' Iterator for Relative KeyingSets ------ */
/* 'Data Sources' for relative Keying Set 'overrides'
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index 701332996aa..4384e2c5f98 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -339,6 +339,7 @@ void ED_keymap_armature(wmKeyConfig *keyconf)
// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0);
/* Pose -> PoseLib ------------- */
/* only set in posemode, by space_view3d listener */
diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h
index 92e9c541b6a..86a1f5c4031 100644
--- a/source/blender/editors/include/ED_keyframing.h
+++ b/source/blender/editors/include/ED_keyframing.h
@@ -193,6 +193,9 @@ struct KeyingSet *ANIM_scene_get_active_keyingset(struct Scene *scene);
/* Get the index of the Keying Set provided, for the given Scene */
int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks);
+/* 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, char title[], char op_name[]);
+
/* Check if KeyingSet can be used in the current context */
short ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks);
diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c
index 25bfd0e6bb5..8ec33f676ca 100644
--- a/source/blender/editors/object/object_ops.c
+++ b/source/blender/editors/object/object_ops.c
@@ -337,6 +337,7 @@ void ED_keymap_object(wmKeyConfig *keyconf)
// XXX this should probably be in screen instead... here for testing purposes in the meantime... - Aligorith
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_insert_menu", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_keyframe_delete_v3d", IKEY, KM_PRESS, KM_ALT, 0);
+ WM_keymap_verify_item(keymap, "ANIM_OT_keying_set_active_set", IKEY, KM_PRESS, KM_CTRL|KM_SHIFT|KM_ALT, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_create", GKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_verify_item(keymap, "GROUP_OT_objects_remove", GKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);