UI: Make button driver and keying set shortcuts configurable
This commit is contained in:
parent
a3d258bfb4
commit
f6c09eadf0
Notes:
blender-bot
2023-08-23 09:41:21 +02:00
Referenced by pull request #111373, Fix #94129: Unable to remove added keying set from context menu
Referenced by commit e2a35debde
, Fix #94129: Unable to remove added keying set from context menu
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) &&
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue