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-10 17:08:12 +0400
committerJoshua Leung <aligorith@gmail.com>2009-04-10 17:08:12 +0400
commit6593bbaca2ceb248426c55e14ceb21bb46553fd1 (patch)
tree9e778b12484bd6d03c349bcebae4219076c7d09a /source/blender/editors/interface/interface_anim.c
parentbe8b7ead51a5efb5dbd762075ee52812465ba8d6 (diff)
2.5 - Groundwork for Adding/Removing Drivers
Drivers can now be Added/Removed from buttons using the D/Alt-D hotkeys, and also through the menu. Driver settings (i.e. the target) are not set by default. To set those, go to the Graph Editor (see notes). Notes: * Buildsystem maintainers - I've added a new file "editors/animation/drivers.c" * Widget colours for the driven-setting indications are needed * To see the new drivers, go into Graph Editor -> "Drivers" mode. Currently, there's a little bug there which prevents editing of the new drivers.
Diffstat (limited to 'source/blender/editors/interface/interface_anim.c')
-rw-r--r--source/blender/editors/interface/interface_anim.c66
1 files changed, 51 insertions, 15 deletions
diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c
index 75fe8331184..3b89fbddebc 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -27,28 +27,41 @@
void ui_but_anim_flag(uiBut *but, float cfra)
{
- but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY);
+ but->flag &= ~(UI_BUT_ANIMATED|UI_BUT_ANIMATED_KEY|UI_BUT_DRIVEN);
if(but->rnaprop && but->rnapoin.id.data) {
AnimData *adt= BKE_animdata_from_id(but->rnapoin.id.data);
FCurve *fcu;
char *path;
- if(adt && adt->action && adt->action->curves.first) {
- /* XXX this function call can become a performance bottleneck */
- path= RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
-
- if(path) {
- fcu= list_find_fcurve(&adt->action->curves, path, but->rnaindex);
-
- if(fcu) {
- but->flag |= UI_BUT_ANIMATED;
-
- if(on_keyframe_fcurve(fcu, cfra))
- but->flag |= UI_BUT_ANIMATED_KEY;
+ if (adt) {
+ if ((adt->action && adt->action->curves.first) || (adt->drivers.first)) {
+ /* XXX this function call can become a performance bottleneck */
+ path= RNA_path_from_ID_to_property(&but->rnapoin, but->rnaprop);
+
+ if (path) {
+ /* animation takes priority over drivers */
+ if (adt->action && adt->action->curves.first) {
+ fcu= list_find_fcurve(&adt->action->curves, path, but->rnaindex);
+
+ if (fcu) {
+ but->flag |= UI_BUT_ANIMATED;
+
+ if (on_keyframe_fcurve(fcu, cfra))
+ but->flag |= UI_BUT_ANIMATED_KEY;
+ }
+ }
+
+ /* if not animated, check if driven */
+ if ((but->flag & UI_BUT_ANIMATED)==0 && (adt->drivers.first)) {
+ fcu= list_find_fcurve(&adt->drivers, path, but->rnaindex);
+
+ if (fcu)
+ but->flag |= UI_BUT_DRIVEN;
+ }
+
+ MEM_freeN(path);
}
-
- MEM_freeN(path);
}
}
}
@@ -86,6 +99,19 @@ void ui_but_anim_delete_keyframe(bContext *C)
WM_operator_name_call(C, "ANIM_OT_delete_keyframe_button", WM_OP_INVOKE_DEFAULT, NULL);
}
+void ui_but_anim_add_driver(bContext *C)
+{
+ /* this operator calls uiAnimContextProperty above */
+ WM_operator_name_call(C, "ANIM_OT_add_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
+}
+
+void ui_but_anim_remove_driver(bContext *C)
+{
+ /* this operator calls uiAnimContextProperty above */
+ WM_operator_name_call(C, "ANIM_OT_remove_driver_button", WM_OP_INVOKE_DEFAULT, NULL);
+}
+
+// TODO: refine the logic for adding/removing drivers...
void ui_but_anim_menu(bContext *C, uiBut *but)
{
uiMenuItem *head;
@@ -100,18 +126,28 @@ void ui_but_anim_menu(bContext *C, uiBut *but)
if(length) {
uiMenuItemBooleanO(head, "Delete Keyframes", 0, "ANIM_OT_delete_keyframe_button", "all", 1);
uiMenuItemBooleanO(head, "Delete Single Keyframe", 0, "ANIM_OT_delete_keyframe_button", "all", 0);
+
+ uiMenuItemBooleanO(head, "Remove Driver", 0, "ANIM_OT_remove_driver_button", "all", 1);
+ uiMenuItemBooleanO(head, "Remove Single Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
}
else {
uiMenuItemBooleanO(head, "Delete Keyframe", 0, "ANIM_OT_delete_keyframe_button", "all", 0);
+
+ uiMenuItemBooleanO(head, "Remove Driver", 0, "ANIM_OT_remove_driver_button", "all", 0);
}
}
else if(RNA_property_animateable(&but->rnapoin, but->rnaprop)) {
if(length) {
uiMenuItemBooleanO(head, "Insert Keyframes", 0, "ANIM_OT_insert_keyframe_button", "all", 1);
uiMenuItemBooleanO(head, "Insert Single Keyframe", 0, "ANIM_OT_insert_keyframe_button", "all", 0);
+
+ uiMenuItemBooleanO(head, "Add Driver", 0, "ANIM_OT_add_driver_button", "all", 1);
+ uiMenuItemBooleanO(head, "Add Single Driver", 0, "ANIM_OT_add_driver_button", "all", 0);
}
else {
uiMenuItemBooleanO(head, "Insert Keyframe", 0, "ANIM_OT_insert_keyframe_button", "all", 0);
+
+ uiMenuItemBooleanO(head, "Add Driver", 0, "ANIM_OT_add_driver_button", "all", 0);
}
}