UI: Configurable shortcuts for keyframe operators
Adds support for editing the shortcuts for inserting (I), deleting (Alt+I) and clearing (Alt+Shift+I) button keyframes.
This commit is contained in:
parent
a7e7479122
commit
e8d953000a
|
@ -1771,8 +1771,10 @@ static int insert_key_button_exec(bContext *C, wmOperator *op)
|
|||
flag = ANIM_get_keyframing_flags(scene, 1);
|
||||
|
||||
/* try to insert keyframe using property retrieved from UI */
|
||||
but = UI_context_active_but_get(C);
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
if (!(but = UI_context_active_but_prop_get(C, &ptr, &prop, &index))) {
|
||||
/* pass event on if no active button found */
|
||||
return (OPERATOR_CANCELLED | OPERATOR_PASS_THROUGH);
|
||||
}
|
||||
|
||||
if ((ptr.id.data && ptr.data && prop) && RNA_property_animateable(&ptr, prop)) {
|
||||
if (ptr.type == &RNA_NlaStrip) {
|
||||
|
@ -1873,7 +1875,10 @@ static int delete_key_button_exec(bContext *C, wmOperator *op)
|
|||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
|
||||
/* try to insert keyframe using property retrieved from UI */
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
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);
|
||||
}
|
||||
|
||||
if (ptr.id.data && ptr.data && prop) {
|
||||
if (ptr.type == &RNA_NlaStrip) {
|
||||
|
@ -1973,7 +1978,10 @@ static int clear_key_button_exec(bContext *C, wmOperator *op)
|
|||
const bool all = RNA_boolean_get(op->ptr, "all");
|
||||
|
||||
/* try to insert keyframe using property retrieved from UI */
|
||||
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
|
||||
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);
|
||||
}
|
||||
|
||||
if (ptr.id.data && ptr.data && prop) {
|
||||
path = RNA_path_from_ID_to_property(&ptr, prop);
|
||||
|
|
|
@ -1027,7 +1027,7 @@ bool UI_context_copy_to_selected_list(
|
|||
|
||||
/* Helpers for Operators */
|
||||
uiBut *UI_context_active_but_get(const struct bContext *C);
|
||||
void UI_context_active_but_prop_get(
|
||||
uiBut *UI_context_active_but_prop_get(
|
||||
const struct bContext *C,
|
||||
struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, int *r_index);
|
||||
void UI_context_active_but_prop_handle(struct bContext *C);
|
||||
|
|
|
@ -272,24 +272,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra)
|
|||
}
|
||||
}
|
||||
|
||||
void ui_but_anim_insert_keyframe(bContext *C)
|
||||
{
|
||||
/* this operator calls UI_context_active_but_prop_get */
|
||||
WM_operator_name_call(C, "ANIM_OT_keyframe_insert_button", WM_OP_INVOKE_DEFAULT, NULL);
|
||||
}
|
||||
|
||||
void ui_but_anim_delete_keyframe(bContext *C)
|
||||
{
|
||||
/* this operator calls UI_context_active_but_prop_get */
|
||||
WM_operator_name_call(C, "ANIM_OT_keyframe_delete_button", WM_OP_INVOKE_DEFAULT, NULL);
|
||||
}
|
||||
|
||||
void ui_but_anim_clear_keyframe(bContext *C)
|
||||
{
|
||||
/* this operator calls UI_context_active_but_prop_get */
|
||||
WM_operator_name_call(C, "ANIM_OT_keyframe_clear_button", WM_OP_INVOKE_DEFAULT, NULL);
|
||||
}
|
||||
|
||||
void ui_but_anim_add_driver(bContext *C)
|
||||
{
|
||||
/* this operator calls UI_context_active_but_prop_get */
|
||||
|
|
|
@ -7040,27 +7040,6 @@ static int ui_do_button(bContext *C, uiBlock *block, uiBut *but, const wmEvent *
|
|||
}
|
||||
}
|
||||
}
|
||||
/* handle keyframing */
|
||||
else if ((event->type == IKEY) &&
|
||||
!IS_EVENT_MOD(event, ctrl, oskey) &&
|
||||
(event->val == KM_PRESS))
|
||||
{
|
||||
if (event->alt) {
|
||||
if (event->shift) {
|
||||
ui_but_anim_clear_keyframe(C);
|
||||
}
|
||||
else {
|
||||
ui_but_anim_delete_keyframe(C);
|
||||
}
|
||||
}
|
||||
else {
|
||||
ui_but_anim_insert_keyframe(C);
|
||||
}
|
||||
|
||||
ED_region_tag_redraw(data->region);
|
||||
|
||||
return WM_UI_HANDLER_BREAK;
|
||||
}
|
||||
/* handle drivers */
|
||||
else if ((event->type == DKEY) &&
|
||||
!IS_EVENT_MOD(event, shift, oskey) &&
|
||||
|
@ -8082,8 +8061,13 @@ uiBut *UI_context_active_but_get(const struct bContext *C)
|
|||
return ui_context_button_active(C, NULL);
|
||||
}
|
||||
|
||||
/* helper function for insert keyframe, reset to default, etc operators */
|
||||
void UI_context_active_but_prop_get(
|
||||
/**
|
||||
* Version of #UI_context_active_but_get that also returns RNA property info.
|
||||
* Helper function for insert keyframe, reset to default, etc operators.
|
||||
*
|
||||
* \return active button, NULL if none found or if it doesn't contain valid RNA data.
|
||||
*/
|
||||
uiBut *UI_context_active_but_prop_get(
|
||||
const bContext *C,
|
||||
struct PointerRNA *r_ptr, struct PropertyRNA **r_prop, int *r_index)
|
||||
{
|
||||
|
@ -8099,6 +8083,8 @@ void UI_context_active_but_prop_get(
|
|||
*r_prop = NULL;
|
||||
*r_index = 0;
|
||||
}
|
||||
|
||||
return activebut;
|
||||
}
|
||||
|
||||
void UI_context_active_but_prop_handle(bContext *C)
|
||||
|
|
|
@ -1114,7 +1114,12 @@ void ED_operatortypes_ui(void)
|
|||
*/
|
||||
void ED_keymap_ui(wmKeyConfig *keyconf)
|
||||
{
|
||||
WM_keymap_find(keyconf, "User Interface", 0, 0);
|
||||
wmKeyMap *keymap = WM_keymap_find(keyconf, "User Interface", 0, 0);
|
||||
|
||||
/* keyframes */
|
||||
WM_keymap_add_item(keymap, "ANIM_OT_keyframe_insert_button", IKEY, KM_PRESS, 0, 0);
|
||||
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);
|
||||
|
||||
eyedropper_modal_keymap(keyconf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue