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-04-20 07:52:13 +0400
committerJoshua Leung <aligorith@gmail.com>2009-04-20 07:52:13 +0400
commit828581fa073c3306ff877fd909c949aeff143101 (patch)
treef490f94a66e0de203954f9ea2084ca47ad22f8af /source/blender/editors/space_outliner
parent387aad7275aaef33c3ac5eae9f917da896da2f9d (diff)
Drivers: Editing ops in the Outliner
In much the same way as Keying Sets are defined in the Outliner, you can now select items in the Datablocks view of the Outliner, and use the D/Alt-D hotkeys to Add/Remove drivers (repectively). This is useful for settings which don't have buttons yet (in the buttons window).
Diffstat (limited to 'source/blender/editors/space_outliner')
-rw-r--r--source/blender/editors/space_outliner/outliner.c215
-rw-r--r--source/blender/editors/space_outliner/outliner_intern.h4
-rw-r--r--source/blender/editors/space_outliner/outliner_ops.c6
3 files changed, 188 insertions, 37 deletions
diff --git a/source/blender/editors/space_outliner/outliner.c b/source/blender/editors/space_outliner/outliner.c
index b03d938843f..6394e38c6e7 100644
--- a/source/blender/editors/space_outliner/outliner.c
+++ b/source/blender/editors/space_outliner/outliner.c
@@ -3047,18 +3047,9 @@ void outliner_operation_menu(Scene *scene, ARegion *ar, SpaceOops *soops)
}
}
-/* ***************** KEYINGSET OPERATIONS *************** */
-
-/* These operators are only available in databrowser mode for now, as
- * they depend on having RNA paths and/or hierarchies available.
- */
-enum {
- KEYINGSET_EDITMODE_ADD = 0,
- KEYINGSET_EDITMODE_REMOVE,
-} eKeyingSet_EditModes;
+/* ***************** ANIMATO OPERATIONS ********************************** */
+/* KeyingSet and Driver Creation - Helper functions */
-/* Utilities ---------------------------------- */
-
/* specialised poll callback for these operators to work in Datablocks view only */
static int ed_operator_outliner_datablocks_active(bContext *C)
{
@@ -3069,33 +3060,9 @@ static int ed_operator_outliner_datablocks_active(bContext *C)
}
return 0;
}
-
-
-/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */
-// TODO: should this be an API func?
-static KeyingSet *verify_active_keyingset(Scene *scene, short add)
-{
- KeyingSet *ks= NULL;
-
- /* sanity check */
- if (scene == NULL)
- return NULL;
-
- /* try to find one from scene */
- if (scene->active_keyingset > 0)
- ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
-
- /* add if none found */
- // XXX the default settings have yet to evolve
- if ((add) && (ks==NULL)) {
- ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0);
- scene->active_keyingset= BLI_countlist(&scene->keyingsets);
- }
-
- return ks;
-}
-/* Helper func to extract an RNA path from seleted tree element
+
+/* Helper func to extract an RNA path from selected tree element
* NOTE: the caller must zero-out all values of the pointers that it passes here first, as
* this function does not do that yet
*/
@@ -3231,6 +3198,180 @@ static void tree_element_to_path(SpaceOops *soops, TreeElement *te, TreeStoreEle
BLI_freelistN(&hierarchy);
}
+/* ***************** KEYINGSET OPERATIONS *************** */
+
+/* These operators are only available in databrowser mode for now, as
+ * they depend on having RNA paths and/or hierarchies available.
+ */
+enum {
+ DRIVERS_EDITMODE_ADD = 0,
+ DRIVERS_EDITMODE_REMOVE,
+} eDrivers_EditModes;
+
+/* Utilities ---------------------------------- */
+
+/* Recursively iterate over tree, finding and working on selected items */
+static void do_outliner_drivers_editop(SpaceOops *soops, ListBase *tree, short mode)
+{
+ TreeElement *te;
+ TreeStoreElem *tselem;
+
+ for (te= tree->first; te; te=te->next) {
+ tselem= TREESTORE(te);
+
+ /* if item is selected, perform operation */
+ if (tselem->flag & TSE_SELECTED) {
+ ID *id= NULL;
+ char *path= NULL;
+ int array_index= 0;
+ short flag= 0;
+ short groupmode= KSP_GROUP_KSNAME;
+
+ /* check if RNA-property described by this selected element is an animateable prop */
+ if ((tselem->type == TSE_RNA_PROPERTY) && RNA_property_animateable(&te->rnaptr, te->directdata)) {
+ /* get id + path + index info from the selected element */
+ tree_element_to_path(soops, te, tselem,
+ &id, &path, &array_index, &flag, &groupmode);
+ }
+
+ /* only if ID and path were set, should we perform any actions */
+ if (id && path) {
+ /* action depends on mode */
+ switch (mode) {
+ case DRIVERS_EDITMODE_ADD:
+ {
+ /* add a new driver with the information obtained (only if valid) */
+ ANIM_add_driver(id, path, array_index, flag);
+ }
+ break;
+ case DRIVERS_EDITMODE_REMOVE:
+ {
+ /* remove driver matching the information obtained (only if valid) */
+ ANIM_remove_driver(id, path, array_index, flag);
+ }
+ break;
+ }
+
+ /* free path, since it had to be generated */
+ MEM_freeN(path);
+ }
+
+
+ }
+
+ /* go over sub-tree */
+ if ((tselem->flag & TSE_CLOSED)==0)
+ do_outliner_drivers_editop(soops, &te->subtree, mode);
+ }
+}
+
+/* Add Operator ---------------------------------- */
+
+static int outliner_drivers_addsel_exec(bContext *C, wmOperator *op)
+{
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
+
+ /* check for invalid states */
+ if (soutliner == NULL)
+ return OPERATOR_CANCELLED;
+
+ /* recursively go into tree, adding selected items */
+ do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_ADD);
+
+ /* send notifiers */
+ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_drivers_add(wmOperatorType *ot)
+{
+ /* api callbacks */
+ ot->idname= "OUTLINER_OT_drivers_add";
+ ot->name= "Add Drivers";
+ ot->description= "Add drivers to selected items.";
+
+ /* api callbacks */
+ ot->exec= outliner_drivers_addsel_exec;
+ ot->poll= ed_operator_outliner_datablocks_active;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+}
+
+
+/* Remove Operator ---------------------------------- */
+
+static int outliner_drivers_deletesel_exec(bContext *C, wmOperator *op)
+{
+ SpaceOops *soutliner= (SpaceOops*)CTX_wm_space_data(C);
+ Scene *scene= CTX_data_scene(C);
+
+ /* check for invalid states */
+ if (soutliner == NULL)
+ return OPERATOR_CANCELLED;
+
+ /* recursively go into tree, adding selected items */
+ do_outliner_drivers_editop(soutliner, &soutliner->tree, DRIVERS_EDITMODE_REMOVE);
+
+ /* send notifiers */
+ WM_event_add_notifier(C, NC_SCENE|ND_KEYINGSET, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+void OUTLINER_OT_drivers_delete(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->idname= "OUTLINER_OT_drivers_delete";
+ ot->name= "Delete Drivers";
+ ot->description= "Delete drivers assigned to selected items.";
+
+ /* api callbacks */
+ ot->exec= outliner_drivers_deletesel_exec;
+ ot->poll= ed_operator_outliner_datablocks_active;
+
+ /* flags */
+ ot->flag = OPTYPE_UNDO;
+}
+
+/* ***************** KEYINGSET OPERATIONS *************** */
+
+/* These operators are only available in databrowser mode for now, as
+ * they depend on having RNA paths and/or hierarchies available.
+ */
+enum {
+ KEYINGSET_EDITMODE_ADD = 0,
+ KEYINGSET_EDITMODE_REMOVE,
+} eKeyingSet_EditModes;
+
+/* Utilities ---------------------------------- */
+
+/* find the 'active' KeyingSet, and add if not found (if adding is allowed) */
+// TODO: should this be an API func?
+static KeyingSet *verify_active_keyingset(Scene *scene, short add)
+{
+ KeyingSet *ks= NULL;
+
+ /* sanity check */
+ if (scene == NULL)
+ return NULL;
+
+ /* try to find one from scene */
+ if (scene->active_keyingset > 0)
+ ks= BLI_findlink(&scene->keyingsets, scene->active_keyingset-1);
+
+ /* add if none found */
+ // XXX the default settings have yet to evolve
+ if ((add) && (ks==NULL)) {
+ ks= BKE_keyingset_add(&scene->keyingsets, "Keying Set", KEYINGSET_ABSOLUTE, 0);
+ scene->active_keyingset= BLI_countlist(&scene->keyingsets);
+ }
+
+ return ks;
+}
+
/* Recursively iterate over tree, finding and working on selected items */
static void do_outliner_keyingset_editop(SpaceOops *soops, KeyingSet *ks, ListBase *tree, short mode)
{
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 067c14dc257..48c904121a5 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -119,9 +119,13 @@ void outliner_select(struct SpaceOops *soops, struct ListBase *lb, int *index, s
void draw_outliner(const struct bContext *C);
void OUTLINER_OT_activate_click(struct wmOperatorType *ot);
+
void OUTLINER_OT_keyingset_add_selected(struct wmOperatorType *ot);
void OUTLINER_OT_keyingset_remove_selected(struct wmOperatorType *ot);
+void OUTLINER_OT_drivers_add(struct wmOperatorType *ot);
+void OUTLINER_OT_drivers_delete(struct wmOperatorType *ot);
+
#if 0
extern void outliner_mouse_event(Scene *scene, ARegion *ar, SpaceOops *soops, short event);
extern void outliner_toggle_visible(SpaceOops *soops);
diff --git a/source/blender/editors/space_outliner/outliner_ops.c b/source/blender/editors/space_outliner/outliner_ops.c
index 920ccb62a7a..0efbdb06cd2 100644
--- a/source/blender/editors/space_outliner/outliner_ops.c
+++ b/source/blender/editors/space_outliner/outliner_ops.c
@@ -47,6 +47,9 @@ void outliner_operatortypes(void)
WM_operatortype_append(OUTLINER_OT_keyingset_add_selected);
WM_operatortype_append(OUTLINER_OT_keyingset_remove_selected);
+
+ WM_operatortype_append(OUTLINER_OT_drivers_add);
+ WM_operatortype_append(OUTLINER_OT_drivers_delete);
}
void outliner_keymap(wmWindowManager *wm)
@@ -61,5 +64,8 @@ void outliner_keymap(wmWindowManager *wm)
WM_keymap_verify_item(keymap, "ANIM_OT_insert_keyframe", IKEY, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "ANIM_OT_delete_keyframe", IKEY, KM_PRESS, KM_ALT, 0);
+
+ WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_add", DKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(keymap, "OUTLINER_OT_drivers_delete", DKEY, KM_PRESS, KM_ALT, 0);
}