Animation: Add Slider operators to hotkey menu #104530

Merged
Christoph Lendenfeld merged 8 commits from ChrisLend/blender:graph_slider_menu into main 2023-02-23 09:29:30 +01:00
5 changed files with 82 additions and 5 deletions
Showing only changes of commit 658eb946a0 - Show all commits

@ -1 +1 @@
Subproject commit 534bf3b76c3b5f3bcd21641f1d53c1062bedcdbe
Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a

View File

@ -1808,6 +1808,7 @@ def km_graph_editor(params):
("graph.delete", {"type": 'DEL', "value": 'PRESS'}, {"properties": [("confirm", False)]}),
("graph.duplicate_move", {"type": 'D', "value": 'PRESS', "shift": True}, None),
("graph.keyframe_insert", {"type": 'I', "value": 'PRESS'}, None),
("graph.slider_choice", {"type": 'D', "value": "PRESS"}, None),
("graph.click_insert", {"type": params.action_mouse, "value": 'CLICK', "ctrl": True}, None),
("graph.click_insert", {"type": params.action_mouse, "value": 'CLICK', "shift": True, "ctrl": True},
{"properties": [("extend", True)]}),

View File

@ -111,6 +111,7 @@ void GRAPH_OT_paste(struct wmOperatorType *ot);
void GRAPH_OT_duplicate(struct wmOperatorType *ot);
void GRAPH_OT_delete(struct wmOperatorType *ot);
void GRAPH_OT_clean(struct wmOperatorType *ot);
void GRAPH_OT_slider_choice(struct wmOperatorType *ot);
void GRAPH_OT_blend_to_neighbor(struct wmOperatorType *ot);
void GRAPH_OT_breakdown(struct wmOperatorType *ot);
void GRAPH_OT_ease(struct wmOperatorType *ot);

View File

@ -462,6 +462,7 @@ void graphedit_operatortypes(void)
WM_operatortype_append(GRAPH_OT_decimate);
WM_operatortype_append(GRAPH_OT_blend_to_neighbor);
WM_operatortype_append(GRAPH_OT_breakdown);
WM_operatortype_append(GRAPH_OT_slider_choice);
WM_operatortype_append(GRAPH_OT_ease);
WM_operatortype_append(GRAPH_OT_blend_to_default);
WM_operatortype_append(GRAPH_OT_euler_filter);

View File

@ -42,6 +42,80 @@
#include "graph_intern.h"
/* -------------------------------------------------------------------- */
/** \name Enum Operator to call different sliders
* \{ */
#define DESCRIPTION_BLEND_NEIGHBOR "Blend selected keyframes to their left or right neighbor"
#define DESCRIPTION_BLEND_DEFAULT \
"Blend selected keys to their default value from their current position"
#define DESCRIPTION_BREAKDOWN \
"Move selected keyframes to an inbetween position relative to adjacent keys"
#define DESCRIPTION_EASE "Align keyframes on a ease-in or ease-out curve"
typedef enum eKeyOperators {
KEYOP_BLEND_NEIGHBOR = 0,
KEYOP_BLEND_DEFAULT = 1,
KEYOP_BREAKDOWN = 2,
KEYOP_EASE = 3,
} eKeyOperators;
const EnumPropertyItem graph_slider_options_enum[] = {
{KEYOP_BLEND_NEIGHBOR, "BLEND_NEIGHBOR", 0, "Blend to Neighbor", DESCRIPTION_BLEND_NEIGHBOR},
{KEYOP_BLEND_DEFAULT, "BLEND_DEFAULT", 0, "Blend to Default", DESCRIPTION_BLEND_DEFAULT},
{KEYOP_BREAKDOWN, "BREAKDOWN", 0, "Breakdown", DESCRIPTION_BREAKDOWN},
{KEYOP_EASE, "EASE", 0, "Ease", DESCRIPTION_EASE},
{0, NULL, 0, NULL, NULL},
};
static int graph_slider_choice_exec(bContext *C, wmOperator *op)
{
const int mode = RNA_enum_get(op->ptr, "mode");
wmOperatorType *ot;
switch (mode) {
case KEYOP_BLEND_NEIGHBOR:
ot = WM_operatortype_find("GRAPH_OT_blend_to_neighbor", false);
return WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL, NULL);
break;
case KEYOP_BLEND_DEFAULT:
ot = WM_operatortype_find("GRAPH_OT_blend_to_default", false);
return WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL, NULL);
break;
case KEYOP_BREAKDOWN:
ot = WM_operatortype_find("GRAPH_OT_breakdown", false);
return WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL, NULL);
break;
case KEYOP_EASE:
ot = WM_operatortype_find("GRAPH_OT_ease", false);
return WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, NULL, NULL);
break;
}
return OPERATOR_CANCELLED;
}
void GRAPH_OT_slider_choice(wmOperatorType *ot)
{
/* Identifiers */
ot->name = "Slider Operators";
ot->idname = "GRAPH_OT_slider_choice";
ot->description = "Choose a slider operator run";
/* API callbacks */
ot->invoke = WM_menu_invoke;
ot->exec = graph_slider_choice_exec;
ot->poll = graphop_editable_keyframes_poll;
/* Flags */
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* Id-props */
ot->prop = RNA_def_enum(ot->srna, "mode", graph_slider_options_enum, 0, "Mode", "");
}
/** \} */
/* -------------------------------------------------------------------- */
/** \name Internal Struct & Defines
* \{ */
@ -651,7 +725,7 @@ void GRAPH_OT_blend_to_neighbor(wmOperatorType *ot)
/* Identifiers. */
ot->name = "Blend to Neighbor";
ot->idname = "GRAPH_OT_blend_to_neighbor";
ot->description = "Blend selected keyframes to their left or right neighbor";
ot->description = DESCRIPTION_BLEND_NEIGHBOR;
/* API callbacks. */
ot->invoke = blend_to_neighbor_invoke;
@ -776,7 +850,7 @@ void GRAPH_OT_breakdown(wmOperatorType *ot)
/* Identifiers. */
ot->name = "Breakdown";
ot->idname = "GRAPH_OT_breakdown";
ot->description = "Move selected keyframes to an inbetween position relative to adjacent keys";
ot->description = DESCRIPTION_BREAKDOWN;
/* API callbacks. */
ot->invoke = breakdown_invoke;
@ -905,7 +979,7 @@ void GRAPH_OT_blend_to_default(wmOperatorType *ot)
/* Identifiers. */
ot->name = "Blend to Default Value";
ot->idname = "GRAPH_OT_blend_to_default";
ot->description = "Blend selected keys to their default value from their current position";
ot->description = DESCRIPTION_BLEND_DEFAULT;
/* API callbacks. */
ot->invoke = blend_to_default_invoke;
@ -1030,7 +1104,7 @@ void GRAPH_OT_ease(wmOperatorType *ot)
/* Identifiers. */
ot->name = "Ease Keyframes";
ot->idname = "GRAPH_OT_ease";
ot->description = "Align keyframes on a ease-in or ease-out curve";
ot->description = DESCRIPTION_EASE;
/* API callbacks. */
ot->invoke = ease_invoke;