Commit: f6c09eadf06161d185835757afbf40c6512cc7cc
Author: Julian Eisel
Date:   Wed Sep 21 20:05:49 2016 +0200
Branches: master
https://developer.blender.org/rBf6c09eadf06161d185835757afbf40c6512cc7cc

UI: Make button driver and keying set shortcuts configurable

===================================================================

M       source/blender/editors/animation/keyingsets.c
M       source/blender/editors/interface/interface_anim.c
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_intern.h
M       source/blender/editors/interface/interface_ops.c

===================================================================

diff --git a/source/blender/editors/animation/keyingsets.c 
b/source/blender/editors/animation/keyingsets.c
index b907ad1..4408ec2 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -296,6 +296,12 @@ static int add_keyingset_button_exec(bContext *C, 
wmOperator *op)
        int index = 0, pflag = 0;
        const bool all = RNA_boolean_get(op->ptr, "all");
        
+       /* try to add to keyingset using property retrieved from UI */
+       if (!UI_context_active_but_prop_get(C, &ptr, &prop, &index)) {
+               /* pass event on if no active button found */
+               return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+       }
+       
        /* verify the Keying Set to use:
         *      - use the active one for now (more control over this can be 
added later)
         *      - add a new one if it doesn't exist 
@@ -326,9 +332,6 @@ static int add_keyingset_button_exec(bContext *C, 
wmOperator *op)
                ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 
1);
        }
        
-       /* try to add to keyingset using property retrieved from UI */
-       UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-       
        /* check if property is able to be added */
        if (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, 
prop)) {
                path = RNA_path_from_ID_to_property(&ptr, prop);
@@ -396,6 +399,12 @@ static int remove_keyingset_button_exec(bContext *C, 
wmOperator *op)
        short success = 0;
        int index = 0;
        
+       /* try to add to keyingset using property retrieved from UI */
+       if (UI_context_active_but_prop_get(C, &ptr, &prop, &index)) {
+               /* pass event on if no active button found */
+               return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
+       }
+       
        /* verify the Keying Set to use:
         *      - use the active one for now (more control over this can be 
added later)
         *      - return error if it doesn't exist
@@ -412,9 +421,6 @@ static int remove_keyingset_button_exec(bContext *C, 
wmOperator *op)
                ks = BLI_findlink(&scene->keyingsets, scene->active_keyingset - 
1);
        }
        
-       /* try to add to keyingset using property retrieved from UI */
-       UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-
        if (ptr.id.data && ptr.data && prop) {
                path = RNA_path_from_ID_to_property(&ptr, prop);
                
diff --git a/source/blender/editors/interface/interface_anim.c 
b/source/blender/editors/interface/interface_anim.c
index 5c4560b..991cd54 100644
--- a/source/blender/editors/interface/interface_anim.c
+++ b/source/blender/editors/interface/interface_anim.c
@@ -272,18 +272,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene 
*scene, float cfra)
        }
 }
 
-void ui_but_anim_add_driver(bContext *C)
-{
-       /* this operator calls UI_context_active_but_prop_get */
-       WM_operator_name_call(C, "ANIM_OT_driver_button_add", 
WM_OP_INVOKE_DEFAULT, NULL);
-}
-
-void ui_but_anim_remove_driver(bContext *C)
-{
-       /* this operator calls UI_context_active_but_prop_get */
-       WM_operator_name_call(C, "ANIM_OT_driver_button_remove", 
WM_OP_INVOKE_DEFAULT, NULL);
-}
-
 void ui_but_anim_copy_driver(bContext *C)
 {
        /* this operator calls UI_context_active_but_prop_get */
@@ -295,15 +283,3 @@ void ui_but_anim_paste_driver(bContext *C)
        /* this operator calls UI_context_active_but_prop_get */
        WM_operator_name_call(C, "ANIM_OT_paste_driver_button", 
WM_OP_INVOKE_DEFAULT, NULL);
 }
-
-void ui_but_anim_add_keyingset(bContext *C)
-{
-       /* this operator calls UI_context_active_but_prop_get */
-       WM_operator_name_call(C, "ANIM_OT_keyingset_button_add", 
WM_OP_INVOKE_DEFAULT, NULL);
-}
-
-void ui_but_anim_remove_keyingset(bContext *C)
-{
-       /* this operator calls UI_context_active_but_prop_get */
-       WM_operator_name_call(C, "ANIM_OT_keyingset_button_remove", 
WM_OP_INVOKE_DEFAULT, NULL);
-}
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index 29c9c03..c40260a 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -7040,36 +7040,6 @@ static int ui_do_button(bContext *C, uiBlock *block, 
uiBut *but, const wmEvent *
                                }
                        }
                }
-               /* handle drivers */
-               else if ((event->type == DKEY) &&
-                        !IS_EVENT_MOD(event, shift, oskey) &&
-                        (event->val == KM_PRESS))
-               {
-                       /* quick check to prevent this opening within the popup 
menu its self */
-                       if (!ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
-                               if (event->alt)
-                                       ui_but_anim_remove_driver(C);
-                               else if (event->ctrl)
-                                       ui_but_anim_add_driver(C);
-
-                               ED_region_tag_redraw(data->region);
-                       }
-                       return WM_UI_HANDLER_BREAK;
-               }
-               /* handle keyingsets */
-               else if ((event->type == KKEY) &&
-                        !IS_EVENT_MOD(event, shift, ctrl, oskey) &&
-                        (event->val == KM_PRESS))
-               {
-                       if (event->alt)
-                               ui_but_anim_remove_keyingset(C);
-                       else
-                               ui_but_anim_add_keyingset(C);
-                               
-                       ED_region_tag_redraw(data->region);
-                       
-                       return WM_UI_HANDLER_BREAK;
-               }
                /* handle menu */
                else if ((event->type == RIGHTMOUSE) &&
                         !IS_EVENT_MOD(event, shift, ctrl, alt, oskey) &&
diff --git a/source/blender/editors/interface/interface_intern.h 
b/source/blender/editors/interface/interface_intern.h
index 418d98e..fcf827b 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -729,15 +729,8 @@ void ui_block_align_calc(uiBlock *block);
 
 /* interface_anim.c */
 void ui_but_anim_flag(uiBut *but, float cfra);
-void ui_but_anim_insert_keyframe(struct bContext *C);
-void ui_but_anim_delete_keyframe(struct bContext *C);
-void ui_but_anim_clear_keyframe(struct bContext *C);
-void ui_but_anim_add_driver(struct bContext *C);
-void ui_but_anim_remove_driver(struct bContext *C);
 void ui_but_anim_copy_driver(struct bContext *C);
 void ui_but_anim_paste_driver(struct bContext *C);
-void ui_but_anim_add_keyingset(struct bContext *C);
-void ui_but_anim_remove_keyingset(struct bContext *C);
 bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen);
 bool ui_but_anim_expression_set(uiBut *but, const char *str);
 bool ui_but_anim_expression_create(uiBut *but, const char *str);
diff --git a/source/blender/editors/interface/interface_ops.c 
b/source/blender/editors/interface/interface_ops.c
index ce23588..77b5367 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -1121,5 +1121,13 @@ void ED_keymap_ui(wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "ANIM_OT_keyframe_delete_button", IKEY, 
KM_PRESS, KM_ALT, 0);
        WM_keymap_add_item(keymap, "ANIM_OT_keyframe_clear_button", IKEY, 
KM_PRESS, KM_SHIFT | KM_ALT, 0);
 
+       /* drivers */
+       WM_keymap_add_item(keymap, "ANIM_OT_driver_button_add", DKEY, KM_PRESS, 
KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "ANIM_OT_driver_button_remove", DKEY, 
KM_PRESS, KM_CTRL | KM_ALT, 0);
+
+       /* keyingsets */
+       WM_keymap_add_item(keymap, "ANIM_OT_keyingset_button_add", KKEY, 
KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "ANIM_OT_keyingset_button_remove", KKEY, 
KM_PRESS, KM_ALT, 0);
+
        eyedropper_modal_keymap(keyconf);
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to