From 658eb946a08f92a88d462f67864301ee44b374e9 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Fri, 3 Feb 2023 11:41:40 +0100 Subject: [PATCH 1/4] first light --- release/scripts/addons | 2 +- .../keyconfig/keymap_data/blender_default.py | 1 + .../editors/space_graph/graph_intern.h | 1 + .../blender/editors/space_graph/graph_ops.c | 1 + .../editors/space_graph/graph_slider_ops.c | 82 ++++++++++++++++++- 5 files changed, 82 insertions(+), 5 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index 534bf3b76c3..b3f0ffc587d 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 534bf3b76c3b5f3bcd21641f1d53c1062bedcdbe +Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 9c2ebfd6b4d..7277323ad85 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -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)]}), diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index a685216db31..5d863ef0d70 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -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); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index b178a3d3430..7bec7211cd4 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -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); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 1bce22959ee..c15f5fa1dbd 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -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; -- 2.30.2 From a8f58d7effb4b05824c0193c424d53e1d86e6f07 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 17:36:41 +0100 Subject: [PATCH 2/4] Revert "first light" This reverts commit 658eb946a08f92a88d462f67864301ee44b374e9. --- release/scripts/addons | 2 +- .../keyconfig/keymap_data/blender_default.py | 1 - .../editors/space_graph/graph_intern.h | 1 - .../blender/editors/space_graph/graph_ops.c | 1 - .../editors/space_graph/graph_slider_ops.c | 82 +------------------ 5 files changed, 5 insertions(+), 82 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index b3f0ffc587d..534bf3b76c3 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a +Subproject commit 534bf3b76c3b5f3bcd21641f1d53c1062bedcdbe diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 90371315c8b..637580364dc 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -1810,7 +1810,6 @@ 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)]}), diff --git a/source/blender/editors/space_graph/graph_intern.h b/source/blender/editors/space_graph/graph_intern.h index 5d863ef0d70..a685216db31 100644 --- a/source/blender/editors/space_graph/graph_intern.h +++ b/source/blender/editors/space_graph/graph_intern.h @@ -111,7 +111,6 @@ 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); diff --git a/source/blender/editors/space_graph/graph_ops.c b/source/blender/editors/space_graph/graph_ops.c index 7bec7211cd4..b178a3d3430 100644 --- a/source/blender/editors/space_graph/graph_ops.c +++ b/source/blender/editors/space_graph/graph_ops.c @@ -462,7 +462,6 @@ 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); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index c15f5fa1dbd..1bce22959ee 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -42,80 +42,6 @@ #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 * \{ */ @@ -725,7 +651,7 @@ void GRAPH_OT_blend_to_neighbor(wmOperatorType *ot) /* Identifiers. */ ot->name = "Blend to Neighbor"; ot->idname = "GRAPH_OT_blend_to_neighbor"; - ot->description = DESCRIPTION_BLEND_NEIGHBOR; + ot->description = "Blend selected keyframes to their left or right neighbor"; /* API callbacks. */ ot->invoke = blend_to_neighbor_invoke; @@ -850,7 +776,7 @@ void GRAPH_OT_breakdown(wmOperatorType *ot) /* Identifiers. */ ot->name = "Breakdown"; ot->idname = "GRAPH_OT_breakdown"; - ot->description = DESCRIPTION_BREAKDOWN; + ot->description = "Move selected keyframes to an inbetween position relative to adjacent keys"; /* API callbacks. */ ot->invoke = breakdown_invoke; @@ -979,7 +905,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 = DESCRIPTION_BLEND_DEFAULT; + ot->description = "Blend selected keys to their default value from their current position"; /* API callbacks. */ ot->invoke = blend_to_default_invoke; @@ -1104,7 +1030,7 @@ void GRAPH_OT_ease(wmOperatorType *ot) /* Identifiers. */ ot->name = "Ease Keyframes"; ot->idname = "GRAPH_OT_ease"; - ot->description = DESCRIPTION_EASE; + ot->description = "Align keyframes on a ease-in or ease-out curve"; /* API callbacks. */ ot->invoke = ease_invoke; -- 2.30.2 From ac0785508a67867ea9fac8c8b89ce9686b6e5574 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 9 Feb 2023 17:41:18 +0100 Subject: [PATCH 3/4] just using python --- .../scripts/presets/keyconfig/keymap_data/blender_default.py | 1 + release/scripts/startup/bl_ui/space_graph.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 637580364dc..617756d5fd5 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -1817,6 +1817,7 @@ def km_graph_editor(params): ("graph.paste", {"type": 'V', "value": 'PRESS', "ctrl": True}, None), ("graph.paste", {"type": 'V', "value": 'PRESS', "shift": True, "ctrl": True}, {"properties": [("flipped", True)]}), + op_menu("GRAPH_MT_slider", {"type": 'D', "value": 'PRESS'}), ("graph.previewrange_set", {"type": 'P', "value": 'PRESS', "ctrl": True, "alt": True}, None), ("graph.view_all", {"type": 'HOME', "value": 'PRESS'}, None), ("graph.view_all", {"type": 'NDOF_BUTTON_FIT', "value": 'PRESS'}, None), diff --git a/release/scripts/startup/bl_ui/space_graph.py b/release/scripts/startup/bl_ui/space_graph.py index 5a550acd107..8e81126c2e6 100644 --- a/release/scripts/startup/bl_ui/space_graph.py +++ b/release/scripts/startup/bl_ui/space_graph.py @@ -329,7 +329,7 @@ class GRAPH_MT_slider(Menu): def draw(self, _context): layout = self.layout - + layout.operator_context = "INVOKE_DEFAULT" layout.operator("graph.breakdown", text="Breakdown") layout.operator("graph.blend_to_neighbor", text="Blend to Neighbor") layout.operator("graph.blend_to_default", text="Blend to Default Value") -- 2.30.2 From 91622885d74d038d6dbf72697000832f1d501ff7 Mon Sep 17 00:00:00 2001 From: Christoph Lendenfeld Date: Thu, 16 Feb 2023 11:40:45 +0100 Subject: [PATCH 4/4] undoing the submodule bump --- release/scripts/addons | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release/scripts/addons b/release/scripts/addons index 534bf3b76c3..b3f0ffc587d 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 534bf3b76c3b5f3bcd21641f1d53c1062bedcdbe +Subproject commit b3f0ffc587d197b37eac9a1566d1d24b7bee7d9a -- 2.30.2