From f6c09eadf06161d185835757afbf40c6512cc7cc Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 21 Sep 2016 20:05:49 +0200 Subject: UI: Make button driver and keying set shortcuts configurable --- source/blender/editors/animation/keyingsets.c | 18 ++++++++----- source/blender/editors/interface/interface_anim.c | 24 ----------------- .../blender/editors/interface/interface_handlers.c | 30 ---------------------- .../blender/editors/interface/interface_intern.h | 7 ----- source/blender/editors/interface/interface_ops.c | 8 ++++++ 5 files changed, 20 insertions(+), 67 deletions(-) (limited to 'source') diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index b907ad150aa..4408ec26b3f 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 5c4560bb0ec..991cd54fecf 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 29c9c03baf9..c40260a8454 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 418d98e8e4a..fcf827bdbe6 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 ce23588f821..77b5367c3e9 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); } -- cgit v1.2.3